detail.vue 16 KB

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