index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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: 5,
  137. querySign: 1,
  138. },
  139. total: 0,
  140. options: {},
  141. };
  142. },
  143. computed: {
  144. ...mapGetters(["userInfo", "config"]),
  145. },
  146. onLoad(options) {
  147. uni.hideTabBar();
  148. this.options = options;
  149. if (this.options.isAct && !this.$method.isLogin()) {
  150. uni.navigateTo({
  151. url: "/pages4/login/login?isBack=" + true + "&isAct=1",
  152. });
  153. return;
  154. }
  155. },
  156. async onShow() {
  157. if (this.options.skipPort) {
  158. await this.$method.skipLogin(this.options.skipPort);
  159. }
  160. this.param.pageNum = 1;
  161. this.questionLists = [];
  162. this.getBankList();
  163. },
  164. onPullDownRefresh() {
  165. this.param.pageNum = 1;
  166. this.questionLists = [];
  167. this.getBankList();
  168. },
  169. onReachBottom() {
  170. if (this.questionLists.length < this.total) {
  171. this.param.pageNum++;
  172. this.getBankList();
  173. }
  174. },
  175. methods: {
  176. // 查询用户拥有免费+自购题库商品 /bank/question/listUserFreeUnionBuyGoodsList
  177. getBankList() {
  178. if (!this.$method.isLogin()) {
  179. return;
  180. }
  181. this.allLoading = true;
  182. this.$api
  183. .listUserFreeUnionBuyGoodsList(this.param)
  184. .then((res) => {
  185. if (res.data.code == 200) {
  186. this.questionLists.push(...(res.data.rows || []));
  187. console.log("this.courseList", this.questionLists);
  188. this.total = res.data.total;
  189. }
  190. this.allLoading = false;
  191. })
  192. .catch((err) => {
  193. this.allLoading = false;
  194. });
  195. },
  196. toChoose() {
  197. uni.switchTab({
  198. url: "/pages/course/index",
  199. });
  200. },
  201. toDailyPractice(item, child) {
  202. this.$method.checkLock("bank").then((res) => {
  203. if (child.paperName == "每日一练") {
  204. uni.navigateTo({
  205. url:
  206. "/pages2/dailyPractice/index?goodsId=" +
  207. item.goodsId +
  208. "&orderGoodsId=" +
  209. item.orderGoodsId,
  210. });
  211. } else if (child.paperName == "随机练习") {
  212. uni.navigateTo({
  213. url:
  214. "/pages2/randomPractice/index?goodsId=" +
  215. item.goodsId +
  216. "&orderGoodsId=" +
  217. item.orderGoodsId,
  218. });
  219. } else {
  220. this.studyques(item, child);
  221. }
  222. });
  223. },
  224. // 进入练习
  225. studyques(item, child) {
  226. let sysTime = this.$method.timest();
  227. if (
  228. item.serviceStartTime &&
  229. item.serviceEndTime &&
  230. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  231. ) {
  232. uni.showToast({
  233. icon: "none",
  234. title: "不在学习服务期,不能进入学习",
  235. });
  236. return;
  237. }
  238. let paperId = (child && child.paperId) || "";
  239. uni.navigateTo({
  240. url:
  241. "/pages2/bank/question_detail?id=" +
  242. item.goodsId +
  243. "&orderGoodsId=" +
  244. item.orderGoodsId +
  245. "&paperId=" +
  246. paperId,
  247. });
  248. },
  249. },
  250. };
  251. </script>
  252. <style>
  253. page {
  254. background: #eaeef1;
  255. }
  256. </style>
  257. <style lang="scss" scoped>
  258. @import "./index.scss";
  259. </style>