index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view>
  3. <!--#ifdef APP-PLUS-->
  4. <view class="lz-status_bar">
  5. <view class="lz-top_view"></view>
  6. </view>
  7. <!--#endif-->
  8. <!-- #ifndef MP-WEIXIN -->
  9. <view class="kaoshi-head">
  10. <view class="kaoshi-head-top">
  11. <view class="kaoshi-head-left"></view>
  12. <view class="kaoshi-head-m">题库</view>
  13. </view>
  14. </view>
  15. <!-- #endif -->
  16. <view class="kaoshi-head-nav">
  17. <view class="kaoshi-head-nav-flex"
  18. @tap="$openrul('/pages/questionBank/questionBankList/index?from_type=1')">
  19. <image :src="static_media.img01" class="kaoshi-head-nav-img"></image>
  20. <view>章节练习</view>
  21. </view>
  22. <view class="kaoshi-head-nav-flex"
  23. @tap="$openrul('/pages/questionBank/questionBankList/index?from_type=2')">
  24. <image :src="static_media.img02" class="kaoshi-head-nav-img"></image>
  25. <view>真题练习</view>
  26. </view>
  27. <view class="kaoshi-head-nav-flex" @tap="navTo('/pages/my/wrongQuestion/index')">
  28. <image :src="static_media.img03" class="kaoshi-head-nav-img"></image>
  29. <view>题库错题</view>
  30. </view>
  31. <view class="kaoshi-head-nav-flex" @tap="navTo('/pages/my/collect/index')">
  32. <image :src="static_media.img04" class="kaoshi-head-nav-img"></image>
  33. <view>我的收藏</view>
  34. </view>
  35. </view>
  36. <view class="kaoshi-tiku-title" v-if="unit_list.length > 0">
  37. <view class="kaoshi-tiku-title-l">章节练习</view>
  38. <view @tap="$openrul('/pages/questionBank/questionBankList/index?from_type=1')" class="kaoshi-tiku-title-r">
  39. 全部章节
  40. </view>
  41. </view>
  42. <view class="kaoshi-tiku">
  43. <block v-for="(item, index) in unit_list" :key="index">
  44. <view class="kaoshi-tiku-content" @tap="goto_detail(item,'1')">
  45. <view class="pub-flex-1">
  46. <view class="kaoshi-tiku-content-flex">
  47. <view class="kaoshi-tiku-content-top">
  48. <view>{{item.name}}
  49. <view v-if="item.is_vip == 1 && !subjectVip" class="vip">
  50. <image src="../../static/img/vip.png" mode=""></image>
  51. <view>VIP</view>
  52. </view></view>
  53. </view>
  54. <view class="kaoshi-tiku-bilv">{{item.scale.toFixed(0)}}
  55. <view class="kaoshi-remind-title">%</view>
  56. </view>
  57. </view>
  58. <view class="kaoshi-tiku-content-flex">
  59. <view class="kaoshi-tiku-content-bottom">
  60. <view class="iconfont icon-dui2"></view>
  61. <view class="pub-gray">已答题{{item.test_num}}/{{item.total_num}}</view>
  62. </view>
  63. <view class="pub-gray">正确率</view>
  64. </view>
  65. </view>
  66. <view class="iconfont icon-arrow"></view>
  67. </view>
  68. </block>
  69. </view>
  70. <view class="kaoshi-tiku-title" v-if="zhenti_list.length > 0">
  71. <view class="kaoshi-tiku-title-l">真题练习</view>
  72. <view @tap="$openrul('/pages/questionBank/questionBankList/index?from_type=2')" class="kaoshi-tiku-title-r">
  73. 全部真题
  74. </view>
  75. </view>
  76. <view class="kaoshi-tiku">
  77. <block v-for="(item, index) in zhenti_list" :key="index">
  78. <view class="kaoshi-tiku-content" @tap="goto_detail(item,'2')">
  79. <view style="flex: 1;">
  80. <view class="kaoshi-tiku-content-flex">
  81. <view class="kaoshi-tiku-content-top">
  82. <view>{{item.name}}
  83. <view v-if="item.is_vip == 1 && !subjectVip" class="vip">
  84. <image src="../../static/img/vip.png" mode=""></image>
  85. <view>VIP</view>
  86. </view></view>
  87. </view>
  88. <view class="kaoshi-tiku-bilv">{{item.scale}}
  89. <view class="kaoshi-remind-title">%</view>
  90. </view>
  91. </view>
  92. <view class="kaoshi-tiku-content-flex">
  93. <view class="kaoshi-tiku-content-bottom">
  94. <view class="iconfont icon-dui2"></view>
  95. <view class="pub-gray">已答题{{item.test_num}}/{{item.total_num}}</view>
  96. </view>
  97. <view class="pub-gray">正确率</view>
  98. </view>
  99. </view>
  100. <view class="iconfont icon-arrow"></view>
  101. </view>
  102. </block>
  103. </view>
  104. <authVip v-if="showAuthVip" @hideAuthVip="showAuthVip = false"></authVip>
  105. </view>
  106. </template>
  107. <script>
  108. import {
  109. mapState
  110. } from 'vuex';
  111. import Error from '@/core/untils/error/index';
  112. import authVip from '@/components/authVip.vue'
  113. export default {
  114. data() {
  115. return {
  116. unit_list: [],
  117. zhenti_list: [],
  118. showAuthVip: false,
  119. };
  120. },
  121. onShow() {
  122. this.get_tiku_list();
  123. this.get_zhenti_list();
  124. },
  125. onLoad() {
  126. // #ifdef MP-WEIXIN
  127. wx.showShareMenu({
  128. withShareTicket: true,
  129. menus: ["shareAppMessage", "shareTimeline"]
  130. })
  131. // #endif
  132. },
  133. computed: {
  134. ...mapState(['subject', 'subjectVip', 'userinfo']),
  135. static_media() {
  136. return {
  137. img01: this.$myConfig.localMedia + '/static/img/tiku-icon1.png',
  138. img02: this.$myConfig.localMedia + '/static/img/tiku-icon2.png',
  139. img03: this.$myConfig.localMedia + '/static/img/tiku-icon3.png',
  140. img04: this.$myConfig.localMedia + '/static/img/tiku-icon4.png',
  141. };
  142. },
  143. },
  144. components: {
  145. authVip
  146. },
  147. methods: {
  148. //章节列表
  149. async get_tiku_list() {
  150. let needLogin = false
  151. if (this.userinfo.token) {
  152. needLogin = true
  153. }
  154. let res = await this.$myHttp.post({
  155. url: this.$myHttp.urlMap.unitList,
  156. data: {
  157. subject_id: this.subject.id,
  158. unit_id: 0,
  159. page: 1,
  160. limit: 4
  161. },
  162. needLogin: needLogin
  163. });
  164. if (res.code === 1) {
  165. this.unit_list = res.data.data;
  166. }
  167. },
  168. //历年真题列表
  169. async get_zhenti_list() {
  170. let needLogin = false
  171. if (this.userinfo.token) {
  172. needLogin = true
  173. }
  174. let res = await this.$myHttp.post({
  175. url: this.$myHttp.urlMap.zhentiList,
  176. data: {
  177. subject_id: this.subject.id,
  178. page: 1,
  179. limit: 4
  180. },
  181. needLogin: needLogin
  182. })
  183. if (res.code === 1) {
  184. this.zhenti_list = res.data.data;
  185. }
  186. },
  187. goto_detail(item, type) {
  188. if (this.$myUserLogin.getToken()) {
  189. if (item.total_num == 0) { //如果目录下没有题目,提示用户
  190. this.$myUtils.$prompt.showToast({
  191. icon: 'none',
  192. title: '当前目录下没有题目,请联系老师'
  193. });
  194. return
  195. }
  196. if (!this.subjectVip && item.is_vip) {
  197. this.showAuthVip = true
  198. return
  199. }
  200. if (type == '1') {
  201. if (item.is_last == 0) {
  202. //非终极栏目,点击进入下级栏目
  203. this.$openrul('/pages/questionBank/detail/index?id=' + item.id + '&from_type=1' + '&name=' +
  204. item.name)
  205. } else if (item.is_last == 1) {
  206. //终极栏目,点击进入答题页
  207. this.$openrul('/pages/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=1' +
  208. '&name=' + item.name)
  209. }
  210. } else if (type == '2') {
  211. //历年真题都是终极栏目,点击进入答题页
  212. this.$openrul('/pages/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=2' +
  213. '&name=' + item.name)
  214. }
  215. } else {
  216. Error.errorNotLoggedIn();
  217. }
  218. },
  219. //跳转前需要登录
  220. navTo(url) {
  221. if (this.$myUserLogin.getToken()) {
  222. this.$openrul(url)
  223. } else {
  224. Error.errorNotLoggedIn();
  225. }
  226. }
  227. }
  228. };
  229. </script>
  230. <style>
  231. page {
  232. background: #f6f6f6;
  233. }
  234. .kaoshi-head-nav {
  235. display: flex;
  236. justify-content: center;
  237. text-align: center;
  238. font-size: 14px;
  239. color: #605d70;
  240. padding: 16px 0;
  241. z-index: 10000;
  242. background: #fff;
  243. width: 93%;
  244. margin: 11px auto;
  245. border-radius: 6px;
  246. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  247. }
  248. .kaoshi-head-nav .kaoshi-head-nav-flex {
  249. flex: 1;
  250. }
  251. .kaoshi-head-nav-img {
  252. width: 38px;
  253. height: 38px;
  254. }
  255. .kaoshi-tiku-title {
  256. width: 92%;
  257. margin: 0 auto;
  258. padding: 12px 0;
  259. display: flex;
  260. align-items: center;
  261. justify-content: space-between;
  262. }
  263. .kaoshi-tiku-title-l {
  264. display: flex;
  265. font-weight: bold;
  266. font-size: 17px;
  267. }
  268. .kaoshi-tiku-title-r {
  269. color: #000;
  270. border: solid 1px #d8d8d8;
  271. padding: 5px 13px;
  272. border-radius: 35px;
  273. font-size: 12px;
  274. }
  275. .kaoshi-tiku {
  276. background: #fff;
  277. width: 93%;
  278. margin: 0 auto 8px;
  279. border-radius: 6px;
  280. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  281. }
  282. .kaoshi-tiku-content {
  283. width: 92%;
  284. margin: 0 auto;
  285. display: flex;
  286. align-items: center;
  287. font-size: 14px;
  288. padding: 10px 0;
  289. border-bottom: solid 1px #f5f5f5;
  290. }
  291. .kaoshi-tiku-content .icon-arrow {
  292. padding-left: 13px;
  293. color: #b3b3b3;
  294. font-size: 14px;
  295. }
  296. .kaoshi-tiku-content-flex {
  297. width: 100%;
  298. display: flex;
  299. justify-content: space-between;
  300. align-items: inherit;
  301. }
  302. .kaoshi-tiku-content .kaoshi-tiku-content-flex:first-child {
  303. padding-bottom: 6px;
  304. }
  305. .kaoshi-tiku-content .kaoshi-tiku-content-flex:last-child {
  306. font-size: 14px;
  307. }
  308. .kaoshi-tiku-content-top {
  309. display: flex;
  310. align-items: center;
  311. flex: 1;
  312. font-size: 16px;
  313. }
  314. .kaoshi-tiku-content-top img {
  315. width: 20px;
  316. height: 22px;
  317. margin-right: 10px;
  318. }
  319. .kaoshi-tiku-content-bottom {
  320. font-size: 13px;
  321. display: flex;
  322. align-items: center;
  323. }
  324. .kaoshi-tiku-content-flex .icon-dui2 {
  325. margin: 2px 2px 0 0;
  326. color: #3c7bfc;
  327. }
  328. .kaoshi-tiku-bilv {
  329. font-size: 22px;
  330. color: #000;
  331. display: flex;
  332. align-items: baseline;
  333. }
  334. .kaoshi-remind-title {
  335. font-size: 13px;
  336. color: #000;
  337. }
  338. </style>