index.vue 8.5 KB

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