detail.vue 16 KB

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