index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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="logo"
  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="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. import config from "@/common/config";
  141. export default {
  142. data() {
  143. return {
  144. logo: config.TOP_LOGO,
  145. allLoading: false, // 加载样式
  146. questionLists: [], // 题库列表
  147. param: {
  148. pageNum: 1,
  149. pageSize: 10,
  150. },
  151. total: 0,
  152. options: {},
  153. };
  154. },
  155. computed: {
  156. ...mapGetters(["userInfo"]),
  157. },
  158. onLoad(options) {
  159. this.options = options;
  160. },
  161. async onShow() {
  162. if (this.options.skipPort) {
  163. await this.$method.skipLogin(this.options.skipPort);
  164. }
  165. this.param.pageNum = 1;
  166. this.questionLists = [];
  167. this.getBankList();
  168. },
  169. onPullDownRefresh() {
  170. this.param.pageNum = 1;
  171. this.questionLists = [];
  172. this.getBankList();
  173. },
  174. onReachBottom() {
  175. if (this.questionLists.length < this.total) {
  176. this.param.pageNum++;
  177. this.getBankList();
  178. }
  179. },
  180. methods: {
  181. // 查询用户拥有免费+自购题库商品 /bank/question/listUserFreeUnionBuyGoodsList
  182. getBankList() {
  183. if (!this.$method.isLogin()) {
  184. return;
  185. }
  186. this.allLoading = true;
  187. this.$api
  188. .listUserFreeUnionBuyGoodsList(this.param)
  189. .then((res) => {
  190. if (res.data.code == 200) {
  191. this.questionLists.push(...(res.data.rows || []));
  192. console.log("this.courseList", this.questionLists);
  193. this.total = res.data.total;
  194. }
  195. this.allLoading = false;
  196. })
  197. .catch((err) => {
  198. this.allLoading = false;
  199. });
  200. },
  201. toChoose() {
  202. uni.switchTab({
  203. url: "/pages/course/index",
  204. });
  205. },
  206. toLink(externalLink) {
  207. if (!externalLink) {
  208. uni.showModal({
  209. showCancel: false,
  210. content: "链接不存在",
  211. });
  212. return;
  213. }
  214. // #ifdef MP-WEIXIN
  215. uni.navigateTo({
  216. url: `/pages/webview/sdlink?url=` + externalLink,
  217. });
  218. // #endif
  219. // #ifdef H5
  220. window.location.href = externalLink;
  221. // #endif
  222. },
  223. toDailyPractice(item, child) {
  224. this.$api
  225. .lockLockStatus({
  226. action: "bank",
  227. uuid: this.$method.getUuid(),
  228. })
  229. .then((res) => {
  230. if (res.data.code == 200) {
  231. //有其他端在操作,不能学习
  232. uni.showToast({
  233. icon: "none",
  234. title: res.data.msg,
  235. duration: 3000,
  236. });
  237. } else if (res.data.code == 500) {
  238. //可以学习
  239. if (child.paperName == "每日一练") {
  240. uni.navigateTo({
  241. url:
  242. "/pages2/dailyPractice/index?goodsId=" +
  243. item.goodsId +
  244. "&orderGoodsId=" +
  245. item.orderGoodsId,
  246. });
  247. } else if (child.paperName == "随机练习") {
  248. uni.navigateTo({
  249. url:
  250. "/pages2/randomPractice/index?goodsId=" +
  251. item.goodsId +
  252. "&orderGoodsId=" +
  253. item.orderGoodsId,
  254. });
  255. } else {
  256. this.studyques(item, child);
  257. }
  258. }
  259. });
  260. },
  261. // 进入练习
  262. studyques(item, child) {
  263. let sysTime = this.$method.timest();
  264. if (
  265. item.serviceStartTime &&
  266. item.serviceEndTime &&
  267. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  268. ) {
  269. uni.showToast({
  270. icon: "none",
  271. title: "不在学习服务期,不能进入学习",
  272. });
  273. return;
  274. }
  275. let paperId = (child && child.paperId) || "";
  276. uni.navigateTo({
  277. url:
  278. "/pages2/bank/question_detail?id=" +
  279. item.goodsId +
  280. "&orderGoodsId=" +
  281. item.orderGoodsId +
  282. "&paperId=" +
  283. paperId,
  284. });
  285. },
  286. },
  287. };
  288. </script>
  289. <style>
  290. page {
  291. background: #eaeef1;
  292. }
  293. </style>
  294. <style lang="scss" scoped>
  295. @import "./index.scss";
  296. </style>