details.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149
  1. <template>
  2. <div class="details-p" ref="sContent" @scroll="showMorePage">
  3. <div class="details-content">
  4. <div class="details-head">
  5. <div class="top-title-group flex-r-c">
  6. <van-icon :name="'diy-' + fileType(detailData.docFileType)"></van-icon>
  7. <div class="flex">{{ detailData.docName }}</div>
  8. </div>
  9. <div class="details-tags">
  10. <div class="tag-item"><span>{{ detailData.viewTimes || 0 }}</span>次浏览</div>
  11. <div class="tag-item"><span>{{ detailData.downTimes || 0 }}</span>次下载</div>
  12. <div class="tag-item"><span>{{ detailData.docFileSize }}</span></div>
  13. <div class="tag-item"><span>{{ dateFormatter(detailData.uploadDate, 'yyyy-MM-dd') }}</span>上传</div>
  14. </div>
  15. </div>
  16. <div class="middles">
  17. <h3>摘要</h3>
  18. <p>{{ detailData.docSummary }}</p>
  19. <div class="continue" v-show="buyed == 0">全文共{{ detailData.docPageSize }}页,<span @click="readAll">阅读全文<van-icon
  20. name="arrow-down" size="18" /></span></div>
  21. </div>
  22. </div>
  23. <van-sticky :offset-top="Offset" @scroll="stickyScroll" v-show="buyed == 1">
  24. <div class="head-tip" :class="{ 'is-fixed': fixed }">
  25. <h3 class="flex" v-show="fixed">
  26. <van-icon class="word01" :name="'diy-' + fileType(detailData.docFileType)" />
  27. <span class="flex">{{ detailData.docName }}</span>
  28. </h3>
  29. <!-- <span class="pages"><i id="page_num"></i> / <i>{{detailData.docPageSize}}</i></span>-->
  30. </div>
  31. </van-sticky>
  32. <div class="botts" v-show="buyed == 1">
  33. <!-- showfileType -->
  34. <div class="pdf_" v-if="showfileType==='pdf'">
  35. <pdf v-for="i in getPageNum" :key="i" :src="pdfPage.url" :page="i"></pdf>
  36. </div>
  37. <div class="doc_" v-if="showfileType==='docx'">
  38. <vue-office-docx
  39. :src="buyShowUrl"
  40. style="height: 100%"
  41. @rendered="rendered"
  42. />
  43. </div>
  44. <div class="excel_" v-if="showfileType==='xlsx' || showfileType==='xls'">
  45. <vue-office-excel
  46. :options="setOptions"
  47. :src="buyShowUrl"
  48. style="height: 100%"
  49. @rendered="renderedHandler"
  50. @error="errorHandler"
  51. ></vue-office-excel>
  52. </div>
  53. <div class="ppt_" v-if="showfileType==='ppt'">
  54. </div>
  55. </div>
  56. <van-goods-action>
  57. <div class="foot-ad">
  58. <div class="warm_text" v-if="warmShow && isrenew">
  59. <van-icon :name="'diy-warmclose'" @click="warmShow = false"></van-icon>
  60. <div class="middle_text">您的文库会员将于{{Remainingtime}}到期,续费即享下载特权!</div>
  61. <div class="warm_btn" @click="bottomBtn('续费文库会员')">去续费</div>
  62. </div>
  63. <div class="ad-box" v-if="showAd && !isrenew">
  64. <van-icon class="Ad_close" name="cross" @click="showAd = false"></van-icon>
  65. <Ad :width="0" :loop="true" :code="$envs.inWX ? 'jy-wx-docmember-detail' : 'jy-app-docmember-detail'" @noData="showAd = false"></Ad>
  66. </div>
  67. </div>
  68. <div class="footbar">
  69. <div class="goods-action">
  70. <!-- <van-goods-action-icon class="no-icon" v-if="needBuy">
  71. <template #default>
  72. <p class="p1">剑鱼币</p>
  73. <p class="p2">{{ detailData.price }}</p>
  74. </template>
  75. </van-goods-action-icon> -->
  76. <van-goods-action-icon icon="diy-jubao" text="投诉举报" @click="jubaod" />
  77. <van-goods-action-icon :icon="collectd == 1 ? 'diy-guanzhu' : 'diy-weiguanzhu'" :text="collectd == 1 ? '已收藏' : '收藏'"
  78. @click="canged" v-if="!flag" />
  79. <van-goods-action-icon :icon="collectd == 1 ? 'diy-guanzhu' : 'diy-weiguanzhu'" :text="collectd == 1 ? '已收藏' : '收藏'"
  80. v-else />
  81. </div>
  82. <!-- <van-goods-action-button text="下载文档" @click="uploaded" /> -->
  83. <!-- 精品 未下载 不是会员 -->
  84. <div class="btnGroup" v-if="boutique && buyed === 0 && !isviper">
  85. <div class="foot_leftbtn" @click="bottomBtn('原价下载')">
  86. <div>
  87. <div class="flex-r-c">
  88. <van-icon :name="'diy-jymoney'"></van-icon>
  89. <span class="fs_large c_red">{{ detailData.price }}</span>
  90. </div>
  91. <p class="fs_small">原价下载</p>
  92. </div>
  93. </div>
  94. <div class="foot_rightbtn" @click="bottomBtn('开通文库会员')">
  95. <div>
  96. <p class="fs_middle">{{detailData.docMemberDiscount}}折下载</p>
  97. <p class="fs_small">开通文库会员</p>
  98. </div>
  99. </div>
  100. </div>
  101. <!-- 会员免费 未下载 不是会员 使用过免费下载次数 -->
  102. <div class="btnGroup" v-if="isvipFree && buyed === 0 && !isviper && power.freeDownload === 1">
  103. <div class="foot_leftbtn" :class="{visibility_hide: downloadStatus === 1}" @click="bottomBtn('原价下载')">
  104. <div>
  105. <div class="flex-r-c">
  106. <van-icon :name="'diy-jymoney'"></van-icon>
  107. <span class="fs_large c_red">{{ detailData.price }}</span>
  108. </div>
  109. <p class="fs_small">原价下载</p>
  110. </div>
  111. </div>
  112. <div class="foot_rightbtn" @click="bottomBtn('开通文库会员')">
  113. <div>
  114. <p class="fs_middle">免费下载</p>
  115. <p class="fs_small">开通文库会员</p>
  116. </div>
  117. </div>
  118. </div>
  119. <!-- 精品 未下载 是会员 -->
  120. <div class="btnGroup" v-if="boutique && buyed === 0 && isviper">
  121. <div class="price_box">
  122. <div>
  123. <div class="flex-end-center">
  124. <span class="vip_price fs_small">会员价:</span>
  125. <van-icon :name="'diy-jymoney'"></van-icon>
  126. <span class="fs_large c_red">{{detailData.docMemberPrice}}</span>
  127. </div>
  128. <div class="flex-end-center">
  129. <span class="c_hui fs_small s_line">原价:</span>
  130. <van-icon :name="'diy-jymoney'" class="opcity_n"></van-icon>
  131. <span class="fs_small c_hui s_line">{{detailData.price}}</span>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="foot_rightbtn" @click="bottomBtn('会员获取文档')">
  136. <div>
  137. <p class="fs_middle">获取文档</p>
  138. </div>
  139. </div>
  140. </div>
  141. <!-- 会员免费 未下载 是会员 -->
  142. <div class="btnGroup" v-if="isvipFree && buyed === 0 && isviper">
  143. <div class="price_box">
  144. <div>
  145. <div class="flex-end-center">
  146. <span class="vip_price fs_small">会员价:</span>
  147. <van-icon :name="'diy-jymoney'"></van-icon>
  148. <span class="fs_middle c_red">免费</span>
  149. </div>
  150. <div class="flex-end-center">
  151. <span class="c_hui fs_small s_line">原价:</span>
  152. <van-icon :name="'diy-jymoney'" class="opcity_n"></van-icon>
  153. <span class="fs_small c_hui s_line">{{detailData.price}}</span>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="foot_rightbtn" @click="getFile">
  158. <div>
  159. <p class="fs_middle" >获取文档</p>
  160. </div>
  161. </div>
  162. </div>
  163. <!-- 未留资或留资未使用免费下载次数 会员免费 未下载 不是会员 -->
  164. <div class="btnGroup" v-if="(power.freeDownload === 2 || power.freeDownload === 0) && isvipFree && buyed === 0 && !isviper">
  165. <div class="foot_leftbtn green_border_width_120" @click="bottomBtn(loginInfo ? '使用免费下载特权' : '原价下载')">
  166. <div v-if="loginInfo">
  167. <div class="flex-r-c">
  168. <span class="fs_middle" >使用免费下载特权</span>
  169. </div>
  170. <p class="fs_small">(1次机会)</p>
  171. </div>
  172. <div v-else>
  173. <div class="flex-r-c">
  174. <van-icon :name="'diy-jymoney'"></van-icon>
  175. <span class="fs_large c_red">{{ detailData.price }}</span>
  176. </div>
  177. <p class="fs_small">原价下载</p>
  178. </div>
  179. </div>
  180. <div class="foot_rightbtn" @click="bottomBtn('开通文库会员')">
  181. <div>
  182. <p class="fs_middle">免费下载</p>
  183. <p class="fs_small">开通文库会员</p>
  184. </div>
  185. </div>
  186. </div>
  187. <!-- 下载过 -->
  188. <div class="btnGroup" v-if="buyed === 1">
  189. <div class="price_box">
  190. </div>
  191. <div class="foot_rightbtn" @click="uploaded('down')">
  192. <div>
  193. <p class="fs_middle">下载文档</p>
  194. </div>
  195. </div>
  196. </div>
  197. </div>
  198. </van-goods-action>
  199. <!-- 充值 -->
  200. <recharge ref="charge" :detailData="detailData" :coins="coins"></recharge>
  201. <!-- 分享 -->
  202. <share-pop ref="shares" :detailData="detailData" :links="links"></share-pop>
  203. <!-- 弹窗 -->
  204. <popupbox ref="popVIPdeplete" title="今日会员免费文档下载特权已用尽" text="建议您明日享受会员特权进行免费下载。" :leftbtnShow="false"
  205. rightbtn="我知道了"
  206. @rightBtn="popBtn({ type: 'popVIPdeplete', btn: '我知道了' }, $event)"></popupbox>
  207. <popupbox ref="popDown" title="文档获取成功" text="已添加到您的文库中,您可前往下载文档。" :leftbtnShow="false" rightbtn="下载文档"
  208. @rightBtn="downLoadFile('popDown', $event)"></popupbox>
  209. <popupbox ref="popJYcurrency" title="剑鱼币余额不足" leftbtn="我再想想" rightbtn="立即充值"
  210. @leftBtn="popBtn({ type: 'popJYcurrency', btn: '我再想想' }, $event)"
  211. @rightBtn="popBtn({ type: 'popJYcurrency', btn: '立即充值' }, $event)">
  212. <template #text>
  213. <span>现有 <span style="color:#2ABED1;">{{coins.balance}}</span> 剑鱼币,还需 <span style="color:#2ABED1;">{{ myprice - coins.balance }}</span> 剑鱼币,请先充值</span>
  214. </template>
  215. </popupbox>
  216. <popupbox ref="popDownVIP" :showFoot="false" type="download" title="文档获取成功" text="已添加到您的文库中,您可前往下载文档。"
  217. @downLoad="downLoadFile('popDownVIP', $event)">
  218. <template #btnUnder>
  219. <div class="fs_small">
  220. <div>- 会员免费文档下载特权 -</div>
  221. <div>消耗 <span style="color:#2ABED1;">1</span> 篇 | 今日还剩余 <span style="color:#2ABED1;">{{surplus}}</span> 篇</div>
  222. </div>
  223. </template>
  224. </popupbox>
  225. </div>
  226. </template>
  227. <script lang="ts">
  228. import { Component, Vue } from 'vue-property-decorator'
  229. import { mapActions, mapMutations } from 'vuex'
  230. import { Icon, Toast, GoodsAction, GoodsActionIcon, GoodsActionButton, Sticky } from 'vant'
  231. import Recharge from '@/components/Recharge.vue'
  232. import sharePop from '@/components/SharePopup.vue'
  233. import popupbox from '@/components/popupbox/index.vue'
  234. import Ad from '@/components/Ad.vue'
  235. import { MixinTop } from '@/utils/mixin-top'
  236. import { weChatShare } from '@/utils/wxShare'
  237. import { formatSize, dateFormatter } from '@/utils/globalFunctions'
  238. import { appCallOpenWindow } from '@/utils/globalFunctionsForApp'
  239. import { isAdd } from '@/api'
  240. import { getDocPay } from '@/api/main'
  241. import pdf from 'vue-pdf'
  242. // 引入VueofficeDocx组件
  243. import VueOfficeDocx from '@vue-office/docx'
  244. // 引入相关样式
  245. import '@vue-office/docx/lib/index.css'
  246. // 号入VueOfficeExcel组件
  247. import VueOfficeExcel from '@vue-office/excel'
  248. // 引入相关样式
  249. import '@vue-office/excel/lib/index.css'
  250. @Component({
  251. name: 'details-p',
  252. mixins: [MixinTop],
  253. components: {
  254. [Icon.name]: Icon,
  255. [Sticky.name]: Sticky,
  256. [GoodsAction.name]: GoodsAction,
  257. [GoodsActionIcon.name]: GoodsActionIcon,
  258. [GoodsActionButton.name]: GoodsActionButton,
  259. Recharge,
  260. sharePop,
  261. popupbox,
  262. Ad,
  263. pdf,
  264. VueOfficeDocx,
  265. VueOfficeExcel
  266. },
  267. methods: {
  268. dateFormatter,
  269. ...mapActions({
  270. getDetails: 'main/getDetails',
  271. getShow: 'main/getShow',
  272. getCoin: 'main/getCoin',
  273. getDown: 'main/getDown',
  274. getShare: 'main/getShare',
  275. getAdd: 'main/getAdd',
  276. getRemove: 'main/getRemove'
  277. }),
  278. ...mapMutations({
  279. clearLibState: 'main/clearMyLibState'
  280. })
  281. }
  282. })
  283. export default class extends Vue {
  284. $envs: any
  285. clearLibState: any
  286. getDetails: any
  287. getCoin: any
  288. getDown: any
  289. getShow: any
  290. getShare: any
  291. loginInfo: any = sessionStorage.getItem('jy-login-info')
  292. links = ''
  293. docIds = ''
  294. fixed = false
  295. coins: any = []
  296. Remainingtime = ''
  297. use = ''
  298. surplus = ''
  299. pdfPage = {
  300. pageNum: 0,
  301. url: ''
  302. }
  303. setOptions = {
  304. xls: true
  305. }
  306. buyShowUrl = ''
  307. downloadStatus = 0
  308. myprice = 0
  309. power: any = {}
  310. getAdd: any
  311. getRemove: any
  312. detailData: any = {}
  313. collectd = 0
  314. isrenew = false
  315. warmShow = true
  316. showAd = true
  317. buyed = 0
  318. flag = false
  319. pdfh5 = null
  320. pData: any = {
  321. heightList: []
  322. }
  323. TopConfig: any = {
  324. actionRightText: '<div style="display:flex;flex-direction: column;align-items: center;"><i class="j-icon icon-iconJianYu"></i><p style="color: #171826;font-size: 10px;line-height: 12px;margin-top:3px;">分享赚剑鱼币</p></div>',
  325. actionRightCallback: this.shared,
  326. actionRightStyle: {
  327. color: '#5F5E64',
  328. fontSize: '20px',
  329. paddingLeft: '10px'
  330. }
  331. }
  332. showPageNum = 2
  333. showPageNumT: any = ''
  334. created () {
  335. this.docIds = this.$route.params.id
  336. this.getPower()
  337. this.onList()
  338. }
  339. get isvipFree () { // 会员免费
  340. return this.detailData.productType === 1
  341. }
  342. get boutique () { // 精品
  343. return this.detailData.productType === 2
  344. }
  345. get isviper () {
  346. return this.power.docStatus > 0
  347. }
  348. get getPageNum () {
  349. return this.showPageNum
  350. }
  351. get Offset () {
  352. const tempN = document.querySelector('.j-header.jy-app-header') as HTMLDivElement
  353. if (tempN) {
  354. return tempN.offsetHeight - 1
  355. } else {
  356. return 0
  357. }
  358. }
  359. get needBuy () {
  360. return this.buyed === 0
  361. }
  362. get showfileType () {
  363. if (this.buyShowUrl.includes('.pdf') || this.detailData.docFileType === 2) {
  364. return 'pdf'
  365. } else if (this.buyShowUrl.includes('.docx')) {
  366. return 'docx'
  367. } else if (this.buyShowUrl.includes('.xlsx')) {
  368. this.setOptions.xls = false
  369. return 'xlsx'
  370. } else if (this.buyShowUrl.includes('.xls')) {
  371. this.setOptions.xls = true
  372. return 'xls'
  373. } else if (this.buyShowUrl.includes('.ppt') || this.detailData.docFileType === 4) {
  374. return 'ppt'
  375. } else if (this.detailData.docFileType === 5) {
  376. return 'txt'
  377. } else {
  378. return ''
  379. }
  380. }
  381. rendered (res: any) {
  382. console.log('完成', res)
  383. }
  384. renderedHandler () {
  385. console.log('完成')
  386. const inputs = document.getElementsByTagName('input')
  387. // 遍历所有input元素并设置readonly属性
  388. for (let i = 0; i < inputs.length; i++) {
  389. inputs[i].setAttribute('readonly', 'readonly')
  390. inputs[i].setAttribute('tabindex', '-1')
  391. }
  392. // 获取页面上的所有textarea元素
  393. const textareas = document.getElementsByTagName('textarea')
  394. // 遍历所有textarea元素并设置事件监听器
  395. for (let i = 0; i < textareas.length; i++) {
  396. textareas[i].setAttribute('tabindex', '-1')
  397. textareas[i].addEventListener('input', function (event) {
  398. event.preventDefault() // 阻止输入
  399. })
  400. }
  401. }
  402. errorHandler () { console.log('失败') }
  403. popBtn (obj: any) {
  404. switch (obj.btn) {
  405. case '立即充值': {
  406. window.location.href = `/page_points_mobile/pay?id=${this.detailData.docId}`
  407. break
  408. }
  409. case '原价下载': {
  410. this.uploaded('Originalprice')
  411. break
  412. }
  413. default:
  414. break
  415. }
  416. (this.$refs[obj.type] as any).value = false
  417. console.log(obj)
  418. }
  419. async bottomBtn (type: string) {
  420. // 未登录跳转登录
  421. if (!this.loginInfo) {
  422. window.location.href = '/jyapp/free/login?to=back'
  423. return
  424. }
  425. switch (type) {
  426. case '开通文库会员': {
  427. window.location.href = '/jy_mobile/order/create/docsvip/?type=buy'
  428. break
  429. }
  430. case '续费文库会员': {
  431. window.location.href = '/jy_mobile/order/create/docsvip/?type=renew'
  432. break
  433. }
  434. case '使用免费下载特权': {
  435. if (this.power.freeDownload === 0) { // 未留资
  436. let url = ''
  437. if (this.$envs.inWX) {
  438. url = '/weixin/frontPage/bigmember/free/perfect_info?source=wx_library_details_free'
  439. } else if (this.$envs.inApp) {
  440. url = '/jyapp/frontPage/bigmember/free/perfect_info?source=app_library_details_free'
  441. } else {
  442. url = '/jyapp/frontPage/bigmember/free/perfect_info?source=h5_library_details_free'
  443. }
  444. window.location.href = url
  445. } else {
  446. const { data } = await getDocPay({ docId: this.docIds, payType: 2 })
  447. if (data.data) {
  448. this.onList();
  449. (this.$refs.popDown as any).value = true
  450. }
  451. }
  452. break
  453. }
  454. case '原价下载': {
  455. this.uploaded('Originalprice')
  456. break
  457. }
  458. case '会员获取文档': {
  459. this.uploaded('vipget')
  460. break
  461. }
  462. default:
  463. break
  464. }
  465. }
  466. downLoadFile (type: string) {
  467. this.uploaded('down');
  468. (this.$refs[type] as any).value = false
  469. }
  470. getMorePage () {
  471. if (this.showPageNum < this.pdfPage.pageNum) {
  472. if (this.showPageNum + 2 <= this.pdfPage.pageNum) {
  473. this.showPageNum = this.showPageNum + 2
  474. } else {
  475. this.showPageNum = this.pdfPage.pageNum
  476. }
  477. }
  478. }
  479. showMorePage () {
  480. const tDom = this.$refs.sContent as HTMLDivElement
  481. const beBottom = tDom.scrollHeight - tDom.clientHeight - tDom.scrollTop
  482. if (beBottom <= 200) {
  483. clearTimeout(this.showPageNumT)
  484. this.showPageNumT = setTimeout(() => {
  485. this.getMorePage()
  486. }, 300)
  487. }
  488. }
  489. getNumPages (url: string) {
  490. try {
  491. const loadingTask = pdf.createLoadingTask(url)
  492. loadingTask.promise.then((pdf: any) => {
  493. this.pdfPage.url = loadingTask
  494. this.pdfPage.pageNum = pdf.numPages
  495. }).catch((err: any) => {
  496. console.error('pdf加载失败', err)
  497. })
  498. } catch (e: any) {
  499. }
  500. }
  501. async getPower () {
  502. const { data } = await isAdd({})
  503. this.power = data.data.docsInfo
  504. const endTime = this.power?.endDate
  505. const date = parseInt(new Date().getTime() / 1000 as any)
  506. const sevenDay = 60 * 60 * 24 * 7
  507. const Remainingtime = endTime - date
  508. if (Remainingtime <= sevenDay && this.power.docStatus > 0) {
  509. this.isrenew = true
  510. }
  511. this.Remainingtime = this.timestampToDays(Remainingtime) as string
  512. }
  513. timestampToDays (timestamp: number) {
  514. const oneDay = 24 * 60 * 60 * 1 // 每天的秒数
  515. if ((timestamp / oneDay) < 1) {
  516. return '今天'
  517. } else {
  518. return (timestamp / oneDay).toFixed(0) + '天后'
  519. }
  520. }
  521. async getShareUrl () {
  522. const { data } = await this.getShare({ docId: this.docIds })
  523. this.links = data.url || location.href
  524. // 注册微信sdk
  525. weChatShare({
  526. config: {
  527. title: this.detailData.docName,
  528. desc: this.detailData.docSummary,
  529. link: this.links
  530. }
  531. })
  532. }
  533. shared () {
  534. (this.$refs.shares as any).show = true
  535. }
  536. updateText (data: any) {
  537. // console.log(data)
  538. switch (data.type) {
  539. case 'count': {
  540. (document.getElementById('page_count') as HTMLDivElement).textContent = data.value
  541. break
  542. }
  543. case 'num': {
  544. (document.getElementById('page_count') as HTMLDivElement).textContent = data.value
  545. break
  546. }
  547. }
  548. }
  549. stickyScroll (data: any) {
  550. if (data.isFixed) {
  551. this.fixed = true
  552. } else {
  553. this.fixed = false
  554. }
  555. }
  556. buyShow () {
  557. this.getShow({ docId: this.docIds }).then((res: any) => {
  558. if (res.data.includes('.pdf') || this.detailData.docFileType === 2) {
  559. this.getNumPages(res.data)
  560. }
  561. this.buyShowUrl = res.data
  562. })
  563. }
  564. onList () {
  565. this.getDetails({ docId: this.docIds, from: this.$route.query.from }).then((res: any) => {
  566. this.detailData = res.data.detail
  567. this.detailData.docFileSize = formatSize(this.detailData.docFileSize)
  568. this.detailData.docSummary = res.data.detail.docSummary.split('').length >= 500 ? res.data.detail.docSummary + '...' : res.data.detail.docSummary
  569. this.buyed = res.data.status
  570. this.downloadStatus = res.data.downloadStatus
  571. if (res.data.status === 1) {
  572. this.buyShow()
  573. }
  574. this.collectd = res.data.collect
  575. this.getShareUrl()
  576. })
  577. this.getCoin({ B: true }).then((res: any) => {
  578. // console.log(res.data.data)
  579. this.coins = res.data.points
  580. })
  581. }
  582. jubaod () {
  583. Toast({
  584. duration: 3500,
  585. message: '如果您发现此内容有侵权行为,请联系客服400-108-6670进行投诉'
  586. })
  587. }
  588. canged () {
  589. if (this.collectd === 0) {
  590. this.getAdd({ docId: this.docIds }).then((res: any) => {
  591. if (res.error_code === 0) {
  592. this.clearLibState('clearCollections') // 清除我的收藏列表缓存数据
  593. this.collectd = 1
  594. Toast('收藏成功')
  595. }
  596. })
  597. this.flag = true
  598. } else {
  599. this.getRemove({ docId: this.docIds }).then((res: any) => {
  600. if (res.error_code === 0) {
  601. this.clearLibState('clearCollections') // 清除我的收藏列表缓存数据
  602. this.collectd = 0
  603. Toast('取消收藏')
  604. }
  605. })
  606. this.flag = true
  607. }
  608. setTimeout(() => {
  609. this.flag = false
  610. }, 1000)
  611. }
  612. async getFile () {
  613. const { data } = await getDocPay({ docId: this.docIds, payType: 0 })
  614. const getData = data.data
  615. if (getData) {
  616. if (getData.status === 0) {
  617. this.onList()
  618. this.surplus = getData.surplus
  619. this.use = getData.use;
  620. (this.$refs.popDownVIP as any).value = true
  621. } else if (getData.status === 1) {
  622. (this.$refs.popVIPdeplete as any).value = true
  623. }
  624. }
  625. }
  626. uploaded (type: string) {
  627. if (type === 'down') { // 下载
  628. this.getDown({ docId: this.docIds }).then((res: any) => {
  629. if (res.error_code === 0) {
  630. if (this.$env.platform === 'app' && this.$env.platform.platformOS === 'ios') {
  631. appCallOpenWindow(res.data)
  632. } else {
  633. window.location.href = res.data
  634. }
  635. }
  636. })
  637. } else if (type === 'vipget') { // 会员下载
  638. if (this.coins.balance < this.detailData.docMemberPrice) {
  639. this.myprice = this.detailData.docMemberPrice as number
  640. // (this.$refs.charge as any).show = true
  641. (this.$refs.popJYcurrency as any).value = true
  642. } else {
  643. this.$router.push({ path: '/purchase/' + this.detailData.docId, query: { payType: '0' } })
  644. }
  645. } else { // 原价下载
  646. if (this.coins.balance < this.detailData.price) {
  647. this.myprice = this.detailData.price as number
  648. // (this.$refs.charge as any).show = true
  649. (this.$refs.popJYcurrency as any).value = true
  650. } else {
  651. this.$router.push({ path: '/purchase/' + this.detailData.docId, query: { payType: '1' } })
  652. }
  653. }
  654. }
  655. readAll () {
  656. if (this.isvipFree && this.buyed === 0 && this.isviper) { // 会员免费 未下载 会员
  657. this.getFile()
  658. } else if ((this.power.freeDownload === 2 || this.power.freeDownload === 0) && this.isvipFree && this.buyed === 0 && !this.isviper) {
  659. this.bottomBtn('使用免费下载特权')
  660. } else if (this.isvipFree && this.buyed === 0 && !this.isviper && this.power.freeDownload === 1) { // 会员免费 未下载 不是会员 使用过免费下载次数
  661. this.bottomBtn('开通文库会员')
  662. } else if (this.boutique && this.buyed === 0 && this.isviper) {
  663. this.bottomBtn('会员获取文档')
  664. } else if (this.boutique && this.buyed === 0 && !this.isviper) {
  665. this.bottomBtn('开通文库会员')
  666. } else if (this.buyed === 1) {
  667. this.uploaded('down')
  668. }
  669. }
  670. fileType (val: any) {
  671. if (val === 1) {
  672. return 'word'
  673. } else if (val === 2) {
  674. return 'pdf'
  675. } else if (val === 3) {
  676. return 'excel'
  677. } else if (val === 4) {
  678. return 'ppt'
  679. } else if (val === 5) {
  680. return 'txt'
  681. } else {
  682. return ''
  683. }
  684. }
  685. }
  686. </script>
  687. <style lang="scss" scoped>
  688. @include diy-icon('pdf', 24, 24);
  689. @include diy-icon('word', 24, 24);
  690. @include diy-icon('excel', 24, 24);
  691. @include diy-icon('ppt', 24, 24);
  692. @include diy-icon('txt', 24, 24);
  693. @include diy-icon('jubao', 20, 20);
  694. @include diy-icon('weiguanzhu', 20, 20);
  695. @include diy-icon('guanzhu', 20, 20);
  696. @include diy-icon('iconJianYu', 24, 24);
  697. @include diy-icon('warmclose', 20, 20);
  698. @include diy-icon('jymoney', 20, 20);
  699. .details-p {
  700. height: 100%;
  701. padding-bottom: 142px;
  702. box-sizing: border-box;
  703. .fs_small {
  704. font-size: 13px;
  705. }
  706. .goods-action {
  707. display: flex;
  708. align-items: center;
  709. }
  710. .excel_{
  711. height: 500px;
  712. ::v-deep{
  713. .x-spreadsheet-overlayer{
  714. z-index: 0;
  715. }
  716. }
  717. }
  718. .doc_{
  719. ::v-deep{
  720. .docx-wrapper{
  721. background-color: #fff;
  722. padding: 0;
  723. section.docx {
  724. box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
  725. z-index: 0;
  726. }
  727. img{
  728. max-width: 100vw;
  729. height: auto !important;
  730. }
  731. }
  732. }
  733. }
  734. .top-title-group {
  735. padding: 24px 12px 0 12px;
  736. box-sizing: border-box;
  737. background-color: #fff;
  738. color: #171826;
  739. font-size: 16px;
  740. line-height: 24px;
  741. letter-spacing: 0px;
  742. text-align: left;
  743. .van-icon {
  744. margin-right: 8px;
  745. }
  746. }
  747. .details-tags {
  748. background-color: #fff;
  749. padding: 12px;
  750. box-sizing: border-box;
  751. display: flex;
  752. align-items: center;
  753. .tag-item {
  754. position: relative;
  755. margin-right: 16px;
  756. font-size: 12px;
  757. line-height: 18px;
  758. color: #9B9CA3;
  759. }
  760. .tag-item::after {
  761. content: "";
  762. position: absolute;
  763. top: 50%;
  764. right: -8px;
  765. margin-top: -6px;
  766. width: 1px;
  767. height: 12px;
  768. background-color: rgba(0, 0, 0, 0.05);
  769. }
  770. .tag-item:last-child::after {
  771. display: none;
  772. }
  773. }
  774. .de-tops {
  775. min-height: 70px;
  776. display: flex;
  777. background: #fff;
  778. padding: 0 16px;
  779. .word {
  780. display: flex;
  781. height: 24px;
  782. margin-right: 8px;
  783. padding-top: 24px;
  784. .word-imgs {
  785. display: flex;
  786. width: 24px;
  787. height: 24px;
  788. }
  789. }
  790. .sp-text {
  791. display: flex;
  792. flex-wrap: wrap;
  793. padding: 24px 0;
  794. color: #171826;
  795. font-size: 20px;
  796. line-height: 30px;
  797. }
  798. }
  799. .middles {
  800. padding: 16px 8px;
  801. background: #fff;
  802. margin: 8px;
  803. border-radius: 12px;
  804. h3 {
  805. font-size: 16px;
  806. line-height: 24px;
  807. font-weight: 500;
  808. color: #171826;
  809. }
  810. p {
  811. color: #5F5E64;
  812. font-size: 14px;
  813. line-height: 20px;
  814. margin-top: 8px;
  815. }
  816. .continue {
  817. color: #5F5E64;
  818. font-size: 14px;
  819. line-height: 20px;
  820. text-align: center;
  821. margin-top: 32px;
  822. span {
  823. display: inline-flex;
  824. align-items: center;
  825. color: #2ABED1;
  826. cursor: pointer;
  827. i {
  828. margin-left: 4px;
  829. }
  830. }
  831. }
  832. }
  833. .head-tip {
  834. width: auto;
  835. height: 0;
  836. background: #fff;
  837. display: flex;
  838. justify-content: flex-end;
  839. align-items: center;
  840. padding: 0 16px;
  841. border-bottom: 1px solid #F2F2F4;
  842. h3 {
  843. display: flex;
  844. align-items: center;
  845. span {
  846. width: 260px;
  847. color: #686868;
  848. font-weight: 500;
  849. font-size: 14px;
  850. line-height: 24px;
  851. overflow: hidden;
  852. text-overflow: ellipsis;
  853. white-space: nowrap;
  854. }
  855. i {
  856. margin-right: 8px;
  857. }
  858. }
  859. .pages {
  860. color: #686868;
  861. font-size: 14px;
  862. i:first-child {
  863. display: inline-block;
  864. font-style: normal;
  865. width: 16px;
  866. height: 16px;
  867. line-height: 18px;
  868. text-align: center;
  869. border-radius: 2px;
  870. background: #FFFFFF;
  871. border: 1px solid #ECECEC;
  872. }
  873. }
  874. }
  875. .is-fixed {
  876. height: 40px;
  877. justify-content: space-between;
  878. }
  879. .botts {
  880. // padding: 16px 24px;
  881. // width: 375px;
  882. background: #fff;
  883. .cont-page {
  884. // width: 375px;
  885. overflow-y: scroll;
  886. background: #fff;
  887. }
  888. }
  889. .van-goods-action {
  890. height: auto;
  891. display: block;
  892. .foot-ad{
  893. width: 100%;
  894. // height: 64px;
  895. .ad-box{
  896. width: 100%;
  897. height: 64px;
  898. position: relative;
  899. .Ad_close{
  900. width: 14px;
  901. height: 14px;
  902. position: absolute;
  903. font-size: 14px;
  904. right: 14px;
  905. top: 50%;
  906. transform: translateY(-50%);
  907. z-index: 100;
  908. color: #fff;
  909. opacity: 0.8;
  910. }
  911. }
  912. .warm_text{
  913. background-color: #FEE9E8;
  914. width: 100%;
  915. height: 54px;
  916. display: flex;
  917. align-items: center;
  918. box-sizing: border-box;
  919. padding-left: 16px;
  920. .middle_text{
  921. width: 240px;
  922. line-height: 20px;
  923. font-size: 13px;
  924. color: #FB483D;
  925. margin-left: 8px;
  926. }
  927. .warm_btn{
  928. width: 72px;
  929. height: 32px;
  930. display: flex;
  931. justify-content: center;
  932. align-items: center;
  933. border-radius: 8px;
  934. border: 1px solid #FB483D;
  935. color: #FB483D;
  936. font-size: 13px;
  937. margin-left: 8px;
  938. }
  939. }
  940. }
  941. .footbar {
  942. width: 100%;
  943. box-sizing: border-box;
  944. padding: 8px 8px;
  945. box-shadow: 0px -2px 8px 0px #eee;
  946. display: flex;
  947. justify-content: space-between;
  948. }
  949. .no-icon {
  950. .p1 {
  951. font-size: 12px;
  952. line-height: 18px;
  953. color: #5F5E64;
  954. }
  955. .p2 {
  956. font-size: 18px;
  957. line-height: 26px;
  958. color: #FB483D;
  959. }
  960. .van-icon {
  961. display: none !important;
  962. }
  963. }
  964. .van-goods-action-icon:not(.no-icon) {
  965. font-size: 10px;
  966. color: #5F5E64;
  967. }
  968. .van-goods-action-button--first {
  969. margin-left: 0;
  970. }
  971. .van-goods-action-button--last {
  972. margin-right: 0;
  973. }
  974. .van-goods-action-button {
  975. flex: none;
  976. }
  977. .van-button--large {
  978. width: 165px;
  979. height: 40px;
  980. }
  981. ::v-deep .van-button--default {
  982. background-color: #2ABED1;
  983. .van-button__content {
  984. .van-button__text {
  985. color: #fff;
  986. // font-size: 16px;
  987. }
  988. }
  989. }
  990. .btnGroup{
  991. display: flex;
  992. }
  993. .visibility_hide{
  994. visibility: hidden;
  995. }
  996. .foot_leftbtn{
  997. margin-right: 8px;
  998. width: 108px;
  999. height: 40px;
  1000. color: #5F5E64;
  1001. font-size: 14px;
  1002. border-radius: 4px;
  1003. display: flex;
  1004. justify-content: center;
  1005. align-items: center;
  1006. box-sizing: border-box;
  1007. border: 1px solid #0000001A;
  1008. }
  1009. .green_border_width_120{
  1010. color: #2ABED1;
  1011. border-color:#2ABED1;
  1012. width: 120px;
  1013. }
  1014. .foot_rightbtn{
  1015. width: 108px;
  1016. height: 40px;
  1017. background-color: #2ABED1;
  1018. color: #fff;
  1019. font-size: 14px;
  1020. border-radius: 4px;
  1021. display: flex;
  1022. justify-content: center;
  1023. align-items: center;
  1024. // line-height: 20px;
  1025. }
  1026. .flex-end-center{
  1027. display: flex;
  1028. justify-content: end;
  1029. align-items: center;
  1030. }
  1031. .s_line{
  1032. text-decoration: line-through;
  1033. }
  1034. .price_box{
  1035. box-sizing: border-box;
  1036. padding-right: 24px;
  1037. }
  1038. .vip_price{
  1039. color: #5F5E64;
  1040. }
  1041. .fs_small{
  1042. font-size: 12px;
  1043. line-height: 18px;
  1044. text-align: center;
  1045. }
  1046. .fs_large{
  1047. font-size: 16px;
  1048. line-height: 22px;
  1049. text-align: center;
  1050. }
  1051. .fs_middle{
  1052. font-size: 14px;
  1053. line-height: 20px;
  1054. text-align: center;
  1055. }
  1056. .opcity_n{
  1057. opacity: 0.9;
  1058. }
  1059. .c_hui{
  1060. color: #9B9CA3;
  1061. }
  1062. .c_red{
  1063. color:#FB483D;
  1064. }
  1065. }
  1066. }
  1067. </style>