Preview.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <!-- 预览 -->
  3. <div class="tarcer-dev-Preview" v-loading="loading" v-if="isData">
  4. <Header />
  5. <HeaderOne v-if="!Ispreview && data" :text="data.name" :allList="allList" />
  6. <div class="main" v-if="data">
  7. <div class="flassify">
  8. <div class="text">
  9. <p class="p1">{{ data.name }}</p>
  10. <p class="p2">
  11. <span v-for="(item, i) in data.teacher" :key="i + item">
  12. {{ item }}{{ i == data.teacher.length - 1 ? "" : "," }}
  13. </span>
  14. </p>
  15. <p>{{ data.updateTime }}</p>
  16. </div>
  17. <div class="pay_collect" v-if="!Ispreview">
  18. <div class="price" v-if="!data.isPurchased">
  19. ¥
  20. <span
  21. class="price_1"
  22. v-html="changePrice(data.price * 1, 24, 16)"
  23. ></span>
  24. </div>
  25. <div class="pay" @click="buy" v-if="!data.isPurchased">
  26. <!-- 购买 -->{{ $t("Key72") }}
  27. </div>
  28. <div class="download" v-if="data.isPurchased && IsDownload">
  29. <img
  30. @click="download"
  31. src="../../assets/teacherdev/download.png"
  32. alt=""
  33. />
  34. <!-- <span>DOWNLOAD</span> -->
  35. </div>
  36. <div class="collect">
  37. <img
  38. @click="changeCollect"
  39. v-show="!data.isFavorite"
  40. src="../../assets/teacherdev/collect4.png"
  41. alt=""
  42. />
  43. <img
  44. @click="changeCollect"
  45. v-show="data.isFavorite"
  46. src="../../assets/teacherdev/collect3.png"
  47. alt=""
  48. />
  49. </div>
  50. </div>
  51. </div>
  52. <div :class="data.isPurchased || Ispreview ? 'buy' : 'NObuy'">
  53. <!--fileUrl需要改成安全地址 file_url_https -->
  54. <iframe
  55. :src="attachment[0].newpath"
  56. width="100%"
  57. height="1000px"
  58. id="ifm"
  59. ></iframe>
  60. <!-- <object
  61. type="text/html"
  62. height="1000px"
  63. width="100%"
  64. :data="attachment[0].newpath"
  65. ></object> -->
  66. <!-- <iframe
  67. v-if="
  68. attachment[0].fileType != 'pdf' && attachment[0].fileType != 'PDF'
  69. "
  70. :src="
  71. 'https://view.officeapps.live.com/op/view.aspx?src=' +
  72. `${attachment[0].fileUrlHttps}`
  73. "
  74. width="100%"
  75. height="1000px"
  76. scrolling="no"
  77. id="if"
  78. >
  79. </iframe>
  80. <iframe
  81. v-else
  82. :src="'./pdf/web/viewer.html?file=' + attachment[0].fileRelativePath"
  83. style="width: 100%; height: 1000px"
  84. ></iframe> -->
  85. <!-- <pdf
  86. v-else
  87. ref="pdf"
  88. :src="attachment[0].fileRelativePath"
  89. v-for="i in numPages"
  90. :key="i"
  91. :page="i"
  92. >
  93. {{ i / numPages }}
  94. </pdf> -->
  95. </div>
  96. <div v-if="!data.isPurchased && !Ispreview" @click="buy" class="buyBtn">
  97. <!-- 点击购买 -->{{ $t("Key574") }}
  98. </div>
  99. </div>
  100. <el-dialog
  101. :visible.sync="NopymentShow"
  102. width="720px"
  103. :before-close="closeNoPyment"
  104. >
  105. <div class="dialogTitle" slot="title">
  106. <!-- 商品详情 -->{{ $t("Key52") }}
  107. </div>
  108. <Confirmorder
  109. ref="Confirmorder"
  110. :data="data"
  111. :goods_type="401"
  112. :changeOrderNumber="changeOrderNumber"
  113. :goods_detail_type="goods_detail_type"
  114. />
  115. </el-dialog>
  116. <el-dialog
  117. top="50px"
  118. :title="$t('Key472') + ':' + orderNumber"
  119. :visible.sync="PymentShow"
  120. width="720px"
  121. :before-close="closePyment"
  122. >
  123. <Payment
  124. :data="data"
  125. :orderNumber="orderNumber"
  126. :closePyment="closePyment"
  127. />
  128. </el-dialog>
  129. </div>
  130. </template>
  131. <script>
  132. import Header from "@/components/Header";
  133. import HeaderOne from "@/components/teacher-dev/HeaderOne";
  134. import pdf from "vue-pdf";
  135. import Confirmorder from "@/components/payment/Confirmorder";
  136. import Payment from "@/components/payment/Payment";
  137. import { updateWordPack } from "@/utils/i18n";
  138. import { getToken, getConfig } from "@/utils/auth";
  139. const Base64 = require("js-base64").Base64;
  140. import {
  141. materialdetail,
  142. materialvisit,
  143. LearnWebSI,
  144. Personamaterialdetail,
  145. getContentFile,
  146. } from "@/api/api";
  147. export default {
  148. name: "tarcer-dev-Preview",
  149. components: {
  150. Header,
  151. HeaderOne,
  152. pdf,
  153. Confirmorder,
  154. Payment,
  155. },
  156. data() {
  157. return {
  158. numPages: null,
  159. isCollect: false,
  160. materialId: null,
  161. data: null,
  162. attachment: null,
  163. loading: false,
  164. Ispreview: "", // 是不是预览
  165. NopymentShow: false, //添加订单弹窗
  166. PymentShow: false, //支付订单弹窗
  167. orderNumber: null, //订单号
  168. IsDownload: false, //是否可以下载
  169. allList: null,
  170. isData: false,
  171. goods_detail_type: null,
  172. file_preview_url: "",
  173. };
  174. },
  175. computed: {},
  176. methods: {
  177. // 下载
  178. download() {
  179. let userInfor = JSON.parse(getToken());
  180. let UserCode = "",
  181. UserType = "",
  182. SessionID = "";
  183. if (userInfor) {
  184. UserCode = userInfor.user_code;
  185. UserType = userInfor.user_type;
  186. SessionID = userInfor.session_id;
  187. }
  188. let FileID = this.attachment[0].fileId;
  189. let data = {
  190. SessionID,
  191. UserCode,
  192. UserType,
  193. FileID,
  194. };
  195. location.href =
  196. process.env.VUE_APP_BASE_API +
  197. `/GCLSFileServer/WebFileDownload?UserCode=${data.UserCode}&UserType=${data.UserType}&SessionID=${data.SessionID}&FileID=${data.FileID}`;
  198. },
  199. // 生成订单 同时切换到支付弹窗
  200. changeOrderNumber(
  201. val,
  202. back_discount_code,
  203. discount_money,
  204. receivables_money
  205. ) {
  206. this.orderNumber = val;
  207. this.NopymentShow = false;
  208. this.data.back_discount_code = back_discount_code;
  209. this.data.discount_money = discount_money;
  210. this.data.receivables_money = receivables_money;
  211. this.PymentShow = true;
  212. console.log(this.data);
  213. },
  214. closeNoPyment() {
  215. this.NopymentShow = false;
  216. this.$refs.Confirmorder.clearData();
  217. },
  218. closePyment(str) {
  219. this.PymentShow = false;
  220. if (str == "支付成功") {
  221. this.getdetail();
  222. }
  223. },
  224. // 处理价格
  225. changePrice(price, fontSize1, fontSize2) {
  226. price = price ? price : 0;
  227. price = price.toFixed(2);
  228. price = price.toString();
  229. let arr = price.split(".");
  230. let str = `<span style="font-size: ${fontSize1 ? fontSize1 : 16}px;">${
  231. arr[0]
  232. }</span>.<span style="font-size: ${fontSize2 ? fontSize2 : 16}px;">${
  233. arr[1]
  234. }</span>`;
  235. return str;
  236. },
  237. // 获取pdf的页数
  238. getNumPages() {
  239. this.loading = true;
  240. let _this = this;
  241. let loadingTask = pdf.createLoadingTask(
  242. _this.attachment[0].fileRelativePath
  243. );
  244. loadingTask.promise
  245. .then((pdf) => {
  246. if (_this.data.isPurchased) {
  247. _this.numPages = pdf.numPages;
  248. } else {
  249. _this.numPages = 2;
  250. }
  251. _this.loading = false;
  252. })
  253. .catch((err) => {
  254. console.error("Pdf Loading failed", err);
  255. });
  256. },
  257. // 修改收藏状态
  258. changeCollect() {
  259. this.loading = true;
  260. if (this.data.isFavorite) {
  261. let Mname = "order-collection_manager-CancelMyGoodsCollection";
  262. LearnWebSI(Mname, {
  263. goods_id_list: [this.materialId],
  264. goods_type: 401,
  265. })
  266. .then((res) => {
  267. this.$message({
  268. type: "success",
  269. message: this.$t("Key396"), //"取消收藏成功",
  270. });
  271. this.data.isFavorite = false;
  272. this.loading = false;
  273. // this.getdetail();
  274. })
  275. .catch((res) => {
  276. this.loading = false;
  277. });
  278. } else {
  279. let Mname = "order-collection_manager-AddMyCollection";
  280. LearnWebSI(Mname, {
  281. goods_id: this.materialId,
  282. goods_type: 401,
  283. goods_name: this.data.name,
  284. goods_person_name_desc: this.data.teacher,
  285. goods_picture_id: this.data.coverFileId,
  286. goods_price: this.data.price,
  287. goods_detail_type: this.goods_detail_type,
  288. })
  289. .then((res) => {
  290. this.$message({
  291. type: "success",
  292. message: this.$t("Key575"), //"收藏成功",
  293. });
  294. this.data.isFavorite = true;
  295. this.loading = false;
  296. // this.getdetail();
  297. })
  298. .catch((res) => {
  299. this.loading = false;
  300. });
  301. }
  302. },
  303. // 购买
  304. buy() {
  305. if (!this.data.isAudited) {
  306. // "您还未通过审核不能购买"
  307. this.$message.warning(this.$t("Key576"));
  308. return;
  309. }
  310. this.NopymentShow = true;
  311. },
  312. // 获取学习资料详情
  313. getdetail() {
  314. this.loading = true;
  315. materialdetail({
  316. materialId: this.materialId,
  317. isSelectForUpdate: this.Ispreview ? true : false,
  318. })
  319. .then((res) => {
  320. if (res.data.result) {
  321. let index = res.data.result.tag.indexOf("downloadable");
  322. if (index != -1) {
  323. this.IsDownload = true;
  324. }
  325. this.data = res.data.result;
  326. this.data.pymentTeacher = "";
  327. res.data.result.teacher.forEach((item, i) => {
  328. if (i != this.data.teacher.length - 1) {
  329. this.data.pymentTeacher += item + ";";
  330. } else {
  331. this.data.pymentTeacher += item;
  332. }
  333. });
  334. this.data.fileType = this.data.tag[this.data.tag.length - 1];
  335. this.attachment = JSON.parse(res.data.result.attachment);
  336. this.loading = false;
  337. // if (
  338. // this.attachment[0].fileType == "pdf" ||
  339. // this.attachment[0].fileType == "PDF"
  340. // ) {
  341. // // this.attachment[0].fileRelativePath =
  342. // // process.env.VUE_APP_BASE_API + this.attachment[0].fileRelativePath;
  343. // this.attachment[0].fileRelativePath =
  344. // process.env.VUE_APP_BASE_API +
  345. // this.attachment[0].fileRelativePath;
  346. // console.log(this.attachment[0].fileRelativePath);
  347. // this.getNumPages();
  348. // }
  349. this.changePrice(this.data.price * 1, 24, 16);
  350. this.goods_detail_type = this.getimgurl(this.data);
  351. // 3000的
  352. // let path = `http://dcsapi.com/?k=71630476088128307289910&url=${this.attachment[0].fileUrlHttps}`;
  353. // this.attachment[0].newpath = path;
  354. // 400的
  355. // let path =
  356. // "http://view.xdocin.com/xdoc?_xdoc=" +
  357. // this.attachment[0].fileUrlHttps+"&printable=false&saveable=false"
  358. // this.attachment[0].newpath = path;
  359. // var originUrl = `${this.attachment[0].fileUrlHttps}?fileId=${this.attachment[0].fileId}`; //要预览文件的访问地址
  360. // var previewUrl =
  361. // originUrl + `&fullfilename=${this.attachment[0].name}`;
  362. // GC 找的免费的 需要后台部署 谷歌可以 火狐和edge不行
  363. let path =
  364. `${this.file_preview_url}/onlinePreview?url=` +
  365. Base64.encode(this.attachment[0].fileUrlHttps);
  366. this.attachment[0].newpath = path;
  367. }
  368. })
  369. .catch((res) => {
  370. this.loading = false;
  371. });
  372. },
  373. PersonalDetail() {
  374. this.loading = true;
  375. Personamaterialdetail({
  376. materialId: this.materialId,
  377. isSelectForUpdate: this.Ispreview ? true : false,
  378. })
  379. .then((res) => {
  380. if (res.data.result) {
  381. let index = res.data.result.tag.indexOf("downloadable");
  382. if (index != -1) {
  383. this.IsDownload = true;
  384. }
  385. this.data = res.data.result;
  386. this.data.pymentTeacher = "";
  387. res.data.result.teacher.forEach((item, i) => {
  388. if (i != this.data.teacher.length - 1) {
  389. this.data.pymentTeacher += item + ";";
  390. } else {
  391. this.data.pymentTeacher += item;
  392. }
  393. });
  394. this.data.fileType = this.data.tag[this.data.tag.length - 1];
  395. this.attachment = JSON.parse(res.data.result.attachment);
  396. let path =
  397. `${this.file_preview_url}/onlinePreview?url=` +
  398. Base64.encode(this.attachment[0].fileUrlHttps);
  399. this.attachment[0].newpath = path;
  400. this.loading = false;
  401. // if (
  402. // this.attachment[0].fileType == "pdf" ||
  403. // this.attachment[0].fileType == "PDF"
  404. // ) {
  405. // // this.attachment[0].fileRelativePath =
  406. // // process.env.VUE_APP_BASE_API + this.attachment[0].fileRelativePath;
  407. // this.attachment[0].fileRelativePath =
  408. // process.env.VUE_APP_BASE_API +
  409. // this.attachment[0].fileRelativePath;
  410. // console.log(this.attachment[0].fileRelativePath);
  411. // this.getNumPages();
  412. // }
  413. this.changePrice(this.data.price * 1, 24, 16);
  414. }
  415. })
  416. .catch((res) => {
  417. this.loading = false;
  418. });
  419. },
  420. getimgurl(item) {
  421. let index = item.tag.indexOf("downloadable");
  422. let type = "";
  423. if (index != -1) {
  424. type = item.tag[2];
  425. } else {
  426. type = item.tag[1];
  427. }
  428. return type;
  429. },
  430. },
  431. async created() {
  432. let data = JSON.parse(getConfig());
  433. this.file_preview_url = data.doc_preview_service_address;
  434. await updateWordPack({
  435. word_key_list: [
  436. "Key5",
  437. "Key8",
  438. "Key9",
  439. "Key39",
  440. "Key43",
  441. "Key52",
  442. "Key53",
  443. "Key54",
  444. "Key55",
  445. "Key58",
  446. "Key72",
  447. "Key94",
  448. "Key107",
  449. "Key109",
  450. "Key131",
  451. "Key214",
  452. "Key232",
  453. "Key108",
  454. "Key396",
  455. "Key472",
  456. "Key473",
  457. "Key474",
  458. "Key572",
  459. "Key574",
  460. "Key575",
  461. "Key576",
  462. "Key696",
  463. "Key697",
  464. ],
  465. });
  466. this.isData = true;
  467. },
  468. mounted() {
  469. this.materialId = this.$route.query.id;
  470. this.Ispreview = this.$route.query.type;
  471. this.allList = this.$route.query.allList;
  472. if (this.$route.query.invok_module == "GCLS-Personal") {
  473. this.PersonalDetail();
  474. } else {
  475. if (this.materialId) {
  476. this.getdetail();
  477. if (!this.Ispreview) {
  478. materialvisit({
  479. id: this.materialId,
  480. })
  481. .then((res) => {})
  482. .catch((res) => {
  483. this.loading = false;
  484. });
  485. }
  486. }
  487. }
  488. },
  489. };
  490. </script>
  491. <style lang="scss" scoped>
  492. .tarcer-dev-Preview {
  493. height: 100%;
  494. .main {
  495. min-height: 543px;
  496. background: #f6f6f6;
  497. padding-bottom: 20px;
  498. padding-top: 30px;
  499. position: relative;
  500. }
  501. .flassify {
  502. position: relative;
  503. width: 1140px;
  504. height: 154px;
  505. margin: 0 auto;
  506. background-color: #fff;
  507. border-radius: 8px;
  508. display: flex;
  509. justify-content: space-between;
  510. // align-items: center;
  511. padding: 0 30px;
  512. .text {
  513. height: 100%;
  514. padding-top: 24px;
  515. .p1 {
  516. font-weight: bold;
  517. font-size: 30px;
  518. color: #1f2127;
  519. }
  520. .p2 {
  521. margin-top: 8px;
  522. margin-bottom: 8px;
  523. font-size: 16px;
  524. color: #1f2127;
  525. }
  526. }
  527. .pay_collect {
  528. // position: absolute;
  529. // right: 30px;
  530. // bottom: 24px;
  531. height: 100%;
  532. padding-top: 90px;
  533. display: flex;
  534. align-content: center;
  535. .price {
  536. font-weight: bold;
  537. font-size: 24px;
  538. margin-right: 20px;
  539. .price_2 {
  540. font-size: 16px;
  541. }
  542. }
  543. .pay {
  544. width: 120px;
  545. height: 40px;
  546. background: #ff9900;
  547. border-radius: 4px;
  548. color: white;
  549. font-weight: 600;
  550. font-size: 20px;
  551. text-align: center;
  552. line-height: 40px;
  553. cursor: pointer;
  554. margin-right: 20px;
  555. }
  556. .collect {
  557. display: flex;
  558. align-items: center;
  559. height: 40px;
  560. font-weight: bold;
  561. font-size: 24px;
  562. color: #1f2127;
  563. img {
  564. width: 24px;
  565. margin-right: 10px;
  566. cursor: pointer;
  567. }
  568. }
  569. .download {
  570. height: 40px;
  571. margin-right: 20px;
  572. display: flex;
  573. align-items: center;
  574. font-weight: bold;
  575. font-size: 24px;
  576. color: #1f2127;
  577. img {
  578. width: 24px;
  579. margin-right: 10px;
  580. cursor: pointer;
  581. }
  582. }
  583. }
  584. }
  585. .buy {
  586. width: 1200px;
  587. margin: 24px auto;
  588. min-height: 1000px;
  589. // filter: blur(8px);
  590. }
  591. .NObuy {
  592. width: 1200px;
  593. margin: 24px auto;
  594. min-height: 1000px;
  595. filter: blur(8px);
  596. }
  597. .buyBtn {
  598. width: 284px;
  599. height: 67px;
  600. background: #ff9900;
  601. border-radius: 8px;
  602. text-align: center;
  603. line-height: 67px;
  604. color: white;
  605. font-weight: bold;
  606. font-size: 22px;
  607. margin: 0 auto;
  608. cursor: pointer;
  609. position: relative;
  610. top: -150px;
  611. }
  612. .dialogTitle {
  613. }
  614. }
  615. </style>
  616. <style lang="scss">
  617. .tarcer-dev-Preview {
  618. .el-dialog__body {
  619. padding: 30px 32px;
  620. }
  621. }
  622. .cui-ribbonTopBars {
  623. display: none !important;
  624. }
  625. .overlay--1PlEz {
  626. display: none !important;
  627. }
  628. #overlay--1PlEz {
  629. display: none !important;
  630. }
  631. </style>