detail.vue 16 KB

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