detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view>
  3. <nav-bar title="题库详情"></nav-bar>
  4. <view style="background-color: #FFFFFF;">
  5. <view>
  6. <image :src="$method.splitImgHost(goodsData.coverUrl, true)" style="width: 100%;"></image>
  7. <view style="padding:20rpx">
  8. <view style="display: flex;margin-top: 13rpx;">
  9. <view class="yearTag" v-if="goodsData.year">{{ goodsData.year }}</view>
  10. <view class="titleTag">{{ goodsData.goodsName }}</view>
  11. </view>
  12. <!-- <view style="display: flex;justify-content: space-between;margin-top: 13rpx;" v-if="false">
  13. <view class="noteTag"><image src="/static/icon/wk_icon1.png" class="wk_icon"></image>
  14. 共 <text class="blackFont">{{goodsData.updateTime}}</text> 张卷 <text class="blackFont">1200</text> 道题 </view>
  15. </view> -->
  16. </view>
  17. </view>
  18. <u-line color="#D6D6DB" />
  19. <view>
  20. <view><u-tabs :list="list" item-width="50%" font-size="30" bar-width="24" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  21. </view>
  22. <u-line color="#D6D6DB" />
  23. </view>
  24. <view class="intro" v-if="current == 0">
  25. <view v-if="goodsData.mobileDetailHtml" class="content" style="padding:10rpx;"><rich-text :nodes="goodsData.mobileDetailHtml"></rich-text></view>
  26. </view>
  27. <view class="title-list" v-if="current == 1">
  28. <view class="content">
  29. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  30. <template v-if="item1.type == 1">
  31. <view class="moduleItem" @click="clickModule" :data-id="item1.majorId" :data-index="index1">
  32. <view class="courseName">{{ item1.name }}</view>
  33. <view>
  34. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  35. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  36. </view>
  37. </view>
  38. <template v-if="item1.showList">
  39. <view v-for="(item2, index2) in item1.list" :key="index2">
  40. <view class="section" @click="changeItem" :data-index1="index1" :data-index2="index2" :data-id="item2.chapterExamId" :data-type="item1.type">
  41. <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image>
  42. <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image>
  43. <!-- <u-icon v-if="!item2.showList" name="arrow-up"></u-icon>
  44. <u-icon v-if="item2.showList" name="arrow-down"></u-icon> -->
  45. <text style="margin-left:34rpx;">{{ item2.name }}</text>
  46. </view>
  47. <view class="article-list" v-if="item2.showList">
  48. <view class="article" :class="{ active: showTest(article.examId) }" v-for="(article, index3) in item2.list" :key="index3">
  49. <view class="flex_auto">{{ article.examName }}</view>
  50. <view class="btn" @click="goTest(item1.type,article)" v-if="showTest(article.examId)">试做</view>
  51. </view>
  52. </view>
  53. <u-line></u-line>
  54. </view>
  55. </template>
  56. </template>
  57. <template v-if="item1.type == 2">
  58. <view class="section" :data-index1="index1" :data-id="item1.majorId" @click="changeItem" :data-type="item1.type">
  59. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image>
  60. <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  61. <!-- <u-icon v-if="!item1.showList" name="arrow-up"></u-icon>
  62. <u-icon v-if="item1.showList" name="arrow-down"></u-icon> -->
  63. <text style="margin-left:34rpx;">{{ item1.name }}</text>
  64. </view>
  65. <view class="article-list" v-if="item1.showList" >
  66. <view class="article" :class="{active:showTest(article.examId)}" :key="index2" v-for="(article,index2) in item1.list">
  67. <view class="flex_auto">{{article.examName}}</view>
  68. <view class="btn" @click="goTest(item1.type,article)" v-if="showTest(article.examId)">试做</view>
  69. </view>
  70. </view>
  71. </template>
  72. <template v-if="item1.type == 3">
  73. <view class="article" :class="{ active: showTest(item1.majorId) }">
  74. <view class="flex_auto">{{ item1.name }}</view>
  75. <view class="btn" @click="goTest(item1.type,item1)" v-if="showTest(item1.majorId)">试做</view>
  76. </view>
  77. </template>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="bottomBox">
  82. <view class="priceTag">¥ {{ toFixed(goodsData.standPrice) }}</view>
  83. <view style="display: flex;color: #FFFFFF;align-items: center;">
  84. <view class="btn1" @click="addCart">加购物车</view>
  85. <view class="btn2" @click="buy">立即购买</view>
  86. </view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import { mapGetters } from 'vuex';
  92. export default {
  93. data() {
  94. return {
  95. list: [
  96. {
  97. name: '详情'
  98. },
  99. {
  100. name: '大纲'
  101. }
  102. ],
  103. current: 0,
  104. id: '',
  105. goodsData: {},
  106. bankList: [],
  107. goodsExamConfig: []
  108. };
  109. },
  110. filters: {
  111. formatDate: function(value) {
  112. var date = new Date(value); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  113. var Y = date.getFullYear();
  114. return Y;
  115. }
  116. },
  117. onUnload() {},
  118. computed: { ...mapGetters(['userInfo']) },
  119. onLoad(option) {
  120. this.id = option.id;
  121. this.getDetail();
  122. this.goodsBankList();
  123. },
  124. onShow() {},
  125. methods: {
  126. toFixed(number) {
  127. if(number) {
  128. return number.toFixed(2)
  129. } else {
  130. return '0.00'
  131. }
  132. },
  133. getDetail() {
  134. this.$api.commonGoodsDetail(this.id).then(res => {
  135. if (res.data.data.mobileDetailHtml) {
  136. res.data.data.mobileDetailHtml = res.data.data.mobileDetailHtml.replace(/<img/gi, '<img style="max-width:100%;"');
  137. }
  138. this.goodsData = res.data.data;
  139. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig);
  140. });
  141. },
  142. goodsBankList() {
  143. this.$api
  144. .goodsBankList({
  145. goodsId: this.id
  146. })
  147. .then(res => {
  148. console.log(res);
  149. this.bankList = res.data.data;
  150. });
  151. },
  152. goodsChapterList(bank, id) {
  153. this.$api
  154. .goodsChapterList({
  155. moduleExamId: id
  156. })
  157. .then(res => {
  158. this.$set(bank, 'list', res.data.data);
  159. });
  160. },
  161. goTest(type,item) {
  162. if(type == 1) {
  163. uni.setStorageSync('testname',item.examName)
  164. uni.navigateTo({
  165. url:'/pages2/bank/questionBankTest?id=' + item.examId + '&num=' + this.showTest(item.examId).num
  166. })
  167. } else if(type == 2) {
  168. uni.setStorageSync('testname',item.examName)
  169. uni.navigateTo({
  170. url:'/pages2/bank/questionBankTest?id='+item.examId+'&num='+ this.showTest(item.examId).num
  171. })
  172. } else if(type == 3) {
  173. uni.setStorageSync('testname',item.name)
  174. uni.navigateTo({
  175. url:'/pages2/bank/questionBankTest?id=' + item.majorId + '&num=' + this.showTest(item.majorId).num
  176. })
  177. }
  178. },
  179. showTest(id) {
  180. return this.goodsExamConfig.find(item => item.examId == id);
  181. },
  182. clickModule(e) {
  183. let index = e.currentTarget.dataset.index;
  184. let id = e.currentTarget.dataset.id;
  185. if (this.bankList[index].list) {
  186. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  187. return;
  188. }
  189. this.$api
  190. .goodsChapterList({
  191. moduleExamId: id
  192. })
  193. .then(res => {
  194. this.$set(this.bankList[index], 'showList', true);
  195. this.$set(this.bankList[index], 'list', res.data.data);
  196. });
  197. },
  198. buy() {
  199. if (this.$method.isGoLogin()) {
  200. return;
  201. }
  202. this.$navTo.togo('/pages2/order/confirm_list?id=' + this.id);
  203. },
  204. addCart() {
  205. if (this.$method.isGoLogin()) {
  206. return;
  207. }
  208. let self = this;
  209. this.$api.addCart({ goodsId: this.id }).then(res => {
  210. if (res.data.code == 200) {
  211. uni.setStorageSync('updateCart', 1); //提醒刷新购物车
  212. uni.showToast({
  213. title: '添加成功'
  214. });
  215. } else {
  216. this.$u.toast(res.data.msg);
  217. }
  218. });
  219. },
  220. open(item) {
  221. item.showChildren = !item.showChildren;
  222. },
  223. change(index) {
  224. this.current = index;
  225. },
  226. changeItem(e) {
  227. let index1 = e.currentTarget.dataset.index1;
  228. let index2 = e.currentTarget.dataset.index2;
  229. let id = e.currentTarget.dataset.id;
  230. let type = e.currentTarget.dataset.type;
  231. if (type == 1) {
  232. if (this.bankList[index1].list[index2].list) {
  233. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  234. return;
  235. }
  236. this.$api
  237. .goodsExamList({
  238. chapterExamId: id
  239. })
  240. .then(res => {
  241. this.$set(this.bankList[index1].list[index2], 'showList', true);
  242. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  243. });
  244. } else if (type == 2) {
  245. if (this.bankList[index1].list) {
  246. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  247. return;
  248. }
  249. this.$api
  250. .goodsExamList({
  251. chapterExamId: id
  252. })
  253. .then(res => {
  254. this.$set(this.bankList[index1], 'showList', true);
  255. this.$set(this.bankList[index1], 'list', res.data.data);
  256. });
  257. }
  258. }
  259. }
  260. };
  261. </script>
  262. <style>
  263. page {
  264. background-color: #eaeef1;
  265. }
  266. </style>
  267. <style lang="scss" scope>
  268. .courseName {
  269. white-space: nowrap;
  270. overflow: hidden;
  271. text-overflow: ellipsis;
  272. }
  273. .icon_up {
  274. width: 32rpx;
  275. height: 32rpx;
  276. }
  277. .intro {
  278. background: #eaeef1;
  279. padding: 16rpx 16rpx 124rpx;
  280. .content {
  281. background: #fff;
  282. border-radius: 16rpx;
  283. .top {
  284. border-radius: 16rpx;
  285. padding: 32rpx 28rpx 16rpx;
  286. font-size: 30rpx;
  287. color: #333333;
  288. }
  289. .img {
  290. width: 100%;
  291. }
  292. }
  293. }
  294. .moduleItem {
  295. height: 80rpx;
  296. color: #333333;
  297. font-size: 32rpx;
  298. line-height: 80rpx;
  299. font-weight: bold;
  300. display: flex;
  301. justify-content: space-between;
  302. }
  303. .title-list {
  304. background: #eaeef1;
  305. padding: 16rpx 16rpx 124rpx;
  306. .content {
  307. .list {
  308. background: #fff;
  309. margin-bottom: 30rpx;
  310. overflow: hidden;
  311. border-radius: 16rpx;
  312. padding: 10rpx 16rpx;
  313. .module {
  314. font-size: 32rpx;
  315. color: #333333;
  316. .icon {
  317. margin-right: 10rpx;
  318. }
  319. }
  320. .section {
  321. font-size: 30rpx;
  322. color: #333;
  323. white-space: nowrap;
  324. overflow: hidden;
  325. text-overflow: ellipsis;
  326. margin: 20rpx 0;
  327. display: flex;
  328. align-items: center;
  329. }
  330. .article-list {
  331. margin-top:20rpx;
  332. .article {
  333. min-height: 80rpx;
  334. display: flex;
  335. align-items: center;
  336. margin-left: 64rpx;
  337. font-size: 30rpx;
  338. color: #666666;
  339. border-bottom: 1rpx solid #eeeeee;
  340. display: flex;
  341. .flex_auto {
  342. flex: 1;
  343. }
  344. &:nth-last-of-type(1) {
  345. border: 0;
  346. }
  347. &.active {
  348. color: #007aff;
  349. .btn {
  350. width: 96rpx;
  351. height: 48rpx;
  352. line-height: 48rpx;
  353. text-align: center;
  354. color: #fff;
  355. font-size: 30rpx;
  356. border-radius: 24rpx;
  357. background: #007aff;
  358. margin-left: 36rpx;
  359. border-radius: 24rpx;
  360. }
  361. }
  362. }
  363. }
  364. }
  365. }
  366. }
  367. .btn2 {
  368. width: 200rpx;
  369. height: 64rpx;
  370. background: linear-gradient(0deg, #ffb102, #fd644f);
  371. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  372. border-radius: 32rpx;
  373. line-height: 64rpx;
  374. text-align: center;
  375. }
  376. .btn1 {
  377. width: 200rpx;
  378. height: 64rpx;
  379. background: linear-gradient(0deg, #015eea, #00c0fa);
  380. border-radius: 32rpx;
  381. line-height: 64rpx;
  382. text-align: center;
  383. margin-right: 20rpx;
  384. }
  385. .bottomBox {
  386. position: fixed;
  387. bottom: 0;
  388. width: 100%;
  389. left: 0;
  390. height: 98rpx;
  391. background-color: #ffffff;
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. padding: 0 30rpx;
  396. }
  397. .blackFont {
  398. color: #333333;
  399. margin: 0 4rpx;
  400. }
  401. .wk_icon {
  402. width: 24rpx;
  403. height: 24rpx;
  404. margin-right: 12rpx;
  405. }
  406. .noteTag {
  407. ont-size: 24rpx;
  408. font-family: PingFang SC;
  409. font-weight: 500;
  410. color: #999999;
  411. align-items: center;
  412. }
  413. .priceTag {
  414. font-size: 30rpx;
  415. font-family: PingFang SC;
  416. font-weight: bold;
  417. color: #ff2d55;
  418. }
  419. .titleTag {
  420. font-size: 32rpx;
  421. font-weight: bold;
  422. color: #333333;
  423. margin-left: 8rpx;
  424. }
  425. .yearTag {
  426. width: 80rpx;
  427. height: 32rpx;
  428. background: #ebf5ff;
  429. border: 2rpx solid #007aff;
  430. border-radius: 16rpx;
  431. font-size: 24rpx;
  432. color: #007aff;
  433. text-align: center;
  434. line-height: 32rpx;
  435. }
  436. .itemBox {
  437. background: #ffffff;
  438. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  439. border-radius: 24rpx;
  440. width: 100%;
  441. padding: 20rpx;
  442. margin-bottom: 20rpx;
  443. }
  444. </style>