index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view :class="type == 1 ? 'bgbox' : ''">
  3. <!--#ifdef APP-PLUS-->
  4. <view class="lz-status_bar">
  5. <view class="lz-top_view"></view>
  6. </view>
  7. <!--#endif-->
  8. <view class="kaoshi-head" :class="{'kaoshi-xcx': type != 1}">
  9. <!-- #ifndef MP-WEIXIN -->
  10. <view class="kaoshi-head-top">
  11. <view class="kaoshi-head-left" @tap="$navigateBack">
  12. <view class="iconfont icon-zuojiantou"></view>
  13. </view>
  14. <view class="kaoshi-head-m">{{type == '1' ? '章节练习' : '真题练习'}}</view>
  15. </view>
  16. <!--#endif-->
  17. <view class="kaoshi-head-banner" v-if="type == '1' && practice_record.scale != undefined">
  18. <view class="kaoshi-user-top-remind-b">
  19. <view class="kaoshi-user-top-remind-b-view">
  20. <view
  21. class="kaoshi-user-top-remind-b-title kaoshi-user-top-remind-b-title-content kaoshi-user-top-h1"
  22. v-cloak>{{practice_record.scale || 0}}
  23. <view class="kaoshi-remind-title">%</view>
  24. </view>
  25. <view>正确率</view>
  26. </view>
  27. <view class="kaoshi-user-top-remind-b-view">
  28. <view class="kaoshi-user-top-remind-b-title kaoshi-user-top-remind-b-title-content">
  29. {{practice_record.test_num || 0}}
  30. <view class="kaoshi-user-top-remind-b-title-p">/{{practice_record.total}}题</view>
  31. </view>
  32. <view>已做题</view>
  33. </view>
  34. <view class="kaoshi-user-top-remind-b-view">
  35. <view class="kaoshi-user-top-remind-b-title kaoshi-user-top-remind-b-title-content">
  36. {{practice_record.right_num || 0}}
  37. <view class="kaoshi-user-top-remind-b-title-p">题</view>
  38. </view>
  39. <view>答对</view>
  40. </view>
  41. </view>
  42. </view>
  43. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  44. :down="downOption" :up="upOption" height="auto">
  45. <view class="kaoshi-tiku">
  46. <block v-for="(item, index) in list" :key="index">
  47. <view class="kaoshi-tiku-content" @tap="goto_detail(item)">
  48. <view style="flex: 1;">
  49. <view class="kaoshi-tiku-content-flex">
  50. <view class="kaoshi-tiku-content-top">
  51. <view>{{item.name}}
  52. <view v-if="item.is_vip == 1 && !subjectVip" class="vip">
  53. <image src="../../../static/img/vip.png" mode=""></image>
  54. <view>VIP</view>
  55. </view></view>
  56. </view>
  57. <view class="kaoshi-tiku-bilv" v-cloak>{{item.scale || 0}}
  58. <view class="kaoshi-remind-title">%</view>
  59. </view>
  60. </view>
  61. <view class="kaoshi-tiku-content-flex">
  62. <view class="kaoshi-tiku-content-bottom">
  63. <view class="iconfont icon-dui2"></view>
  64. <view class="pub-gray">已答题{{item.test_num}}/{{item.total_num}}</view>
  65. </view>
  66. <view class="pub-gray">正确率</view>
  67. </view>
  68. </view>
  69. <view class="iconfont icon-arrow"></view>
  70. </view>
  71. </block>
  72. </view>
  73. </mescroll-body>
  74. </view>
  75. <authVip v-if="showAuthVip" @hideAuthVip="showAuthVip = false"></authVip>
  76. </view>
  77. </template>
  78. <script>
  79. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  80. import {
  81. mapState
  82. } from 'vuex'
  83. import Error from '@/core/untils/error/index';
  84. import authVip from '@/components/authVip.vue'
  85. export default {
  86. mixins: [MescrollMixin], // 使用mixin
  87. data() {
  88. return {
  89. mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
  90. // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  91. downOption: {
  92. use: true, // 是否启用下拉刷新; 默认true
  93. auto: false, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
  94. native: false // 启用系统自带的下拉组件,默认false;仅mescroll-body生效,mescroll-uni无效(native: true, 则需在pages.json中配置"enablePullDownRefresh":true)
  95. },
  96. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  97. upOption: {
  98. page: {
  99. num: 0,
  100. size: 10 // 每页数据的数量,默认10
  101. },
  102. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  103. empty: {
  104. tip: '暂无相关数据'
  105. }
  106. },
  107. // 列表数据
  108. list: [],
  109. type: '',
  110. practice_record: {},
  111. showAuthVip: false, //弹窗
  112. }
  113. },
  114. onShow() {
  115. if (this.$myUserLogin.getToken()) {
  116. if (this.type == 1) {
  117. //获取顶部正确率
  118. this.get_record();
  119. }
  120. }
  121. },
  122. onLoad(opts) {
  123. if (opts && opts.from_type) {
  124. this.type = opts.from_type
  125. uni.setNavigationBarTitle({
  126. title: this.type == 1 ? '章节练习' : '真题练习'
  127. });
  128. }
  129. },
  130. mounted() {
  131. },
  132. computed: {
  133. ...mapState(['subject', "userinfo", 'subjectVip']),
  134. },
  135. components: {
  136. authVip
  137. },
  138. methods: {
  139. /*上拉加载的回调*/
  140. async upCallback(page) {
  141. let pageNum = page.num; // 页码, 默认从1开始
  142. let pageSize = page.size; // 页长, 默认每页10条
  143. let needLogin = false
  144. if (this.userinfo.token) {
  145. needLogin = true
  146. }
  147. let res = await this.$myHttp.post({
  148. url: this.type == '1' ? this.$myHttp.urlMap.unitList : this.$myHttp.urlMap.zhentiList,
  149. data: {
  150. subject_id: this.subject.id,
  151. unit_id: 0,
  152. page: pageNum,
  153. limit: pageSize
  154. },
  155. needLogin: needLogin
  156. })
  157. if (res.code == 1) {
  158. // 接口返回的当前页数据列表 (数组)
  159. let curPageData = res.data.data;
  160. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  161. let curPageLen = curPageData.length;
  162. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  163. // let totalPage = data.xxx;
  164. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  165. let totalSize = res.data.total;
  166. this.mescroll.endBySize(curPageLen, totalSize);
  167. if (page.num == 1) this.list = []; //如果是第一页需手动置空列表
  168. this.list = this.list.concat(curPageData); //追加新数据
  169. } else {
  170. this.mescroll.endErr()
  171. }
  172. // 此处仍可以继续写其他接口请求...
  173. // 调用其他方法...
  174. },
  175. async get_record() {
  176. let res = await this.$myHttp.post({
  177. url: this.$myHttp.urlMap.unitPracticeRecord,
  178. data: {
  179. subject_id: this.subject.id,
  180. },
  181. needLogin: true
  182. })
  183. if (res.code == 1) {
  184. this.practice_record = res.data
  185. }
  186. },
  187. goto_detail(item) {
  188. if (item.total_num == 0) { //如果目录下没有题目,提示用户
  189. this.$myUtils.$prompt.showToast({
  190. icon: 'none',
  191. title: '当前目录下没有题目,请联系老师'
  192. });
  193. return
  194. }
  195. if (!this.subjectVip && item.is_vip) {
  196. if (this.$myUserLogin.getToken()) {
  197. this.showAuthVip = true
  198. return
  199. } else {
  200. Error.errorNotLoggedIn();
  201. return
  202. }
  203. }
  204. if (this.type == '1') {
  205. if (item.is_last == 0) {
  206. //非终极栏目,点击进入下级栏目
  207. this.$openrul('/pages/questionBank/detail/index?id=' + item.id + '&from_type=' + this.type +
  208. '&name=' + item.name)
  209. } else if (item.is_last == 1) {
  210. if (this.$myUserLogin.getToken()) {
  211. //终极栏目,点击进入答题页
  212. this.$openrul('/pages/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=' +
  213. this.type + '&name=' + item.name)
  214. } else {
  215. Error.errorNotLoggedIn();
  216. }
  217. }
  218. } else if (this.type == '2') {
  219. if (this.$myUserLogin.getToken()) {
  220. //点击进入答题页
  221. this.$openrul('/pages/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=' + this
  222. .type + '&name=' + item.name)
  223. } else {
  224. Error.errorNotLoggedIn();
  225. }
  226. }
  227. }
  228. }
  229. }
  230. </script>
  231. <style>
  232. .bgbox {
  233. background-image: linear-gradient(#026aef 0, #fff 180px, #fff 200px, #f9f9f9 230px, #f9f9f9 100%);
  234. background-repeat: no-repeat;
  235. background-color: #f9f9f9;
  236. }
  237. .kaoshi-head {
  238. background: none
  239. }
  240. .kaoshi-head-top {
  241. color: #fff;
  242. }
  243. .kaoshi-head-top .kaoshi-head-m {
  244. font-weight: normal;
  245. }
  246. .kaoshi-head-banner {
  247. background: #fff;
  248. border-radius: 5px;
  249. width: 92%;
  250. margin: 10px auto;
  251. box-shadow: 0 0 10px rgba(208, 208, 208, 0.5);
  252. margin-bottom: 18px;
  253. padding: 16px 0 18px 0;
  254. }
  255. .kaoshi-user-top-remind-b {
  256. display: flex;
  257. justify-content: center;
  258. text-align: center;
  259. font-size: 14px;
  260. color: #c5c5c5;
  261. }
  262. .kaoshi-user-top-remind-b-view {
  263. flex: 1;
  264. }
  265. .kaoshi-user-top-remind-b-title {
  266. font-size: 18px;
  267. color: #000;
  268. padding: 4px 0 6px 0;
  269. }
  270. .kaoshi-remind-title {
  271. font-size: 13px;
  272. color: #000;
  273. }
  274. .kaoshi-user-top-remind-b-title-content {
  275. display: flex;
  276. align-items: baseline;
  277. justify-content: center;
  278. }
  279. .kaoshi-user-top-remind-b img {
  280. width: 48px;
  281. height: 26px;
  282. }
  283. .kaoshi-user-top-h1 {
  284. font-size: 26px !important;
  285. padding: 0 !important;
  286. }
  287. /*题库列表*/
  288. .kaoshi-tiku {
  289. background: #fff;
  290. width: 93%;
  291. margin: 0 auto;
  292. border-radius: 8px;
  293. }
  294. .kaoshi-xcx .kaoshi-tiku {
  295. width: 100%;
  296. }
  297. .kaoshi-tiku-content {
  298. width: 92%;
  299. margin: 0 auto;
  300. display: flex;
  301. flex-direction: row;
  302. align-items: center;
  303. font-size: 16px;
  304. padding: 14px 0;
  305. border-bottom: solid 1px #f5f5f5;
  306. }
  307. .kaoshi-tiku-content-flex {
  308. width: 100%;
  309. display: flex;
  310. justify-content: space-between;
  311. align-items: center;
  312. }
  313. .kaoshi-tiku-content .icon-arrow {
  314. padding-left: 13px;
  315. color: #b3b3b3;
  316. font-size: 14px;
  317. }
  318. .kaoshi-tiku-content .kaoshi-tiku-content-flex:first-child {
  319. padding-bottom: 2px;
  320. }
  321. .kaoshi-tiku-content .kaoshi-tiku-content-flex:last-child {
  322. font-size: 14px;
  323. }
  324. .kaoshi-tiku-content-top {
  325. display: flex;
  326. align-items: center;
  327. }
  328. .kaoshi-tiku-content-top img {
  329. width: 20px;
  330. height: 22px;
  331. margin-right: 10px;
  332. }
  333. .kaoshi-tiku-content-bottom {
  334. display: flex;
  335. align-items: center;
  336. }
  337. .kaoshi-tiku-content-flex .icon-dui2 {
  338. margin: 2px 2px 0 0;
  339. color: #3c7bfc;
  340. }
  341. .kaoshi-tiku-bilv {
  342. font-size: 22px;
  343. color: #000;
  344. display: flex;
  345. align-items: baseline;
  346. }
  347. .kaoshi-user-top-remind-b-title-p {
  348. font-size: 15px;
  349. }
  350. /* #ifdef MP-WEIXIN */
  351. .kaoshi-xcx {
  352. background: #fff;
  353. padding-top: 8px;
  354. }
  355. .bgbox {
  356. padding-top: 8px;
  357. }
  358. /* #endif */
  359. .kaoshi-xcx .kaoshi-head-top {
  360. color: #000;
  361. }
  362. .kaoshi-xcx {
  363. background: #fff;
  364. }
  365. </style>