index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 && !this.$method.isLogin()) {
  159. uni.navigateTo({
  160. url: "/pages4/login/login?isBack=" + true + "&isAct=1",
  161. });
  162. return;
  163. }
  164. },
  165. async onShow() {
  166. if (this.options.skipPort) {
  167. await this.$method.skipLogin(this.options.skipPort);
  168. }
  169. this.param.pageNum = 1;
  170. this.questionLists = [];
  171. this.getBankList();
  172. },
  173. onPullDownRefresh() {
  174. this.param.pageNum = 1;
  175. this.questionLists = [];
  176. this.getBankList();
  177. },
  178. onReachBottom() {
  179. if (this.questionLists.length < this.total) {
  180. this.param.pageNum++;
  181. this.getBankList();
  182. }
  183. },
  184. methods: {
  185. // 查询用户拥有免费+自购题库商品 /bank/question/listUserFreeUnionBuyGoodsList
  186. getBankList() {
  187. if (!this.$method.isLogin()) {
  188. return;
  189. }
  190. this.allLoading = true;
  191. this.$api
  192. .listUserFreeUnionBuyGoodsList(this.param)
  193. .then((res) => {
  194. if (res.data.code == 200) {
  195. this.questionLists.push(...(res.data.rows || []));
  196. console.log("this.courseList", this.questionLists);
  197. this.total = res.data.total;
  198. }
  199. this.allLoading = false;
  200. })
  201. .catch((err) => {
  202. this.allLoading = false;
  203. });
  204. },
  205. toChoose() {
  206. uni.switchTab({
  207. url: "/pages/course/index",
  208. });
  209. },
  210. toDailyPractice(item, child) {
  211. this.$api
  212. .lockLockStatus({
  213. action: "bank",
  214. uuid: this.$method.getUuid(),
  215. })
  216. .then((res) => {
  217. if (res.data.code == 200) {
  218. //有其他端在操作,不能学习
  219. uni.showToast({
  220. icon: "none",
  221. title: res.data.msg,
  222. duration: 3000,
  223. });
  224. } else if (res.data.code == 500) {
  225. //可以学习
  226. if (child.paperName == "每日一练") {
  227. uni.navigateTo({
  228. url:
  229. "/pages2/dailyPractice/index?goodsId=" +
  230. item.goodsId +
  231. "&orderGoodsId=" +
  232. item.orderGoodsId,
  233. });
  234. } else if (child.paperName == "随机练习") {
  235. uni.navigateTo({
  236. url:
  237. "/pages2/randomPractice/index?goodsId=" +
  238. item.goodsId +
  239. "&orderGoodsId=" +
  240. item.orderGoodsId,
  241. });
  242. } else {
  243. this.studyques(item, child);
  244. }
  245. }
  246. });
  247. },
  248. // 进入练习
  249. studyques(item, child) {
  250. let sysTime = this.$method.timest();
  251. if (
  252. item.serviceStartTime &&
  253. item.serviceEndTime &&
  254. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  255. ) {
  256. uni.showToast({
  257. icon: "none",
  258. title: "不在学习服务期,不能进入学习",
  259. });
  260. return;
  261. }
  262. let paperId = (child && child.paperId) || "";
  263. uni.navigateTo({
  264. url:
  265. "/pages2/bank/question_detail?id=" +
  266. item.goodsId +
  267. "&orderGoodsId=" +
  268. item.orderGoodsId +
  269. "&paperId=" +
  270. paperId,
  271. });
  272. },
  273. },
  274. };
  275. </script>
  276. <style>
  277. page {
  278. background: #eaeef1;
  279. }
  280. </style>
  281. <style lang="scss" scoped>
  282. @import "./index.scss";
  283. </style>