converter.vue 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  1. <template>
  2. <div class="page-converter">
  3. <div class="date-tips flex content-center justify-center py-6px">
  4. <img src="http://cn-file.17pdf.com/website/common/ic_notice.svg" class="align-middle">
  5. <div class="text-container">
  6. <span class="text">
  7. 转档后的文件支持在云端保留24小时,<span v-if="userInfo?.subscriberType === 1">会员尊享5G容量,</span>请在24小时内下载文件至本地永久保存
  8. </span>
  9. <span v-if="userInfo?.subscriberType === 1" class="vip tip">
  10. <img src="http://cn-file.17pdf.com/website/common/ic_info.svg" alt="">
  11. <div class="tip-text">
  12. 若已有文件大小超出5G,将按转档时间计算(从最近一次转档往过去推算),即保留最近的5G容量文件,超出部分文件将不再保留
  13. </div>
  14. </span>
  15. </div>
  16. </div>
  17. <h1 class="text-48px text-opacity-100 font-500 text-[#3333] mt-48px mb-10px text-center">文件转换器</h1>
  18. <h2 class="text-20px text-center text-[#666] mt-20px font-normal">PDF文件格式转换器,一键转档,支持批量转换,精准快速。</h2>
  19. <div class="text-center mb-80px">
  20. <a
  21. class="mt-20px text-[#4D4D4D] text-16px font-600 inline-flex items-center leading-22px hover:text-$btn-color-primary hover:underline"
  22. href="https://www.compdf.com/pdf-conversion-sdk?utm_source=anroidapp&utm_medium=17pdfweb&utm_campaign=pdfsdk" target="_blank">由 ComPDFKit Conversion SDK 提供技术支持
  23. <svg class="ml-8px" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
  24. <path d="M6 12.9567L10.714 8.24261L6 3.52856" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
  25. </svg>
  26. </a>
  27. </div>
  28. <div class="transfer-container-wrap">
  29. <div class="index-converter w-[80%] h-700px relative top-0 left-[50%] -ml-[40%]">
  30. <div class="transfer-container absolute w-full h-auto my-0 -mx-15px bg-white pb-60px">
  31. <button type="button" class="close hidden" data-dismiss="modal" aria-label="Close">
  32. <span aria-hidden="true">×</span>
  33. </button>
  34. <div class="recharge py-0 px-[10%] h-48px mx-0 mt-24px mb-14px absolute right-0 -top-70px z-2">
  35. <span @click="handlSubmit($event, 'buy')" class="recharge-btn float-right bg-white border border-[#ff4f4f] boder-solid text-16px py-7px px-18px rounded-4px mt-4px cursor-pointer hover:bg-[#ff4f4f]">
  36. <a class="text-[#ff4f4f] no-underline leading-normal">充值</a>
  37. </span>
  38. <div class="need-volume float-right right-48px text-16px text-[#666] leading-48px mr-20px">
  39. 所需券:<span class="text-[#0dd299] text-16px" :class="{'text-red-500': requiredCoupon > userInfo?.points}">{{ requiredCoupon }}券</span> / 剩余券:<span class="text-[#0dd299] text-16px">{{ userInfo.points ? userInfo.points : 0 }}券</span>
  40. </div>
  41. </div>
  42. <div class="transfer-panel">
  43. <div>
  44. <form enctype="multipart/form-data">
  45. <input type="hidden" name="folder" value="converter/input"/>
  46. <div class="file-input theme-explorer file-input-ajax-new h-380px mt-17px py-0 px-[10%]">
  47. <div class="file-preview rounded-5px w-[100%] h-[100%]">
  48. <div class="file-drop-zone border border-dashed border-[#d1d1d1] rounded-4px h-[100%] text-center align-middle overflow-y-auto">
  49. <div v-show="fileList.length <= 0" class="file-drop-zone-title text-[#999] text-16px pt-222px cursor-default">
  50. <div></div>
  51. 点击从电脑上传文件或把文件拖到这里
  52. <p class="text-14px">(支持PDF to Word、PPT、Excel、TXT、JPG/PNG无限次数转换)</p>
  53. </div>
  54. <table id="table-fileinput" class="table table-hover w-[100%] max-w-[100%]">
  55. <thead v-show="fileList.length > 0">
  56. <tr class="h-40px bg-[#eee]">
  57. <th class="!w-[5.5%]"></th>
  58. <th class="!text-left w-[26.5%]">文档名</th>
  59. <th class="!w-[17%]">大小</th>
  60. <th class="!w-[13%]">所需券</th>
  61. <th class="!w-[9.5%]">转为</th>
  62. <th class="!w-[23%]">状态</th>
  63. <th class="!w-[4.5%]"></th>
  64. </tr>
  65. </thead>
  66. <tbody v-show="fileList.length > 0" class="file-preview-thumbnails cursor-default">
  67. <tr v-for="(item, index) in fileList" id="preview-1668340925733-0" :key="index" class="file-preview-frame explorer-frame kv-preview-thumb w-100px h-38px hover:bg-[#f5f5f5]" data-fileindex="0" data-template="pdf" title="test.pdf">
  68. <td class="file-details-cell">{{ index+1 }}</td>
  69. <td class="file-details-cell !text-left">
  70. <div class="explorer-caption max-w-260px truncate block text-[#777]" title="test.pdf">{{ item.name }}</div>
  71. </td>
  72. <td class="file-details-cell text-[#999]">{{ getfilesize(item.size) }}</td>
  73. <td class="file-details-cell points">{{ userInfo.subscriberType === 1 ? 0 : item.price }}</td>
  74. <td class="file-details-cell select w-106px">
  75. <select v-if="item.status !== 6" v-model="item.output" class="transfer-select appearance-none text-center min-w-90px" @change="changeOutput(item, index)">
  76. <option value="png" class="text-center">PNG</option>
  77. <option value="xlsx" class="text-center">XLSX</option>
  78. <option value="pptx" class="text-center">PPTX</option>
  79. <option value="docx" class="text-center">DOCX</option>
  80. <option value="txt" class="text-center">TXT</option>
  81. <option value="jpg" class="text-center">JPG</option>
  82. </select>
  83. <span v-else>{{ item.output }}</span>
  84. </td>
  85. <td class="file-details-cell state text-14px text-[#878787]" v-html="fileStatus(item, index)"></td>
  86. <!-- <td v-else class="file-details-cell state text-14px text-red-500">转换失败<img src="/converter/menu_ic_pdfconvert.png" @click="rechangeFile" /></td> -->
  87. <td class="file-actions-cell w-50px p-0">
  88. <div class="file-actions text-center">
  89. <div class="file-footer-buttons" @click="deleteFile(index)">
  90. <button type="button" class="kv-file-remove btn btn-xs btn-default bg-inherit !border-none pr-7px py-1px pl-5px text-12px leading-normal rounded-3px" title="删除文件"><i class="pdf-removeicon"></i></button>
  91. </div>
  92. </div>
  93. </td>
  94. </tr>
  95. </tbody>
  96. </table>
  97. <div class="clearfix"></div>
  98. <div class="file-preview-status text-success text-center text-[#3c763d]"></div>
  99. </div>
  100. </div>
  101. <div class="kv-upload-progress hide">
  102. <div class="progress overflow-hidden h-20px mb-20px bg-[#f5f5f5] rounded-4px ring-inset-2 ring-[rgba(0,0,0/10%)]">
  103. <div class="progress-bar progress-bar-success progress-bar-striped active w-0 bg-[#5cb85c]" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
  104. </div>
  105. </div>
  106. <div class="input-group file-caption-main w-[100%] -top-450px relative table border-separate">
  107. <div class="input-group-btn relative text-0px whitespace-nowrap !flex">
  108. <div tabindex="500" class="btn btn-file" :class="{'btn-file-left' : fileList.length > 0}">
  109. <div class="add-file" :class="{'add-file-left':(fileList.length > 0)}">{{ fileList.length > 0 ? '添加文件' : '' }}</div>
  110. <input id="fileinput-explorer" ref="file" name="file" accept=".pdf" title="上传文件" type="file" multiple=""
  111. class="absolute top-0 right-0 p-0 m-0 min-w-[100%] h-[100%] w-90px text-right opacity-0 bg-none bg-repeat bg-scroll block outline-none border-0 cursor-pointer"
  112. @change="addFile($event)" @click="handlSubmit($event, '')"/>
  113. </div>
  114. <div v-if="fileList.length > 0" class="inline-block ml-30px bg-white border border-[#ff4f4f] boder-solid text-16px py-7px px-18px rounded-4px mt-4px cursor-pointer text-[#ff4f4f] leading-normal hover:bg-[#ff4f4f] hover:text-white" @click="deleteAllFile">清空</div>
  115. </div>
  116. </div>
  117. </div>
  118. </form>
  119. </div>
  120. <div class="transfer-btn mt-30px h-64px text-center">
  121. <div class="cursor-not-allowed inline-block">
  122. <span :class="{'disabledBtn' : !checkbox || !changeFileFlag }" class="btn transfer-start-btn bg-[#ff524f] text-20px py-0 px-150px rounded-4px h-60px w-386px text-white hover:bg-[#f34545]" @click="handlSubmit($event, 'change')">
  123. <a class="text-white leading-60px">{{ !changeFileFlag ? '转换中...' : '开始转换' }}</a>
  124. <span v-if="!changeFileFlag" class="loading"></span>
  125. </span>
  126. </div>
  127. <span class="hide btn btn-down small w-240px h-60px bg-[#0dd299] rounded-4px text-20px ml-15px hover:bg-[#0fc993]"><a class="leading-60px text-white">下载全部</a></span>
  128. </div>
  129. </div>
  130. <div class="transfer-remember mt-23px text-center">
  131. <div class="checkbox checkbox-danger relative block mt-10px mb-10px">
  132. <label for="remember" class="text-12px font-normal text-[#999] min-h-20px pl-20px mb-0 inline-block max-w-[100%]">
  133. <input v-model="checkbox" type="checkbox" name="remember" class="remember_pass cursor-pointer" :disabled="!changeFileFlag" :class="{'cursor-not-allowed' : !changeFileFlag }" />确保上传的文档不涉及版权问题及违法内容
  134. </label>
  135. </div>
  136. </div>
  137. </div>
  138. <div class="modal verifi-modal top-[20%!important]" d="verifiPayModal" tabindex="-1" role="dialog" aria-labelledby="verifiPayModal">
  139. <div class="modal-dialog verifi-dialog w-480px h-426px my-50px" role="document">
  140. <div class="modal-content relative bg-white rounded-6px border border-solid border-[rgba(0,0,0,0.2)] outline-0 bg-clip-padding ring-[rgba(0,0,0/50%)] ring-offseet-3px ring-9px md:ring-offset-5 md:ring-15px">
  141. <div class="">
  142. <button id="verifi-close" type="button" class="close pompt_close py-5px px-10px outline-none" data-dismiss="modal" aria-label="Close">
  143. <span aria-hidden="true">×</span>
  144. </button>
  145. </div>
  146. <div class="verifi-content text-center pt-60px px-0 pb-35px">
  147. <img src="http://cn-file.17pdf.com/website/converter/pic_trans_diomands.png"/>
  148. <p>该功能为付费套餐专属</p>
  149. <p>订阅解锁更多特权</p>
  150. <a href="javascript:;" class="now_pricing" value="0"
  151. >立即订阅</a
  152. >
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. <div class="file_num w-[100%] h-120px text-center text-white leading-120px text-30px mb-76px">
  159. 17PDF Reader,当前已转换了<span class="text-32px"> 1,859,726 </span> 个文件
  160. </div>
  161. <div id="more_type" class="pdf_converter clear w-[80%] my-0 mx-auto">
  162. <div class="package_type">
  163. <h3 class="text-24px text-[#333] font-normal mx-0 mt-0 mb-49px h-30px leading-30px">会员专享格式</h3>
  164. <ul class="flex justify-center w-[100%] min-w-340px p-0 mt-0 mb-10">
  165. <li>
  166. <a href="/converter">
  167. <img src="/converter/ic_pdf_word.png" />
  168. <span>PDF To Word</span>
  169. </a>
  170. </li>
  171. <li>
  172. <a href="/converter">
  173. <img src="/converter/ic_pdf_ppt.png"/>
  174. <span>PDF to PowerPoint</span>
  175. </a>
  176. </li>
  177. <li>
  178. <a href="/converter">
  179. <img src="/converter/ic_pdf_execl.png"/>
  180. <span>PDF to EXCEL</span>
  181. </a>
  182. </li>
  183. <li>
  184. <a href="/converter">
  185. <img src="/converter/ic_pdf_txt.png" />
  186. <span>PDF to TXT</span>
  187. </a>
  188. </li>
  189. <li>
  190. <a href="/converter">
  191. <img src="/converter/ic_pdf_picture.png" />
  192. <span>PDF to JPG/PNG</span>
  193. </a>
  194. </li>
  195. </ul>
  196. </div>
  197. </div>
  198. <div class="about_converter w-[100%] bg-[#fafafa] py-60px px-[10%] mt-102px">
  199. <h3 class="name text-24px text-[#333] font-normal mx-0 mt-0 mb-49px h-30px leading-30px">关于转档</h3>
  200. <ul class="clear p-0">
  201. <li>
  202. <img src="http://cn-file.17pdf.com/website/converter/ic_way.png" />
  203. <div class="content">
  204. <h3>如何转档</h3>
  205. <p>
  206. 进入“文件转换器”区域。点击下方“添加文件”选择添加本地目标文件,然后在“转为”栏选择转换目标格式,最后点击“开始转换”即可。
  207. </p>
  208. </div>
  209. </li>
  210. <li>
  211. <img
  212. src="http://cn-file.17pdf.com/website/converter/ic_quality.png"
  213. />
  214. <div class="content">
  215. <h3>领先品质</h3>
  216. <p>
  217. 行业领先的转换品质,经过转换的文件版面清晰、保持格式的一致,支持一键转档,批量转换,精准快速的文件格式转换,稳定的转换品质,是您处理转格式转换的首选。
  218. </p>
  219. </div>
  220. </li>
  221. <li>
  222. <img src="http://cn-file.17pdf.com/website/converter/ic_safe.png" />
  223. <div class="content">
  224. <h3>文件安全</h3>
  225. <p>
  226. 我们尊重每位用户的隐私信息和文件安全。转档后的文件仅在云端保留24小时,让您免去后顾之忧。
  227. </p>
  228. </div>
  229. </li>
  230. <li>
  231. <img src="http://cn-file.17pdf.com/website/converter/ic_more.png" />
  232. <div class="content">
  233. <h3>多平台支持</h3>
  234. <p>
  235. 文件格式转换器可以在所有计算机(Mac、Windows及Linux)上使用,也可下载App
  236. 17PDF Reader在移动端使用,让您在手机上也能轻松转档文件。
  237. </p>
  238. </div>
  239. </li>
  240. </ul>
  241. </div>
  242. <div class="converter_question px-[10%] pt-76px pb-60px text-center">
  243. <h3 class="name text-24px text-[#333] font-normal m-0 h-30px leading-30px text-left">常见问题</h3>
  244. <table class="w-[100%] p-0 bg-transparent">
  245. <tbody>
  246. <tr>
  247. <td>
  248. <h3>1. 支持哪些格式转换?</h3>
  249. <p>
  250. <span></span>支持PDF to
  251. Word、PPT、Excel、TXT、JPG/PNG无限次数转换
  252. </p>
  253. </td>
  254. <td>
  255. <h3>2. 为什么图片格式的文件转档效果不好?</h3>
  256. <p>
  257. 如原文件为图片格式或者通过扫描文档保存为PDF文件的,转档后的文件可能无法选取文字进行高亮等编辑。
  258. </p>
  259. </td>
  260. </tr>
  261. <tr>
  262. <td>
  263. <h3>3. 文件转档后出现乱码?</h3>
  264. <p>
  265. 如果是原文件就有乱码问题,先处理好文件再提交转档;如果原文件正常而转档后目标文件乱码,请联系我们处理。
  266. </p>
  267. </td>
  268. </tr>
  269. </tbody>
  270. </table>
  271. <a class="more w-auto h-30px leading-30px text-[#666] inline-block text-center mx-auto mt-48px mb-0 link:no-underline hover:(!border-[#ff4f4f] text-[#ff4f4f])" href="/question#convert">更多问题请查看帮助</a>
  272. </div>
  273. <div class="download_code fixed right-14px bottom-50px bg-white w-134px py-12px px-0 rounded-6px text-center ">
  274. <span class="large text-16px inline-block w-[100%] my-6px mx-0">下载APP</span>
  275. <img src="http://cn-file.17pdf.com/website/download/android_code.png" class="w-110px border-0 align-middle inline-block" />
  276. <span class="inline-block w-[100%] text-14px my-6px mx-0">使用更便捷</span>
  277. </div>
  278. </div>
  279. <el-dialog :visible.sync="visiable" :close-on-click-modal="false" :close-on-press-escape="false" width="480px" append-to-body center>
  280. <div class="changepwd-tittle">
  281. <p class="text-20px text-center text-$btn-color-primary">提示</p>
  282. </div>
  283. <div class="text-16px text-[#707070] text-center my-30px">
  284. 您还未登录或注册,请先
  285. <span class="text-$btn-color-primary cursor-pointer" @click="login">登录</span>
  286. <span class="text-$btn-color-primary cursor-pointer" @click="register">注册</span>
  287. </div>
  288. </el-dialog>
  289. </div>
  290. </template>
  291. <script>
  292. import { mapState } from 'vuex'
  293. export default {
  294. data () {
  295. return {
  296. fileList: [],
  297. uniqFileArr: [],
  298. checkbox: true,
  299. changeFileFlag: true,
  300. uploadNum: 0,
  301. getFileStatusTimer: null,
  302. changeSucesssNumTotal: 0,
  303. changeSucesssFileList: [],
  304. visiable: false
  305. }
  306. },
  307. middleware: 'user',
  308. head() {
  309. return {
  310. title: 'PDF转换器免费在线转档',
  311. meta: [
  312. {
  313. hid: 'description',
  314. content: '17PDF Reader免费提供在线PDF格式转换文件转档服务,支持PDF转word,PDF转doc,PDF转PPT,PDF转png,PDF转html,PDF转epub,PDF转xls,psd转ai等。轻松拖曳,一键转档,批量转换,支持多种常用格式相互转档。先进的转换引擎,极速转换,精准度高达99.99%。',
  315. },
  316. {
  317. name: 'keywords',
  318. content: '格式转换,文件转档,pdf convert,converter, word to pdf'
  319. }
  320. ]
  321. }
  322. },
  323. computed: {
  324. ...mapState([
  325. 'userInfo'
  326. ]),
  327. // 所需券数
  328. requiredCoupon () {
  329. let total = 0
  330. for (let i = 0; i < this.fileList.length; i++) {
  331. total += this.fileList[i].price
  332. }
  333. if (this.userInfo.subscriberType !== null && this.userInfo.subscriberType === 1) {
  334. total = 0
  335. }
  336. return total
  337. }
  338. },
  339. mounted () {
  340. if (localStorage.getItem('file') !== null) {
  341. this.fileList = JSON.parse(localStorage.getItem('file'))
  342. }
  343. },
  344. methods: {
  345. handlSubmit(event, type) {
  346. if (!this.$store.state.token) {
  347. event.preventDefault()
  348. this.visiable = true
  349. return
  350. }
  351. if (type === 'buy') {
  352. this.handlerBuy('ticket')
  353. } else if (type === 'change') {
  354. this.createFileMission()
  355. }
  356. // this.$store.commit('OPEN_LOGIN', true)
  357. // this.$store.commit('SET_INTERFACE', 'vip')
  358. },
  359. login() {
  360. this.visiable = false
  361. this.$store.commit('OPEN_LOGIN', true)
  362. this.$store.commit('SET_INTERFACE', 'login')
  363. },
  364. register() {
  365. this.visiable = false
  366. this.$store.commit('OPEN_LOGIN', true)
  367. this.$store.commit('SET_INTERFACE', 'register')
  368. },
  369. // 充值弹框
  370. handlerBuy(type) {
  371. this.$store.commit('OPEN_LOGIN', true)
  372. this.$store.commit('SET_INTERFACE', type)
  373. },
  374. // 添加文件
  375. async addFile (event) {
  376. // 阻止发生默认行为
  377. event.preventDefault()
  378. const array = event.target.files
  379. const defaultPrice = await this.getFilePrice('pdf', 'docx')
  380. for (let i = 0; i < array.length; i++) {
  381. const fileObj = {
  382. name: array[i].name,
  383. size: array[i].size,
  384. price: defaultPrice,
  385. input: 'pdf',
  386. output: 'docx',
  387. status: 0
  388. }
  389. this.fileList.push(fileObj)
  390. this.uniqFileArr.push(array[i])
  391. }
  392. console.log('fileList:', this.fileList)
  393. console.log('uniqFileArr:', this.uniqFileArr)
  394. },
  395. // 查询文件所需券数
  396. async getFilePrice (input, output) {
  397. let price = 0
  398. await this.$axios.get(`/convertType/getConvertTypeList?input=${input}&output=${output}`).then((res) => {
  399. if(res.code === 200) {
  400. price = res.result[0].price
  401. }
  402. })
  403. return price
  404. },
  405. // 改变要转换的格式
  406. async changeOutput (item, index) {
  407. const price = await this.getFilePrice(item.input, item.output)
  408. this.$set(this.fileList[index], 'price', price)
  409. this.$set(this.fileList[index], 'output', item.output)
  410. },
  411. // 计算文件大小函数(保留两位小数),Size为字节大小
  412. getfilesize (size) {
  413. if (!size) return ""
  414. const num = 1024.00 // byte
  415. if (size < num) {
  416. return size + "B"
  417. }
  418. if (size < Math.pow(num, 2)) {
  419. return (size / num).toFixed(2) + "K"
  420. }
  421. if (size < Math.pow(num, 3)) {
  422. return (size / Math.pow(num, 2)).toFixed(2) + "M"
  423. }
  424. if (size < Math.pow(num, 4)) {
  425. return (size / Math.pow(num, 3)).toFixed(2) + "G"
  426. }
  427. else {
  428. return (size / Math.pow(num, 4)).toFixed(2) + "T"
  429. }
  430. },
  431. // 删除文件
  432. deleteFile (index) {
  433. this.fileList.splice(index, 1)
  434. this.uniqFileArr.splice(index-this.changeSucesssNumTotal, 1)
  435. this.changeSucesssFileList = []
  436. localStorage.removeItem('file')
  437. this.fileList.forEach(item => {
  438. if (item.status === 6) {
  439. this.changeSucesssFileList.push(item)
  440. }
  441. })
  442. localStorage.setItem('file', JSON.stringify(this.changeSucesssFileList))
  443. },
  444. // 清空
  445. deleteAllFile () {
  446. this.fileList = []
  447. this.uniqFileArr = []
  448. this.changeFileStatus('all', 5)
  449. this.changeSucesssFileList = []
  450. localStorage.removeItem('file')
  451. },
  452. // 转档第一步,根据文件列表创建任务和插入文件信息
  453. createFileMission () {
  454. // if (this.fileList.length === 0) return
  455. const points = this.userInfo.points
  456. if (this.requiredCoupon > points) {
  457. alert('券数不足,请充值')
  458. return
  459. }
  460. const filterFileList = this.fileList.filter(function(item){
  461. return item.status !== 6
  462. })
  463. console.log(filterFileList)
  464. let fileArr = []
  465. for (let i = 0; i < filterFileList.length; i++) {
  466. const file = {}
  467. file.sourceType = 0
  468. file.size = filterFileList[i].size
  469. file.input = 'pdf'
  470. file.output = filterFileList[i].output
  471. file.filename = filterFileList[i].name
  472. fileArr[i] = file;
  473. }
  474. fileArr = JSON.stringify(fileArr)
  475. console.log(fileArr)
  476. this.changeFileFlag = false
  477. this.changeFileStatus('all', 1)
  478. const config = {
  479. method: 'post',
  480. url: '/mission/create',
  481. headers: {
  482. 'Accept': '*/*',
  483. 'Content-Type': 'application/json'
  484. },
  485. data: fileArr
  486. }
  487. this.$axios('/mission/create', config).then((res) => {
  488. if(res.code === 200) {
  489. const missionFiles = res.result.missionFilePoJos
  490. console.log(missionFiles)
  491. for (let i = 0; i < missionFiles.length; i++) {
  492. this.changeFileStatus(missionFiles[i].fileName, 2)
  493. this.uploadFile(this.uniqFileArr[i], missionFiles[i].id, res.result.id)
  494. }
  495. } else {
  496. this.changeFileFlag = true
  497. this.changeFileStatus('all', 5)
  498. }
  499. })
  500. },
  501. // 修改文件状态
  502. changeFileStatus (fileName, status) {
  503. if (fileName === 'all') {
  504. this.fileList.forEach(item => {
  505. if (item.status !== 6) {
  506. this.$set(item, 'status', status)
  507. }
  508. })
  509. } else {
  510. this.fileList.forEach(item => {
  511. if (item.name === fileName) {
  512. this.$set(item, 'status', status)
  513. }
  514. })
  515. }
  516. },
  517. // 文件状态: 0未转换,1上传中,2上传完成,3转换中,4转换成功,5转换失败,6已转档
  518. fileStatus (item, index) {
  519. switch (item.status) {
  520. case 0:
  521. this.$set(this.fileList[index], 'status', 0)
  522. return '未转换'
  523. case 1:
  524. this.$set(this.fileList[index], 'status', 1)
  525. return '上传中'
  526. case 2:
  527. this.$set(this.fileList[index], 'status', 2)
  528. return '上传完成'
  529. case 3:
  530. this.$set(this.fileList[index], 'status', 3)
  531. return '转换中'
  532. case 4:
  533. this.$set(this.fileList[index], 'status', 4)
  534. return '<span style="color: orange">转换成功</span>'
  535. case 5:
  536. this.$set(this.fileList[index], 'status', 5)
  537. return '<span style="color: red">转换失败</span>'
  538. case 6:
  539. this.$set(this.fileList[index], 'status', 6)
  540. return `<a href="${item.path}" style="color: #0dd299">下载</a>`
  541. }
  542. },
  543. // 转档第二步,上传文件
  544. uploadFile (file, id, missionId) {
  545. console.log(file)
  546. const formData = new FormData()
  547. formData.append('file', file)
  548. formData.append('missionFileId', id)
  549. const config = {
  550. headers: {
  551. 'Content-Type': 'multipart/form-data;boundary = ' + new Date().getTime()
  552. }
  553. }
  554. this.$axios.post('/missionFile/upload', formData, config).then((res) => {
  555. console.log('上传文件')
  556. if(res.code === 200) {
  557. this.changeFileStatus(file.name, 3)
  558. this.uploadNum++
  559. console.log(this.uploadNum)
  560. if (this.uploadNum === this.uniqFileArr.length) {
  561. this.convertFile(file.name, missionId)
  562. }
  563. } else {
  564. this.changeFileFlag = true
  565. this.changeFileStatus(file.name, 5)
  566. }
  567. })
  568. },
  569. // 转档第三步,开始转档
  570. convertFile (file, missionId) {
  571. const formData = new FormData()
  572. formData.append('missionId', missionId)
  573. const config = {
  574. headers: {
  575. 'Content-Type': 'multipart/form-data;boundary = ' + new Date().getTime()
  576. }
  577. }
  578. this.$axios.post('/mission/convertFile', formData, config).then((res) => {
  579. console.log('开始转档')
  580. if(res.code === 200) {
  581. this.changeFileStatus('all', 4)
  582. this.getFileStatusTimer = window.setInterval(() => {
  583. setTimeout(this.getFileStatus(formData, config), 0)
  584. }, 3000)
  585. } else {
  586. this.uploadNum = 0
  587. this.changeFileStatus('all', 5)
  588. this.changeFileFlag = true
  589. }
  590. })
  591. },
  592. // 转档最后一步,轮询文件状态和下载链接
  593. getFileStatus (formData, config) {
  594. this.$axios.post('/mission/queryFileStatus', formData, config).then((res) => {
  595. console.log('获取文件状态')
  596. if(res.code === 200) {
  597. const getFileList = res.result[0].missionFilePoJos
  598. console.log(getFileList)
  599. let changeSucesssNum = 0
  600. for (let i = 0; i < getFileList.length; i++) {
  601. if (getFileList[i].status === 2) {
  602. this.changeFileStatus(getFileList[i].fileName, 6)
  603. changeSucesssNum++
  604. this.fileList.forEach(item => {
  605. if (item.name === getFileList[i].fileName) {
  606. this.$set(item, 'path', getFileList[i].path)
  607. this.changeSucesssFileList.push(item)
  608. }
  609. })
  610. }
  611. }
  612. if (changeSucesssNum === getFileList.length) {
  613. clearInterval(this.getFileStatusTimer)
  614. this.getFileStatusTimer = null
  615. this.changeSucesssNumTotal += changeSucesssNum
  616. this.uniqFileArr = []
  617. }
  618. console.log(this.fileList)
  619. console.log('changeSucesssFileList:', this.changeSucesssFileList)
  620. localStorage.setItem('file', JSON.stringify(this.changeSucesssFileList))
  621. } else {
  622. this.uploadNum = 0
  623. this.changeFileStatus('all', 5)
  624. }
  625. this.changeFileFlag = true
  626. })
  627. }
  628. }
  629. }
  630. </script>
  631. <style lang="scss" scoped>
  632. ::v-deep body {
  633. min-width: 1200px !important;
  634. }
  635. .page-converter {
  636. .date-tips {
  637. background: linear-gradient(0deg, #fff2f6, #fff2f6),
  638. linear-gradient(90deg, snow 10.37%, rgba(255, 243, 243, 0) 91.75%),
  639. linear-gradient(90deg, #fff2f6 2.26%, rgba(255, 242, 246, 0.21) 101.41%);
  640. .text-container {
  641. display: flex;
  642. align-items: center;
  643. margin-left: 16px;
  644. img {
  645. margin-left: 8px;
  646. }
  647. }
  648. span {
  649. font-size: 14px;
  650. line-height: 24px;
  651. vertical-align: middle;
  652. }
  653. .text {
  654. display: inline-flex;
  655. align-items: center;
  656. }
  657. .tip {
  658. position: relative;
  659. font-size: 0;
  660. .tip-text {
  661. display: none;
  662. position: absolute;
  663. left: -3px;
  664. width: 258px;
  665. padding: 15px 14px 10px 10px;
  666. background: url('http://cn-file.17pdf.com/website/members/ic_tip.svg')
  667. left top no-repeat;
  668. background-size: auto 100%;
  669. font-size: 12px;
  670. line-height: 18px;
  671. color: #fff;
  672. border-radius: 4px;
  673. }
  674. &:hover .tip-text {
  675. display: block;
  676. }
  677. }
  678. }
  679. .transfer-container {
  680. .hide {
  681. display: none !important;
  682. }
  683. button {
  684. padding-right: 7px;
  685. }
  686. .close {
  687. float: right;
  688. font-size: 21px;
  689. font-weight: bold;
  690. line-height: 1;
  691. color: #000;
  692. text-shadow: 0 1px 0 #fff;
  693. opacity: 0.2;
  694. filter: alpha(opacity=20);
  695. }
  696. button.close {
  697. padding: 0;
  698. cursor: pointer;
  699. background: transparent;
  700. border: 0;
  701. -webkit-appearance: none;
  702. }
  703. button:focus {
  704. outline: none;
  705. }
  706. .close:hover,
  707. .close:focus {
  708. color: #000;
  709. text-decoration: none;
  710. cursor: pointer;
  711. opacity: 0.5;
  712. filter: alpha(opacity=50);
  713. }
  714. .recharge .recharge-btn:hover a {
  715. color: #fff;
  716. }
  717. .transfer-btn .loading {
  718. display: inline-block;
  719. border: 3px solid #fff;
  720. border-bottom: 3px solid #cccccc;
  721. height: 35px;
  722. width: 35px;
  723. border-radius: 50%;
  724. position: relative;
  725. top: 10px;
  726. left: 100px;
  727. -webkit-animation: loading 1s infinite linear;
  728. -moz-animation: loading 1s infinite linear;
  729. -o-animation: loading 1s infinite linear;
  730. animation: loading 1s infinite linear;
  731. }
  732. }
  733. .table>caption+thead>tr:first-child>th, .table>caption+thead>tr:first-child>td, .table>colgroup+thead>tr:first-child>th, .table>colgroup+thead>tr:first-child>td, .table>thead:first-child>tr:first-child>th, .table>thead:first-child>tr:first-child>td {
  734. border-top: 0;
  735. }
  736. .file-drop-zone .table thead tr th {
  737. color: #666666;
  738. text-align: center;
  739. }
  740. .table>thead>tr>th {
  741. vertical-align: bottom;
  742. border-bottom: 2px solid #ddd;
  743. }
  744. .table>thead>tr>th, .table>thead>tr>td, .table>tbody>tr>th, .table>tbody>tr>td, .table>tfoot>tr>th, .table>tfoot>tr>td {
  745. padding: 8px;
  746. line-height: 1.428571429;
  747. vertical-align: top;
  748. border-top: 1px solid #ddd;
  749. }
  750. .table th, .table td {
  751. vertical-align: middle;
  752. box-sizing: border-box;
  753. }
  754. th {
  755. text-align: left;
  756. }
  757. td, th {
  758. padding: 0;
  759. }
  760. .input-group-btn {
  761. position: relative;
  762. font-size: 0;
  763. white-space: nowrap;
  764. }
  765. .input-group-addon, .input-group-btn {
  766. white-space: nowrap;
  767. vertical-align: middle;
  768. }
  769. .input-group-addon, .input-group-btn, .input-group .form-control {
  770. display: table-cell;
  771. }
  772. .clearfix:before, .clearfix:after {
  773. content: " ";
  774. display: table;
  775. }
  776. .input-group-btn:last-child>.btn, .input-group-btn:last-child>.btn-group {
  777. z-index: 2;
  778. margin-left: -1px;
  779. }
  780. .input-group-btn:first-child>.btn, .input-group-btn:first-child>.btn-group {
  781. margin-right: -1px;
  782. }
  783. .input-group .form-control:last-child, .input-group-addon:last-child, .input-group-btn:last-child>.btn, .input-group-btn:last-child>.btn-group>.btn, .input-group-btn:last-child>.dropdown-toggle, .input-group-btn:first-child>.btn:not(:first-child), .input-group-btn:first-child>.btn-group:not(:first-child)>.btn {
  784. border-bottom-left-radius: 0;
  785. border-top-left-radius: 0;
  786. }
  787. .input-group .form-control:first-child, .input-group-addon:first-child, .input-group-btn:first-child>.btn, .input-group-btn:first-child>.btn-group>.btn, .input-group-btn:first-child>.dropdown-toggle, .input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle), .input-group-btn:last-child>.btn-group:not(:last-child)>.btn {
  788. border-bottom-right-radius: 0;
  789. border-top-right-radius: 0;
  790. }
  791. .input-group-btn>.btn {
  792. position: relative;
  793. }
  794. .btn.disabled, .btn[disabled], fieldset[disabled] .btn {
  795. cursor: not-allowed;
  796. opacity: 0.65;
  797. filter: alpha(opacity=65);
  798. -webkit-box-shadow: none;
  799. box-shadow: none;
  800. }
  801. .btn-file {
  802. position: relative;
  803. overflow: hidden;
  804. margin: 0;
  805. top: 170px;
  806. left: 50%;
  807. margin-left: -45px !important;
  808. outline: none;
  809. cursor: pointer;
  810. }
  811. .btn {
  812. display: inline-block;
  813. margin-bottom: 0;
  814. font-weight: normal;
  815. text-align: center;
  816. vertical-align: middle;
  817. touch-action: manipulation;
  818. cursor: pointer;
  819. background-image: none;
  820. border: 1px solid transparent;
  821. white-space: nowrap;
  822. border-radius: 4px;
  823. -webkit-user-select: none;
  824. -moz-user-select: none;
  825. -ms-user-select: none;
  826. user-select: none;
  827. }
  828. .btn-file .add-file {
  829. background: url(http://cn-file.17pdf.com/website/fileinput/ic_file_add.png) no-repeat;
  830. width: 90px;
  831. height: 100px;
  832. }
  833. .btn-file .add-file-left {
  834. background: url(http://cn-file.17pdf.com/website/fileinput/ic_add.png) no-repeat;
  835. width: 120px;
  836. height: 30px;
  837. margin-top: 10px;
  838. margin-left: 10px;
  839. padding-left: 38px;
  840. font-size: 16px;
  841. line-height: 30px;
  842. color: #666666;
  843. }
  844. .btn-file-left {
  845. position: relative;
  846. top: 0px;
  847. left: 20px;
  848. }
  849. .transfer-container .transfer-remember .checkbox input[type="checkbox"] {
  850. top: 3px;
  851. }
  852. .radio input[type="radio"], .radio-inline input[type="radio"], .checkbox input[type="checkbox"], .checkbox-inline input[type="checkbox"] {
  853. position: absolute;
  854. margin-left: -20px;
  855. }
  856. input[type="radio"], input[type="checkbox"] {
  857. margin: 4px 0 0;
  858. line-height: normal;
  859. }
  860. .modal {
  861. display: none;
  862. overflow: hidden;
  863. position: fixed;
  864. top: 0;
  865. right: 0;
  866. bottom: 0;
  867. left: 0;
  868. z-index: 1050;
  869. -webkit-overflow-scrolling: touch;
  870. outline: 0;
  871. }
  872. .file-drop-zone .table tbody tr:hover td {
  873. background: #dfdfdf;
  874. }
  875. .file-drop-zone .table tbody tr td {
  876. border-top: 0px;
  877. }
  878. .theme-explorer .explorer-frame td {
  879. vertical-align: middle;
  880. text-align: center;
  881. }
  882. .file-drop-zone .table tbody tr:hover td .transfer-select {
  883. border-color: #ff4f4f;
  884. background: url(http://cn-file.17pdf.com/website/converter/ic_trans_xiala_hover.png) no-repeat 72px 6px;
  885. }
  886. .file-drop-zone .table tbody tr .transfer-select {
  887. width: 100%;
  888. height: 22px;
  889. border: 1px solid #dadada;
  890. padding: 0px;
  891. outline: none;
  892. font-size: 14px;
  893. color: #ff4f4f;
  894. line-height: 22px;
  895. // padding-left: 30px;
  896. border-radius: 2px;
  897. background: url(http://cn-file.17pdf.com/website/converter/ic_trans_xiala_nor.png) no-repeat 72px 6px;
  898. }
  899. .theme-explorer .file-actions-cell .file-actions .file-footer-buttons .pdf-removeicon:before {
  900. content: url(https://cn-file.17pdf.com/website/converter/ic_delet_red.png) !important;
  901. display: none;
  902. }
  903. .file-drop-zone .table tbody tr:hover td .file-actions .file-footer-buttons .pdf-removeicon:before {
  904. display: block;
  905. }
  906. .btn.disabledBtn {
  907. background-color: rgb(204, 204, 204);
  908. pointer-events: none;
  909. }
  910. .file_num {
  911. background: url(http://cn-file.17pdf.com/website/converter/pic_account_bg.png) repeat -10px 0px;
  912. }
  913. .clear {
  914. zoom: 1;
  915. }
  916. .clear:after {
  917. visibility: hidden;
  918. display: block;
  919. font-size: 0;
  920. content: " ";
  921. clear: both;
  922. height: 0;
  923. }
  924. .pdf_converter .package_type h3:before,
  925. .about_converter .name:before,
  926. .converter_question .name:before {
  927. content: '';
  928. display: inline-block;
  929. width: 5px;
  930. height: 22px;
  931. background: #ff4f4f;
  932. margin-right: 10px;
  933. margin-top: 4px;
  934. vertical-align: top;
  935. }
  936. .pdf_converter .package_type ul li {
  937. width: 120px;
  938. list-style: none;
  939. text-align: center;
  940. margin-right: 30px;
  941. cursor: pointer;
  942. a {
  943. display: block;
  944. font-size: 14px;
  945. color: #333333;
  946. img {
  947. display: inline-block;
  948. width: 80px;
  949. height: 80px;
  950. margin-bottom: 20px;
  951. vertical-align: middle;
  952. }
  953. span {
  954. display: block;
  955. white-space: nowrap;
  956. transition: all .5s;
  957. }
  958. }
  959. }
  960. .about_converter ul li {
  961. width: 50%;
  962. float: left;
  963. list-style: none;
  964. margin-bottom: 85px;
  965. img {
  966. width: 70px;
  967. height: 70px;
  968. float: left;
  969. margin: 10px 36px 0px 0px;
  970. }
  971. .content {
  972. width: 330px;
  973. float: left;
  974. h3 {
  975. font-size: 20px;
  976. color: #333333;
  977. margin: 0px 0px 10px;
  978. font-weight: normal;
  979. }
  980. p {
  981. font-size: 16px;
  982. color: #4c4c4c;
  983. margin: 0px !important;
  984. }
  985. }
  986. }
  987. table {
  988. border-collapse: collapse;
  989. border-spacing: 0;
  990. }
  991. .converter_question table td {
  992. width: 50%;
  993. vertical-align: top;
  994. h3 {
  995. font-size: 18px;
  996. color: #333333;
  997. margin: 54px 0px 14px;
  998. font-weight: normal;
  999. text-align: left;
  1000. }
  1001. p {
  1002. width: 75%;
  1003. font-size: 16px;
  1004. color: #4c4c4c;
  1005. text-align: left;
  1006. span {
  1007. width: 8px;
  1008. height: 8px;
  1009. display: inline-block;
  1010. border-radius: 100%;
  1011. background: #333333;
  1012. margin-right: 12px;
  1013. margin-left: 4px;
  1014. }
  1015. }
  1016. }
  1017. .converter_question .more {
  1018. border-bottom: 1px solid #999999;
  1019. }
  1020. .download_code {
  1021. box-shadow: 0px 1px 5px rgb(0 0 0 / 12%);
  1022. }
  1023. .file-details-cell.state img {
  1024. display: inline-block;
  1025. cursor: pointer;
  1026. }
  1027. }
  1028. </style>