detail.vue 27 KB

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