detail.vue 17 KB

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