TextbookDetail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. <template>
  2. <!-- 教材详情 -->
  3. <div class="TextbookDetail" v-if="TextbookData && isData">
  4. <div class="nav">
  5. <!-- 登录导航 -->
  6. <Header />
  7. <div class="shade"></div>
  8. </div>
  9. <div class="main" v-loading="loading">
  10. <div class="bookDetail" v-if="detailSHow">
  11. <div class="rightUp">
  12. <span>HOT</span>
  13. </div>
  14. <div class="img">
  15. <img :src="TextbookData.picture_url" alt="" />
  16. </div>
  17. <div class="text">
  18. <p class="p1">{{ TextbookData.name }}</p>
  19. <p class="p2">{{ TextbookData.org_name }}</p>
  20. <p class="p2">{{ TextbookData.author }}</p>
  21. <p class="p3">
  22. {{ TextbookData.description }}
  23. </p>
  24. <div class="operation">
  25. <span class="price">
  26. ¥<span
  27. class="price_1"
  28. v-html="changePrice(TextbookData.price)"
  29. ></span>
  30. </span>
  31. <button @click="getPurchase" class="get">
  32. <!-- Key390-去学习 Key72-购买 -->
  33. {{ bookIsBuy == "true" ? this.$t("Key390") : this.$t("Key72") }}
  34. </button>
  35. <!-- <button class="acquired">
  36. ACQUIRED
  37. </button> -->
  38. <span class="enshrine" @click="enshrineEvent">
  39. <img
  40. v-if="enshrine == 'false'"
  41. src="../assets/textBookDetail/enshrine2.png"
  42. alt=""
  43. />
  44. <img v-else src="../assets/textBookDetail/enshrine1.png" alt="" />
  45. </span>
  46. </div>
  47. </div>
  48. </div>
  49. <!-- <div class="more" v-if="detailSHow">
  50. <div class="moreTitle">更多推荐</div>
  51. <div class="moreList">
  52. <div class="moreOne">
  53. <div>
  54. <img src="../assets/textBookDetail/Rectangle 905.png" alt="" />
  55. </div>
  56. <div class="text">
  57. <p class="p1">Learn Chinese with Ease-Learn Chinese with Ease</p>
  58. <p>Beijing language and Culture University</p>
  59. <p>Esther Howard</p>
  60. <div class="operation">
  61. <span class="price">
  62. <span
  63. class="price_1"
  64. v-text="changePrice('19.99')"
  65. ></span>
  66. <span
  67. class="price_2"
  68. v-text="changePrice('19.99')"
  69. ></span>
  70. </span>
  71. <button class="get">GET</button>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="moreOne">
  76. <div>
  77. <img src="../assets/textBookDetail/Rectangle 906.png" alt="" />
  78. </div>
  79. <div class="text">
  80. <p class="p1">Learn Chinese with Ease-Learn Chinese with Ease</p>
  81. <p>Beijing language and Culture University</p>
  82. <p>Esther Howard</p>
  83. <div class="operation">
  84. <span class="price">
  85. <span
  86. class="price_1"
  87. v-text="changePrice('19.99')"
  88. ></span>
  89. <span
  90. class="price_2"
  91. v-text="changePrice('19.99')"
  92. ></span>
  93. </span>
  94. <button class="get">GET</button>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="moreOne">
  99. <div>
  100. <img src="../assets/textBookDetail/Rectangle 907.png" alt="" />
  101. </div>
  102. <div class="text">
  103. <p class="p1">Learn Chinese with Ease-Learn Chinese with Ease</p>
  104. <p>Beijing language and Culture University</p>
  105. <p>Esther Howard</p>
  106. <div class="operation">
  107. <span class="price">
  108. <span
  109. class="price_1"
  110. v-text="changePrice('1', '19.99')"
  111. ></span>
  112. <span
  113. class="price_2"
  114. v-text="changePrice('2', '19.99')"
  115. ></span>
  116. </span>
  117. <button class="get">GET</button>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div> -->
  123. <div class="cutDownOrimg" v-if="detailSHow">
  124. <div class="sele">
  125. <div
  126. @click="SelectShowEvent('1')"
  127. :class="SelectShow == '1' ? 'select' : ''"
  128. >
  129. <!-- 目录 -->{{ $t("Key612") }}
  130. </div>
  131. <div
  132. @click="SelectShowEvent('2')"
  133. :class="SelectShow == '1' ? '' : 'select'"
  134. >
  135. <!-- 资源 -->{{ $t("Key613") }}
  136. </div>
  137. </div>
  138. </div>
  139. <div v-if="SelectShow == '1'" class="Catalogue">
  140. <BookView
  141. :bookId="TextBookId"
  142. @bookdetailShow="bookdetailShow"
  143. :bookIsBuy="bookIsBuy"
  144. ></BookView>
  145. </div>
  146. <div v-else class="Resources">
  147. <div>
  148. <img src="../assets/textBookDetail/fileType1.png" alt="" />
  149. <span> 文件名 </span>
  150. <img src="../assets/textBookDetail/upload.png" alt="" />
  151. </div>
  152. </div>
  153. </div>
  154. <!-- 商品详情 -->
  155. <el-dialog
  156. class="buyWindow"
  157. :title="$t('Key52')"
  158. :visible.sync="NopymentShow"
  159. width="720px"
  160. :before-close="closeNoPyment"
  161. >
  162. <Confirmorder
  163. :data="TextbookData"
  164. :goods_type="101"
  165. :changeOrderNumber="changeOrderNumber"
  166. ref="Confirmorder"
  167. />
  168. </el-dialog>
  169. <!-- 订单号 -->
  170. <el-dialog
  171. :title="$t('Key472') + ':' + orderNumber"
  172. :visible.sync="PymentShow"
  173. width="720px"
  174. :before-close="closePyment"
  175. >
  176. <Payment
  177. :data="TextbookData"
  178. :orderNumber="orderNumber"
  179. :closePyment="closePyment"
  180. />
  181. </el-dialog>
  182. </div>
  183. </template>
  184. <script>
  185. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  186. //例如:import 《组件名称》from ‘《组件路径》';
  187. import Header from "@/components/Header";
  188. import { TextbookAPI, LearnWebSI } from "@/api/ajax";
  189. import Confirmorder from "@/components/pyment/Confirmorder";
  190. import Payment from "@/components/pyment/Payment";
  191. import BookView from "@/views/bookView"; // 教材预览
  192. import { updateWordPack } from "@/utils/i18n";
  193. export default {
  194. //import引入的组件需要注入到对象中才能使用
  195. components: {
  196. Header,
  197. Confirmorder,
  198. Payment,
  199. BookView,
  200. },
  201. props: {},
  202. data() {
  203. //这里存放数据
  204. return {
  205. enshrine: "false",
  206. IsPurchase: false,
  207. SelectShow: "1", //选择展示课程资源还是下载
  208. TextBookId: null,
  209. TextbookData: null,
  210. loading: false,
  211. NopymentShow: false, //添加订单弹窗
  212. PymentShow: false, //支付订单弹窗
  213. orderNumber: null, //订单号
  214. IsDownload: false, //是否可以下载
  215. detailSHow: true, // 除教材预览外其他内容是否显示
  216. bookIsBuy: "false", // 教材是否已购买
  217. isData: false,
  218. };
  219. },
  220. //计算属性 类似于data概念
  221. computed: {},
  222. //监控data中数据变化
  223. watch: {},
  224. //方法集合
  225. methods: {
  226. closeNoPyment() {
  227. this.NopymentShow = false;
  228. this.$refs.Confirmorder.clearData();
  229. },
  230. closePyment(str) {
  231. this.PymentShow = false;
  232. this.$refs.Confirmorder.clearData();
  233. if (str == "支付成功") {
  234. this.getdetail();
  235. }
  236. },
  237. // 生成订单 同时切换到支付弹窗
  238. changeOrderNumber(
  239. val,
  240. back_discount_code,
  241. discount_money,
  242. receivables_money
  243. ) {
  244. this.orderNumber = val;
  245. this.NopymentShow = false;
  246. this.TextbookData.back_discount_code = back_discount_code;
  247. this.TextbookData.discount_money = discount_money;
  248. this.TextbookData.receivables_money = receivables_money;
  249. this.PymentShow = true;
  250. this.isConfirmorder = false;
  251. },
  252. // 选择课程资源还是下载
  253. SelectShowEvent(num) {
  254. this.SelectShow = num;
  255. },
  256. changePrice(price) {
  257. let str = "";
  258. price = price ? price.toString() : "0.00";
  259. if (price.indexOf(".") > -1) {
  260. let arr = price.split(".");
  261. str = `<span style="font-size: 24px;">${arr[0]}</span>.<span style="font-size: 16px;">${arr[1]}</span>`;
  262. } else {
  263. str = `<span style="font-size: 24px;">${price}</span>.<span style="font-size: 16px;">00</span>`;
  264. }
  265. return str;
  266. },
  267. // 收藏
  268. enshrineEvent() {
  269. // this.enshrine = !this.enshrine;
  270. if (this.enshrine == "false") {
  271. let Mname = "order-collection_manager-AddMyCollection";
  272. let data = {
  273. goods_id: this.TextBookId,
  274. goods_type: 101,
  275. goods_name: this.TextbookData.name,
  276. goods_person_name_desc: this.TextbookData.author,
  277. goods_picture_id: this.TextbookData.picture_id,
  278. goods_price: this.TextbookData.price,
  279. };
  280. LearnWebSI(Mname, data).then((res) => {
  281. this.enshrine = "true";
  282. this.$message.success(this.$t("Key575")); //"收藏成功"
  283. });
  284. } else {
  285. let Mname = "order-collection_manager-CancelMyGoodsCollection";
  286. let data = {
  287. goods_type: 101,
  288. goods_id_list: [this.TextBookId],
  289. };
  290. LearnWebSI(Mname, data).then((res) => {
  291. this.enshrine = "false";
  292. this.$message.success(this.$t("Key396")); //"取消收藏成功"
  293. });
  294. }
  295. },
  296. // 购买
  297. getPurchase() {
  298. if (this.bookIsBuy == "true") {
  299. this.$router.push("/courseview?bookId=" + this.TextBookId);
  300. } else {
  301. this.NopymentShow = true;
  302. }
  303. },
  304. bookdetailShow(flag) {
  305. this.detailSHow = flag;
  306. },
  307. //获取当前书籍是否已购买
  308. handleIsBuy() {
  309. let Mname = "order-order_manager-CheckMyGoodsBuyStatus";
  310. let data = {
  311. goods_type: 101,
  312. goods_id: this.TextBookId,
  313. };
  314. LearnWebSI(Mname, data).then((res) => {
  315. this.bookIsBuy = res.is_buy;
  316. });
  317. },
  318. // 获取当前书籍是否已收藏
  319. handleIsEnshrine() {
  320. let Mname = "order-collection_manager-CheckMyGoodsCollectionStatus";
  321. let data = {
  322. goods_type: 101,
  323. goods_id: this.TextBookId,
  324. };
  325. LearnWebSI(Mname, data).then((res) => {
  326. this.enshrine = res.is_collection;
  327. });
  328. },
  329. getdetail() {
  330. this.loading = true;
  331. this.TextBookId = this.$route.query.goods_id;
  332. let Mname = "book-book_manager-GetBook";
  333. // 获取课程详情
  334. TextbookAPI(Mname, {
  335. id: this.TextBookId,
  336. })
  337. .then((res) => {
  338. this.TextbookData = res;
  339. this.loading = false;
  340. })
  341. .catch((res) => {
  342. this.loading = false;
  343. });
  344. this.handleIsBuy();
  345. this.handleIsEnshrine();
  346. },
  347. },
  348. //生命周期 - 创建完成(可以访问当前this实例)
  349. async created() {
  350. await updateWordPack({
  351. word_key_list: [
  352. "Key9",
  353. "Key38",
  354. "Key39",
  355. "Key52",
  356. "Key53",
  357. "Key54",
  358. "Key55",
  359. "Key72",
  360. "Key94",
  361. "Key108",
  362. "Key109",
  363. "Key116",
  364. "Key390",
  365. "Key396",
  366. "Key472",
  367. "Key473",
  368. "Key474",
  369. "Key475",
  370. "Key575",
  371. "Key612",
  372. "Key613",
  373. ],
  374. });
  375. this.isData = true;
  376. this.getdetail();
  377. },
  378. //生命周期 - 挂载完成(可以访问DOM元素)
  379. mounted() {},
  380. //生命周期-创建之前
  381. beforeCreated() {},
  382. //生命周期-挂载之前
  383. beforeMount() {},
  384. //生命周期-更新之前
  385. beforUpdate() {},
  386. //生命周期-更新之后
  387. updated() {},
  388. //生命周期-销毁之前
  389. beforeDestory() {},
  390. //生命周期-销毁完成
  391. destoryed() {},
  392. //如果页面有keep-alive缓存功能,这个函数会触发
  393. activated() {},
  394. };
  395. </script>
  396. <style lang="scss" scoped>
  397. /* @import url(); 引入css类 */
  398. .TextbookDetail {
  399. // height: 100%;
  400. .price_1 {
  401. font-style: normal;
  402. font-weight: 600;
  403. font-size: 24px;
  404. line-height: 150%;
  405. color: #ffffff;
  406. .num1 {
  407. font-size: 24px;
  408. }
  409. .num2 {
  410. font-size: 16px;
  411. }
  412. }
  413. .nav {
  414. background: url("../assets/textBookDetail/Homebg2.png") no-repeat center;
  415. background-size: 100% 100%;
  416. // height: 60px;
  417. border-bottom-left-radius: 20px;
  418. border-bottom-right-radius: 20px;
  419. position: relative;
  420. .shade {
  421. position: absolute;
  422. top: 0;
  423. width: 100%;
  424. height: 100%;
  425. background: rgba(0, 0, 0, 0.5);
  426. display: flex;
  427. color: #fff;
  428. font-weight: bold;
  429. font-size: 18px;
  430. justify-content: space-around;
  431. align-items: center;
  432. .el-menu-demo {
  433. background: rgba(0, 0, 0, 0);
  434. }
  435. // 取消组件默认的样式
  436. .el-menu.el-menu--horizontal {
  437. border-bottom: none;
  438. li:hover {
  439. background: none;
  440. }
  441. li {
  442. background: none;
  443. }
  444. }
  445. .nav_title {
  446. text-align: left;
  447. }
  448. .seek {
  449. input {
  450. width: 450px;
  451. height: 46px;
  452. background: #979797;
  453. border: none;
  454. outline: none;
  455. color: white;
  456. font-size: 18px;
  457. opacity: 0.5;
  458. }
  459. img {
  460. position: relative;
  461. right: 40px;
  462. top: 8px;
  463. cursor: pointer;
  464. }
  465. }
  466. }
  467. }
  468. .headerone {
  469. // margin-top: 10px;
  470. }
  471. .main {
  472. min-height: 100%;
  473. padding-top: 52px;
  474. background: #e5e5e5;
  475. padding-bottom: 20px;
  476. .bookDetail {
  477. width: 1240px;
  478. margin: 0 auto;
  479. background: #6e767c;
  480. border-radius: 8px;
  481. display: flex;
  482. position: relative;
  483. overflow: hidden;
  484. padding: 40px;
  485. box-sizing: border-box;
  486. .img {
  487. margin-right: 32px;
  488. img {
  489. width: 168px;
  490. height: 224px;
  491. }
  492. }
  493. .rightUp {
  494. margin: 0;
  495. width: 72px;
  496. height: 72px;
  497. background: url("../assets/textBookDetail/Rectangle903.png");
  498. position: absolute;
  499. right: 0;
  500. top: 0;
  501. // text-align: right;
  502. span {
  503. display: inline-block;
  504. color: #fff;
  505. transform: rotateZ(45deg);
  506. position: absolute;
  507. left: 30px;
  508. top: 15px;
  509. }
  510. }
  511. .text {
  512. width: 900px;
  513. color: white;
  514. p {
  515. font-size: 16px;
  516. margin: 0;
  517. }
  518. .p1 {
  519. font-size: 40px;
  520. font-weight: normal;
  521. font-size: 40px;
  522. line-height: 150%;
  523. color: #ffffff;
  524. }
  525. > :not(.p1) {
  526. margin-top: 16px;
  527. }
  528. .p2 {
  529. font-weight: 600;
  530. font-size: 16px;
  531. line-height: 150%;
  532. color: #ffffff;
  533. }
  534. .p3 {
  535. font-weight: normal;
  536. font-size: 16px;
  537. line-height: 150%;
  538. color: #ffffff;
  539. }
  540. .price {
  541. font-size: 24px;
  542. .price_2 {
  543. font-size: 16px;
  544. }
  545. }
  546. .operation {
  547. display: flex;
  548. align-items: center;
  549. margin-top: 16px;
  550. }
  551. .get {
  552. width: 120px;
  553. height: 40px;
  554. background: #ff9900;
  555. border-radius: 4px;
  556. border: none;
  557. outline: none;
  558. color: white;
  559. font-size: 20px;
  560. margin-left: 30px;
  561. cursor: pointer;
  562. }
  563. .acquired {
  564. width: 120px;
  565. height: 40px;
  566. background: #d5d5d5;
  567. border-radius: 4px;
  568. border: none;
  569. outline: none;
  570. color: white;
  571. font-size: 16px;
  572. margin-left: 30px;
  573. cursor: pointer;
  574. }
  575. .enshrine {
  576. margin-left: 30px;
  577. img {
  578. width: 24px;
  579. cursor: pointer;
  580. }
  581. }
  582. }
  583. }
  584. .more {
  585. width: 1240px;
  586. margin: 0 auto;
  587. margin-top: 30px;
  588. .moreTitle {
  589. font-weight: 600;
  590. font-size: 20px;
  591. color: #000000;
  592. }
  593. .moreTitle::before {
  594. content: "|";
  595. background: #ff9900;
  596. color: #ff9900;
  597. margin-right: 16px;
  598. }
  599. .moreList {
  600. width: 1300px;
  601. margin: 0 auto;
  602. // margin-top: 20px;
  603. display: flex;
  604. flex-wrap: wrap;
  605. // overflow-y: hidden;
  606. // overflow-x: scroll;
  607. .moreOne {
  608. margin-right: 20px;
  609. margin-top: 20px;
  610. width: 598px;
  611. height: 236px;
  612. background: #ffffff;
  613. border-radius: 8px;
  614. display: flex;
  615. > div {
  616. margin-left: 32px;
  617. margin-top: 32px;
  618. img {
  619. width: 120px;
  620. height: 160px;
  621. }
  622. }
  623. .text {
  624. width: 390px;
  625. margin-right: 23px;
  626. > p:not(.p1) {
  627. font-size: 16px;
  628. color: #2c2c2c;
  629. opacity: 0.7;
  630. margin-top: 10px;
  631. }
  632. .p1 {
  633. font-weight: 600;
  634. font-size: 20px;
  635. color: #2c2c2c;
  636. }
  637. .operation {
  638. margin-top: 10px;
  639. text-align: right;
  640. }
  641. .get {
  642. width: 120px;
  643. height: 40px;
  644. background: #ff9900;
  645. border-radius: 4px;
  646. border: none;
  647. outline: none;
  648. color: white;
  649. font-size: 20px;
  650. margin-left: 30px;
  651. cursor: pointer;
  652. }
  653. .acquired {
  654. width: 120px;
  655. height: 40px;
  656. background: #d5d5d5;
  657. border-radius: 4px;
  658. border: none;
  659. outline: none;
  660. color: white;
  661. font-size: 16px;
  662. margin-left: 30px;
  663. cursor: pointer;
  664. }
  665. .price {
  666. font-size: 24px;
  667. .price_2 {
  668. font-size: 16px;
  669. }
  670. }
  671. }
  672. }
  673. }
  674. }
  675. .cutDownOrimg {
  676. width: 1240px;
  677. margin: 0 auto;
  678. margin-top: 24px;
  679. .sele {
  680. width: 318px;
  681. height: 48px;
  682. background: #ebebeb;
  683. border-radius: 30px;
  684. color: #9f9f9f;
  685. font-size: 20px;
  686. display: flex;
  687. align-items: center;
  688. > div {
  689. width: 158px;
  690. height: 48px;
  691. border-radius: 30px;
  692. line-height: 48px;
  693. text-align: center;
  694. cursor: pointer;
  695. }
  696. .select {
  697. background: #ff9900;
  698. color: white;
  699. box-shadow: 0px 2px 8px rgba(255, 153, 0, 0.15);
  700. }
  701. }
  702. }
  703. .Catalogue {
  704. margin: 24px auto;
  705. width: 1240px;
  706. height: 710px;
  707. background: #ffffff;
  708. display: flex;
  709. .left {
  710. width: 340px;
  711. height: 710px;
  712. border-right: 1px solid #d9d9d9;
  713. .title {
  714. width: 80%;
  715. margin: 29px auto;
  716. font-weight: 600;
  717. font-size: 24px;
  718. color: #000000;
  719. cursor: pointer;
  720. }
  721. .subtitle {
  722. width: 80%;
  723. margin: 0 auto;
  724. height: 44px;
  725. line-height: 44px;
  726. font-weight: bold;
  727. font-size: 14px;
  728. color: #000000;
  729. cursor: pointer;
  730. }
  731. }
  732. .right {
  733. width: 860px;
  734. height: 710px;
  735. }
  736. }
  737. .Resources {
  738. margin: 24px auto;
  739. width: 1240px;
  740. height: 710px;
  741. background: #ffffff;
  742. display: flex;
  743. box-sizing: border-box;
  744. padding: 20px 24px;
  745. div {
  746. height: 40px;
  747. margin: 12px 8px;
  748. border: 1px solid rgba(44, 44, 44, 0.15);
  749. border-radius: 4px;
  750. padding: 0 10px;
  751. display: flex;
  752. justify-content: center;
  753. align-items: center;
  754. cursor: pointer;
  755. img {
  756. width: 24px;
  757. margin: 0 10px;
  758. }
  759. span {
  760. width: 182px;
  761. overflow: hidden;
  762. text-overflow: ellipsis;
  763. white-space: nowrap;
  764. }
  765. }
  766. }
  767. }
  768. }
  769. </style>
  770. <style lang="scss">
  771. .buyWindow {
  772. .el-dialog__body {
  773. padding: 20px 32px;
  774. }
  775. .el-dialog__header {
  776. padding: 20px 32px 10px;
  777. }
  778. }
  779. </style>