detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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%;height: 400rpx;"></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 class="contents">
  21. <view class="cou_title">
  22. <view class="title_name">
  23. <view class="titleTag">{{ goodsData.goodsName }}</view>
  24. </view>
  25. <view style="display: flex;justify-content: space-between;margin-top: 13rpx;">
  26. <view class="noteTag">
  27. <!-- 共 <text class="blackFont">{{ goodsData.chapterNum }} 张卷 {{goodsData || '-'}}</text> 道题 -->
  28. </view>
  29. <view class="prices">
  30. <text class="price_sym">¥</text>
  31. <text class="price_word">{{ goodsData.standPrice }}</text>
  32. </view>
  33. </view>
  34. <view><u-line color="#D6D6DB" /></view>
  35. </view>
  36. <!-- <view>
  37. <view><u-tabs :list="list" item-width="50%" font-size="30" bar-width="24" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  38. </view> -->
  39. <view class="tabs">
  40. <view v-for="(item, index) in list" :key="index" class="tab_item"
  41. :class="[{nactive: current == index}]" @click="change(index)">{{ item.name }}</view>
  42. </view>
  43. <view class="intro" v-if="current == 0">
  44. <view v-if="goodsData.mobileDetailHtml" class="content" style="padding:10rpx;"><rich-text :nodes="goodsData.mobileDetailHtml"></rich-text></view>
  45. </view>
  46. <view class="title-list" v-if="current == 1">
  47. <view class="content">
  48. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  49. <template v-if="item1.type == 1">
  50. <view class="moduleItem" @click="clickModule(index1,item1.majorId)">
  51. <view class="courseName">{{ item1.name }}</view>
  52. <view>
  53. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  54. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  55. </view>
  56. </view>
  57. <template v-if="item1.showList">
  58. <view v-for="(item2, index2) in item1.list" :key="index2">
  59. <view class="section" @click="changeItem(index1,index2,item2.chapterExamId,item1.type)">
  60. <!-- <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image>
  61. <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image> -->
  62. <u-icon v-if="!item2.showList" name="arrow-right" color="#999" size="24"></u-icon>
  63. <u-icon v-if="item2.showList" name="arrow-down" color="#999" size="24"></u-icon>
  64. <text class="item_name">{{ item2.name }}</text>
  65. </view>
  66. <view class="article-list" v-if="item2.showList">
  67. <view class="article" :class="{ active: showTest(article.examId) }" v-for="(article, index3) in item2.list" :key="index3">
  68. <view class="flex_auto">{{ article.examName }}</view>
  69. <view class="btn" @click="goTest(item1.type,article)" v-if="showTest(article.examId)">试做</view>
  70. </view>
  71. </view>
  72. <u-line></u-line>
  73. </view>
  74. </template>
  75. </template>
  76. <template v-if="item1.type == 2">
  77. <view class="section" @click="changeItem(index1,'',item1.majorId,item1.type)" >
  78. <!-- <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image>
  79. <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image> -->
  80. <u-icon v-if="!item1.showList" name="arrow-right" color="#999" size="24"></u-icon>
  81. <u-icon v-if="item1.showList" name="arrow-down" color="#999" size="24"></u-icon>
  82. <text class="item_name">{{ item1.name }}</text>
  83. </view>
  84. <view class="article-list" v-if="item1.showList" >
  85. <view class="article" :class="{active:showTest(article.examId)}" :key="index2" v-for="(article,index2) in item1.list">
  86. <view class="flex_auto">{{article.examName}}</view>
  87. <view class="btn" @click="goTest(item1.type,article)" v-if="showTest(article.examId)">试做</view>
  88. </view>
  89. </view>
  90. </template>
  91. <template v-if="item1.type == 3">
  92. <view class="article" :class="{ active: showTest(item1.majorId) }">
  93. <view class="flex_auto">{{ item1.name }}</view>
  94. <view class="btn" @click="goTest(item1.type,item1)" v-if="showTest(item1.majorId)">试做</view>
  95. </view>
  96. </template>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="bottomBox" v-if="!hideBuyState">
  102. <!-- <view class="priceTag">¥ {{ toFixed(goodsData.standPrice) }}</view> -->
  103. <view class="icons">
  104. <image src="/static/index/share.png" class="share"></image>
  105. <image src="/static/index/shopcar.png" class="shopcar" @click="toShopcar()"></image>
  106. </view>
  107. <view style="display: flex;color: #FFFFFF;align-items: center;">
  108. <view class="btn1" @click="addCart">加购物车</view>
  109. <view class="btn2" @click="buy">立即购买</view>
  110. </view>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. // import { websocket } from '@/common/socket.js';
  116. import { mapGetters } from 'vuex';
  117. export default {
  118. data() {
  119. return {
  120. list: [
  121. {
  122. name: '详情'
  123. },
  124. {
  125. name: '大纲'
  126. }
  127. ],
  128. current: 0,
  129. id: '',
  130. goodsData: {},
  131. bankList: [],
  132. goodsExamConfig: []
  133. };
  134. },
  135. filters: {
  136. formatDate: function(value) {
  137. var date = new Date(value); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  138. var Y = date.getFullYear();
  139. return Y;
  140. }
  141. },
  142. onUnload() {},
  143. computed: { ...mapGetters(['userInfo','hideBuyState']) },
  144. onLoad(option) {
  145. this.id = option.id;
  146. this.getDetail();
  147. this.goodsBankList();
  148. },
  149. onShow() {},
  150. methods: {
  151. toFixed(number) {
  152. if(number) {
  153. return number.toFixed(2)
  154. } else {
  155. return '0.00'
  156. }
  157. },
  158. getDetail() {
  159. // '/app/common/goods/'+ data 获取商品详细信息
  160. this.$api.commonGoodsDetail(this.id).then(res => {
  161. if (res.data.data.mobileDetailHtml) {
  162. res.data.data.mobileDetailHtml = res.data.data.mobileDetailHtml.replace(/<img/gi, '<img style="max-width:100%;"');
  163. }
  164. this.goodsData = res.data.data;
  165. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig);
  166. });
  167. },
  168. goodsBankList() {
  169. this.$api
  170. .goodsBankList({
  171. goodsId: this.id
  172. })
  173. .then(res => {
  174. console.log(res);
  175. this.bankList = res.data.data;
  176. this.showAllCharpter();
  177. });
  178. },
  179. /**
  180. * 展示第一个章下的节内容
  181. */
  182. showAllCharpter() {
  183. for(let i = 0; i < this.bankList.length; i++) {
  184. if(this.bankList[i].type == 1) { //第一个是模块直接展开,再展开章下面的节
  185. this.$api
  186. .goodsChapterList({
  187. moduleExamId: this.bankList[i].majorId
  188. })
  189. .then(res => {
  190. this.$set(this.bankList[i], 'showList', true);
  191. this.$set(this.bankList[i], 'list', res.data.data);
  192. this.changeItem(i,0,this.bankList[i].list[0].chapterExamId,this.bankList[i].type)
  193. });
  194. break;
  195. } else if(this.bankList[i].type == 2) { //第一个章展开下面的节
  196. this.changeItem(i,'',this.bankList[i].majorId,this.bankList[i].type)
  197. break;
  198. }
  199. }
  200. },
  201. goodsChapterList(bank, id) {
  202. this.$api
  203. .goodsChapterList({
  204. moduleExamId: id
  205. })
  206. .then(res => {
  207. this.$set(bank, 'list', res.data.data);
  208. });
  209. },
  210. goTest(type,item) {
  211. if(type == 1) {
  212. uni.setStorageSync('testname',item.examName)
  213. uni.navigateTo({
  214. url:'/pages2/bank/questionBankTest?id=' + item.examId + '&num=' + this.showTest(item.examId).num
  215. })
  216. } else if(type == 2) {
  217. uni.setStorageSync('testname',item.examName)
  218. uni.navigateTo({
  219. url:'/pages2/bank/questionBankTest?id='+item.examId+'&num='+ this.showTest(item.examId).num
  220. })
  221. } else if(type == 3) {
  222. uni.setStorageSync('testname',item.name)
  223. uni.navigateTo({
  224. url:'/pages2/bank/questionBankTest?id=' + item.majorId + '&num=' + this.showTest(item.majorId).num
  225. })
  226. }
  227. },
  228. showTest(id) {
  229. return this.goodsExamConfig.find(item => item.examId == id);
  230. },
  231. clickModule(index,id) {
  232. if (this.bankList[index].list) {
  233. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  234. return;
  235. }
  236. this.$api
  237. .goodsChapterList({
  238. moduleExamId: id
  239. })
  240. .then(res => {
  241. this.$set(this.bankList[index], 'showList', true);
  242. this.$set(this.bankList[index], 'list', res.data.data);
  243. });
  244. },
  245. buy() {
  246. if (this.$method.isGoLogin()) {
  247. return;
  248. }
  249. this.$navTo.togo('/pages2/order/confirm_list?id=' + this.id);
  250. },
  251. addCart() {
  252. if (this.$method.isGoLogin()) {
  253. return;
  254. }
  255. let self = this;
  256. this.$api.addCart({ goodsId: this.id }).then(res => {
  257. if (res.data.code == 200) {
  258. uni.setStorageSync('updateCart', 1); //提醒刷新购物车
  259. uni.showToast({
  260. title: '添加成功'
  261. });
  262. } else {
  263. this.$u.toast(res.data.msg);
  264. }
  265. });
  266. },
  267. open(item) {
  268. item.showChildren = !item.showChildren;
  269. },
  270. change(index) {
  271. this.current = index;
  272. },
  273. changeItem(index1,index2,id,type) {
  274. if (type == 1) {
  275. console.log(1)
  276. if (this.bankList[index1].list[index2].list) {
  277. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  278. return;
  279. }
  280. this.$api
  281. .goodsExamList({
  282. chapterExamId: id
  283. })
  284. .then(res => {
  285. this.$set(this.bankList[index1].list[index2], 'showList', true);
  286. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  287. });
  288. } else if (type == 2) {
  289. console.log(2)
  290. if (this.bankList[index1].list) {
  291. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  292. return;
  293. }
  294. this.$api
  295. .goodsExamList({
  296. chapterExamId: id
  297. })
  298. .then(res => {
  299. this.$set(this.bankList[index1], 'showList', true);
  300. this.$set(this.bankList[index1], 'list', res.data.data);
  301. });
  302. }
  303. },
  304. toShopcar() {
  305. uni.switchTab({
  306. url: '/pages/shopping/shoppingCart'
  307. })
  308. }
  309. }
  310. };
  311. </script>
  312. <style>
  313. page {
  314. background-color: #ffffff;
  315. }
  316. </style>
  317. <style lang="scss" scope>
  318. .contents {
  319. width: 100%;
  320. height: 100%;
  321. background-color: #ffffff;
  322. border-radius: 24rpx 24rpx 0rpx 0rpx;
  323. position: relative;
  324. top: -27rpx;
  325. left: 0;
  326. .cou_title {
  327. height: 210rpx;
  328. padding: 27rpx 56rpx 0rpx 56rpx;
  329. display: flex;
  330. flex-direction: column;
  331. justify-content: space-around;
  332. }
  333. .prices {
  334. .price_sym {
  335. font-size: 20rpx;
  336. color: #333333;
  337. position: relative;
  338. top: -23rpx;
  339. left: 0;
  340. margin-right: 10rpx;
  341. }
  342. .price_word {
  343. font-size: 42rpx;
  344. font-weight: bold;
  345. color: #FC3F3F;
  346. }
  347. }
  348. // tab
  349. .tabs {
  350. // width: 100%;
  351. height: 78rpx;
  352. display: flex;
  353. align-items: center;
  354. justify-content: space-between;
  355. background-color: #F2F7FF;
  356. border-radius: 38rpx;
  357. margin: 24rpx;
  358. padding: 0rpx 5rpx;
  359. .tab_item {
  360. width: 345rpx;
  361. height: 65rpx;
  362. line-height: 65rpx;
  363. font-size: 28rpx;
  364. font-weight: bold;
  365. border-radius: 32rpx;
  366. text-align: center;
  367. color: #333;
  368. &.nactive {
  369. color: #fff;
  370. background-color: #3577E8;
  371. }
  372. // &.twoBtn {
  373. // width: 50%;
  374. // }
  375. }
  376. }
  377. }
  378. .courseName {
  379. white-space: nowrap;
  380. overflow: hidden;
  381. text-overflow: ellipsis;
  382. }
  383. .icon_up {
  384. width: 32rpx;
  385. height: 32rpx;
  386. }
  387. .intro {
  388. background: #fff;
  389. padding: 16rpx 16rpx 124rpx;
  390. .content {
  391. background: #fff;
  392. border-radius: 16rpx;
  393. .top {
  394. border-radius: 16rpx;
  395. padding: 32rpx 28rpx 16rpx;
  396. font-size: 30rpx;
  397. color: #333333;
  398. }
  399. .img {
  400. width: 100%;
  401. }
  402. }
  403. }
  404. .moduleItem {
  405. height: 80rpx;
  406. color: #333333;
  407. font-size: 32rpx;
  408. line-height: 80rpx;
  409. font-weight: bold;
  410. display: flex;
  411. justify-content: space-between;
  412. }
  413. .title-list {
  414. background: #fff;
  415. padding: 16rpx 16rpx 124rpx;
  416. .content {
  417. .list {
  418. background: #fff;
  419. margin-bottom: 30rpx;
  420. overflow: hidden;
  421. border-radius: 16rpx;
  422. padding: 10rpx 16rpx;
  423. .module {
  424. font-size: 32rpx;
  425. color: #333333;
  426. .icon {
  427. margin-right: 10rpx;
  428. }
  429. }
  430. .section {
  431. font-size: 30rpx;
  432. color: #333;
  433. white-space: nowrap;
  434. overflow: hidden;
  435. text-overflow: ellipsis;
  436. padding: 20rpx 0;
  437. display: flex;
  438. align-items: center;
  439. border-bottom: 1rpx solid #eee;
  440. }
  441. .item_name {
  442. font-size: 24rpx;
  443. font-family: PingFang SC;
  444. font-weight: bold;
  445. color: #333;
  446. white-space: nowrap;
  447. overflow: hidden;
  448. text-overflow: ellipsis;
  449. margin-left: 8rpx;
  450. }
  451. // .article-list {
  452. // margin-top:20rpx;
  453. // }
  454. .article {
  455. padding:10rpx 0;
  456. min-height: 80rpx;
  457. display: flex;
  458. align-items: center;
  459. margin-left: 35rpx;
  460. font-size: 30rpx;
  461. color: #666666;
  462. border-bottom: 1rpx solid #eeeeee;
  463. display: flex;
  464. .flex_auto {
  465. flex: 1;
  466. font-size: 30rpx;
  467. color: #666666;
  468. }
  469. &:nth-last-of-type(1) {
  470. border: 0;
  471. }
  472. &.active {
  473. color: #007aff;
  474. .btn {
  475. width: 103rpx;
  476. height: 48rpx;
  477. line-height: 48rpx;
  478. text-align: center;
  479. color: #3577E8;
  480. font-size: 24rpx;
  481. border-radius: 24rpx;
  482. background: #fff;
  483. margin-left: 36rpx;
  484. border: 1rpx solid #3577E8;
  485. }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. .btn2 {
  492. width: 187rpx;
  493. height: 79rpx;
  494. line-height: 79rpx;
  495. background: #FC3F3F;
  496. border-radius: 40rpx;
  497. text-align: center;
  498. font-size: 24rpx;
  499. }
  500. .btn1 {
  501. width: 187rpx;
  502. height: 79rpx;
  503. line-height: 79rpx;
  504. background: #FFB102;
  505. border-radius: 40rpx;
  506. text-align: center;
  507. margin-right: 11rpx;
  508. font-size: 24rpx;
  509. }
  510. .bottomBox {
  511. position: fixed;
  512. bottom: 0;
  513. width: 100%;
  514. left: 0;
  515. height: 98rpx;
  516. background-color: #ffffff;
  517. display: flex;
  518. justify-content: space-between;
  519. align-items: center;
  520. padding: 0 24rpx;
  521. box-shadow: 0px -5px 20px 1px rgba(1,99,235,0.1000);
  522. .share {
  523. width: 38rpx;
  524. height: 38rpx;
  525. margin-left: 32rpx;
  526. margin-right: 60rpx;
  527. }
  528. .shopcar {
  529. width: 40rpx;
  530. height: 40rpx;
  531. }
  532. }
  533. .blackFont {
  534. color: #333333;
  535. margin: 0 4rpx;
  536. }
  537. .wk_icon {
  538. width: 24rpx;
  539. height: 24rpx;
  540. margin-right: 12rpx;
  541. }
  542. .noteTag {
  543. font-size: 24rpx;
  544. font-family: PingFang SC;
  545. font-weight: 500;
  546. color: #999999;
  547. align-items: center;
  548. }
  549. .priceTag {
  550. font-size: 30rpx;
  551. font-family: PingFang SC;
  552. font-weight: bold;
  553. color: #ff2d55;
  554. }
  555. .titleTag {
  556. font-size: 32rpx;
  557. font-weight: bold;
  558. color: #333333;
  559. margin-left: 8rpx;
  560. }
  561. .yearTag {
  562. width: 80rpx;
  563. height: 32rpx;
  564. background: #ebf5ff;
  565. border: 2rpx solid #007aff;
  566. border-radius: 16rpx;
  567. font-size: 24rpx;
  568. color: #007aff;
  569. text-align: center;
  570. line-height: 32rpx;
  571. }
  572. .itemBox {
  573. background: #ffffff;
  574. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  575. border-radius: 24rpx;
  576. width: 100%;
  577. padding: 20rpx;
  578. margin-bottom: 20rpx;
  579. }
  580. </style>