index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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: 5,
  137. querySign: 1,
  138. },
  139. total: 0,
  140. options: {},
  141. isGetOtherQuetion: false,
  142. };
  143. },
  144. computed: {
  145. ...mapGetters(["userInfo", "config"]),
  146. },
  147. async onLoad(options) {
  148. uni.hideTabBar();
  149. this.options = options;
  150. if (this.options.isAct && !this.$method.isLogin()) {
  151. uni.navigateTo({
  152. url: "/pages4/login/login?isBack=" + true + "&isAct=1",
  153. });
  154. return;
  155. }
  156. },
  157. async onShow() {
  158. let { skipPort, sign } = this.options;
  159. if (skipPort) {
  160. this.options.skipPort = undefined;
  161. this.options.sign = undefined;
  162. await this.$method.skipLogin(skipPort);
  163. }
  164. this.param.pageNum = 1;
  165. this.questionLists = [];
  166. this.isGetOtherQuetion = sign || (await this.getIsHaveOtherQuetion());
  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. const fn = this.isGetOtherQuetion
  188. ? "sdQuestionList"
  189. : "listUserFreeUnionBuyGoodsList";
  190. this.$api[fn](this.param)
  191. .then((res) => {
  192. if (res.data.code == 200) {
  193. this.questionLists.push(...(res.data.rows || []));
  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.$method.checkLock("bank").then((res) => {
  209. if (child.paperName == "每日一练") {
  210. uni.navigateTo({
  211. url:
  212. "/pages2/dailyPractice/index?goodsId=" +
  213. item.goodsId +
  214. "&orderGoodsId=" +
  215. item.orderGoodsId,
  216. });
  217. } else if (child.paperName == "随机练习") {
  218. uni.navigateTo({
  219. url:
  220. "/pages2/randomPractice/index?goodsId=" +
  221. item.goodsId +
  222. "&orderGoodsId=" +
  223. item.orderGoodsId,
  224. });
  225. } else {
  226. this.studyques(item, child);
  227. }
  228. });
  229. },
  230. // 进入练习
  231. studyques(item, child) {
  232. let sysTime = this.$method.timest();
  233. if (
  234. item.serviceStartTime &&
  235. item.serviceEndTime &&
  236. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  237. ) {
  238. uni.showToast({
  239. icon: "none",
  240. title: "不在学习服务期,不能进入学习",
  241. });
  242. return;
  243. }
  244. let paperId = (child && child.paperId) || "";
  245. uni.navigateTo({
  246. url:
  247. "/pages2/bank/question_detail?id=" +
  248. item.goodsId +
  249. "&orderGoodsId=" +
  250. item.orderGoodsId +
  251. "&paperId=" +
  252. paperId,
  253. });
  254. },
  255. // 是否含有山东题库
  256. async getIsHaveOtherQuetion() {
  257. return new Promise((resolve, reject) => {
  258. this.$api.getIsHaveOtherQuetion().then((res) => {
  259. if (res.data.data == 1) {
  260. uni.showModal({
  261. title: "提示",
  262. content: "是否学习山东题库?",
  263. success: (res) => {
  264. resolve(res.confirm);
  265. },
  266. });
  267. } else {
  268. resolve(false);
  269. }
  270. });
  271. });
  272. },
  273. toSdLearn(item) {
  274. this.$api.getOtherExamId({ relId: item.qsId }).then((res) => {
  275. if (res.data.code == 200) {
  276. uni.navigateTo({
  277. url:
  278. "/pages2/bank/questionBank?id=" +
  279. res.data.data.examId +
  280. "&goodsid=" +
  281. item.goodsId +
  282. "&orderGoodsId=" +
  283. item.orderGoodsId +
  284. "&entryType=sd",
  285. });
  286. } else {
  287. uni.showToast({
  288. icon: "none",
  289. title: res.data.msg,
  290. });
  291. }
  292. });
  293. },
  294. toRecord(type) {
  295. let url = [
  296. "/pages2/subject/collect",
  297. "/pages2/bank/question_record",
  298. "/pages2/subject/wrong",
  299. "",
  300. ][type];
  301. if (this.isGetOtherQuetion) {
  302. url += "?isOther=1";
  303. }
  304. uni.navigateTo({
  305. url,
  306. });
  307. },
  308. },
  309. };
  310. </script>
  311. <style>
  312. page {
  313. background: #eaeef1;
  314. }
  315. </style>
  316. <style lang="scss" scoped>
  317. @import "./index.scss";
  318. </style>