detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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"></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. }
  305. };
  306. </script>
  307. <style>
  308. page {
  309. background-color: #ffffff;
  310. }
  311. </style>
  312. <style lang="scss" scope>
  313. .contents {
  314. width: 100%;
  315. height: 100%;
  316. background-color: #ffffff;
  317. border-radius: 24rpx 24rpx 0rpx 0rpx;
  318. position: relative;
  319. top: -27rpx;
  320. left: 0;
  321. .cou_title {
  322. height: 210rpx;
  323. padding: 27rpx 56rpx 0rpx 56rpx;
  324. display: flex;
  325. flex-direction: column;
  326. justify-content: space-around;
  327. }
  328. .prices {
  329. .price_sym {
  330. font-size: 20rpx;
  331. color: #333333;
  332. position: relative;
  333. top: -23rpx;
  334. left: 0;
  335. margin-right: 10rpx;
  336. }
  337. .price_word {
  338. font-size: 42rpx;
  339. font-weight: bold;
  340. color: #FC3F3F;
  341. }
  342. }
  343. // tab
  344. .tabs {
  345. // width: 100%;
  346. height: 78rpx;
  347. display: flex;
  348. align-items: center;
  349. justify-content: space-between;
  350. background-color: #F2F7FF;
  351. border-radius: 38rpx;
  352. margin: 24rpx;
  353. padding: 0rpx 5rpx;
  354. .tab_item {
  355. width: 345rpx;
  356. height: 65rpx;
  357. line-height: 65rpx;
  358. font-size: 28rpx;
  359. font-weight: bold;
  360. border-radius: 32rpx;
  361. text-align: center;
  362. color: #333;
  363. &.nactive {
  364. color: #fff;
  365. background-color: #3577E8;
  366. }
  367. // &.twoBtn {
  368. // width: 50%;
  369. // }
  370. }
  371. }
  372. }
  373. .courseName {
  374. white-space: nowrap;
  375. overflow: hidden;
  376. text-overflow: ellipsis;
  377. }
  378. .icon_up {
  379. width: 32rpx;
  380. height: 32rpx;
  381. }
  382. .intro {
  383. background: #fff;
  384. padding: 16rpx 16rpx 124rpx;
  385. .content {
  386. background: #fff;
  387. border-radius: 16rpx;
  388. .top {
  389. border-radius: 16rpx;
  390. padding: 32rpx 28rpx 16rpx;
  391. font-size: 30rpx;
  392. color: #333333;
  393. }
  394. .img {
  395. width: 100%;
  396. }
  397. }
  398. }
  399. .moduleItem {
  400. height: 80rpx;
  401. color: #333333;
  402. font-size: 32rpx;
  403. line-height: 80rpx;
  404. font-weight: bold;
  405. display: flex;
  406. justify-content: space-between;
  407. }
  408. .title-list {
  409. background: #fff;
  410. padding: 16rpx 16rpx 124rpx;
  411. .content {
  412. .list {
  413. background: #fff;
  414. margin-bottom: 30rpx;
  415. overflow: hidden;
  416. border-radius: 16rpx;
  417. padding: 10rpx 16rpx;
  418. .module {
  419. font-size: 32rpx;
  420. color: #333333;
  421. .icon {
  422. margin-right: 10rpx;
  423. }
  424. }
  425. .section {
  426. font-size: 30rpx;
  427. color: #333;
  428. white-space: nowrap;
  429. overflow: hidden;
  430. text-overflow: ellipsis;
  431. padding: 20rpx 0;
  432. display: flex;
  433. align-items: center;
  434. border-bottom: 1rpx solid #eee;
  435. }
  436. .item_name {
  437. font-size: 24rpx;
  438. font-family: PingFang SC;
  439. font-weight: bold;
  440. color: #333;
  441. white-space: nowrap;
  442. overflow: hidden;
  443. text-overflow: ellipsis;
  444. margin-left: 8rpx;
  445. }
  446. // .article-list {
  447. // margin-top:20rpx;
  448. // }
  449. .article {
  450. padding:10rpx 0;
  451. min-height: 80rpx;
  452. display: flex;
  453. align-items: center;
  454. margin-left: 35rpx;
  455. font-size: 30rpx;
  456. color: #666666;
  457. border-bottom: 1rpx solid #eeeeee;
  458. display: flex;
  459. .flex_auto {
  460. flex: 1;
  461. font-size: 30rpx;
  462. color: #666666;
  463. }
  464. &:nth-last-of-type(1) {
  465. border: 0;
  466. }
  467. &.active {
  468. color: #007aff;
  469. .btn {
  470. width: 103rpx;
  471. height: 48rpx;
  472. line-height: 48rpx;
  473. text-align: center;
  474. color: #3577E8;
  475. font-size: 24rpx;
  476. border-radius: 24rpx;
  477. background: #fff;
  478. margin-left: 36rpx;
  479. border: 1rpx solid #3577E8;
  480. }
  481. }
  482. }
  483. }
  484. }
  485. }
  486. .btn2 {
  487. width: 187rpx;
  488. height: 79rpx;
  489. line-height: 79rpx;
  490. background: #FC3F3F;
  491. border-radius: 40rpx;
  492. text-align: center;
  493. font-size: 24rpx;
  494. }
  495. .btn1 {
  496. width: 187rpx;
  497. height: 79rpx;
  498. line-height: 79rpx;
  499. background: #FFB102;
  500. border-radius: 40rpx;
  501. text-align: center;
  502. margin-right: 11rpx;
  503. font-size: 24rpx;
  504. }
  505. .bottomBox {
  506. position: fixed;
  507. bottom: 0;
  508. width: 100%;
  509. left: 0;
  510. height: 98rpx;
  511. background-color: #ffffff;
  512. display: flex;
  513. justify-content: space-between;
  514. align-items: center;
  515. padding: 0 24rpx;
  516. box-shadow: 0px -5px 20px 1px rgba(1,99,235,0.1000);
  517. .share {
  518. width: 38rpx;
  519. height: 38rpx;
  520. margin-left: 32rpx;
  521. margin-right: 60rpx;
  522. }
  523. .shopcar {
  524. width: 40rpx;
  525. height: 40rpx;
  526. }
  527. }
  528. .blackFont {
  529. color: #333333;
  530. margin: 0 4rpx;
  531. }
  532. .wk_icon {
  533. width: 24rpx;
  534. height: 24rpx;
  535. margin-right: 12rpx;
  536. }
  537. .noteTag {
  538. font-size: 24rpx;
  539. font-family: PingFang SC;
  540. font-weight: 500;
  541. color: #999999;
  542. align-items: center;
  543. }
  544. .priceTag {
  545. font-size: 30rpx;
  546. font-family: PingFang SC;
  547. font-weight: bold;
  548. color: #ff2d55;
  549. }
  550. .titleTag {
  551. font-size: 32rpx;
  552. font-weight: bold;
  553. color: #333333;
  554. margin-left: 8rpx;
  555. }
  556. .yearTag {
  557. width: 80rpx;
  558. height: 32rpx;
  559. background: #ebf5ff;
  560. border: 2rpx solid #007aff;
  561. border-radius: 16rpx;
  562. font-size: 24rpx;
  563. color: #007aff;
  564. text-align: center;
  565. line-height: 32rpx;
  566. }
  567. .itemBox {
  568. background: #ffffff;
  569. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  570. border-radius: 24rpx;
  571. width: 100%;
  572. padding: 20rpx;
  573. margin-bottom: 20rpx;
  574. }
  575. </style>