detail.vue 16 KB

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