detail.vue 17 KB

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