index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view class="questionBank">
  3. <nav-logo title="题库中心"></nav-logo>
  4. <!-- 有学习的课程 -->
  5. <view class="had_courses" v-if="$method.isLogin()">
  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 v-for="(item, index) in questionLists" :key="index" class="course_item">
  32. <view>
  33. <view class="cou_titles">{{ item.goodsName }}</view>
  34. <view v-if="
  35. item.serviceStartTime &&
  36. item.serviceEndTime &&
  37. !item.externalLinkStatus
  38. " class="learn_ranges">
  39. <image class="l_range" src="/static/learn/learn_range.png"></image>
  40. {{ isGetOtherQuetion ? "有效期" : "学习周期" }}:
  41. <text class="l_time">{{ item.serviceStartTime | formate("yyyy.mm.dd") }}-{{
  42. item.serviceEndTime | formate("yyyy.mm.dd")
  43. }}</text>
  44. </view>
  45. </view>
  46. <view class="c_downs">
  47. <view class="lefts">
  48. <image class="lefet_img" :src="$method.splitImgHost(item.coverUrl, true)" mode="">
  49. </image>
  50. </view>
  51. <view class="rights" v-if="!item.externalLinkStatus">
  52. <view class="learn_progress">
  53. <view class="progress_up">
  54. <view v-if="isGetOtherQuetion">
  55. 总题数:{{ item.questionNum || 300 }}题
  56. </view>
  57. <template v-else>
  58. <view>
  59. 学习进度:{{ item.doNum }}/{{ item.totalNum }}
  60. </view>
  61. <view class="progress_bar" style="width: 100%">
  62. <u-line-progress :show-percent="false" height="22"
  63. active-color="#ff9900"
  64. :percent="(item.doNum / item.totalNum) * 100"></u-line-progress>
  65. </view>
  66. </template>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 按钮 -->
  72. <view class="study_btns" v-if="isGetOtherQuetion">
  73. <view class="exam_word intos" @click="toSdLearn(item)">开始刷题</view>
  74. </view>
  75. <view class="study_btns" v-else-if="!item.externalLinkStatus">
  76. <view v-for="(child, c_index) in item.paperVos" :key="c_index" class="exam_word intos"
  77. @click.stop="toDailyPractice(item, child)">{{ child.paperName }}</view>
  78. </view>
  79. <view class="study_btns" v-else>
  80. <view class="exam_word intos" @click.stop="$method.toLink(item.externalLink)">进入学习</view>
  81. </view>
  82. </view>
  83. </template>
  84. </view>
  85. </view>
  86. <!-- 没有学习的课程 -->
  87. <view v-if="!allLoading && !questionLists.length" class="no_datas">
  88. <!-- <image class="courses" src="/static/learn/no_course.png" mode=""></image>
  89. <view class="no_learns">您目前没有可学习的题库</view> -->
  90. <image src="/static/learn/empty_status.png" class="empty_status"></image>
  91. <text class="word_tip">暂无题库</text>
  92. <view class="choose" @click="toChoose()">立即去选购</view>
  93. </view>
  94. <!-- tabbar -->
  95. <myTabbar :backTopBtn="backTopBtn"></myTabbar>
  96. </view>
  97. </template>
  98. <script>
  99. import {
  100. mapGetters
  101. } from "vuex";
  102. export default {
  103. data() {
  104. return {
  105. backTopBtn:false,
  106. allLoading: false, // 加载样式
  107. questionLists: [], // 题库列表
  108. param: {
  109. pageNum: 1,
  110. pageSize: 5,
  111. querySign: 1,
  112. },
  113. total: 0,
  114. options: {},
  115. isGetOtherQuetion: false,
  116. };
  117. },
  118. computed: {
  119. ...mapGetters(["userInfo", "config"]),
  120. },
  121. async onLoad(options) {
  122. uni.hideTabBar();
  123. this.options = options;
  124. if (this.options.isAct && !this.$method.isLogin()) {
  125. uni.navigateTo({
  126. url: "/pages4/login/login?isBack=" + true + "&isAct=1",
  127. });
  128. return;
  129. }
  130. },
  131. async onShow() {
  132. let {
  133. skipPort,
  134. sign
  135. } = this.options;
  136. if (skipPort) {
  137. this.options.skipPort = undefined;
  138. this.options.sign = undefined;
  139. await this.$method.skipLogin(skipPort);
  140. }
  141. if (this.$method.isLogin()) {
  142. this.param.pageNum = 1;
  143. this.questionLists = [];
  144. this.isGetOtherQuetion = sign || (await this.getIsHaveOtherQuetion());
  145. this.getBankList();
  146. }
  147. },
  148. onPullDownRefresh() {
  149. this.param.pageNum = 1;
  150. this.questionLists = [];
  151. this.getBankList();
  152. },
  153. onPageScroll(e) {
  154. if (e.scrollTop > 100) {
  155. this.backTopBtn = true
  156. } else {
  157. this.backTopBtn = false
  158. }
  159. },
  160. onReachBottom() {
  161. if (this.questionLists.length < this.total) {
  162. this.param.pageNum++;
  163. this.getBankList();
  164. }
  165. },
  166. methods: {
  167. // 查询用户拥有免费+自购题库商品 /bank/question/listUserFreeUnionBuyGoodsList
  168. getBankList() {
  169. if (!this.$method.isLogin()) {
  170. return;
  171. }
  172. this.allLoading = true;
  173. const fn = this.isGetOtherQuetion ?
  174. "sdQuestionList" :
  175. "listUserFreeUnionBuyGoodsList";
  176. this.$api[fn](this.param)
  177. .then((res) => {
  178. if (res.data.code == 200) {
  179. this.questionLists.push(...(res.data.rows || []));
  180. this.total = res.data.total;
  181. }
  182. this.allLoading = false;
  183. })
  184. .catch((err) => {
  185. this.allLoading = false;
  186. });
  187. },
  188. toChoose() {
  189. this.$store.state.current = 2
  190. uni.switchTab({
  191. url: '/pages/course/index'
  192. });
  193. },
  194. toDailyPractice(item, child) {
  195. this.$method.checkLock("bank").then((res) => {
  196. if (child.paperName == "每日一练") {
  197. uni.navigateTo({
  198. url: "/pages2/dailyPractice/index?goodsId=" +
  199. item.goodsId +
  200. "&orderGoodsId=" +
  201. item.orderGoodsId,
  202. });
  203. } else if (child.paperName == "随机练习") {
  204. uni.navigateTo({
  205. url: "/pages2/randomPractice/index?goodsId=" +
  206. item.goodsId +
  207. "&orderGoodsId=" +
  208. item.orderGoodsId,
  209. });
  210. } else {
  211. this.studyques(item, child);
  212. }
  213. });
  214. },
  215. // 进入练习
  216. studyques(item, child) {
  217. let sysTime = this.$method.timest();
  218. if (
  219. item.serviceStartTime &&
  220. item.serviceEndTime &&
  221. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  222. ) {
  223. uni.showToast({
  224. icon: "none",
  225. title: "不在学习服务期,不能进入学习",
  226. });
  227. return;
  228. }
  229. let paperId = (child && child.paperId) || "";
  230. uni.navigateTo({
  231. url: "/pages2/bank/question_detail?id=" +
  232. item.goodsId +
  233. "&orderGoodsId=" +
  234. item.orderGoodsId +
  235. "&paperId=" +
  236. paperId,
  237. });
  238. },
  239. // 是否含有山东题库
  240. async getIsHaveOtherQuetion() {
  241. return new Promise((resolve, reject) => {
  242. this.$api.getIsHaveOtherQuetion().then((res) => {
  243. if (res.data.data == 1) {
  244. uni.showModal({
  245. title: "提示",
  246. content: "是否学习山东题库?",
  247. success: (res) => {
  248. resolve(res.confirm);
  249. },
  250. });
  251. } else {
  252. resolve(false);
  253. }
  254. });
  255. });
  256. },
  257. toSdLearn(item) {
  258. this.$api.getOtherExamId({
  259. relId: item.qsId
  260. }).then((res) => {
  261. if (res.data.code == 200) {
  262. uni.navigateTo({
  263. url: "/pages2/bank/questionBank?id=" +
  264. res.data.data.examId +
  265. "&goodsid=" +
  266. item.goodsId +
  267. "&orderGoodsId=" +
  268. item.orderGoodsId +
  269. "&entryType=sd",
  270. });
  271. } else {
  272. uni.showToast({
  273. icon: "none",
  274. title: res.data.msg,
  275. });
  276. }
  277. });
  278. },
  279. toRecord(type) {
  280. let url = [
  281. "/pages2/subject/collect",
  282. "/pages2/bank/question_record",
  283. "/pages2/subject/wrong",
  284. "",
  285. ][type];
  286. if (this.isGetOtherQuetion) {
  287. url += "?isOther=1";
  288. }
  289. uni.navigateTo({
  290. url,
  291. });
  292. },
  293. },
  294. };
  295. </script>
  296. <style>
  297. page {
  298. background: #eaeef1;
  299. }
  300. </style>
  301. <style lang="scss" scoped>
  302. @import "./index.scss";
  303. </style>