index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="questionBank">
  3. <nav-logo title="题库中心"></nav-logo>
  4. <!-- 有学习的课程 -->
  5. <view v-if="questionLists.length" class="had_courses">
  6. <!-- 我的题库 -->
  7. <view class="my_courses">
  8. <text class="titles">我的题库</text>
  9. <view class="bottoms">
  10. <navigator hover-class="none" url="/pages2/subject/collect">
  11. <view class="item collect">
  12. <view class="text"
  13. >收藏集<u-icon name="arrow-right"></u-icon
  14. ></view>
  15. <image class="img" src="/static/questionBank_collect.png"></image>
  16. </view>
  17. </navigator>
  18. <view class="item list">
  19. <navigator hover-class="none" url="/pages2/bank/question_record">
  20. <view class="list-in">
  21. <image
  22. class="img"
  23. src="/static/questionBank_record.png"
  24. ></image>
  25. <view class="text">
  26. 做题记录 <u-icon name="arrow-right"></u-icon>
  27. </view>
  28. </view>
  29. </navigator>
  30. <navigator hover-class="none" url="/pages2/subject/wrong">
  31. <view class="list-in">
  32. <image class="img" src="/static/questionBank_wrong.png"></image>
  33. <view class="text">
  34. 错题集 <u-icon name="arrow-right"></u-icon>
  35. </view>
  36. </view>
  37. </navigator>
  38. </view>
  39. </view>
  40. <template v-if="questionLists.length">
  41. <!-- @click="studyques(item)" -->
  42. <view
  43. v-for="(item, index) in questionLists"
  44. :key="index"
  45. class="course_item"
  46. >
  47. <view>
  48. <view class="cou_titles">{{ item.goodsName }}</view>
  49. <view
  50. v-if="
  51. item.serviceStartTime &&
  52. item.serviceEndTime &&
  53. !item.externalLinkStatus
  54. "
  55. class="learn_ranges"
  56. >
  57. <image
  58. class="l_range"
  59. src="/static/learn/learn_range.png"
  60. ></image>
  61. 学习周期:
  62. <text class="l_time"
  63. >{{ item.serviceStartTime | formate("yyyy.mm.dd") }} -
  64. {{ item.serviceEndTime | formate("yyyy.mm.dd") }}</text
  65. >
  66. </view>
  67. </view>
  68. <view class="c_downs">
  69. <view class="lefts">
  70. <image
  71. class="lefet_img"
  72. :src="$method.splitImgHost(item.coverUrl, true)"
  73. mode=""
  74. ></image>
  75. </view>
  76. <view class="rights" v-if="!item.externalLinkStatus">
  77. <view class="learn_progress">
  78. <view class="progress_up">
  79. <view>
  80. 学习进度:{{ item.doNum }}/{{ item.totalNum }}
  81. </view>
  82. <view class="progress_bar" style="width: 100%">
  83. <u-line-progress
  84. :show-percent="false"
  85. height="22"
  86. active-color="#ff9900"
  87. :percent="(item.doNum / item.totalNum) * 100"
  88. ></u-line-progress>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. <!-- 按钮 -->
  95. <view class="study_btns" v-if="!item.externalLinkStatus">
  96. <view
  97. v-for="(child, c_index) in item.paperVos"
  98. :key="c_index"
  99. class="exam_word intos"
  100. @click.stop="toDailyPractice(item, child)"
  101. >{{ child.paperName }}</view
  102. >
  103. </view>
  104. <view class="study_btns" v-else>
  105. <view
  106. class="exam_word intos"
  107. @click.stop="$method.toLink(item.externalLink)"
  108. >进入学习</view
  109. >
  110. </view>
  111. </view>
  112. </template>
  113. </view>
  114. </view>
  115. <!-- 没有学习的课程 -->
  116. <view v-if="!allLoading && !questionLists.length" class="no_datas">
  117. <!-- <image class="courses" src="/static/learn/no_course.png" mode=""></image>
  118. <view class="no_learns">您目前没有可学习的题库</view> -->
  119. <image src="/static/learn/empty_status.png" class="empty_status"></image>
  120. <text class="word_tip">暂无题库</text>
  121. <view class="choose" @click="toChoose()">立即去选购</view>
  122. </view>
  123. <!-- tabbar -->
  124. <myTabbar></myTabbar>
  125. </view>
  126. </template>
  127. <script>
  128. import { mapGetters } from "vuex";
  129. export default {
  130. data() {
  131. return {
  132. allLoading: false, // 加载样式
  133. questionLists: [], // 题库列表
  134. param: {
  135. pageNum: 1,
  136. pageSize: 10,
  137. },
  138. total: 0,
  139. options: {},
  140. };
  141. },
  142. computed: {
  143. ...mapGetters(["userInfo", "config"]),
  144. },
  145. onLoad(options) {
  146. uni.hideTabBar()
  147. this.options = options;
  148. if (this.options.isAct && !this.$method.isLogin()) {
  149. uni.navigateTo({
  150. url: "/pages4/login/login?isBack=" + true + "&isAct=1",
  151. });
  152. return;
  153. }
  154. },
  155. async onShow() {
  156. if (this.options.skipPort) {
  157. await this.$method.skipLogin(this.options.skipPort);
  158. }
  159. this.param.pageNum = 1;
  160. this.questionLists = [];
  161. this.getBankList();
  162. },
  163. onPullDownRefresh() {
  164. this.param.pageNum = 1;
  165. this.questionLists = [];
  166. this.getBankList();
  167. },
  168. onReachBottom() {
  169. if (this.questionLists.length < this.total) {
  170. this.param.pageNum++;
  171. this.getBankList();
  172. }
  173. },
  174. methods: {
  175. // 查询用户拥有免费+自购题库商品 /bank/question/listUserFreeUnionBuyGoodsList
  176. getBankList() {
  177. if (!this.$method.isLogin()) {
  178. return;
  179. }
  180. this.allLoading = true;
  181. this.$api
  182. .listUserFreeUnionBuyGoodsList(this.param)
  183. .then((res) => {
  184. if (res.data.code == 200) {
  185. this.questionLists.push(...(res.data.rows || []));
  186. console.log("this.courseList", this.questionLists);
  187. this.total = res.data.total;
  188. }
  189. this.allLoading = false;
  190. })
  191. .catch((err) => {
  192. this.allLoading = false;
  193. });
  194. },
  195. toChoose() {
  196. uni.switchTab({
  197. url: "/pages/course/index",
  198. });
  199. },
  200. toDailyPractice(item, child) {
  201. this.$method.checkLock("bank").then((res) => {
  202. if (child.paperName == "每日一练") {
  203. uni.navigateTo({
  204. url:
  205. "/pages2/dailyPractice/index?goodsId=" +
  206. item.goodsId +
  207. "&orderGoodsId=" +
  208. item.orderGoodsId,
  209. });
  210. } else if (child.paperName == "随机练习") {
  211. uni.navigateTo({
  212. url:
  213. "/pages2/randomPractice/index?goodsId=" +
  214. item.goodsId +
  215. "&orderGoodsId=" +
  216. item.orderGoodsId,
  217. });
  218. } else {
  219. this.studyques(item, child);
  220. }
  221. });
  222. },
  223. // 进入练习
  224. studyques(item, child) {
  225. let sysTime = this.$method.timest();
  226. if (
  227. item.serviceStartTime &&
  228. item.serviceEndTime &&
  229. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  230. ) {
  231. uni.showToast({
  232. icon: "none",
  233. title: "不在学习服务期,不能进入学习",
  234. });
  235. return;
  236. }
  237. let paperId = (child && child.paperId) || "";
  238. uni.navigateTo({
  239. url:
  240. "/pages2/bank/question_detail?id=" +
  241. item.goodsId +
  242. "&orderGoodsId=" +
  243. item.orderGoodsId +
  244. "&paperId=" +
  245. paperId,
  246. });
  247. },
  248. },
  249. };
  250. </script>
  251. <style>
  252. page {
  253. background: #eaeef1;
  254. }
  255. </style>
  256. <style lang="scss" scoped>
  257. @import "./index.scss";
  258. </style>