index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. <view class="item collect" @click="toRecord(0)">
  11. <view class="text">收藏集<u-icon name="arrow-right"></u-icon></view>
  12. <image class="img" src="/static/questionBank_collect.png"></image>
  13. </view>
  14. <view class="item list">
  15. <view class="list-in" @click="toRecord(1)">
  16. <image class="img" src="/static/questionBank_record.png"></image>
  17. <view class="text">
  18. 做题记录 <u-icon name="arrow-right"></u-icon>
  19. </view>
  20. </view>
  21. <view class="list-in" @click="toRecord(2)">
  22. <image class="img" src="/static/questionBank_wrong.png"></image>
  23. <view class="text">
  24. 错题集 <u-icon name="arrow-right"></u-icon>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <template v-if="questionLists.length">
  30. <!-- @click="studyques(item)" -->
  31. <view
  32. v-for="(item, index) in questionLists"
  33. :key="index"
  34. class="course_item"
  35. >
  36. <view>
  37. <view class="cou_titles">{{ item.goodsName }}</view>
  38. <view
  39. v-if="
  40. item.serviceStartTime &&
  41. item.serviceEndTime &&
  42. !item.externalLinkStatus
  43. "
  44. class="learn_ranges"
  45. >
  46. <image
  47. class="l_range"
  48. src="/static/learn/learn_range.png"
  49. ></image>
  50. {{ isGetOtherQuetion ? "有效期" : "学习周期" }}:
  51. <text class="l_time"
  52. >{{ item.serviceStartTime | formate("yyyy.mm.dd") }}-{{
  53. item.serviceEndTime | formate("yyyy.mm.dd")
  54. }}</text
  55. >
  56. </view>
  57. </view>
  58. <view class="c_downs">
  59. <view class="lefts">
  60. <image
  61. class="lefet_img"
  62. :src="$method.splitImgHost(item.coverUrl, true)"
  63. mode=""
  64. ></image>
  65. </view>
  66. <view class="rights" v-if="!item.externalLinkStatus">
  67. <view class="learn_progress">
  68. <view class="progress_up">
  69. <view v-if="isGetOtherQuetion">
  70. 总题数:{{ item.questionNum || 300 }}题
  71. </view>
  72. <template v-else>
  73. <view>
  74. 学习进度:{{ item.doNum }}/{{ item.totalNum }}
  75. </view>
  76. <view class="progress_bar" style="width: 100%">
  77. <u-line-progress
  78. :show-percent="false"
  79. height="22"
  80. active-color="#ff9900"
  81. :percent="(item.doNum / item.totalNum) * 100"
  82. ></u-line-progress>
  83. </view>
  84. </template>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 按钮 -->
  90. <view class="study_btns" v-if="isGetOtherQuetion">
  91. <view class="exam_word intos" @click="toSdLearn(item)"
  92. >开始刷题</view
  93. >
  94. </view>
  95. <view class="study_btns" v-else-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. isGetOtherQuetion: true,
  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.getIsHaveOtherQuetion();
  161. this.param.pageNum = 1;
  162. this.questionLists = [];
  163. this.getBankList();
  164. },
  165. onPullDownRefresh() {
  166. this.param.pageNum = 1;
  167. this.questionLists = [];
  168. this.getBankList();
  169. },
  170. onReachBottom() {
  171. if (this.questionLists.length < this.total) {
  172. this.param.pageNum++;
  173. this.getBankList();
  174. }
  175. },
  176. methods: {
  177. // 查询用户拥有免费+自购题库商品 /bank/question/listUserFreeUnionBuyGoodsList
  178. getBankList() {
  179. if (!this.$method.isLogin()) {
  180. return;
  181. }
  182. this.allLoading = true;
  183. const fn = this.isGetOtherQuetion
  184. ? "sdQuestionList"
  185. : "listUserFreeUnionBuyGoodsList";
  186. this.$api[fn](this.param)
  187. .then((res) => {
  188. if (res.data.code == 200) {
  189. this.questionLists.push(...(res.data.rows || []));
  190. console.log("this.courseList", this.questionLists);
  191. this.total = res.data.total;
  192. }
  193. this.allLoading = false;
  194. })
  195. .catch((err) => {
  196. this.allLoading = false;
  197. });
  198. },
  199. toChoose() {
  200. uni.switchTab({
  201. url: "/pages/course/index",
  202. });
  203. },
  204. toDailyPractice(item, child) {
  205. this.$method.checkLock("bank").then((res) => {
  206. if (child.paperName == "每日一练") {
  207. uni.navigateTo({
  208. url:
  209. "/pages2/dailyPractice/index?goodsId=" +
  210. item.goodsId +
  211. "&orderGoodsId=" +
  212. item.orderGoodsId,
  213. });
  214. } else if (child.paperName == "随机练习") {
  215. uni.navigateTo({
  216. url:
  217. "/pages2/randomPractice/index?goodsId=" +
  218. item.goodsId +
  219. "&orderGoodsId=" +
  220. item.orderGoodsId,
  221. });
  222. } else {
  223. this.studyques(item, child);
  224. }
  225. });
  226. },
  227. // 进入练习
  228. studyques(item, child) {
  229. let sysTime = this.$method.timest();
  230. if (
  231. item.serviceStartTime &&
  232. item.serviceEndTime &&
  233. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  234. ) {
  235. uni.showToast({
  236. icon: "none",
  237. title: "不在学习服务期,不能进入学习",
  238. });
  239. return;
  240. }
  241. let paperId = (child && child.paperId) || "";
  242. uni.navigateTo({
  243. url:
  244. "/pages2/bank/question_detail?id=" +
  245. item.goodsId +
  246. "&orderGoodsId=" +
  247. item.orderGoodsId +
  248. "&paperId=" +
  249. paperId,
  250. });
  251. },
  252. // 是否含有山东题库
  253. async getIsHaveOtherQuetion() {
  254. let res = await this.$api.getIsHaveOtherQuetion();
  255. if (res.data.data == 1) {
  256. uni.showModal({
  257. title: "提示",
  258. content: "是否学习山东题库?",
  259. success: (res) => {
  260. this.isGetOtherQuetion = res.confirm;
  261. if (res.confirm) {
  262. this.getBankList();
  263. }
  264. },
  265. });
  266. }
  267. },
  268. toSdLearn(item) {
  269. this.$api.getOtherExamId({ relId: item.qsId }).then((res) => {
  270. if (res.data.code == 200) {
  271. uni.navigateTo({
  272. url:
  273. "/pages2/bank/questionBank?id=" +
  274. res.data.data.examId +
  275. "&goodsid=" +
  276. item.goodsId +
  277. "&orderGoodsId=" +
  278. item.orderGoodsId +
  279. "&entryType=sd",
  280. });
  281. } else {
  282. uni.showToast({
  283. icon: "none",
  284. title: res.data.msg,
  285. });
  286. }
  287. });
  288. },
  289. toRecord(type) {
  290. let url = [
  291. "/pages2/subject/collect",
  292. "/pages2/bank/question_record",
  293. "/pages2/subject/wrong",
  294. "",
  295. ][type];
  296. if (this.isGetOtherQuetion) {
  297. url += "?isOther=1";
  298. }
  299. uni.navigateTo({
  300. url,
  301. });
  302. },
  303. },
  304. };
  305. </script>
  306. <style>
  307. page {
  308. background: #eaeef1;
  309. }
  310. </style>
  311. <style lang="scss" scoped>
  312. @import "./index.scss";
  313. </style>