detail.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <template>
  2. <view>
  3. <nav-bar title="题库详情"></nav-bar>
  4. <view style="background-color: #ffffff">
  5. <image
  6. :src="$method.splitImgHost(goodsData.coverUrl)"
  7. style="width: 100%; height: 400rpx"
  8. ></image>
  9. <view class="cou_title">
  10. <view class="title_name">
  11. <view class="titleTag">{{ goodsData.goodsName }}</view>
  12. </view>
  13. <view
  14. style="
  15. display: flex;
  16. justify-content: space-between;
  17. margin-top: 13rpx;
  18. "
  19. >
  20. <view class="prices">
  21. <!-- <text class="price_sym"></text> -->
  22. <text v-if="goodsData.standPrice" class="price_word"
  23. >¥ {{ goodsData.standPrice }}</text
  24. >
  25. <text v-else class="price_word free">免费</text>
  26. <text v-if="goodsData.linePrice" class="sale"> ¥ </text>
  27. <text v-if="goodsData.linePrice" class="price_line">
  28. {{ goodsData.linePrice }}</text
  29. >
  30. </view>
  31. <view class="noteTag">
  32. <!-- 共 <text class="blackFont">{{ goodsData.chapterNum }} 张卷 {{goodsData || '-'}}</text> 道题 -->
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="contents">
  38. <!-- <view>
  39. <view><u-tabs :list="list" item-width="50%" font-size="30" bar-width="24" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  40. </view> -->
  41. <view class="tabs">
  42. <view
  43. v-for="(item, index) in list"
  44. :key="index"
  45. class="tab_item"
  46. :class="[{ nactive: current == index }]"
  47. @click="change(index)"
  48. >{{ item.name }}</view
  49. >
  50. </view>
  51. <view class="intro" v-if="current == 0">
  52. <view
  53. v-if="goodsData.mobileDetailHtml"
  54. class="content"
  55. style="padding: 10rpx"
  56. ><rich-text :nodes="goodsData.mobileDetailHtml"></rich-text
  57. ></view>
  58. </view>
  59. <view class="title-list" v-if="current == 1">
  60. <view class="content">
  61. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  62. <template v-if="item1.type == 1">
  63. <view
  64. class="moduleItem"
  65. @click="clickModule(index1, item1.majorId)"
  66. >
  67. <view class="courseName">{{ item1.name }}</view>
  68. <view>
  69. <image
  70. src="/static/icon/up.png"
  71. class="icon_up"
  72. v-if="!item1.showList"
  73. ></image>
  74. <image
  75. src="/static/icon/down.png"
  76. class="icon_up"
  77. v-if="item1.showList"
  78. ></image>
  79. </view>
  80. </view>
  81. <template v-if="item1.showList">
  82. <view v-for="(item2, index2) in item1.list" :key="index2">
  83. <view
  84. class="section"
  85. @click="
  86. changeItem(
  87. index1,
  88. index2,
  89. item2.chapterExamId,
  90. item1.type
  91. )
  92. "
  93. >
  94. <!-- <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image>
  95. <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image> -->
  96. <u-icon
  97. v-if="!item2.showList"
  98. name="arrow-right"
  99. color="#999"
  100. size="24"
  101. ></u-icon>
  102. <u-icon
  103. v-if="item2.showList"
  104. name="arrow-down"
  105. color="#999"
  106. size="24"
  107. ></u-icon>
  108. <text class="item_name">{{ item2.name }}</text>
  109. </view>
  110. <view class="article-list" v-if="item2.showList">
  111. <view
  112. class="article"
  113. :class="{ active: showTest(article.examId) }"
  114. v-for="(article, index3) in item2.list"
  115. :key="index3"
  116. >
  117. <view class="flex_auto">{{ article.examName }}</view>
  118. <view
  119. class="btn"
  120. @click="goTest(item1.type, article)"
  121. v-if="showTest(article.examId)"
  122. >试做</view
  123. >
  124. </view>
  125. </view>
  126. <u-line></u-line>
  127. </view>
  128. </template>
  129. </template>
  130. <template v-if="item1.type == 2">
  131. <view
  132. class="section"
  133. @click="changeItem(index1, '', item1.majorId, item1.type)"
  134. >
  135. <!-- <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image>
  136. <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image> -->
  137. <u-icon
  138. v-if="!item1.showList"
  139. name="arrow-right"
  140. color="#999"
  141. size="24"
  142. ></u-icon>
  143. <u-icon
  144. v-if="item1.showList"
  145. name="arrow-down"
  146. color="#999"
  147. size="24"
  148. ></u-icon>
  149. <text class="item_name">{{ item1.name }}</text>
  150. </view>
  151. <view class="article-list" v-if="item1.showList">
  152. <view
  153. class="article"
  154. :class="{ active: showTest(article.examId) }"
  155. :key="index2"
  156. v-for="(article, index2) in item1.list"
  157. >
  158. <view class="flex_auto">{{ article.examName }}</view>
  159. <view
  160. class="btn"
  161. @click="goTest(item1.type, article)"
  162. v-if="showTest(article.examId)"
  163. >试做</view
  164. >
  165. </view>
  166. </view>
  167. </template>
  168. <template v-if="item1.type == 3">
  169. <view
  170. class="article"
  171. :class="{ active: showTest(item1.majorId) }"
  172. >
  173. <view class="flex_auto">{{ item1.name }}</view>
  174. <view
  175. class="btn"
  176. @click="goTest(item1.type, item1)"
  177. v-if="showTest(item1.majorId)"
  178. >试做</view
  179. >
  180. </view>
  181. </template>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. <view class="bottomBox" v-if="!hideBuyState">
  187. <!-- <view class="priceTag">¥ {{ toFixed(goodsData.standPrice) }}</view> -->
  188. <view class="icons">
  189. <view class="icon_item ones">
  190. <image src="/static/index/share.png" class="share"></image>
  191. <button type="default" open-type="share" class="bt_share"></button>
  192. <view class="share_w">分享</view>
  193. </view>
  194. <view class="icon_item">
  195. <image
  196. src="/static/index/shopcar.png"
  197. class="shopcar"
  198. @click="toShopcar()"
  199. ></image>
  200. <view class="share_w">购物车</view>
  201. </view>
  202. </view>
  203. <view style="display: flex; color: #ffffff; align-items: center">
  204. <view class="btn1" @click="addCart">加购物车</view>
  205. <view class="btn2" @click="buy">立即购买</view>
  206. </view>
  207. </view>
  208. <!-- 已购买过课程的弹窗 -->
  209. <u-popup v-model="bugCourseModel" mode="center" border-radius="40">
  210. <view class="had_bugCourse">
  211. <image src="/pages2/static/hadBug.png" class="share"></image>
  212. <view class="tips">
  213. <view class="warns">温馨提示</view>
  214. <view class="words">您<text>已购买过</text>该商品课程</view>
  215. <view class="words">可立即前往学习</view>
  216. </view>
  217. <view class="tip_botton">
  218. <view class="cancel_btn" @click="changeKown()">知道了</view>
  219. <view class="confirm_btn" @click="toStudy()">去学习</view>
  220. </view>
  221. </view>
  222. </u-popup>
  223. <!-- 选择规格弹窗 -->
  224. <u-popup v-model="toggleSkuShow" mode="bottom" border-radius="40">
  225. <view class="popup_box">
  226. <view class="check_head">
  227. <view class="headers">
  228. <view class="grade">选择规格</view>
  229. <u-icon
  230. name="close"
  231. color="#9C9C9C"
  232. size="40"
  233. @click="closePop()"
  234. ></u-icon>
  235. </view>
  236. </view>
  237. <view v-if="Object.keys(skuItem).length" class="pop_prices">
  238. <view class="lefts">
  239. <image
  240. :src="$method.splitImgHost(skuItem.coverUrl)"
  241. class="imgs"
  242. ></image>
  243. </view>
  244. <view class="rights">
  245. <view class="goods_titles">{{ skuItem.goodsName }}</view>
  246. <view class="goods_price">¥{{ skuItem.standPrice }}</view>
  247. </view>
  248. </view>
  249. <view class="lines"></view>
  250. <view class="check_con">
  251. <scroll-view scroll-y="true" style="height: 490rpx">
  252. <view
  253. v-for="(item, index) in specList"
  254. :key="index"
  255. class="check_items"
  256. >
  257. <view class="grades">{{ item.name }}</view>
  258. <!-- <scroll-view scroll-y="true" style="height: 180rpx;"> -->
  259. <view class="grade_names">
  260. <view
  261. class="course_items"
  262. v-for="(child, c_index) in item.specAttrList"
  263. :key="c_index"
  264. :class="{ nactive: child.check }"
  265. @click="selectSku(child, index)"
  266. >
  267. {{ child.name }}
  268. </view>
  269. </view>
  270. <!-- </scroll-view> -->
  271. </view>
  272. </scroll-view>
  273. </view>
  274. <view class="confirm_btns">
  275. <view
  276. v-if="
  277. Object.keys(skuItem).length == 0 || specList.length != isCheckSku
  278. "
  279. class="right_now r_disable"
  280. >确 定</view
  281. >
  282. <view v-else class="right_now" @click="rightNowBuy()">确 定</view>
  283. </view>
  284. </view>
  285. </u-popup>
  286. </view>
  287. </template>
  288. <script>
  289. // import { websocket } from '@/common/socket.js';
  290. import { mapGetters } from "vuex";
  291. export default {
  292. data() {
  293. return {
  294. list: [
  295. {
  296. name: "详情",
  297. },
  298. {
  299. name: "大纲",
  300. },
  301. ],
  302. current: 0,
  303. id: "",
  304. goodsData: {},
  305. bankList: [],
  306. goodsExamConfig: [],
  307. bugCourseModel: false, // 弹窗
  308. hadBuyCourse: {}, // 已购买课程信息
  309. toggleSkuShow: false,
  310. skuItem: {},
  311. isCarOrBuy: 1, // 1加入购物车 2立即购买
  312. specList: [], // 规格列表
  313. options: {},
  314. };
  315. },
  316. filters: {
  317. formatDate: function (value) {
  318. var date = new Date(value); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  319. var Y = date.getFullYear();
  320. return Y;
  321. },
  322. },
  323. onUnload() {},
  324. computed: {
  325. ...mapGetters(["userInfo", "hideBuyState"]),
  326. isCheckSku() {
  327. let checkCout = 0;
  328. this.specList.forEach((item, index) => {
  329. if (item.specAttrList && item.specAttrList.length) {
  330. item.specAttrList.forEach((child, c_index) => {
  331. if (child.check) {
  332. checkCout++;
  333. }
  334. });
  335. }
  336. });
  337. return checkCout;
  338. },
  339. },
  340. onLoad(option) {
  341. console.log("题库option:", option);
  342. if (option.scene) {
  343. // scene 生成二维码扫码进来的
  344. let optObj = {};
  345. let arrs = decodeURIComponent(option.scene).split("&");
  346. for (let i = 0; i < arrs.length; i++) {
  347. optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
  348. }
  349. this.id = optObj.id;
  350. uni.setStorageSync("newUser_sc", optObj.sc);
  351. uni.setStorageSync("shareActivityCode", optObj.sac);
  352. if (optObj.sac && this.$method.isLogin()) {
  353. this.editShareActivityCode();
  354. }
  355. } else {
  356. // 小程序正常跳转的
  357. // this.id => goodsId
  358. this.id = option.id;
  359. this.options = option;
  360. if (option.sac) {
  361. uni.setStorageSync("shareActivityCode", option.sac);
  362. if (this.$method.isLogin()) {
  363. //已登录
  364. this.editShareActivityCode();
  365. }
  366. }
  367. }
  368. option.distributionCode ? this.getFxDetail() : this.getDetail();
  369. this.goodsBankList();
  370. this.getIsBuy(); // 判断是否已经购买过该课程
  371. wx.showShareMenu({
  372. withShareTicket: true,
  373. menus: ["shareAppMessage", "shareTimeline"],
  374. });
  375. },
  376. onShow() {},
  377. // 分享到朋友圈
  378. onShareTimeline() {
  379. return {
  380. title: this.goodsData.goodsName,
  381. query: "id=" + this.id,
  382. imageUrl: this.$method.splitImgHost(this.goodsData.coverUrl),
  383. };
  384. },
  385. onShareAppMessage() {
  386. return {
  387. title: this.goodsData.goodsName,
  388. path: `/pages2/bank/detail?id=` + this.id,
  389. imageUrl: this.$method.splitImgHost(this.goodsData.coverUrl),
  390. };
  391. },
  392. methods: {
  393. // 修改用户活动邀请码
  394. editShareActivityCode() {
  395. console.log("修改用户活动邀请码");
  396. this.$http({
  397. url: "/app/user/edit/shareActivityCode",
  398. method: "post",
  399. data: {
  400. shareActivityCode: uni.getStorageSync("shareActivityCode"),
  401. },
  402. }).then((res) => {
  403. if (res.data.code == 200) {
  404. }
  405. });
  406. },
  407. toFixed(number) {
  408. if (number) {
  409. return number.toFixed(2);
  410. } else {
  411. return "0.00";
  412. }
  413. },
  414. getFxDetail() {
  415. this.$api
  416. .fxGoodsDetail({
  417. goodsId: this.id,
  418. disCode: this.options.distributionCode,
  419. })
  420. .then((res) => {
  421. if (res.data.data) {
  422. if (res.data.data.mobileDetailHtml) {
  423. res.data.data.mobileDetailHtml =
  424. res.data.data.mobileDetailHtml.replace(
  425. /<img/gi,
  426. '<img style="max-width:100%;"'
  427. );
  428. }
  429. this.goodsData = res.data.data;
  430. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig);
  431. }
  432. });
  433. },
  434. getDetail() {
  435. // '/app/common/goods/'+ data 获取商品详细信息
  436. this.$api.commonGoodsDetail(this.id).then((res) => {
  437. if (res.data.data) {
  438. if (res.data.data.mobileDetailHtml) {
  439. res.data.data.mobileDetailHtml =
  440. res.data.data.mobileDetailHtml.replace(
  441. /<img/gi,
  442. '<img style="max-width:100%;"'
  443. );
  444. }
  445. this.goodsData = res.data.data;
  446. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig);
  447. }
  448. });
  449. },
  450. goodsBankList() {
  451. this.$api
  452. .goodsBankList({
  453. goodsId: this.id,
  454. })
  455. .then((res) => {
  456. console.log(res);
  457. this.bankList = res.data.data;
  458. this.showAllCharpter();
  459. });
  460. },
  461. /**
  462. * 展示第一个章下的节内容
  463. */
  464. showAllCharpter() {
  465. for (let i = 0; i < this.bankList.length; i++) {
  466. if (this.bankList[i].type == 1) {
  467. //第一个是模块直接展开,再展开章下面的节
  468. this.$api
  469. .goodsChapterList({
  470. moduleExamId: this.bankList[i].majorId,
  471. })
  472. .then((res) => {
  473. this.$set(this.bankList[i], "showList", true);
  474. this.$set(this.bankList[i], "list", res.data.data);
  475. this.changeItem(
  476. i,
  477. 0,
  478. this.bankList[i].list[0].chapterExamId,
  479. this.bankList[i].type
  480. );
  481. });
  482. break;
  483. } else if (this.bankList[i].type == 2) {
  484. //第一个章展开下面的节
  485. this.changeItem(
  486. i,
  487. "",
  488. this.bankList[i].majorId,
  489. this.bankList[i].type
  490. );
  491. break;
  492. }
  493. }
  494. },
  495. goodsChapterList(bank, id) {
  496. this.$api
  497. .goodsChapterList({
  498. moduleExamId: id,
  499. })
  500. .then((res) => {
  501. this.$set(bank, "list", res.data.data);
  502. });
  503. },
  504. goTest(type, item) {
  505. if (type == 1) {
  506. uni.setStorageSync("testname", item.examName);
  507. uni.navigateTo({
  508. url:
  509. "/pages2/bank/questionBankTest?id=" +
  510. item.examId +
  511. "&num=" +
  512. this.showTest(item.examId).num,
  513. });
  514. } else if (type == 2) {
  515. uni.setStorageSync("testname", item.examName);
  516. uni.navigateTo({
  517. url:
  518. "/pages2/bank/questionBankTest?id=" +
  519. item.examId +
  520. "&num=" +
  521. this.showTest(item.examId).num,
  522. });
  523. } else if (type == 3) {
  524. uni.setStorageSync("testname", item.name);
  525. uni.navigateTo({
  526. url:
  527. "/pages2/bank/questionBankTest?id=" +
  528. item.majorId +
  529. "&num=" +
  530. this.showTest(item.majorId).num,
  531. });
  532. }
  533. },
  534. showTest(id) {
  535. return this.goodsExamConfig.find((item) => item.examId == id);
  536. },
  537. toConfirmList(id) {
  538. let str = "?id=" + id;
  539. if (this.options.distributionCode) {
  540. str += "&distributionCode=" + this.options.distributionCode;
  541. }
  542. if (this.options.linkCode) {
  543. str += "&linkCode=" + this.options.linkCode;
  544. }
  545. uni.navigateTo({
  546. url: "/pages2/order/confirm_list" + str,
  547. });
  548. },
  549. clickModule(index, id) {
  550. if (this.bankList[index].list) {
  551. this.$set(
  552. this.bankList[index],
  553. "showList",
  554. !this.bankList[index].showList
  555. );
  556. return;
  557. }
  558. this.$api
  559. .goodsChapterList({
  560. moduleExamId: id,
  561. })
  562. .then((res) => {
  563. this.$set(this.bankList[index], "showList", true);
  564. this.$set(this.bankList[index], "list", res.data.data);
  565. });
  566. },
  567. buy() {
  568. if (this.$method.isGoLogin()) {
  569. return;
  570. }
  571. // 判断有没有规格选择
  572. if (this.goodsData.specTemplateId) {
  573. this.isCarOrBuy = 2;
  574. this.getSpecDetail();
  575. return;
  576. }
  577. this.toConfirmList(this.id);
  578. },
  579. addCart() {
  580. // this.getSpecDetail()
  581. // return
  582. if (this.$method.isGoLogin()) {
  583. return;
  584. }
  585. // 判断有没有规格选择
  586. if (this.goodsData.specTemplateId) {
  587. this.isCarOrBuy = 1;
  588. this.getSpecDetail();
  589. return;
  590. }
  591. this.addShopCart(this.id);
  592. },
  593. addShopCart(goodsId) {
  594. this.$api
  595. .addCart({
  596. goodsId: goodsId,
  597. distributionCode: this.options.distributionCode,
  598. })
  599. .then((res) => {
  600. if (res.data.code == 200) {
  601. uni.setStorageSync("updateCart", 1); //提醒刷新购物车
  602. uni.showToast({
  603. title: "添加成功",
  604. });
  605. } else {
  606. this.$u.toast(res.data.msg);
  607. }
  608. });
  609. },
  610. getSpecDetail() {
  611. let data = {};
  612. let url = `/app/common/spec/${this.detail.specTemplateId}`;
  613. let { distributionCode } = this.options;
  614. if (distributionCode) {
  615. url = "/app/common/distribution/spec";
  616. data = {
  617. disCode: distributionCode,
  618. specTemplateId: this.detail.specTemplateId,
  619. };
  620. }
  621. this.$http({
  622. url,
  623. method: "get",
  624. noToken: true,
  625. data,
  626. }).then((res) => {
  627. let data = res.data.data;
  628. if (data) {
  629. this.toggleSkuShow = true;
  630. this.specList = data && (data.specList || []);
  631. this.specList.forEach((item, index) => {
  632. item.specAttrList.forEach((child, i_index) => {
  633. this.$set(
  634. this.specList[index].specAttrList[i_index],
  635. "check",
  636. false
  637. );
  638. });
  639. });
  640. } else {
  641. if (this.isCarOrBuy == 1) {
  642. // 加入购物车
  643. this.addShopCart(this.id);
  644. } else {
  645. this.toConfirmList(this.id);
  646. }
  647. this.closePop();
  648. }
  649. });
  650. },
  651. change(index) {
  652. this.current = index;
  653. },
  654. changeItem(index1, index2, id, type) {
  655. if (type == 1) {
  656. console.log(1);
  657. if (this.bankList[index1].list[index2].list) {
  658. this.$set(
  659. this.bankList[index1].list[index2],
  660. "showList",
  661. !this.bankList[index1].list[index2].showList
  662. );
  663. return;
  664. }
  665. this.$api
  666. .goodsExamList({
  667. chapterExamId: id,
  668. })
  669. .then((res) => {
  670. this.$set(this.bankList[index1].list[index2], "showList", true);
  671. this.$set(
  672. this.bankList[index1].list[index2],
  673. "list",
  674. res.data.data
  675. );
  676. });
  677. } else if (type == 2) {
  678. console.log(2);
  679. if (this.bankList[index1].list) {
  680. this.$set(
  681. this.bankList[index1],
  682. "showList",
  683. !this.bankList[index1].showList
  684. );
  685. return;
  686. }
  687. this.$api
  688. .goodsExamList({
  689. chapterExamId: id,
  690. })
  691. .then((res) => {
  692. this.$set(this.bankList[index1], "showList", true);
  693. this.$set(this.bankList[index1], "list", res.data.data);
  694. });
  695. }
  696. },
  697. toShopcar() {
  698. uni.navigateTo({
  699. url: "/pages4/shopping/shoppingCart",
  700. });
  701. },
  702. getIsBuy() {
  703. if (this.$method.isGoLogin()) {
  704. return;
  705. }
  706. this.$http({
  707. url: "/order/buyGoodsNotExpired",
  708. method: "get",
  709. data: { goodsId: this.id },
  710. }).then((res) => {
  711. if (res.data.code == 200) {
  712. if (res.data.data) {
  713. // 有data返回是已经购买过的课程
  714. this.hadBuyCourse = res.data.data;
  715. this.bugCourseModel = true;
  716. }
  717. }
  718. });
  719. },
  720. changeKown() {
  721. this.bugCourseModel = false;
  722. },
  723. toStudy() {
  724. let sysTime = this.$method.timest();
  725. const { serviceStartTime, serviceEndTime, goodsId, orderGoodsId } =
  726. this.hadBuyCourse;
  727. if (
  728. serviceStartTime &&
  729. serviceEndTime &&
  730. (sysTime <= serviceStartTime || sysTime >= serviceEndTime)
  731. ) {
  732. uni.showToast({
  733. icon: "none",
  734. title: "不在学习服务期,不能进入学习",
  735. });
  736. return;
  737. }
  738. uni.navigateTo({
  739. url:
  740. "/pages2/bank/question_detail?id=" +
  741. goodsId +
  742. "&orderGoodsId=" +
  743. orderGoodsId,
  744. });
  745. this.bugCourseModel = false;
  746. },
  747. closePop() {
  748. this.toggleSkuShow = false;
  749. this.skuItem = {};
  750. },
  751. selectSku(item, index) {
  752. this.specList[index].specAttrList.forEach((i_item, i_index) => {
  753. if (item.specAttributeId == i_item.specAttributeId) {
  754. this.$set(this.specList[index].specAttrList[i_index], "check", true);
  755. } else {
  756. this.$set(this.specList[index].specAttrList[i_index], "check", false);
  757. }
  758. });
  759. // console.log('this.specList', this.specList, this.isCheckSku)
  760. if (this.specList.length == this.isCheckSku) {
  761. let specAttrIds = [];
  762. this.specList.forEach((item) => {
  763. let result = item.specAttrList.find((e) => e.check);
  764. if (result) {
  765. specAttrIds.push(result.specAttributeId);
  766. }
  767. });
  768. this.getGoodsInfos(specAttrIds);
  769. }
  770. },
  771. // 获取规格属性值对应的商品信息
  772. getGoodsInfos(specAttrIds) {
  773. this.$http({
  774. url: "/app/common/attr/goods",
  775. method: "get",
  776. data: {
  777. specTemplateId: this.goodsData.specTemplateId,
  778. specAttrIds: specAttrIds.join(","),
  779. },
  780. noToken: true,
  781. }).then((res) => {
  782. if (res.data.code == 200) {
  783. this.skuItem = res.data.data || {};
  784. } else {
  785. this.skuItem = {};
  786. this.$u.toast("商品已下架, 请重新选择");
  787. }
  788. });
  789. },
  790. rightNowBuy() {
  791. if (this.specList.length != this.isCheckSku) {
  792. this.$u.toast("请先选择所有的规格");
  793. return;
  794. }
  795. if (this.skuItem.goodsStatus == 0) {
  796. this.$u.toast("商品已下架, 请重新选择");
  797. return;
  798. }
  799. let sysTime = this.$method.timest();
  800. if (
  801. sysTime <= this.skuItem.validityStartTime ||
  802. sysTime >= this.skuItem.validityEndTime
  803. ) {
  804. this.$u.toast("商品不在有效期, 请重新选择");
  805. return;
  806. }
  807. if (this.isCarOrBuy == 1) {
  808. // 加入购物车
  809. this.addShopCart(this.skuItem.goodsId);
  810. } else {
  811. this.toConfirmList(this.skuItem.goodsId);
  812. }
  813. this.closePop();
  814. },
  815. },
  816. };
  817. </script>
  818. <style>
  819. page {
  820. background-color: #f2f2f2;
  821. }
  822. </style>
  823. <style lang="scss" scope>
  824. @import "../../pages3/course/index.scss";
  825. .contents {
  826. width: 100%;
  827. height: 100%;
  828. background-color: #ffffff;
  829. margin-top: 16rpx;
  830. overflow: hidden;
  831. // tab
  832. .tabs {
  833. // width: 100%;
  834. height: 78rpx;
  835. display: flex;
  836. align-items: center;
  837. justify-content: space-between;
  838. background-color: #f2f7ff;
  839. border-radius: 38rpx;
  840. margin: 24rpx;
  841. padding: 0rpx 5rpx;
  842. .tab_item {
  843. width: 345rpx;
  844. height: 65rpx;
  845. line-height: 65rpx;
  846. font-size: 28rpx;
  847. font-weight: bold;
  848. border-radius: 32rpx;
  849. text-align: center;
  850. color: #333;
  851. &.nactive {
  852. color: #fff;
  853. background-color: #3577e8;
  854. }
  855. // &.twoBtn {
  856. // width: 50%;
  857. // }
  858. }
  859. }
  860. }
  861. .cou_title {
  862. padding: 24rpx 32rpx 40rpx 32rpx;
  863. display: flex;
  864. flex-direction: column;
  865. justify-content: space-around;
  866. }
  867. .prices {
  868. .price_word {
  869. font-size: 40rpx;
  870. font-weight: 800;
  871. color: #fc3f3f;
  872. }
  873. .sale {
  874. color: #999999;
  875. font-size: 28rpx;
  876. margin-left: 8rpx;
  877. }
  878. .price_line {
  879. color: #999999;
  880. font-size: 28rpx;
  881. text-decoration: line-through;
  882. font-weight: 400;
  883. }
  884. .free {
  885. font-size: 32rpx;
  886. }
  887. }
  888. .courseName {
  889. white-space: nowrap;
  890. overflow: hidden;
  891. text-overflow: ellipsis;
  892. }
  893. .icon_up {
  894. width: 32rpx;
  895. height: 32rpx;
  896. }
  897. .intro {
  898. background: #fff;
  899. padding: 16rpx 16rpx 124rpx;
  900. .content {
  901. background: #fff;
  902. border-radius: 16rpx;
  903. .top {
  904. border-radius: 16rpx;
  905. padding: 32rpx 28rpx 16rpx;
  906. font-size: 30rpx;
  907. color: #333333;
  908. }
  909. .img {
  910. width: 100%;
  911. }
  912. }
  913. }
  914. .moduleItem {
  915. height: 80rpx;
  916. color: #333333;
  917. font-size: 32rpx;
  918. line-height: 80rpx;
  919. font-weight: bold;
  920. display: flex;
  921. justify-content: space-between;
  922. }
  923. .title-list {
  924. background: #fff;
  925. padding: 16rpx 16rpx 124rpx;
  926. .content {
  927. .list {
  928. background: #fff;
  929. margin-bottom: 30rpx;
  930. overflow: hidden;
  931. border-radius: 16rpx;
  932. padding: 10rpx 16rpx;
  933. .module {
  934. font-size: 32rpx;
  935. color: #333333;
  936. .icon {
  937. margin-right: 10rpx;
  938. }
  939. }
  940. .section {
  941. font-size: 30rpx;
  942. color: #333;
  943. white-space: nowrap;
  944. overflow: hidden;
  945. text-overflow: ellipsis;
  946. padding: 20rpx 0;
  947. display: flex;
  948. align-items: center;
  949. border-bottom: 1rpx solid #eee;
  950. }
  951. .item_name {
  952. font-size: 24rpx;
  953. font-family: PingFang SC;
  954. font-weight: bold;
  955. color: #333;
  956. white-space: nowrap;
  957. overflow: hidden;
  958. text-overflow: ellipsis;
  959. margin-left: 8rpx;
  960. }
  961. // .article-list {
  962. // margin-top:20rpx;
  963. // }
  964. .article {
  965. padding: 10rpx 0;
  966. min-height: 80rpx;
  967. display: flex;
  968. align-items: center;
  969. margin-left: 35rpx;
  970. font-size: 30rpx;
  971. color: #666666;
  972. border-bottom: 1rpx solid #eeeeee;
  973. display: flex;
  974. .flex_auto {
  975. flex: 1;
  976. font-size: 30rpx;
  977. color: #666666;
  978. word-break: break-all;
  979. }
  980. &:nth-last-of-type(1) {
  981. border: 0;
  982. }
  983. &.active {
  984. color: #007aff;
  985. .btn {
  986. width: 103rpx;
  987. height: 48rpx;
  988. line-height: 48rpx;
  989. text-align: center;
  990. color: #3577e8;
  991. font-size: 24rpx;
  992. border-radius: 24rpx;
  993. background: #fff;
  994. margin-left: 36rpx;
  995. border: 1rpx solid #3577e8;
  996. }
  997. }
  998. }
  999. }
  1000. }
  1001. }
  1002. .btn2 {
  1003. width: 187rpx;
  1004. height: 79rpx;
  1005. line-height: 79rpx;
  1006. background: #fc3f3f;
  1007. border-radius: 40rpx;
  1008. text-align: center;
  1009. font-size: 24rpx;
  1010. }
  1011. .btn1 {
  1012. width: 187rpx;
  1013. height: 79rpx;
  1014. line-height: 79rpx;
  1015. background: #ffb102;
  1016. border-radius: 40rpx;
  1017. text-align: center;
  1018. margin-right: 11rpx;
  1019. font-size: 24rpx;
  1020. }
  1021. .blackFont {
  1022. color: #333333;
  1023. margin: 0 4rpx;
  1024. }
  1025. .wk_icon {
  1026. width: 24rpx;
  1027. height: 24rpx;
  1028. margin-right: 12rpx;
  1029. }
  1030. .noteTag {
  1031. font-size: 24rpx;
  1032. font-family: PingFang SC;
  1033. font-weight: 500;
  1034. color: #999999;
  1035. align-items: center;
  1036. }
  1037. .priceTag {
  1038. font-size: 30rpx;
  1039. font-family: PingFang SC;
  1040. font-weight: bold;
  1041. color: #ff2d55;
  1042. }
  1043. .titleTag {
  1044. font-size: 36rpx;
  1045. font-weight: bold;
  1046. color: #333333;
  1047. // margin-left: 8rpx;
  1048. }
  1049. .yearTag {
  1050. width: 80rpx;
  1051. height: 32rpx;
  1052. background: #ebf5ff;
  1053. border: 2rpx solid #007aff;
  1054. border-radius: 16rpx;
  1055. font-size: 24rpx;
  1056. color: #007aff;
  1057. text-align: center;
  1058. line-height: 32rpx;
  1059. }
  1060. .itemBox {
  1061. background: #ffffff;
  1062. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  1063. border-radius: 24rpx;
  1064. width: 100%;
  1065. padding: 20rpx;
  1066. margin-bottom: 20rpx;
  1067. }
  1068. </style>