header.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. <template>
  2. <div>
  3. <div style="-webkit-app-region: drag;height:45px;line-height: 45px;">
  4. <div class="soft-head">
  5. <p class="soft-name" style="-webkit-app-region: drag;">
  6. <img src="../assets/image/icon.png" class="soft-icon" />
  7. <span style="letter-spacing: 2px;">{{productName}}</span>
  8. </p>
  9. <div style="-webkit-app-region:no-drag">
  10. <div>
  11. <template v-if="authority.validity_type != 2">
  12. <span v-if="authority.isAuthority" class="o-member twinkle_text" @click="openVip()">
  13. <img src="../assets/image/i-vip.png" />
  14. <span>会员中心</span>
  15. </span>
  16. <span v-else class="o-member twinkle_text" @click="openVip()">
  17. <img src="../assets/image/i-vip.png" />
  18. <span>开通会员</span>
  19. </span>
  20. </template>
  21. <div class="login-cur" v-if="!userInfo.username" @click="loginModel = true">
  22. <el-avatar icon="el-icon-user-solid" size="small" class="login-icon"></el-avatar><span class="font-12">未登录</span>
  23. </div>
  24. <div class="login-cur" v-else>
  25. <img v-if="userInfo.avatar" :src="userInfo.avatar" class="login-icon" />
  26. <el-avatar v-else icon="el-icon-user-solid" size="small" class="login-icon"></el-avatar>
  27. <span v-if="userInfo.username">{{userInfo.username}}</span>
  28. <span v-else>微信用户</span>
  29. <img src="../assets/image/vip.png" v-if="authority.isAuthority" style="width: 25px;vertical-align: middle;"/>
  30. </div>
  31. <el-dropdown @command="changeMenu">
  32. <i class="el-icon-s-operation sys-icon" title="菜单"></i>
  33. <el-dropdown-menu slot="dropdown">
  34. <el-dropdown-item command="vip">{{authority.isAuthority ? '会员中心' : '开通会员'}}</el-dropdown-item>
  35. <el-dropdown-item command="update">检查更新</el-dropdown-item>
  36. <el-dropdown-item command="help"><a href="https://www.xingyousoft.com/help2" style="color: inherit;">使用教程</a></el-dropdown-item>
  37. <el-dropdown-item command="setting">软件设置</el-dropdown-item>
  38. <el-dropdown-item command="developer">开发者模式</el-dropdown-item>
  39. <el-dropdown-item command="out" v-if="userInfo.username || userInfo.avatar">退出登录</el-dropdown-item>
  40. </el-dropdown-menu>
  41. </el-dropdown>
  42. <i class="el-icon-minus sys-icon" @click="softMini()"></i>
  43. <i class="el-icon-full-screen sys-icon" @click="softMax()"></i>
  44. <i class="el-icon-close sys-icon" @click="softClose()"></i>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <!-- 登录 -->
  50. <el-dialog title="用户注册登录" :visible.sync="loginModel" width="400px" :close-on-click-modal="false">
  51. <div class="login-model" style="position: relative;">
  52. <iframe v-if="loginModel" id="loginFrame" ref="loginFrame" style="border: none; width: 100%; height:100%;" :src="loginUrl"></iframe>
  53. <img src="../assets/image/icon-b.png" style="position: absolute; bottom: -30px; right: -20px; width: 40px;"/>
  54. </div>
  55. <span slot="title">
  56. <img src="../assets/image/logo.png" style="width: 25px; vertical-align: middle; margin-right: 4px;"/>注册用户登录
  57. </span>
  58. </el-dialog>
  59. <!-- 会员弹窗 -->
  60. <el-dialog custom-class="member-dialog member-dialog1" :visible.sync="vipModel" width="700px" :close-on-click-modal="false">
  61. <div slot="title">
  62. <p class="soft-mtitle">
  63. <img src="../assets/image/icon.png" class="soft-icon" />
  64. {{productName}}
  65. </p>
  66. </div>
  67. <div style="height: 580px;">
  68. <iframe v-if="vipModel" id="vipFrame" style="border: none; width: 100%; height:100%;" :src="vipUrl"></iframe>
  69. </div>
  70. </el-dialog>
  71. <!-- 未登录弹窗 -->
  72. <el-dialog :visible.sync="memberModel" width="400px" custom-class="member-dialog member-dialog2" style="border-radius: 20px; overflow: hidden;">
  73. <div class="member-model">
  74. <div class="adv-banner" v-if="popupAdvInfo.logo">
  75. <img :src="imgUrl + popupAdvInfo.logo" style="width: 100%; height: 100%;"/>
  76. </div>
  77. <div class="font-12" style="padding: 20px; margin-bottom: 10px;">
  78. <div style="text-align: center; margin-bottom: 10px;">
  79. <p style="font-size: 16px;font-weight: 600;color: #f73131;">非VIP可免费解析,下载视频需开通VIP使用</p>
  80. <p style="font-size: 14px; font-weight: 600; margin-top: 15px;">开通会员即享以下权益</p>
  81. </div>
  82. <el-row :gutter="20" class="micon-list">
  83. <el-col :span="6" class="micon-item">
  84. <img src="../assets/image/member1.png" style="width: 60px;"/>
  85. <p>不限功能</p>
  86. </el-col>
  87. <el-col :span="6" class="micon-item">
  88. <img src="../assets/image/member2.png" style="width: 60px;"/>
  89. <p>不限设备</p>
  90. </el-col>
  91. <el-col :span="6" class="micon-item">
  92. <img src="../assets/image/member3.png" style="width: 60px;"/>
  93. <p>免费升级</p>
  94. </el-col>
  95. <el-col :span="6" class="micon-item">
  96. <img src="../assets/image/member4.png" style="width: 60px;"/>
  97. <p>技术支持</p>
  98. </el-col>
  99. </el-row>
  100. </div>
  101. <div class="micon-btn">
  102. <el-button class="micon-btn1" style="margin:0 10px;" v-if="!isClick" @click="next()" :round="true">开始试用</el-button>
  103. <el-button class="micon-btn1" style="margin:0 10px;" v-else @click="next()" :round="true">开始下载</el-button>
  104. <el-button class="micon-btn2" type="primary" @click="openVip()" :round="true">开通会员</el-button>
  105. </div>
  106. </div>
  107. </el-dialog>
  108. <!-- 退出提示 -->
  109. <el-dialog title="关闭提示" :visible.sync="closeModel" width="400px">
  110. <div style="text-align:center">
  111. <el-radio-group v-model="closeType" style="text-align:left">
  112. <el-radio :label="1">最小化到系统托盘</el-radio>
  113. <div style="height: 20px;"> </div>
  114. <el-radio :label="2">直接退出应用程序</el-radio>
  115. </el-radio-group>
  116. </div>
  117. <span slot="footer" class="dialog-footer">
  118. <el-checkbox v-model="isRemember" style="float:left">不再提醒</el-checkbox>
  119. <el-button type="primary" size="small" @click="saveClose">确定</el-button>
  120. </span>
  121. </el-dialog>
  122. <!-- 软件设置 -->
  123. <el-dialog title="软件设置" :visible.sync="settingModal" width="400px" :close-on-click-modal="false">
  124. <div>
  125. <el-divider content-position="left">
  126. 账号登录
  127. <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="账号登录完成后请关闭浏览器使用">
  128. <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
  129. </el-popover>
  130. </el-divider>
  131. <el-row type="flex" justify="space-around">
  132. <el-button size="mini" @click="toLogin('alibaba')" :loading="alibabaLoading">阿里巴巴</el-button>
  133. <el-button size="mini" @click="toLogin('jd')" :loading="jdLoading">京东</el-button>
  134. <el-button size="mini" @click="toLogin('tb')" :loading="tbLoading">天猫/淘宝</el-button>
  135. <el-button size="mini" @click="toLogin('red')" :loading="redLoading">小红书</el-button>
  136. </el-row>
  137. <el-divider content-position="left">
  138. 浏览器启动地址
  139. <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="仅支持谷歌浏览器/和基于Chromium的Microsoft Edge浏览器">
  140. <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
  141. </el-popover>
  142. </el-divider>
  143. <!-- <el-row style="text-align: center;">
  144. <el-radio-group v-model="chromeType">
  145. <el-radio :label="1">本地电脑浏览器</el-radio>
  146. <el-radio :label="2">软件内置浏览器</el-radio>
  147. </el-radio-group>
  148. </el-row> -->
  149. <el-row style="text-align: center; margin-top: 10px;">
  150. <el-input size="small" v-model="chromePath" placeholder="请输入本地Chrome/Edge浏览器启动地址" clearable></el-input>
  151. <div>
  152. <el-link @click="chromeHelp('https://www.xingyousoft.com/news/detail/Z80IPpNVNNC1')" type="danger" style="text-decoration: underline; font-size: 12px;" :underline="false">查看如何输入地址</el-link>
  153. </div>
  154. </el-row>
  155. <!-- <el-divider content-position="left">
  156. 内置浏览器版本
  157. <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="win10以下版本(不含win10),请使用兼容版本的浏览器">
  158. <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
  159. </el-popover>
  160. </el-divider>
  161. <el-row style="text-align: center;">
  162. <el-radio-group v-model="versionType">
  163. <el-radio :label="1">兼容版本</el-radio>
  164. <el-radio :label="2">最新版本</el-radio>
  165. </el-radio-group>
  166. </el-row> -->
  167. <el-divider content-position="left">
  168. 分页间隔时间
  169. <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="默认为5秒,加大下载间隔时间减少访问频率,降低风控风险">
  170. <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
  171. </el-popover>
  172. </el-divider>
  173. <el-row style="text-align: center;">
  174. <el-input-number v-model="gap" :min="1" :max="60" label="间隔时间" size="mini" style="margin-right: 5px;"></el-input-number>秒
  175. </el-row>
  176. <el-divider content-position="left">清理缓存</el-divider>
  177. <el-row style="text-align: center;">
  178. <el-button size="small" type="primary" @click="clearCache()" :loading="cacheLoading">点击清除软件缓存</el-button>
  179. </el-row>
  180. <el-divider content-position="left">退出设置</el-divider>
  181. <el-row style="text-align: center;">
  182. <el-radio-group v-model="closeType">
  183. <el-radio :label="1">最小化到系统托盘</el-radio>
  184. <el-radio :label="2">直接退出应用程序</el-radio>
  185. </el-radio-group>
  186. </el-row>
  187. </div>
  188. <span slot="footer" class="dialog-footer">
  189. <el-button type="primary" @click="saveSetting" :loading="saveLoading">保存设置</el-button>
  190. </span>
  191. </el-dialog>
  192. <!-- 开发者模式 -->
  193. <el-dialog title="开发者模式" :visible.sync="developerModal" width="400px" :close-on-click-modal="false" :close-on-press-escape="false">
  194. <div>
  195. <p style="text-align: center; color: #F56C6C;">开发者参数设置,软件退出后会重置</p>
  196. <p style="text-align: center; color: #F56C6C;">(网络连接:networkidle2)</p>
  197. <el-divider content-position="left">网络连接</el-divider>
  198. <el-row style="text-align: center;">
  199. <el-radio-group v-model="waitUntil">
  200. <el-radio style="margin-bottom: 20px;" label="load">load</el-radio>
  201. <el-radio style="margin-bottom: 20px;" label="domcontentloaded">domcontentloaded</el-radio>
  202. <el-radio style="margin-bottom: 20px;" label="networkidle0">networkidle0</el-radio>
  203. <el-radio style="margin-bottom: 20px;" label="networkidle2">networkidle2</el-radio>
  204. </el-radio-group>
  205. </el-row>
  206. </div>
  207. <span slot="footer" class="dialog-footer">
  208. <el-button type="primary" @click="saveDevelop" :loading="saveDevelopLoading">保存设置</el-button>
  209. </span>
  210. </el-dialog>
  211. <!-- 通知 -->
  212. <el-dialog title="软件通知" :visible.sync="noticeModel" width="400px">
  213. <div style="padding-left: 20px; line-height: 1.8;" v-html="noticeValue.desc">
  214. </div>
  215. <span slot="footer" class="dialog-footer">
  216. <el-checkbox v-model="isRead" style="float:left">我已知晓,7天内不再提醒</el-checkbox>
  217. <el-button type="primary" size="small" @click="readClose">确定</el-button>
  218. </span>
  219. </el-dialog>
  220. </div>
  221. </template>
  222. <script>
  223. import {
  224. ipcRenderer
  225. } from 'electron';
  226. import QRCode from 'qrcodejs2'
  227. import pjson from '/package.json'
  228. import electronApi from '@/utils/electronApi';
  229. import fs from 'fs';
  230. import os from 'os';
  231. import path from 'path';
  232. const regedit = require('regedit');
  233. export default {
  234. name: "headerTop",
  235. data(){
  236. return {
  237. edgePath: ['C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
  238. 'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe',
  239. 'C:\\Program Files\\Microsoft\\Edge\\msedge.exe'],
  240. sysInfo: {},
  241. vipUrl: '',
  242. loginUrl: '',
  243. memberUrl: '',
  244. settingModal: false,
  245. boot: false, // 开机启动
  246. closeModel: false,
  247. closeType: 2,
  248. numType: 1,
  249. isRemember:true,
  250. versionType: 2,
  251. chromeType: 2,
  252. chromePath: '',
  253. gap: 5,
  254. pageMs: 600,
  255. //
  256. productName: pjson.softInfo.softName,
  257. imgUrl: this.$api.imgUrl,
  258. loginType: 1,
  259. loginModel: false, // 登录弹窗
  260. loginImg: '',
  261. loginExpire: 100,
  262. loginInterval: false, // 登录倒计时
  263. checkLoginInterval: false,
  264. isLogin: false,
  265. userInfo: {},
  266. authority: { //软件的会员权限
  267. isAuthority: false
  268. },
  269. memberModel: false,
  270. isClick: false, // 是否点击转换按钮
  271. vipModel: false, // 会员弹窗
  272. productInfo: {},
  273. productIndex: 4,
  274. payType: 1, // 支付方式 1微信 2支付宝
  275. checkPayInterval: false,
  276. order_no: '', //创建的订单号
  277. alipayUrl: '', // 支付宝
  278. payMoney: 0,
  279. clickVip: false,
  280. popupAdvInfo: [],
  281. vipAdvInfo: [],
  282. agreementInfo: [], // 会员协议
  283. agreeFlag: true,
  284. agreementModel: false,
  285. alipayDoc: '',
  286. limitModal: false, // 限时购买弹窗
  287. limitLogin: false, // 限时购买时的登录状态
  288. alibabaLoading: false,
  289. jdLoading: false,
  290. tbLoading: false,
  291. redLoading: false,
  292. cacheLoading: false,
  293. saveLoading: false,
  294. saveDevelopLoading: false,
  295. developerModal: false,
  296. headless: 1,
  297. waitUntil: 'networkidle2',
  298. isRead: false,
  299. noticeValue: {},
  300. noticeModel: false,
  301. }
  302. },
  303. props: {
  304. },
  305. async mounted(){
  306. this.getAdv();
  307. this.checkLogin();
  308. if(this.$utils.getStorage('userInfo')){
  309. this.userInfo = this.$utils.getStorage('userInfo');
  310. }
  311. if(!this.$utils.getStorage('chromeType')){
  312. for(let i = 0; i<this.edgePath.length; i++){
  313. if (fs.existsSync(this.edgePath[i])) {
  314. this.$utils.setStorage('chromeType', 1);
  315. this.$utils.setStorage('chromePath', this.edgePath[i]);
  316. break;
  317. }
  318. }
  319. }
  320. window.addEventListener('message', e => {
  321. if (e.origin === 'https://www.xingyousoft.com') {
  322. if(e.data.userInfo){ // 返回用户信息
  323. this.userInfo = e.data.userInfo;
  324. this.$utils.setStorage('userInfo', e.data.userInfo);
  325. this.loginModel = false;
  326. }
  327. if(e.data.officialToken != undefined){
  328. this.$utils.setStorage('token', e.data.officialToken);
  329. this.getUserInfo();
  330. this.loginModel = false;
  331. }
  332. if(e.data == 'paySuccess'){ // 支付成功
  333. this.vipModel = false;
  334. this.$notify({title: '成功',message: '支付成功',type: 'success'});
  335. this.getUserInfo();
  336. }
  337. if(e.data == 'next'){
  338. this.next();
  339. }
  340. if(e.data == 'openVip'){
  341. this.openVip();
  342. }
  343. }else{
  344. return;
  345. }
  346. }, false);
  347. //加载的时候会出现白屏,延迟加载解决白屏问题
  348. setTimeout(() => {
  349. ipcRenderer.send('close-loading-window', {isClose:true});
  350. }, 2000);
  351. // 判断是否设置开机启动
  352. await electronApi.call('getLoginItem').then((res)=>{
  353. if(res.openAtLogin){
  354. this.boot = true;
  355. }else{
  356. this.boot = false;
  357. }
  358. });
  359. if(fs.existsSync(path.join(os.tmpdir() , '../../Roaming/Microsoft/Windows/Start Menu/Programs/Startup/'+pjson.softInfo.softName+'.lnk'))){
  360. this.boot = true;
  361. }
  362. // 接收系统托盘命令 - 软件设置
  363. ipcRenderer.on('setting', (event, message) => {
  364. this.changeMenu('setting');
  365. })
  366. // 接收系统托盘命令 - 帮助中心
  367. ipcRenderer.on('help', (event, message) => {
  368. electronApi.openExternal("https://www.xingyousoft.com/help2");
  369. })
  370. },
  371. methods: {
  372. // 打开浏览器
  373. chromeHelp(url){
  374. // 打开浏览器
  375. const {
  376. shell
  377. } = require('electron');
  378. shell.openExternal(url);
  379. },
  380. // 清空缓存
  381. clearCache(){
  382. this.$confirm('此操作将清除软件缓存, 后续账号需要重新登录,是否继续?', '提示', {
  383. confirmButtonText: '确定',
  384. cancelButtonText: '取消',
  385. type: 'warning'
  386. }).then(() => {
  387. this.cacheLoading = true;
  388. let closeFlag = true;
  389. setTimeout(() => {
  390. let path1 = os.tmpdir() + '\\' + 'chrome-data-capture';
  391. let path2 = os.tmpdir() + '\\' + 'chrome-data-capture-jd';
  392. let path3 = os.tmpdir() + '\\' + 'chrome-data-capture-local';
  393. try{
  394. this.deleteFolder(path1, false);
  395. this.deleteFolder(path2, false);
  396. this.deleteFolder(path3, false);
  397. }catch(e){
  398. this.cacheLoading = false;
  399. if(e.toString().indexOf('operation not permitted') > -1){
  400. this.$notify.error({
  401. title: '提示',
  402. message: '请关闭浏览器后在执行清除缓存操作!'
  403. });
  404. closeFlag = false;
  405. return false;
  406. }
  407. }
  408. if(closeFlag){
  409. setTimeout(() => {
  410. this.$message({message: '缓存清除成功!', type: 'success'});
  411. this.$emit('clear-cache', true);
  412. this.cacheLoading = false;
  413. }, 2000);
  414. }
  415. }, 500);
  416. }).catch(() => {
  417. });
  418. },
  419. // 删除文件夹内容
  420. deleteFolder(folderPath, flag) {
  421. if (fs.existsSync(folderPath)) {
  422. fs.readdirSync(folderPath).forEach((file, index) => {
  423. var curPath = path.join(folderPath, file);
  424. if (fs.lstatSync(curPath).isDirectory()) {
  425. this.deleteFolder(curPath, true);
  426. } else {
  427. fs.unlinkSync(curPath);
  428. }
  429. });
  430. if(flag){
  431. fs.rmdirSync(folderPath);
  432. }
  433. }
  434. },
  435. // 点击去登录
  436. toLogin(type){
  437. let url = '';
  438. if(type == 'alibaba'){
  439. url = 'https://www.1688.com';
  440. }else if(type == 'jd'){
  441. url = 'https://www.jd.com';
  442. }else if(type == 'tb'){
  443. url = 'https://login.taobao.com';
  444. }else if(type == 'red'){
  445. url = 'https://www.xiaohongshu.com';
  446. }
  447. this[type + 'Loading'] = true;
  448. setTimeout(() => {
  449. this[type + 'Loading'] = false;
  450. }, 2000)
  451. this.$emit('login-url', url);
  452. },
  453. softMini() { // 软件最小化
  454. ipcRenderer.send('min');
  455. },
  456. softMax() { // 软件最大化
  457. ipcRenderer.send('max');
  458. },
  459. softClose() { // 软件关闭
  460. let isRemember = this.$utils.getStorage('isRemember');
  461. if(isRemember == true){
  462. let type = this.$utils.getStorage('closeType');
  463. if(type == 2){
  464. ipcRenderer.send('exit');
  465. }else{
  466. ipcRenderer.send('tray');
  467. }
  468. }else{
  469. this.closeModel = true;
  470. }
  471. },
  472. saveClose(){
  473. if(this.isRemember == true){
  474. this.$utils.setStorage('closeType',this.closeType);
  475. }
  476. this.$utils.setStorage('isRemember', this.isRemember);
  477. if(this.closeType == 2){
  478. ipcRenderer.send('exit');
  479. }else{
  480. this.closeModel = false;
  481. ipcRenderer.send('tray');
  482. }
  483. },
  484. readClose(){
  485. if(this.isRead == true){
  486. this.$utils.setStorage('isRead', {token: true, expire: 60*60*24*7});
  487. }else{
  488. this.$utils.setStorage('isRead', false);
  489. }
  490. this.noticeModel = false;
  491. },
  492. // 保存设置
  493. saveSetting(){
  494. this.saveLoading = true;
  495. if(this.chromeType == 1){ // 用户选择电脑本地的浏览器使用
  496. let chromePath = this.chromePath.replace(/^["']|["']$/g, '');
  497. if(!chromePath.endsWith('.exe') || /[\u4e00-\u9fff]/.test(chromePath)){ //判断文件路径结尾而且不包含中文
  498. this.$notify({
  499. title: '提示',
  500. message: '浏览器启动地址不能含有中文且必须以".exe"结尾,请核对后重新输入',
  501. type: 'warning'
  502. });
  503. this.saveLoading = false;
  504. return false;
  505. }
  506. this.chromePath = chromePath;
  507. this.$utils.setStorage('chromePath', this.chromePath);
  508. this.setPublic();
  509. }else{ //用户选择内置浏览器使用校验
  510. let systemVersion = 10;
  511. if(os.release() && os.release().indexOf('.')){
  512. systemVersion = Number(os.release().split('.')[0]);
  513. }
  514. if(systemVersion < 10 && this.versionType == 2){ // win10以下版本,而且选择了最新版本时提示
  515. this.$confirm("检测到当前Windows系统不兼容最新版浏览器,是否继续选择最新版?", '提示', {
  516. type: 'warning'
  517. }).then(() => {
  518. this.setPublic();
  519. }).catch(() => {
  520. this.saveLoading = false;
  521. });
  522. }else{
  523. this.setPublic();
  524. }
  525. }
  526. },
  527. // 保存设置公共代码部分
  528. setPublic(){
  529. this.$utils.setStorage('closeType', this.closeType);
  530. this.$utils.setStorage('pageMs', this.pageMs);
  531. this.$utils.setStorage('gap', this.gap);
  532. this.$utils.setStorage('versionType', this.versionType);
  533. this.$utils.setStorage('isRemember', true);
  534. this.$utils.setStorage('chromeType', this.chromeType);
  535. ipcRenderer.send('boot', this.boot);
  536. setTimeout(() => {
  537. this.saveLoading = false;
  538. this.settingModal = false;
  539. }, 800)
  540. },
  541. // 保存开发者设置
  542. saveDevelop(){
  543. this.saveDevelopLoading = true;
  544. this.$utils.setStorage('headless', this.headless);
  545. this.$utils.setStorage('waitUntil', this.waitUntil);
  546. setTimeout(() => {
  547. this.saveDevelopLoading = false;
  548. this.developerModal = false;
  549. }, 800)
  550. },
  551. //
  552. getAdv() {
  553. // 非会员广告接口
  554. this.$http.post(this.$api.target + '/api/api/m_position_list_byid', { id: pjson.softInfo.popupAdvId }).then((response) => {
  555. if (!response.data.error) {
  556. this.popupAdvInfo = response.data.result;
  557. }
  558. })
  559. electronApi.spawnExec(['cert.exe','token']).then(res => {
  560. this.sysInfo = JSON.parse(res.stdout.toString());
  561. this.$utils.setStorage('session', this.sysInfo.windows_uuid);
  562. this.loginUrl = "https://www.xingyousoft.com/soft/login2/"+pjson.softInfo.softMid+"?p_mid="+pjson.softInfo.softMid+"&agent_mid="+this.sysInfo.agentMid+"&uuid="+this.sysInfo.windows_uuid+"&soft_type="+this.sysInfo.softType;
  563. this.memberUrl = "https://www.xingyousoft.com/soft/reminder2/"+pjson.softInfo.softMid+"?p_mid="+pjson.softInfo.softMid+"&agent_mid="+this.sysInfo.agentMid+"&uuid="+this.sysInfo.windows_uuid+"&soft_type="+this.sysInfo.softType;
  564. if(process.env.NODE_ENV != "development"){ // 非开发环境运行
  565. let params = {
  566. type: 3,
  567. tag: '',
  568. product_version: pjson.version,
  569. windows_uuid: this.sysInfo.windows_uuid,
  570. os_platform: this.sysInfo.os_platform,
  571. os_version: this.sysInfo.os_version,
  572. cpu: this.sysInfo.cpu,
  573. statistics_flag: '',
  574. from: this.sysInfo.from,
  575. }
  576. // 使用日志
  577. // this.$http.post(this.$api.statistics + pjson.softInfo.softMid, params).then((response) => {
  578. // })
  579. }
  580. }).catch(err => {
  581. console.log(err);
  582. let windows_uuid = this.$utils.guid();
  583. if(this.$utils.getStorage('session')){
  584. windows_uuid = this.$utils.getStorage('session');
  585. }
  586. this.$utils.setStorage('session', windows_uuid);
  587. this.loginUrl = "https://www.xingyousoft.com/soft/login2/"+pjson.softInfo.softMid+"?p_mid="+pjson.softInfo.softMid+"&agent_mid="+this.sysInfo.agentMid+"&uuid="+windows_uuid+"&soft_type="+this.sysInfo.softType;
  588. this.memberUrl = "https://www.xingyousoft.com/soft/reminder2/"+pjson.softInfo.softMid+"?p_mid="+pjson.softInfo.softMid+"&agent_mid="+this.sysInfo.agentMid+"&uuid="+windows_uuid+"&soft_type="+this.sysInfo.softType;
  589. });
  590. this.$http.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
  591. this.$http.get(pjson.softInfo.downloadPrefix + '/' + pjson.name + "/notice.json?"+Math.random()).then((response) => {
  592. this.noticeValue = response.data || {};
  593. let nowTime = new Date().getTime();
  594. let isRead = this.$utils.getStorage('isRead');
  595. if(this.noticeValue.t > nowTime && !isRead){
  596. this.noticeModel = true;
  597. }
  598. }).catch(function(error){
  599. console.log(error);
  600. });
  601. },
  602. // 刷新登录二维码
  603. refreshCode() {
  604. this.clearLoginInterval();
  605. let data = {
  606. scene_str: pjson.softInfo.softMid + ':' + this.$utils.getStorage('session')
  607. };
  608. this.$http.post(this.$api.createQrcode, data).then((response) => {
  609. if (response.data.result) {
  610. this.loginImg = response.data.result.url;
  611. this.loginExpire = response.data.result.expire_seconds;
  612. this.loginInterval = setInterval(() => {
  613. this.loginExpire--;
  614. if (this.loginExpire <= 0) {
  615. this.clearLoginInterval();
  616. }
  617. }, 1000)
  618. this.checkLoginInterval = setInterval(() => {
  619. this.checkLogin();
  620. }, 3000)
  621. }
  622. });
  623. },
  624. // 继续试用 or 开始转换
  625. next() {
  626. if(this.isClick){ // 开始转换
  627. this.$emit('export-file', true);
  628. }else{ // 继续试用
  629. this.memberModel = false;
  630. }
  631. },
  632. // 开通会员
  633. openVip() {
  634. this.clickVip = true;
  635. this.memberModel = false;
  636. if (this.$utils.getStorage('token')) {
  637. this.vipModel = true;
  638. this.vipUrl = "https://www.xingyousoft.com/soft/buy2/"+pjson.softInfo.softMid+"?p_mid="+pjson.softInfo.softMid+"&agent_mid="+this.sysInfo.agentMid+"&uuid="+this.sysInfo.windows_uuid+"&token="+this.$utils.getStorage('token')+"&soft_type="+this.sysInfo.softType+"&time="+new Date().getTime();
  639. } else {
  640. this.loginModel = true;
  641. }
  642. },
  643. // 检查微信是否登录
  644. checkLogin() {
  645. let data = {
  646. scene_str: pjson.softInfo.softMid + ':' + this.$utils.getStorage('session')
  647. };
  648. this.$http.post(this.$api.checkLogin, data).then((response) => {
  649. if (response.data.error) { // 未登录
  650. this.authority.isAuthority = false;
  651. this.userInfo = {};
  652. this.$utils.setStorage('token', '');
  653. this.$utils.setStorage('userInfo', '');
  654. if(!this.loginModel && !this.limitModal) {
  655. this.memberModel = true;
  656. }
  657. }else{ // 登录成功
  658. this.$utils.setStorage('token', response.data.result);
  659. this.loginModel = false;
  660. this.getUserInfo();
  661. if(this.limitModal){ // 限时优惠 已登录
  662. this.limitLogin = true;
  663. }
  664. if (this.clickVip) { // 点击开通会员 登陆后直接展示会员购买弹窗
  665. this.vipModel = true;
  666. this.vipUrl = "https://www.xingyousoft.com/soft/buy2/"+pjson.softInfo.softMid+"?p_mid="+pjson.softInfo.softMid+"&agent_mid="+this.sysInfo.agentMid+"&uuid="+this.sysInfo.windows_uuid+"&token="+this.$utils.getStorage('token')+"&soft_type="+this.sysInfo.softType+"&time="+new Date().getTime();
  667. this.clickVip = false;
  668. }else{
  669. // this.getProductInfo();
  670. }
  671. }
  672. });
  673. },
  674. // 获取用户信息
  675. getUserInfo() {
  676. this.$http.post(this.$api.getUserInfo).then((response) => {
  677. if (!response.data.error) {
  678. this.userInfo = response.data.result;
  679. this.getAuthority();
  680. }
  681. });
  682. },
  683. // 清空登录有关定时器
  684. clearLoginInterval() {
  685. clearInterval(this.loginInterval);
  686. clearInterval(this.checkLoginInterval);
  687. },
  688. // 获取用户账单
  689. getAuthority() {
  690. this.$http.post(this.$api.userBill + pjson.softInfo.softMid).then((response) => {
  691. if (!response.data.error) {
  692. this.authority = response.data.result;
  693. let nowDate = new Date().getTime();
  694. if (nowDate <= new Date(this.authority.validity_end_time).getTime() || this.authority.validity_type == 2) {
  695. this.authority.isAuthority = true;
  696. } else {
  697. this.authority.isAuthority = false;
  698. if (!this.vipModel && !this.limitModal) {
  699. this.memberModel = true;
  700. }
  701. }
  702. this.$forceUpdate();
  703. }
  704. })
  705. },
  706. // 监听会员弹窗状态
  707. vipChange(e) {
  708. },
  709. // 监听显示购买弹窗状态
  710. limitChange(e){
  711. if (e) {
  712. if(!this.limitLogin && this.limitModal){
  713. this.refreshCode();
  714. }
  715. }else{
  716. clearInterval(this.checkPayInterval)
  717. }
  718. },
  719. // 监听登录弹窗状态
  720. loginChange(e) {
  721. if (e) {
  722. this.refreshCode();
  723. } else {
  724. this.clickVip = false;
  725. this.clearLoginInterval();
  726. }
  727. },
  728. // 选择支付方式
  729. selectPaytype(index) {
  730. this.payType = index; // 1微信支付 2支付宝支付
  731. if(this.limitModal){
  732. this.selectTerm(5);
  733. }else{
  734. this.selectTerm();
  735. }
  736. },
  737. // 生成微信支付二维码
  738. createQrcode(str) {
  739. document.getElementById('qrcode').innerHTML = ''
  740. let qrcode = new QRCode('qrcode', {
  741. width: 210,
  742. height: 210, // 高度
  743. text: str, // 二维码内容
  744. render: 'canvas', // 设置渲染方式(有两种方式 table和canvas,默认是canvas)
  745. background: '#f0f',
  746. foreground: '#ff0'
  747. })
  748. },
  749. // 选择会员期限创建订单
  750. selectTerm(index) {
  751. if (index) {
  752. this.productIndex = index;
  753. }
  754. this.payMoney = this.productInfo['price' + this.productIndex];
  755. let params = {
  756. product_type: 1,
  757. id: this.productInfo.id,
  758. type: this.productIndex
  759. };
  760. clearInterval(this.checkPayInterval);
  761. this.$http.post(this.$api.target + '/order/createOrder', params).then((response) => {
  762. if (response.data.result) {
  763. this.order_no = response.data.data;
  764. if (this.payType == 1) { // 微信支付
  765. this.wepay();
  766. } else {
  767. this.alipay();
  768. }
  769. } else {
  770. this.$message.error(response.data.msg);
  771. }
  772. });
  773. },
  774. // 微信支付
  775. wepay() {
  776. this.$http.post(this.$api.target + '/pay/wechatPay', { order_no: this.order_no }).then((res) => {
  777. if (res.data.result) {
  778. if (JSON.stringify(res.data.data) != '[]') {
  779. this.wxPayErcode = res.data.data.code_url
  780. this.createQrcode(res.data.data.code_url)
  781. this.checkWxPay()
  782. }
  783. }
  784. });
  785. },
  786. // 支付宝支付
  787. alipay() {
  788. this.$http.post(this.$api.target + '/pay/alipay', { order_no: this.order_no }).then((res) => {
  789. var content = res.data; //内容
  790. this.alipayDoc = content;
  791. this.checkWxPay();
  792. });
  793. },
  794. // 每2秒检测一次是否支付成功
  795. checkWxPay() {
  796. clearInterval(this.checkPayInterval);
  797. this.checkPayInterval = setInterval(() => {
  798. this.$http.post(this.$api.target + '/order/checkIsWXPay', { order_no: this.order_no, product_type: 1 }).then((res) => {
  799. if (res.data.result) {
  800. if (JSON.stringify(res.data.data) != '[]') {
  801. if (res.data.code == '1001') {
  802. clearInterval(this.checkPayInterval);
  803. this.vipModel = false;
  804. this.limitModal = false;
  805. this.getAuthority();
  806. this.$notify({title: '支付通知',message: res.data.msg,type: 'success'});
  807. }
  808. }
  809. }
  810. });
  811. }, 2000)
  812. // 5分钟后关闭
  813. // setTimeout(() => {
  814. // clearInterval(this.checkPayInterval)
  815. // }, 1000 * 300)
  816. },
  817. // 选择菜单
  818. changeMenu(e) {
  819. if (e === 'out') {
  820. this.$confirm("是否退出登录该账号?", '提示', {
  821. type: 'warning'
  822. }).then(() => {
  823. this.$http.post(this.$api.loginOut).then((response) => {
  824. if (!response.data.error) {
  825. this.userInfo = {};
  826. this.authority.isAuthority = false;
  827. this.$utils.setStorage('token', '');
  828. this.$utils.setStorage('userInfo', '');
  829. this.$message({message: '账号已退出',type: 'success'});
  830. // this.$refs.loginFrame.contentWindow.postMessage('out', '*');
  831. }
  832. });
  833. }).catch(() => {
  834. });
  835. } else if (e === 'vip') {
  836. this.openVip();
  837. } else if (e === 'update') {
  838. this.$emit('update-soft', true);
  839. } else if (e === 'setting'){
  840. this.settingModal = true;
  841. this.saveLoading = false;
  842. // 获取设置
  843. let closeType = this.$utils.getStorage('closeType');
  844. let pageMs = this.$utils.getStorage('pageMs');
  845. let gap = this.$utils.getStorage('gap');
  846. let versionType = this.$utils.getStorage('versionType');
  847. let chromeType = this.$utils.getStorage('chromeType');
  848. let chromePath = this.$utils.getStorage('chromePath');
  849. if(closeType){
  850. this.closeType = closeType;
  851. }
  852. if(pageMs){
  853. this.pageMs = pageMs;
  854. }
  855. if(gap){
  856. this.gap = gap;
  857. }
  858. if(versionType){
  859. this.versionType = versionType;
  860. }
  861. if(chromeType){
  862. this.chromeType = chromeType;
  863. }
  864. if(chromePath){
  865. this.chromePath = chromePath;
  866. }
  867. } else if (e == 'developer'){ //开发者模式
  868. let password = '9d0b17e04db20927047de3d09152db0f'; //默认密钥
  869. this.$http.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8';
  870. this.$http.get(pjson.softInfo.downloadPrefix + '/' + pjson.name + "/developer.json?"+Math.random()).then((response) => {
  871. let getResult = response.data || '';
  872. if(getResult && typeof(response.data) == 'string'){
  873. password = getResult;
  874. }
  875. }).catch(function(error){
  876. console.log(error);
  877. });
  878. this.$prompt('请输入开发者密钥:', '提示', {
  879. confirmButtonText: '确定',
  880. cancelButtonText: '取消',
  881. inputPlaceholder: '请联系软件底部企业微信客服咨询使用',
  882. }).then(({ value }) => {
  883. if(value == password){
  884. this.developerModal = true;
  885. }else{
  886. this.$message.error('密钥错误,已退出');
  887. }
  888. }).catch(() => {
  889. });
  890. }
  891. },
  892. },
  893. }
  894. </script>
  895. <style lang="scss">
  896. .vip-banner{
  897. background-color: #eee;
  898. height: 60px;
  899. width: 100%;
  900. margin-bottom: 15px;
  901. }
  902. .adv-banner{
  903. height: 150px;
  904. width: 100%;
  905. }
  906. .login-cur{
  907. margin: 0 10px;
  908. display: inline-block;
  909. cursor: pointer;
  910. }
  911. .vip-modal .ivu-icon-ios-close{
  912. color: #f8f8f8 !important;
  913. }
  914. .setting-dialog{
  915. .el-dialog__body{
  916. padding: 0 20px;
  917. }
  918. }
  919. .member-dialog{
  920. .el-dialog__header{
  921. padding: 0;
  922. }
  923. .el-dialog__body{
  924. padding: 0;
  925. }
  926. }
  927. .member-dialog1{
  928. .el-dialog__headerbtn{
  929. top: 13px;
  930. }
  931. }
  932. .member-dialog2{
  933. border-radius: 20px !important;
  934. overflow: hidden;
  935. }
  936. .micon-list{
  937. padding: 20px 10px;
  938. background: linear-gradient(to bottom, #fdd6ca69, #ffffff);
  939. border-radius: 20px;
  940. }
  941. .micon-item{
  942. text-align: center;
  943. font-size: 14px;
  944. font-weight: 600;
  945. color: #ec6b44;
  946. }
  947. .micon-btn{
  948. text-align: center;
  949. padding-bottom: 20px;
  950. }
  951. .soft-mtitle{
  952. font-size: 16px;
  953. line-height: 40px;
  954. font-weight: 600;
  955. padding: 0 15px;
  956. }
  957. </style>