index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. if(this.$method.isLogin()){
  165. this.param.pageNum = 1;
  166. this.questionLists = [];
  167. this.isGetOtherQuetion = sign || (await this.getIsHaveOtherQuetion());
  168. this.getBankList();
  169. }
  170. },
  171. onPullDownRefresh() {
  172. this.param.pageNum = 1;
  173. this.questionLists = [];
  174. this.getBankList();
  175. },
  176. onReachBottom() {
  177. if (this.questionLists.length < this.total) {
  178. this.param.pageNum++;
  179. this.getBankList();
  180. }
  181. },
  182. methods: {
  183. // 查询用户拥有免费+自购题库商品 /bank/question/listUserFreeUnionBuyGoodsList
  184. getBankList() {
  185. if (!this.$method.isLogin()) {
  186. return;
  187. }
  188. this.allLoading = true;
  189. const fn = this.isGetOtherQuetion
  190. ? "sdQuestionList"
  191. : "listUserFreeUnionBuyGoodsList";
  192. this.$api[fn](this.param)
  193. .then((res) => {
  194. if (res.data.code == 200) {
  195. this.questionLists.push(...(res.data.rows || []));
  196. this.total = res.data.total;
  197. }
  198. this.allLoading = false;
  199. })
  200. .catch((err) => {
  201. this.allLoading = false;
  202. });
  203. },
  204. toChoose() {
  205. this.$store.state.current = 2
  206. uni.switchTab({
  207. url: '/pages/course/index'
  208. });
  209. },
  210. toDailyPractice(item, child) {
  211. this.$method.checkLock("bank").then((res) => {
  212. if (child.paperName == "每日一练") {
  213. uni.navigateTo({
  214. url:
  215. "/pages2/dailyPractice/index?goodsId=" +
  216. item.goodsId +
  217. "&orderGoodsId=" +
  218. item.orderGoodsId,
  219. });
  220. } else if (child.paperName == "随机练习") {
  221. uni.navigateTo({
  222. url:
  223. "/pages2/randomPractice/index?goodsId=" +
  224. item.goodsId +
  225. "&orderGoodsId=" +
  226. item.orderGoodsId,
  227. });
  228. } else {
  229. this.studyques(item, child);
  230. }
  231. });
  232. },
  233. // 进入练习
  234. studyques(item, child) {
  235. let sysTime = this.$method.timest();
  236. if (
  237. item.serviceStartTime &&
  238. item.serviceEndTime &&
  239. (sysTime <= item.serviceStartTime || sysTime >= item.serviceEndTime)
  240. ) {
  241. uni.showToast({
  242. icon: "none",
  243. title: "不在学习服务期,不能进入学习",
  244. });
  245. return;
  246. }
  247. let paperId = (child && child.paperId) || "";
  248. uni.navigateTo({
  249. url:
  250. "/pages2/bank/question_detail?id=" +
  251. item.goodsId +
  252. "&orderGoodsId=" +
  253. item.orderGoodsId +
  254. "&paperId=" +
  255. paperId,
  256. });
  257. },
  258. // 是否含有山东题库
  259. async getIsHaveOtherQuetion() {
  260. return new Promise((resolve, reject) => {
  261. this.$api.getIsHaveOtherQuetion().then((res) => {
  262. if (res.data.data == 1) {
  263. uni.showModal({
  264. title: "提示",
  265. content: "是否学习山东题库?",
  266. success: (res) => {
  267. resolve(res.confirm);
  268. },
  269. });
  270. } else {
  271. resolve(false);
  272. }
  273. });
  274. });
  275. },
  276. toSdLearn(item) {
  277. this.$api.getOtherExamId({ relId: item.qsId }).then((res) => {
  278. if (res.data.code == 200) {
  279. uni.navigateTo({
  280. url:
  281. "/pages2/bank/questionBank?id=" +
  282. res.data.data.examId +
  283. "&goodsid=" +
  284. item.goodsId +
  285. "&orderGoodsId=" +
  286. item.orderGoodsId +
  287. "&entryType=sd",
  288. });
  289. } else {
  290. uni.showToast({
  291. icon: "none",
  292. title: res.data.msg,
  293. });
  294. }
  295. });
  296. },
  297. toRecord(type) {
  298. let url = [
  299. "/pages2/subject/collect",
  300. "/pages2/bank/question_record",
  301. "/pages2/subject/wrong",
  302. "",
  303. ][type];
  304. if (this.isGetOtherQuetion) {
  305. url += "?isOther=1";
  306. }
  307. uni.navigateTo({
  308. url,
  309. });
  310. },
  311. },
  312. };
  313. </script>
  314. <style>
  315. page {
  316. background: #eaeef1;
  317. }
  318. </style>
  319. <style lang="scss" scoped>
  320. @import "./index.scss";
  321. </style>