detail.vue 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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. })
  601. .then((res) => {
  602. if (res.data.code == 200) {
  603. uni.setStorageSync("updateCart", 1); //提醒刷新购物车
  604. uni.showToast({
  605. title: "添加成功",
  606. });
  607. } else {
  608. this.$u.toast(res.data.msg);
  609. }
  610. });
  611. },
  612. getSpecDetail() {
  613. let data = {};
  614. let url = `/app/common/spec/${this.detail.specTemplateId}`;
  615. if (this.disCode) {
  616. url = "/app/common/distribution/spec";
  617. data = {
  618. disCode: this.disCode,
  619. specTemplateId: this.detail.specTemplateId,
  620. };
  621. }
  622. this.$http({
  623. url,
  624. method: "get",
  625. noToken: true,
  626. data,
  627. }).then((res) => {
  628. let data = res.data.data;
  629. if (data) {
  630. this.toggleSkuShow = true;
  631. this.specList = data && (data.specList || []);
  632. this.specList.forEach((item, index) => {
  633. item.specAttrList.forEach((child, i_index) => {
  634. this.$set(
  635. this.specList[index].specAttrList[i_index],
  636. "check",
  637. false
  638. );
  639. });
  640. });
  641. } else {
  642. if (this.isCarOrBuy == 1) {
  643. // 加入购物车
  644. this.addShopCart(this.id);
  645. } else {
  646. this.toConfirmList(this.id);
  647. }
  648. this.closePop();
  649. }
  650. });
  651. },
  652. change(index) {
  653. this.current = index;
  654. },
  655. changeItem(index1, index2, id, type) {
  656. if (type == 1) {
  657. console.log(1);
  658. if (this.bankList[index1].list[index2].list) {
  659. this.$set(
  660. this.bankList[index1].list[index2],
  661. "showList",
  662. !this.bankList[index1].list[index2].showList
  663. );
  664. return;
  665. }
  666. this.$api
  667. .goodsExamList({
  668. chapterExamId: id,
  669. })
  670. .then((res) => {
  671. this.$set(this.bankList[index1].list[index2], "showList", true);
  672. this.$set(
  673. this.bankList[index1].list[index2],
  674. "list",
  675. res.data.data
  676. );
  677. });
  678. } else if (type == 2) {
  679. console.log(2);
  680. if (this.bankList[index1].list) {
  681. this.$set(
  682. this.bankList[index1],
  683. "showList",
  684. !this.bankList[index1].showList
  685. );
  686. return;
  687. }
  688. this.$api
  689. .goodsExamList({
  690. chapterExamId: id,
  691. })
  692. .then((res) => {
  693. this.$set(this.bankList[index1], "showList", true);
  694. this.$set(this.bankList[index1], "list", res.data.data);
  695. });
  696. }
  697. },
  698. toShopcar() {
  699. uni.navigateTo({
  700. url: "/pages4/shopping/shoppingCart",
  701. });
  702. },
  703. getIsBuy() {
  704. if (this.$method.isGoLogin()) {
  705. return;
  706. }
  707. this.$http({
  708. url: "/order/buyGoodsNotExpired",
  709. method: "get",
  710. data: { goodsId: this.id },
  711. }).then((res) => {
  712. if (res.data.code == 200) {
  713. if (res.data.data) {
  714. // 有data返回是已经购买过的课程
  715. this.hadBuyCourse = res.data.data;
  716. this.bugCourseModel = true;
  717. }
  718. }
  719. });
  720. },
  721. changeKown() {
  722. this.bugCourseModel = false;
  723. },
  724. toStudy() {
  725. let sysTime = this.$method.timest();
  726. const { serviceStartTime, serviceEndTime, goodsId, orderGoodsId } =
  727. this.hadBuyCourse;
  728. if (
  729. serviceStartTime &&
  730. serviceEndTime &&
  731. (sysTime <= serviceStartTime || sysTime >= serviceEndTime)
  732. ) {
  733. uni.showToast({
  734. icon: "none",
  735. title: "不在学习服务期,不能进入学习",
  736. });
  737. return;
  738. }
  739. uni.navigateTo({
  740. url:
  741. "/pages2/bank/question_detail?id=" +
  742. goodsId +
  743. "&orderGoodsId=" +
  744. orderGoodsId,
  745. });
  746. this.bugCourseModel = false;
  747. },
  748. closePop() {
  749. this.toggleSkuShow = false;
  750. this.skuItem = {};
  751. },
  752. selectSku(item, index) {
  753. this.specList[index].specAttrList.forEach((i_item, i_index) => {
  754. if (item.specAttributeId == i_item.specAttributeId) {
  755. this.$set(this.specList[index].specAttrList[i_index], "check", true);
  756. } else {
  757. this.$set(this.specList[index].specAttrList[i_index], "check", false);
  758. }
  759. });
  760. // console.log('this.specList', this.specList, this.isCheckSku)
  761. if (this.specList.length == this.isCheckSku) {
  762. let specAttrIds = [];
  763. this.specList.forEach((item) => {
  764. let result = item.specAttrList.find((e) => e.check);
  765. if (result) {
  766. specAttrIds.push(result.specAttributeId);
  767. }
  768. });
  769. this.getGoodsInfos(specAttrIds);
  770. }
  771. },
  772. // 获取规格属性值对应的商品信息
  773. getGoodsInfos(specAttrIds) {
  774. this.$http({
  775. url: "/app/common/attr/goods",
  776. method: "get",
  777. data: {
  778. specTemplateId: this.goodsData.specTemplateId,
  779. specAttrIds: specAttrIds.join(","),
  780. },
  781. noToken: true,
  782. }).then((res) => {
  783. if (res.data.code == 200) {
  784. this.skuItem = res.data.data || {};
  785. } else {
  786. this.skuItem = {};
  787. this.$u.toast("商品已下架, 请重新选择");
  788. }
  789. });
  790. },
  791. rightNowBuy() {
  792. if (this.specList.length != this.isCheckSku) {
  793. this.$u.toast("请先选择所有的规格");
  794. return;
  795. }
  796. if (this.skuItem.goodsStatus == 0) {
  797. this.$u.toast("商品已下架, 请重新选择");
  798. return;
  799. }
  800. let sysTime = this.$method.timest();
  801. if (
  802. sysTime <= this.skuItem.validityStartTime ||
  803. sysTime >= this.skuItem.validityEndTime
  804. ) {
  805. this.$u.toast("商品不在有效期, 请重新选择");
  806. return;
  807. }
  808. if (this.isCarOrBuy == 1) {
  809. // 加入购物车
  810. this.addShopCart(this.skuItem.goodsId);
  811. } else {
  812. this.toConfirmList(this.skuItem.goodsId);
  813. }
  814. this.closePop();
  815. },
  816. },
  817. };
  818. </script>
  819. <style>
  820. page {
  821. background-color: #f2f2f2;
  822. }
  823. </style>
  824. <style lang="scss" scope>
  825. @import "../../pages3/course/index.scss";
  826. .contents {
  827. width: 100%;
  828. height: 100%;
  829. background-color: #ffffff;
  830. margin-top: 16rpx;
  831. overflow: hidden;
  832. // tab
  833. .tabs {
  834. // width: 100%;
  835. height: 78rpx;
  836. display: flex;
  837. align-items: center;
  838. justify-content: space-between;
  839. background-color: #f2f7ff;
  840. border-radius: 38rpx;
  841. margin: 24rpx;
  842. padding: 0rpx 5rpx;
  843. .tab_item {
  844. width: 345rpx;
  845. height: 65rpx;
  846. line-height: 65rpx;
  847. font-size: 28rpx;
  848. font-weight: bold;
  849. border-radius: 32rpx;
  850. text-align: center;
  851. color: #333;
  852. &.nactive {
  853. color: #fff;
  854. background-color: #3577e8;
  855. }
  856. // &.twoBtn {
  857. // width: 50%;
  858. // }
  859. }
  860. }
  861. }
  862. .cou_title {
  863. padding: 24rpx 32rpx 40rpx 32rpx;
  864. display: flex;
  865. flex-direction: column;
  866. justify-content: space-around;
  867. }
  868. .prices {
  869. .price_word {
  870. font-size: 40rpx;
  871. font-weight: 800;
  872. color: #fc3f3f;
  873. }
  874. .sale {
  875. color: #999999;
  876. font-size: 28rpx;
  877. margin-left: 8rpx;
  878. }
  879. .price_line {
  880. color: #999999;
  881. font-size: 28rpx;
  882. text-decoration: line-through;
  883. font-weight: 400;
  884. }
  885. .free {
  886. font-size: 32rpx;
  887. }
  888. }
  889. .courseName {
  890. white-space: nowrap;
  891. overflow: hidden;
  892. text-overflow: ellipsis;
  893. }
  894. .icon_up {
  895. width: 32rpx;
  896. height: 32rpx;
  897. }
  898. .intro {
  899. background: #fff;
  900. padding: 16rpx 16rpx 124rpx;
  901. .content {
  902. background: #fff;
  903. border-radius: 16rpx;
  904. .top {
  905. border-radius: 16rpx;
  906. padding: 32rpx 28rpx 16rpx;
  907. font-size: 30rpx;
  908. color: #333333;
  909. }
  910. .img {
  911. width: 100%;
  912. }
  913. }
  914. }
  915. .moduleItem {
  916. height: 80rpx;
  917. color: #333333;
  918. font-size: 32rpx;
  919. line-height: 80rpx;
  920. font-weight: bold;
  921. display: flex;
  922. justify-content: space-between;
  923. }
  924. .title-list {
  925. background: #fff;
  926. padding: 16rpx 16rpx 124rpx;
  927. .content {
  928. .list {
  929. background: #fff;
  930. margin-bottom: 30rpx;
  931. overflow: hidden;
  932. border-radius: 16rpx;
  933. padding: 10rpx 16rpx;
  934. .module {
  935. font-size: 32rpx;
  936. color: #333333;
  937. .icon {
  938. margin-right: 10rpx;
  939. }
  940. }
  941. .section {
  942. font-size: 30rpx;
  943. color: #333;
  944. white-space: nowrap;
  945. overflow: hidden;
  946. text-overflow: ellipsis;
  947. padding: 20rpx 0;
  948. display: flex;
  949. align-items: center;
  950. border-bottom: 1rpx solid #eee;
  951. }
  952. .item_name {
  953. font-size: 24rpx;
  954. font-family: PingFang SC;
  955. font-weight: bold;
  956. color: #333;
  957. white-space: nowrap;
  958. overflow: hidden;
  959. text-overflow: ellipsis;
  960. margin-left: 8rpx;
  961. }
  962. // .article-list {
  963. // margin-top:20rpx;
  964. // }
  965. .article {
  966. padding: 10rpx 0;
  967. min-height: 80rpx;
  968. display: flex;
  969. align-items: center;
  970. margin-left: 35rpx;
  971. font-size: 30rpx;
  972. color: #666666;
  973. border-bottom: 1rpx solid #eeeeee;
  974. display: flex;
  975. .flex_auto {
  976. flex: 1;
  977. font-size: 30rpx;
  978. color: #666666;
  979. word-break: break-all;
  980. }
  981. &:nth-last-of-type(1) {
  982. border: 0;
  983. }
  984. &.active {
  985. color: #007aff;
  986. .btn {
  987. width: 103rpx;
  988. height: 48rpx;
  989. line-height: 48rpx;
  990. text-align: center;
  991. color: #3577e8;
  992. font-size: 24rpx;
  993. border-radius: 24rpx;
  994. background: #fff;
  995. margin-left: 36rpx;
  996. border: 1rpx solid #3577e8;
  997. }
  998. }
  999. }
  1000. }
  1001. }
  1002. }
  1003. .btn2 {
  1004. width: 187rpx;
  1005. height: 79rpx;
  1006. line-height: 79rpx;
  1007. background: #fc3f3f;
  1008. border-radius: 40rpx;
  1009. text-align: center;
  1010. font-size: 24rpx;
  1011. }
  1012. .btn1 {
  1013. width: 187rpx;
  1014. height: 79rpx;
  1015. line-height: 79rpx;
  1016. background: #ffb102;
  1017. border-radius: 40rpx;
  1018. text-align: center;
  1019. margin-right: 11rpx;
  1020. font-size: 24rpx;
  1021. }
  1022. .blackFont {
  1023. color: #333333;
  1024. margin: 0 4rpx;
  1025. }
  1026. .wk_icon {
  1027. width: 24rpx;
  1028. height: 24rpx;
  1029. margin-right: 12rpx;
  1030. }
  1031. .noteTag {
  1032. font-size: 24rpx;
  1033. font-family: PingFang SC;
  1034. font-weight: 500;
  1035. color: #999999;
  1036. align-items: center;
  1037. }
  1038. .priceTag {
  1039. font-size: 30rpx;
  1040. font-family: PingFang SC;
  1041. font-weight: bold;
  1042. color: #ff2d55;
  1043. }
  1044. .titleTag {
  1045. font-size: 36rpx;
  1046. font-weight: bold;
  1047. color: #333333;
  1048. // margin-left: 8rpx;
  1049. }
  1050. .yearTag {
  1051. width: 80rpx;
  1052. height: 32rpx;
  1053. background: #ebf5ff;
  1054. border: 2rpx solid #007aff;
  1055. border-radius: 16rpx;
  1056. font-size: 24rpx;
  1057. color: #007aff;
  1058. text-align: center;
  1059. line-height: 32rpx;
  1060. }
  1061. .itemBox {
  1062. background: #ffffff;
  1063. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  1064. border-radius: 24rpx;
  1065. width: 100%;
  1066. padding: 20rpx;
  1067. margin-bottom: 20rpx;
  1068. }
  1069. </style>