TextbookDetail.vue 20 KB

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