detail.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098
  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" v-if="!disCode">
  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" v-if="!disCode" @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. disCode() {
  340. return this.options.distributionCode;
  341. },
  342. },
  343. onLoad(option) {
  344. console.log("题库option:", option);
  345. if (option.scene) {
  346. // scene 生成二维码扫码进来的
  347. let optObj = {};
  348. let arrs = decodeURIComponent(option.scene).split("&");
  349. for (let i = 0; i < arrs.length; i++) {
  350. optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
  351. }
  352. this.id = optObj.id;
  353. uni.setStorageSync("newUser_sc", optObj.sc);
  354. uni.setStorageSync("shareActivityCode", optObj.sac);
  355. if (optObj.sac && this.$method.isLogin()) {
  356. this.editShareActivityCode();
  357. }
  358. } else {
  359. // 小程序正常跳转的
  360. // this.id => goodsId
  361. this.id = option.id;
  362. this.options = option;
  363. if (option.sac) {
  364. uni.setStorageSync("shareActivityCode", option.sac);
  365. if (this.$method.isLogin()) {
  366. //已登录
  367. this.editShareActivityCode();
  368. }
  369. }
  370. }
  371. this.disCode ? this.getFxDetail() : this.getDetail();
  372. this.goodsBankList();
  373. this.getIsBuy(); // 判断是否已经购买过该课程
  374. wx.showShareMenu({
  375. withShareTicket: true,
  376. menus: ["shareAppMessage", "shareTimeline"],
  377. });
  378. },
  379. onShow() {},
  380. // 分享到朋友圈
  381. onShareTimeline() {
  382. return {
  383. title: this.goodsData.goodsName,
  384. query: "id=" + this.id,
  385. imageUrl: this.$method.splitImgHost(this.goodsData.coverUrl),
  386. };
  387. },
  388. onShareAppMessage() {
  389. return {
  390. title: this.goodsData.goodsName,
  391. path: `/pages2/bank/detail?id=` + this.id,
  392. imageUrl: this.$method.splitImgHost(this.goodsData.coverUrl),
  393. };
  394. },
  395. methods: {
  396. // 修改用户活动邀请码
  397. editShareActivityCode() {
  398. console.log("修改用户活动邀请码");
  399. this.$http({
  400. url: "/app/user/edit/shareActivityCode",
  401. method: "post",
  402. data: {
  403. shareActivityCode: uni.getStorageSync("shareActivityCode"),
  404. },
  405. }).then((res) => {
  406. if (res.data.code == 200) {
  407. }
  408. });
  409. },
  410. toFixed(number) {
  411. if (number) {
  412. return number.toFixed(2);
  413. } else {
  414. return "0.00";
  415. }
  416. },
  417. getFxDetail() {
  418. this.$api
  419. .fxGoodsDetail({
  420. goodsId: this.id,
  421. disCode: this.disCode,
  422. })
  423. .then((res) => {
  424. if (res.data.data) {
  425. if (res.data.data.mobileDetailHtml) {
  426. res.data.data.mobileDetailHtml =
  427. res.data.data.mobileDetailHtml.replace(
  428. /<img/gi,
  429. '<img style="max-width:100%;"'
  430. );
  431. }
  432. this.goodsData = res.data.data;
  433. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig);
  434. }
  435. });
  436. },
  437. getDetail() {
  438. // '/app/common/goods/'+ data 获取商品详细信息
  439. this.$api.commonGoodsDetail(this.id).then((res) => {
  440. if (res.data.data) {
  441. if (res.data.data.mobileDetailHtml) {
  442. res.data.data.mobileDetailHtml =
  443. res.data.data.mobileDetailHtml.replace(
  444. /<img/gi,
  445. '<img style="max-width:100%;"'
  446. );
  447. }
  448. this.goodsData = res.data.data;
  449. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig);
  450. }
  451. });
  452. },
  453. goodsBankList() {
  454. this.$api
  455. .goodsBankList({
  456. goodsId: this.id,
  457. })
  458. .then((res) => {
  459. console.log(res);
  460. this.bankList = res.data.data;
  461. this.showAllCharpter();
  462. });
  463. },
  464. /**
  465. * 展示第一个章下的节内容
  466. */
  467. showAllCharpter() {
  468. for (let i = 0; i < this.bankList.length; i++) {
  469. if (this.bankList[i].type == 1) {
  470. //第一个是模块直接展开,再展开章下面的节
  471. this.$api
  472. .goodsChapterList({
  473. moduleExamId: this.bankList[i].majorId,
  474. })
  475. .then((res) => {
  476. this.$set(this.bankList[i], "showList", true);
  477. this.$set(this.bankList[i], "list", res.data.data);
  478. this.changeItem(
  479. i,
  480. 0,
  481. this.bankList[i].list[0].chapterExamId,
  482. this.bankList[i].type
  483. );
  484. });
  485. break;
  486. } else if (this.bankList[i].type == 2) {
  487. //第一个章展开下面的节
  488. this.changeItem(
  489. i,
  490. "",
  491. this.bankList[i].majorId,
  492. this.bankList[i].type
  493. );
  494. break;
  495. }
  496. }
  497. },
  498. goodsChapterList(bank, id) {
  499. this.$api
  500. .goodsChapterList({
  501. moduleExamId: id,
  502. })
  503. .then((res) => {
  504. this.$set(bank, "list", res.data.data);
  505. });
  506. },
  507. goTest(type, item) {
  508. if (type == 1) {
  509. uni.setStorageSync("testname", item.examName);
  510. uni.navigateTo({
  511. url:
  512. "/pages2/bank/questionBankTest?id=" +
  513. item.examId +
  514. "&num=" +
  515. this.showTest(item.examId).num,
  516. });
  517. } else if (type == 2) {
  518. uni.setStorageSync("testname", item.examName);
  519. uni.navigateTo({
  520. url:
  521. "/pages2/bank/questionBankTest?id=" +
  522. item.examId +
  523. "&num=" +
  524. this.showTest(item.examId).num,
  525. });
  526. } else if (type == 3) {
  527. uni.setStorageSync("testname", item.name);
  528. uni.navigateTo({
  529. url:
  530. "/pages2/bank/questionBankTest?id=" +
  531. item.majorId +
  532. "&num=" +
  533. this.showTest(item.majorId).num,
  534. });
  535. }
  536. },
  537. showTest(id) {
  538. return this.goodsExamConfig.find((item) => item.examId == id);
  539. },
  540. toConfirmList(id) {
  541. let str = "?id=" + id;
  542. if (this.disCode) {
  543. str += "&distributionCode=" + this.disCode;
  544. }
  545. if (this.options.linkCode) {
  546. str += "&linkCode=" + this.options.linkCode;
  547. }
  548. uni.navigateTo({
  549. url: "/pages2/order/confirm_list" + str,
  550. });
  551. },
  552. clickModule(index, id) {
  553. if (this.bankList[index].list) {
  554. this.$set(
  555. this.bankList[index],
  556. "showList",
  557. !this.bankList[index].showList
  558. );
  559. return;
  560. }
  561. this.$api
  562. .goodsChapterList({
  563. moduleExamId: id,
  564. })
  565. .then((res) => {
  566. this.$set(this.bankList[index], "showList", true);
  567. this.$set(this.bankList[index], "list", res.data.data);
  568. });
  569. },
  570. buy() {
  571. if (this.$method.isGoLogin()) {
  572. return;
  573. }
  574. // 判断有没有规格选择
  575. if (this.goodsData.specTemplateId) {
  576. this.isCarOrBuy = 2;
  577. this.getSpecDetail();
  578. return;
  579. }
  580. this.toConfirmList(this.id);
  581. },
  582. addCart() {
  583. // this.getSpecDetail()
  584. // return
  585. if (this.$method.isGoLogin()) {
  586. return;
  587. }
  588. // 判断有没有规格选择
  589. if (this.goodsData.specTemplateId) {
  590. this.isCarOrBuy = 1;
  591. this.getSpecDetail();
  592. return;
  593. }
  594. this.addShopCart(this.id);
  595. },
  596. addShopCart(goodsId) {
  597. this.$api
  598. .addCart({
  599. goodsId: goodsId,
  600. choiceStatus: 1,
  601. })
  602. .then((res) => {
  603. if (res.data.code == 200) {
  604. uni.setStorageSync("updateCart", 1); //提醒刷新购物车
  605. uni.showToast({
  606. title: "添加成功",
  607. });
  608. } else {
  609. this.$u.toast(res.data.msg);
  610. }
  611. });
  612. },
  613. getSpecDetail() {
  614. let data = {};
  615. let url = `/app/common/spec/${this.detail.specTemplateId}`;
  616. if (this.disCode) {
  617. url = "/app/common/distribution/spec";
  618. data = {
  619. disCode: this.disCode,
  620. specTemplateId: this.detail.specTemplateId,
  621. };
  622. }
  623. this.$http({
  624. url,
  625. method: "get",
  626. noToken: true,
  627. data,
  628. }).then((res) => {
  629. let data = res.data.data;
  630. if (data) {
  631. this.toggleSkuShow = true;
  632. this.specList = data && (data.specList || []);
  633. this.specList.forEach((item, index) => {
  634. item.specAttrList.forEach((child, i_index) => {
  635. this.$set(
  636. this.specList[index].specAttrList[i_index],
  637. "check",
  638. false
  639. );
  640. });
  641. });
  642. } else {
  643. if (this.isCarOrBuy == 1) {
  644. // 加入购物车
  645. this.addShopCart(this.id);
  646. } else {
  647. this.toConfirmList(this.id);
  648. }
  649. this.closePop();
  650. }
  651. });
  652. },
  653. change(index) {
  654. this.current = index;
  655. },
  656. changeItem(index1, index2, id, type) {
  657. if (type == 1) {
  658. console.log(1);
  659. if (this.bankList[index1].list[index2].list) {
  660. this.$set(
  661. this.bankList[index1].list[index2],
  662. "showList",
  663. !this.bankList[index1].list[index2].showList
  664. );
  665. return;
  666. }
  667. this.$api
  668. .goodsExamList({
  669. chapterExamId: id,
  670. })
  671. .then((res) => {
  672. this.$set(this.bankList[index1].list[index2], "showList", true);
  673. this.$set(
  674. this.bankList[index1].list[index2],
  675. "list",
  676. res.data.data
  677. );
  678. });
  679. } else if (type == 2) {
  680. console.log(2);
  681. if (this.bankList[index1].list) {
  682. this.$set(
  683. this.bankList[index1],
  684. "showList",
  685. !this.bankList[index1].showList
  686. );
  687. return;
  688. }
  689. this.$api
  690. .goodsExamList({
  691. chapterExamId: id,
  692. })
  693. .then((res) => {
  694. this.$set(this.bankList[index1], "showList", true);
  695. this.$set(this.bankList[index1], "list", res.data.data);
  696. });
  697. }
  698. },
  699. toShopcar() {
  700. uni.navigateTo({
  701. url: "/pages4/shopping/shoppingCart",
  702. });
  703. },
  704. getIsBuy() {
  705. if (this.$method.isGoLogin()) {
  706. return;
  707. }
  708. this.$http({
  709. url: "/order/buyGoodsNotExpired",
  710. method: "get",
  711. data: { goodsId: this.id },
  712. }).then((res) => {
  713. if (res.data.code == 200) {
  714. if (res.data.data) {
  715. // 有data返回是已经购买过的课程
  716. this.hadBuyCourse = res.data.data;
  717. this.bugCourseModel = true;
  718. }
  719. }
  720. });
  721. },
  722. changeKown() {
  723. this.bugCourseModel = false;
  724. },
  725. toStudy() {
  726. let sysTime = this.$method.timest();
  727. const { serviceStartTime, serviceEndTime, goodsId, orderGoodsId } =
  728. this.hadBuyCourse;
  729. if (
  730. serviceStartTime &&
  731. serviceEndTime &&
  732. (sysTime <= serviceStartTime || sysTime >= serviceEndTime)
  733. ) {
  734. uni.showToast({
  735. icon: "none",
  736. title: "不在学习服务期,不能进入学习",
  737. });
  738. return;
  739. }
  740. uni.navigateTo({
  741. url:
  742. "/pages2/bank/question_detail?id=" +
  743. goodsId +
  744. "&orderGoodsId=" +
  745. orderGoodsId,
  746. });
  747. this.bugCourseModel = false;
  748. },
  749. closePop() {
  750. this.toggleSkuShow = false;
  751. this.skuItem = {};
  752. },
  753. selectSku(item, index) {
  754. this.specList[index].specAttrList.forEach((i_item, i_index) => {
  755. if (item.specAttributeId == i_item.specAttributeId) {
  756. this.$set(this.specList[index].specAttrList[i_index], "check", true);
  757. } else {
  758. this.$set(this.specList[index].specAttrList[i_index], "check", false);
  759. }
  760. });
  761. // console.log('this.specList', this.specList, this.isCheckSku)
  762. if (this.specList.length == this.isCheckSku) {
  763. let specAttrIds = [];
  764. this.specList.forEach((item) => {
  765. let result = item.specAttrList.find((e) => e.check);
  766. if (result) {
  767. specAttrIds.push(result.specAttributeId);
  768. }
  769. });
  770. this.getGoodsInfos(specAttrIds);
  771. }
  772. },
  773. // 获取规格属性值对应的商品信息
  774. getGoodsInfos(specAttrIds) {
  775. this.$http({
  776. url: "/app/common/attr/goods",
  777. method: "get",
  778. data: {
  779. specTemplateId: this.goodsData.specTemplateId,
  780. specAttrIds: specAttrIds.join(","),
  781. },
  782. noToken: true,
  783. }).then((res) => {
  784. if (res.data.code == 200) {
  785. this.skuItem = res.data.data || {};
  786. } else {
  787. this.skuItem = {};
  788. this.$u.toast("商品已下架, 请重新选择");
  789. }
  790. });
  791. },
  792. rightNowBuy() {
  793. if (this.specList.length != this.isCheckSku) {
  794. this.$u.toast("请先选择所有的规格");
  795. return;
  796. }
  797. if (this.skuItem.goodsStatus == 0) {
  798. this.$u.toast("商品已下架, 请重新选择");
  799. return;
  800. }
  801. let sysTime = this.$method.timest();
  802. if (
  803. sysTime <= this.skuItem.validityStartTime ||
  804. sysTime >= this.skuItem.validityEndTime
  805. ) {
  806. this.$u.toast("商品不在有效期, 请重新选择");
  807. return;
  808. }
  809. if (this.isCarOrBuy == 1) {
  810. // 加入购物车
  811. this.addShopCart(this.skuItem.goodsId);
  812. } else {
  813. this.toConfirmList(this.skuItem.goodsId);
  814. }
  815. this.closePop();
  816. },
  817. },
  818. };
  819. </script>
  820. <style>
  821. page {
  822. background-color: #f2f2f2;
  823. }
  824. </style>
  825. <style lang="scss" scope>
  826. @import "../../pages3/course/index.scss";
  827. .contents {
  828. width: 100%;
  829. height: 100%;
  830. background-color: #ffffff;
  831. margin-top: 16rpx;
  832. overflow: hidden;
  833. // tab
  834. .tabs {
  835. // width: 100%;
  836. height: 78rpx;
  837. display: flex;
  838. align-items: center;
  839. justify-content: space-between;
  840. background-color: #f2f7ff;
  841. border-radius: 38rpx;
  842. margin: 24rpx;
  843. padding: 0rpx 5rpx;
  844. .tab_item {
  845. width: 345rpx;
  846. height: 65rpx;
  847. line-height: 65rpx;
  848. font-size: 28rpx;
  849. font-weight: bold;
  850. border-radius: 32rpx;
  851. text-align: center;
  852. color: #333;
  853. &.nactive {
  854. color: #fff;
  855. background-color: #3577e8;
  856. }
  857. // &.twoBtn {
  858. // width: 50%;
  859. // }
  860. }
  861. }
  862. }
  863. .cou_title {
  864. padding: 24rpx 32rpx 40rpx 32rpx;
  865. display: flex;
  866. flex-direction: column;
  867. justify-content: space-around;
  868. }
  869. .prices {
  870. .price_word {
  871. font-size: 40rpx;
  872. font-weight: 800;
  873. color: #fc3f3f;
  874. }
  875. .sale {
  876. color: #999999;
  877. font-size: 28rpx;
  878. margin-left: 8rpx;
  879. }
  880. .price_line {
  881. color: #999999;
  882. font-size: 28rpx;
  883. text-decoration: line-through;
  884. font-weight: 400;
  885. }
  886. .free {
  887. font-size: 32rpx;
  888. }
  889. }
  890. .courseName {
  891. white-space: nowrap;
  892. overflow: hidden;
  893. text-overflow: ellipsis;
  894. }
  895. .icon_up {
  896. width: 32rpx;
  897. height: 32rpx;
  898. }
  899. .intro {
  900. background: #fff;
  901. padding: 16rpx 16rpx 124rpx;
  902. .content {
  903. background: #fff;
  904. border-radius: 16rpx;
  905. .top {
  906. border-radius: 16rpx;
  907. padding: 32rpx 28rpx 16rpx;
  908. font-size: 30rpx;
  909. color: #333333;
  910. }
  911. .img {
  912. width: 100%;
  913. }
  914. }
  915. }
  916. .moduleItem {
  917. height: 80rpx;
  918. color: #333333;
  919. font-size: 32rpx;
  920. line-height: 80rpx;
  921. font-weight: bold;
  922. display: flex;
  923. justify-content: space-between;
  924. }
  925. .title-list {
  926. background: #fff;
  927. padding: 16rpx 16rpx 124rpx;
  928. .content {
  929. .list {
  930. background: #fff;
  931. margin-bottom: 30rpx;
  932. overflow: hidden;
  933. border-radius: 16rpx;
  934. padding: 10rpx 16rpx;
  935. .module {
  936. font-size: 32rpx;
  937. color: #333333;
  938. .icon {
  939. margin-right: 10rpx;
  940. }
  941. }
  942. .section {
  943. font-size: 30rpx;
  944. color: #333;
  945. white-space: nowrap;
  946. overflow: hidden;
  947. text-overflow: ellipsis;
  948. padding: 20rpx 0;
  949. display: flex;
  950. align-items: center;
  951. border-bottom: 1rpx solid #eee;
  952. }
  953. .item_name {
  954. font-size: 24rpx;
  955. font-family: PingFang SC;
  956. font-weight: bold;
  957. color: #333;
  958. white-space: nowrap;
  959. overflow: hidden;
  960. text-overflow: ellipsis;
  961. margin-left: 8rpx;
  962. }
  963. // .article-list {
  964. // margin-top:20rpx;
  965. // }
  966. .article {
  967. padding: 10rpx 0;
  968. min-height: 80rpx;
  969. display: flex;
  970. align-items: center;
  971. margin-left: 35rpx;
  972. font-size: 30rpx;
  973. color: #666666;
  974. border-bottom: 1rpx solid #eeeeee;
  975. display: flex;
  976. .flex_auto {
  977. flex: 1;
  978. font-size: 30rpx;
  979. color: #666666;
  980. word-break: break-all;
  981. }
  982. &:nth-last-of-type(1) {
  983. border: 0;
  984. }
  985. &.active {
  986. color: #007aff;
  987. .btn {
  988. width: 103rpx;
  989. height: 48rpx;
  990. line-height: 48rpx;
  991. text-align: center;
  992. color: #3577e8;
  993. font-size: 24rpx;
  994. border-radius: 24rpx;
  995. background: #fff;
  996. margin-left: 36rpx;
  997. border: 1rpx solid #3577e8;
  998. }
  999. }
  1000. }
  1001. }
  1002. }
  1003. }
  1004. .btn2 {
  1005. width: 187rpx;
  1006. height: 79rpx;
  1007. line-height: 79rpx;
  1008. background: #fc3f3f;
  1009. border-radius: 40rpx;
  1010. text-align: center;
  1011. font-size: 24rpx;
  1012. }
  1013. .btn1 {
  1014. width: 187rpx;
  1015. height: 79rpx;
  1016. line-height: 79rpx;
  1017. background: #ffb102;
  1018. border-radius: 40rpx;
  1019. text-align: center;
  1020. margin-right: 11rpx;
  1021. font-size: 24rpx;
  1022. }
  1023. .blackFont {
  1024. color: #333333;
  1025. margin: 0 4rpx;
  1026. }
  1027. .wk_icon {
  1028. width: 24rpx;
  1029. height: 24rpx;
  1030. margin-right: 12rpx;
  1031. }
  1032. .noteTag {
  1033. font-size: 24rpx;
  1034. font-family: PingFang SC;
  1035. font-weight: 500;
  1036. color: #999999;
  1037. align-items: center;
  1038. }
  1039. .priceTag {
  1040. font-size: 30rpx;
  1041. font-family: PingFang SC;
  1042. font-weight: bold;
  1043. color: #ff2d55;
  1044. }
  1045. .titleTag {
  1046. font-size: 36rpx;
  1047. font-weight: bold;
  1048. color: #333333;
  1049. // margin-left: 8rpx;
  1050. }
  1051. .yearTag {
  1052. width: 80rpx;
  1053. height: 32rpx;
  1054. background: #ebf5ff;
  1055. border: 2rpx solid #007aff;
  1056. border-radius: 16rpx;
  1057. font-size: 24rpx;
  1058. color: #007aff;
  1059. text-align: center;
  1060. line-height: 32rpx;
  1061. }
  1062. .itemBox {
  1063. background: #ffffff;
  1064. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  1065. border-radius: 24rpx;
  1066. width: 100%;
  1067. padding: 20rpx;
  1068. margin-bottom: 20rpx;
  1069. }
  1070. </style>