index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div id="Mybank">
  3. <div class="no-data" v-if="!bankData.goodsName">暂无可以学习的题库哦~</div>
  4. <div v-else>
  5. <h4 class="headerTitle">
  6. <span v-if="bankData.subjectNames" style="font-size: 20px"
  7. >【{{ bankData.subjectNames }}】</span
  8. >{{ bankData.goodsName
  9. }}<el-button
  10. size="mini"
  11. type="primary"
  12. plain
  13. icon="el-icon-sort"
  14. style="margin-left: 14px"
  15. @click="changeBank"
  16. >切换题库</el-button
  17. >
  18. </h4>
  19. <bank-detail-copy ref="bankDetailCopy" />
  20. </div>
  21. <el-dialog title="切换题库" :visible.sync="dialogVisible" width="900px">
  22. <div class="topstyle">
  23. <p>当前试题</p>
  24. <div class="list_styleHeader">
  25. <span
  26. class="btn_style"
  27. :style="
  28. bankData.goodsType == 5
  29. ? 'background-color:#00D6B9;'
  30. : 'background-color:#3F8DFD;'
  31. "
  32. >{{ bankData.goodsType == 5 ? "赠送" : "自购" }}</span
  33. >
  34. <span style="font-weight: bold; font-size: 18px">{{
  35. bankData.goodsName
  36. }}</span>
  37. </div>
  38. </div>
  39. <div class="height_style">
  40. <div
  41. v-for="(item, index) in list"
  42. :key="index"
  43. class="list_style"
  44. :style="
  45. index % 2 != 1
  46. ? 'background-color:#F8F8F9;'
  47. : 'background-color:#fff;'
  48. "
  49. @click="activeFunc(item)"
  50. >
  51. <span
  52. class="btn_style"
  53. :style="
  54. item.goodsType == 5
  55. ? 'background-color:#00D6B9;'
  56. : 'background-color:#3F8DFD;'
  57. "
  58. >{{ item.goodsType == 5 ? "赠送" : "自购" }}</span
  59. >
  60. <span style="font-weight: bold; font-size: 18px">{{
  61. item.goodsName
  62. }}</span>
  63. <span
  64. v-if="
  65. item.validityStartTime &&
  66. item.validityEndTime &&
  67. item.goodsType != 5
  68. "
  69. style="float: right; color: #999; font-size: 14px"
  70. >{{ $tools.timestampToTime(item.validityStartTime) }} -
  71. {{ $tools.timestampToTime(item.validityEndTime) }}
  72. <span
  73. style="color: #3f8dfd; font-size: 14px"
  74. v-if="getNewTime() < item.validityStartTime ? true : false"
  75. >/未开始</span
  76. >
  77. <span
  78. style="color: #999; font-size: 14px"
  79. v-if="getNewTime() > item.validityEndTime ? true : false"
  80. >/已过期</span
  81. ></span
  82. >
  83. </div>
  84. </div>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import bankDetailCopy from "../bank-detailCopy/index.vue";
  90. export default {
  91. name: "Mybank",
  92. components: { bankDetailCopy },
  93. data() {
  94. return {
  95. bankData: {},
  96. dialogVisible: false,
  97. list: [],
  98. };
  99. },
  100. mounted() {
  101. this.getList();
  102. },
  103. methods: {
  104. getNewTime() {
  105. console.log(parseInt(new Date().getTime() / 1000));
  106. return parseInt(new Date().getTime() / 1000);
  107. },
  108. getInfoData(data) {
  109. return new Promise((resolve, reject) => {
  110. this.$request.goodsDetail(data.goodsId).then((res) => {
  111. res.data.orderGoodsId = data.orderGoodsId;
  112. resolve(res.data);
  113. });
  114. });
  115. },
  116. getList() {
  117. this.$request.examrecordgetUserDoLast().then(async (res) => {
  118. let { goodsId } = this.$route.query;
  119. if (res.data && res.data.goodsId && !goodsId) {
  120. const result = await this.getInfoData(res.data);
  121. this.bankData = result;
  122. this.$nextTick(() => {
  123. this.$refs.bankDetailCopy.initData(this.bankData, res.data);
  124. });
  125. } else {
  126. this.$request
  127. .bankquestionlistUserFreeUnionBuyGoodsList()
  128. .then((res) => {
  129. if (res.rows.length > 0) {
  130. this.bankData = !goodsId
  131. ? res.rows[0]
  132. : res.rows.find((e) => e.goodsId == goodsId);
  133. this.$nextTick(() => {
  134. this.$refs.bankDetailCopy.initData(this.bankData);
  135. });
  136. }
  137. });
  138. }
  139. });
  140. },
  141. /**
  142. * 切换题库
  143. */
  144. changeBank() {
  145. this.$request.bankquestionlistUserFreeUnionBuyGoodsList().then((res) => {
  146. this.list = res.rows;
  147. this.dialogVisible = true;
  148. });
  149. },
  150. /**
  151. * 确定选中
  152. */
  153. activeFunc(item) {
  154. const Times = parseInt(new Date().getTime() / 1000);
  155. if (item.goodsType != 5) {
  156. if (Times < item.validityStartTime || Times > item.validityEndTime) {
  157. if (Times < item.validityStartTime) {
  158. this.$message.warning("题卷学习时间未开始");
  159. return;
  160. } else if (Times > item.validityEndTime) {
  161. this.$message.warning("题卷学习时间已过期");
  162. return;
  163. }
  164. }
  165. }
  166. this.$refs.bankDetailCopy.initData(item);
  167. this.bankData = item;
  168. this.dialogVisible = false;
  169. },
  170. },
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. .headerTitle {
  175. padding: 30px 0px;
  176. font-size: 24px;
  177. font-weight: bold;
  178. color: #222;
  179. }
  180. /deep/ .el-dialog__wrapper .el-dialog {
  181. margin-top: 5vh !important;
  182. }
  183. .topstyle {
  184. border-bottom: 2px solid #eee;
  185. margin-bottom: 16px;
  186. p {
  187. background-color: #f8f8f9;
  188. font-size: 14px;
  189. color: #3f8dfd;
  190. padding: 5px 12px;
  191. }
  192. }
  193. .height_style {
  194. max-height: 600px;
  195. overflow-y: auto;
  196. }
  197. .list_style {
  198. height: 60px;
  199. color: #222;
  200. line-height: 58px;
  201. padding: 0px 16px;
  202. cursor: pointer;
  203. transition: all 0.2s;
  204. &:hover {
  205. background-color: rgba(63, 141, 253, 0.3) !important;
  206. }
  207. }
  208. .list_styleHeader {
  209. height: 60px;
  210. color: #3f8dfd;
  211. line-height: 58px;
  212. padding: 0px 16px;
  213. }
  214. .btn_style {
  215. padding: 0px 3px;
  216. color: #fff;
  217. margin-right: 8px;
  218. border-radius: 2px;
  219. }
  220. </style>