index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="my-bank">
  3. <div class="my-bank__header">
  4. <el-tabs :value="activeName" @tab-click="tabChange">
  5. <el-tab-pane
  6. v-for="(tab, tabIndex) in tabList"
  7. :key="tabIndex"
  8. :label="tab.educationName"
  9. :name="tab.id"
  10. ></el-tab-pane>
  11. </el-tabs>
  12. </div>
  13. <div class="my-bank__body">
  14. <div class="no-data" v-if="list.length == 0">暂无可以学习的题库哦~</div>
  15. <div class="list" v-else>
  16. <div class="bank-item" v-for="(item, index) in list" :key="index">
  17. <div class="bank-item__header">
  18. {{ item.goodsName }}
  19. <div
  20. class="time"
  21. v-if="item.serviceStartTime && item.serviceEndTime"
  22. >
  23. 学习服务期:{{
  24. $tools.timestampToTime(item.serviceStartTime, true, true)
  25. }}-{{ $tools.timestampToTime(item.serviceEndTime, true, true) }}
  26. </div>
  27. </div>
  28. <div class="bank-item__body clearfix">
  29. <div class="img">
  30. <img :src="$tools.splitImgHost(item.coverUrl, true)" alt="" />
  31. </div>
  32. <div class="text">
  33. <!-- <div class="title">
  34. <div class="note">60学时</div>
  35. </div> -->
  36. <div class="progress">
  37. 学习进度
  38. <el-progress
  39. class="progress-line"
  40. :stroke-width="16"
  41. :format="progressText(item)"
  42. :percentage="
  43. item.totalNum != 0 ? (item.doNum / item.totalNum) * 100 : 0
  44. "
  45. ></el-progress>
  46. </div>
  47. </div>
  48. <div class="btns-wrap">
  49. <div class="btns">
  50. <el-button type="primary" class="btn" @click="goStudy(item)"
  51. >进入学习</el-button
  52. >
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="pagination">
  59. <el-pagination
  60. @current-change="currentChange"
  61. background
  62. layout="prev, pager, next"
  63. :total="total"
  64. :pager-count="5"
  65. :page-size="param.pageSize"
  66. >
  67. </el-pagination>
  68. </div>
  69. </div>
  70. </div>
  71. </template>
  72. <script>
  73. export default {
  74. name: "Mybank",
  75. data() {
  76. return {
  77. param: {
  78. pageNum: 1,
  79. pageSize: 10,
  80. },
  81. tabList: [],
  82. list: [],
  83. activeName: "-1",
  84. total: 0,
  85. };
  86. },
  87. async mounted() {
  88. // await this.orderUserEduList();
  89. this.bankQuestionListFreeGoodsList();
  90. },
  91. methods: {
  92. tabChange(e) {
  93. if (this.activeName == e.name) {
  94. return;
  95. }
  96. console.log(e.name);
  97. this.activeName = e.name;
  98. this.bankQuestionListFreeGoodsList();
  99. },
  100. orderUserEduList() {
  101. return new Promise((resolve) => {
  102. this.$request
  103. .orderUserEduList({
  104. goodsType: 2,
  105. })
  106. .then((res) => {
  107. res.rows.forEach((row) => {
  108. row.id = row.id + "";
  109. });
  110. this.tabList.push(
  111. {
  112. educationName: "全部题库",
  113. id: "-1",
  114. },
  115. ...res.rows
  116. );
  117. resolve();
  118. });
  119. });
  120. },
  121. progressText(item) {
  122. return () => {
  123. return item.doNum + "/" + item.totalNum;
  124. };
  125. },
  126. currentChange(e) {
  127. this.param.pageNum = e;
  128. this.bankQuestionListFreeGoodsList();
  129. },
  130. bankQuestionListFreeGoodsList() {
  131. let param = JSON.parse(JSON.stringify(this.param));
  132. if (this.activeName == "-1") {
  133. param.educationTypeId = "";
  134. } else {
  135. param.educationTypeId = this.activeName;
  136. }
  137. this.$request.bankQuestionListFreeGoodsList(param).then((res) => {
  138. res.rows.forEach((item) => {
  139. console.log(`${item.goodsName}:${item.doNum}/${item.totalNum}`);
  140. });
  141. this.list = res.rows;
  142. this.total = res.total;
  143. });
  144. },
  145. pay() {
  146. this.$router.push({
  147. path: "payment-success",
  148. });
  149. },
  150. goStudy(item) {
  151. this.$router.push({
  152. path: "/person-center/free-bank/bank-detail/" + item.goodsId,
  153. query: {
  154. orderGoodsId: item.orderGoodsId,
  155. },
  156. });
  157. },
  158. },
  159. };
  160. </script>
  161. <!-- Add "scoped" attribute to limit CSS to this component only -->
  162. <style scoped lang="scss">
  163. .my-bank {
  164. &__header {
  165. /deep/ .el-tabs__header {
  166. margin-bottom: 0;
  167. }
  168. }
  169. &__body {
  170. .list {
  171. .bank-item {
  172. margin-top: 24px;
  173. background: #fafbfc;
  174. border-radius: 8px;
  175. overflow: hidden;
  176. &__header {
  177. height: 40px;
  178. line-height: 40px;
  179. border-bottom: 1px solid #eee;
  180. padding: 0 18px;
  181. font-size: 16px;
  182. font-family: Microsoft YaHei;
  183. font-weight: bold;
  184. color: #333333;
  185. .time {
  186. float: right;
  187. line-height: 40px;
  188. text-align: right;
  189. font-size: 12px;
  190. font-family: Microsoft YaHei;
  191. font-weight: 400;
  192. color: #666666;
  193. }
  194. }
  195. &__body {
  196. .img {
  197. float: left;
  198. width: 160px;
  199. height: 90px;
  200. display: table-cell;
  201. img {
  202. max-width: 100%;
  203. max-height: 100%;
  204. display: inline-block;
  205. vertical-align: middle;
  206. }
  207. }
  208. .text {
  209. float: left;
  210. margin-left: 12px;
  211. .title {
  212. margin-top: 10px;
  213. font-size: 16px;
  214. font-family: Microsoft YaHei;
  215. font-weight: bold;
  216. color: #333333;
  217. .note {
  218. display: inline-block;
  219. vertical-align: middle;
  220. border: 1px solid #333333;
  221. border-radius: 4px;
  222. font-size: 12px;
  223. font-family: Microsoft YaHei;
  224. font-weight: 400;
  225. color: #333333;
  226. padding: 2px 5px;
  227. }
  228. }
  229. .progress {
  230. margin-top: 30px;
  231. font-size: 14px;
  232. font-family: Microsoft YaHei;
  233. font-weight: 400;
  234. color: #333333;
  235. &-line {
  236. width: 250px;
  237. display: inline-block;
  238. }
  239. /deep/ .el-progress-bar {
  240. padding-right: 100px;
  241. margin-right: -100px;
  242. }
  243. }
  244. }
  245. .btns-wrap {
  246. display: table;
  247. float: right;
  248. height: 90px;
  249. width: 130px;
  250. .btns {
  251. display: table-cell;
  252. vertical-align: middle;
  253. text-align: center;
  254. .btn {
  255. cursor: pointer;
  256. margin: 2px 0;
  257. width: 122px;
  258. height: 32px;
  259. border-radius: 16px;
  260. display: inline-block;
  261. text-align: center;
  262. line-height: 32px;
  263. padding: 0;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. }
  270. .no-data {
  271. text-align: center;
  272. padding: 50px 0;
  273. color: #666;
  274. font-size: 16px;
  275. }
  276. .pagination {
  277. padding: 30px 0;
  278. text-align: center;
  279. }
  280. }
  281. }
  282. </style>