index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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. // #ifdef MP-WEIXIN
  125. if (this.userinfo.user_id !== undefined) {
  126. this.share.path = 'pages/index/index?scene=' + this.userinfo.user_id
  127. console.log(this.userinfo,'this.userinfo')
  128. wx.showShareMenu({
  129. withShareTicket: true,
  130. menus: ["shareAppMessage"]
  131. })
  132. }else {
  133. wx.hideShareMenu()
  134. }
  135. // #endif
  136. },
  137. onLoad() {
  138. // // #ifdef MP-WEIXIN
  139. // wx.showShareMenu({
  140. // withShareTicket: true,
  141. // menus: ["shareAppMessage", "shareTimeline"]
  142. // })
  143. // // #endif
  144. },
  145. computed: {
  146. ...mapState(['subject', 'subjectVip', 'userinfo']),
  147. static_media() {
  148. return {
  149. img01: this.$myConfig.localMedia + '/static/img/tiku-icon1.png',
  150. img02: this.$myConfig.localMedia + '/static/img/tiku-icon2.png',
  151. img03: this.$myConfig.localMedia + '/static/img/tiku-icon3.png',
  152. img04: this.$myConfig.localMedia + '/static/img/tiku-icon4.png',
  153. };
  154. },
  155. },
  156. components: {
  157. authVip
  158. },
  159. methods: {
  160. //章节列表
  161. async get_tiku_list() {
  162. let needLogin = false
  163. if (this.userinfo.token) {
  164. needLogin = true
  165. }
  166. let res = await this.$myHttp.post({
  167. url: this.$myHttp.urlMap.unitList,
  168. data: {
  169. subject_id: this.subject.id,
  170. unit_id: 0,
  171. page: 1,
  172. limit: 4
  173. },
  174. needLogin: needLogin
  175. });
  176. if (res.code === 1) {
  177. this.unit_list = res.data.data;
  178. }
  179. },
  180. //历年真题列表
  181. async get_zhenti_list() {
  182. let needLogin = false
  183. if (this.userinfo.token) {
  184. needLogin = true
  185. }
  186. let res = await this.$myHttp.post({
  187. url: this.$myHttp.urlMap.zhentiList,
  188. data: {
  189. subject_id: this.subject.id,
  190. page: 1,
  191. limit: 4
  192. },
  193. needLogin: needLogin
  194. })
  195. if (res.code === 1) {
  196. this.zhenti_list = res.data.data;
  197. }
  198. },
  199. goto_detail(item, type) {
  200. if (this.$myUserLogin.getToken()) {
  201. if (item.total_num == 0) { //如果目录下没有题目,提示用户
  202. this.$myUtils.$prompt.showToast({
  203. icon: 'none',
  204. title: '当前目录下没有题目,请联系老师'
  205. });
  206. return
  207. }
  208. if (!this.subjectVip && item.is_vip) {
  209. this.showAuthVip = true
  210. return
  211. }
  212. if (type == '1') {
  213. if (item.is_last == 0) {
  214. //非终极栏目,点击进入下级栏目
  215. this.$openrul('/pages/questionBank/detail/index?id=' + item.id + '&from_type=1' + '&name=' +
  216. item.name)
  217. } else if (item.is_last == 1) {
  218. //终极栏目,点击进入答题页
  219. this.$openrul('/pages/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=1' +
  220. '&name=' + item.name)
  221. }
  222. } else if (type == '2') {
  223. //历年真题都是终极栏目,点击进入答题页
  224. this.$openrul('/pages/questionBank/questionBankAnswer/index?id=' + item.id + '&from_type=2' +
  225. '&name=' + item.name)
  226. }
  227. } else {
  228. Error.errorNotLoggedIn();
  229. }
  230. },
  231. //跳转前需要登录
  232. navTo(url) {
  233. if (this.$myUserLogin.getToken()) {
  234. this.$openrul(url)
  235. } else {
  236. Error.errorNotLoggedIn();
  237. }
  238. }
  239. }
  240. };
  241. </script>
  242. <style>
  243. page {
  244. background: #f6f6f6;
  245. }
  246. .kaoshi-head-nav {
  247. display: flex;
  248. justify-content: center;
  249. text-align: center;
  250. font-size: 14px;
  251. color: #605d70;
  252. padding: 16px 0;
  253. z-index: 10000;
  254. background: #fff;
  255. width: 93%;
  256. margin: 11px auto;
  257. border-radius: 6px;
  258. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  259. }
  260. .kaoshi-head-nav .kaoshi-head-nav-flex {
  261. flex: 1;
  262. }
  263. .kaoshi-head-nav-img {
  264. width: 38px;
  265. height: 38px;
  266. }
  267. .kaoshi-tiku-title {
  268. width: 92%;
  269. margin: 0 auto;
  270. padding: 12px 0;
  271. display: flex;
  272. align-items: center;
  273. justify-content: space-between;
  274. }
  275. .kaoshi-tiku-title-l {
  276. display: flex;
  277. font-weight: bold;
  278. font-size: 17px;
  279. }
  280. .kaoshi-tiku-title-r {
  281. color: #000;
  282. border: solid 1px #d8d8d8;
  283. padding: 5px 13px;
  284. border-radius: 35px;
  285. font-size: 12px;
  286. }
  287. .kaoshi-tiku {
  288. background: #fff;
  289. width: 93%;
  290. margin: 0 auto 8px;
  291. border-radius: 6px;
  292. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  293. }
  294. .kaoshi-tiku-content {
  295. width: 92%;
  296. margin: 0 auto;
  297. display: flex;
  298. align-items: center;
  299. font-size: 14px;
  300. padding: 10px 0;
  301. border-bottom: solid 1px #f5f5f5;
  302. }
  303. .kaoshi-tiku-content .icon-arrow {
  304. padding-left: 13px;
  305. color: #b3b3b3;
  306. font-size: 14px;
  307. }
  308. .kaoshi-tiku-content-flex {
  309. width: 100%;
  310. display: flex;
  311. justify-content: space-between;
  312. align-items: inherit;
  313. }
  314. .kaoshi-tiku-content .kaoshi-tiku-content-flex:first-child {
  315. padding-bottom: 6px;
  316. }
  317. .kaoshi-tiku-content .kaoshi-tiku-content-flex:last-child {
  318. font-size: 14px;
  319. }
  320. .kaoshi-tiku-content-top {
  321. display: flex;
  322. align-items: center;
  323. flex: 1;
  324. font-size: 16px;
  325. }
  326. .kaoshi-tiku-content-top img {
  327. width: 20px;
  328. height: 22px;
  329. margin-right: 10px;
  330. }
  331. .kaoshi-tiku-content-bottom {
  332. font-size: 13px;
  333. display: flex;
  334. align-items: center;
  335. }
  336. .kaoshi-tiku-content-flex .icon-dui2 {
  337. margin: 2px 2px 0 0;
  338. color: #3c7bfc;
  339. }
  340. .kaoshi-tiku-bilv {
  341. font-size: 22px;
  342. color: #000;
  343. display: flex;
  344. align-items: baseline;
  345. }
  346. .kaoshi-remind-title {
  347. font-size: 13px;
  348. color: #000;
  349. }
  350. </style>