header.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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="out" v-if="userInfo.username || userInfo.avatar">退出登录</el-dropdown-item>
  39. </el-dropdown-menu>
  40. </el-dropdown>
  41. <i class="el-icon-minus sys-icon" @click="softMini()"></i>
  42. <i class="el-icon-full-screen sys-icon" @click="softMax()"></i>
  43. <i class="el-icon-close sys-icon" @click="softClose()"></i>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <!-- 登录 -->
  49. <el-dialog title="用户注册登录" :visible.sync="loginModel" width="400px" :close-on-click-modal="false">
  50. <div class="login-model" style="position: relative;">
  51. <iframe v-if="loginModel" id="loginFrame" ref="loginFrame" style="border: none; width: 100%; height:100%;" :src="loginUrl"></iframe>
  52. <img src="../assets/image/icon-b.png" style="position: absolute; bottom: -30px; right: -20px; width: 40px;"/>
  53. </div>
  54. <span slot="title">
  55. <img src="../assets/image/logo.png" style="width: 25px; vertical-align: middle; margin-right: 4px;"/>注册用户登录
  56. </span>
  57. </el-dialog>
  58. <!-- 会员弹窗 -->
  59. <el-dialog custom-class="member-dialog member-dialog1" :visible.sync="vipModel" width="700px" :close-on-click-modal="false">
  60. <div slot="title">
  61. <p class="soft-mtitle">
  62. <img src="../assets/image/icon.png" class="soft-icon" />
  63. {{productName}}
  64. </p>
  65. </div>
  66. <div style="height: 580px;">
  67. <iframe v-if="vipModel" id="vipFrame" style="border: none; width: 100%; height:100%;" :src="vipUrl"></iframe>
  68. </div>
  69. </el-dialog>
  70. <!-- 未登录弹窗 -->
  71. <el-dialog :visible.sync="memberModel" width="400px" custom-class="member-dialog member-dialog2" style="border-radius: 20px; overflow: hidden;">
  72. <div class="member-model">
  73. <div class="adv-banner" v-if="popupAdvInfo.logo">
  74. <img :src="imgUrl + popupAdvInfo.logo" style="width: 100%; height: 100%;"/>
  75. </div>
  76. <div class="font-12" style="padding: 20px; margin-bottom: 10px;">
  77. <div style="text-align: center; margin-bottom: 10px;">
  78. <p style="font-size: 16px;font-weight: 600;color: #f73131;">非VIP每个图片类型仅下载前3张,图片处理导出图片有官方水印</p>
  79. <p style="font-size: 14px; font-weight: 600; margin-top: 15px;">开通会员即享以下权益</p>
  80. </div>
  81. <el-row :gutter="20" class="micon-list">
  82. <el-col :span="6" class="micon-item">
  83. <img src="../assets/image/member1.png" style="width: 60px;"/>
  84. <p>不限功能</p>
  85. </el-col>
  86. <el-col :span="6" class="micon-item">
  87. <img src="../assets/image/member2.png" style="width: 60px;"/>
  88. <p>不限设备</p>
  89. </el-col>
  90. <el-col :span="6" class="micon-item">
  91. <img src="../assets/image/member3.png" style="width: 60px;"/>
  92. <p>免费升级</p>
  93. </el-col>
  94. <el-col :span="6" class="micon-item">
  95. <img src="../assets/image/member4.png" style="width: 60px;"/>
  96. <p>技术支持</p>
  97. </el-col>
  98. </el-row>
  99. </div>
  100. <div class="micon-btn">
  101. <el-button class="micon-btn1" style="margin:0 10px;" v-if="!isClick" @click="next()" :round="true">开始试用</el-button>
  102. <el-button class="micon-btn1" style="margin:0 10px;" v-else @click="next()" :round="true">开始下载</el-button>
  103. <el-button class="micon-btn2" type="primary" @click="openVip()" :round="true">开通会员</el-button>
  104. </div>
  105. </div>
  106. </el-dialog>
  107. <!-- 退出提示 -->
  108. <el-dialog title="关闭提示" :visible.sync="closeModel" width="400px">
  109. <div style="text-align:center">
  110. <el-radio-group v-model="closeType" style="text-align:left">
  111. <el-radio :label="1">最小化到系统托盘</el-radio>
  112. <div style="height: 20px;"> </div>
  113. <el-radio :label="2">直接退出应用程序</el-radio>
  114. </el-radio-group>
  115. </div>
  116. <span slot="footer" class="dialog-footer">
  117. <el-checkbox v-model="isRemember" style="float:left">不再提醒</el-checkbox>
  118. <el-button type="primary" size="small" @click="saveClose">确定</el-button>
  119. </span>
  120. </el-dialog>
  121. <!-- 软件设置 -->
  122. <el-dialog title="软件设置" :visible.sync="settingModal" width="400px">
  123. <div>
  124. <el-divider content-position="left">
  125. 账号登录
  126. <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="账号登录完成后请关闭浏览器使用">
  127. <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
  128. </el-popover>
  129. </el-divider>
  130. <el-row type="flex" justify="space-around">
  131. <el-button size="mini" @click="toLogin('alibaba')" :loading="alibabaLoading">阿里巴巴</el-button>
  132. <el-button size="mini" @click="toLogin('jd')" :loading="jdLoading">京东</el-button>
  133. <el-button size="mini" @click="toLogin('tb')" :loading="tbLoading">天猫/淘宝</el-button>
  134. <el-button size="mini" @click="toLogin('red')" :loading="redLoading">小红书</el-button>
  135. </el-row>
  136. <!-- <el-divider content-position="left">
  137. 同时下载量
  138. <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="同时下载量过多,可能会触发平台拦截">
  139. <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
  140. </el-popover>
  141. </el-divider>
  142. <el-row style="text-align: center;">
  143. <el-radio-group v-model="numType">
  144. <el-radio :label="1">1个</el-radio>
  145. <el-radio :label="2">2个</el-radio>
  146. <el-radio :label="3">3个</el-radio>
  147. <el-radio :label="4">4个</el-radio>
  148. </el-radio-group>
  149. </el-row> -->
  150. <el-divider content-position="left">
  151. 浏览器版本
  152. <el-popover placement="bottom" popper-class="popper-open" trigger="hover" content="win10以下版本(不含win10),请使用兼容版本的浏览器">
  153. <i class="el-icon-info" slot="reference" style="margin-left: 10px; color: #F56C6C;"></i>
  154. </el-popover>
  155. </el-divider>
  156. <el-row style="text-align: center;">
  157. <el-radio-group v-model="versionType">
  158. <el-radio :label="1">兼容版本</el-radio>
  159. <el-radio :label="2">最新版本</el-radio>
  160. </el-radio-group>
  161. </el-row>
  162. <el-divider content-position="left">清理缓存</el-divider>
  163. <el-row style="text-align: center;">
  164. <el-button size="small" type="primary" @click="clearCache()" :loading="cacheLoading">点击清除软件缓存</el-button>
  165. </el-row>
  166. <el-divider content-position="left">退出设置</el-divider>
  167. <el-row style="text-align: center;">
  168. <el-radio-group v-model="closeType">
  169. <el-radio :label="1">最小化到系统托盘</el-radio>
  170. <el-radio :label="2">直接退出应用程序</el-radio>
  171. </el-radio-group>
  172. </el-row>
  173. </div>
  174. <span slot="footer" class="dialog-footer">
  175. <el-button type="primary" @click="saveSetting" :loading="saveLoading">保存设置</el-button>
  176. </span>
  177. </el-dialog>
  178. </div>
  179. </template>
  180. <script>
  181. import {
  182. ipcRenderer
  183. } from 'electron';
  184. import QRCode from 'qrcodejs2'
  185. import pjson from '/package.json'
  186. import electronApi from '@/utils/electronApi';
  187. import fs from 'fs';
  188. import os from 'os';
  189. import path from 'path';
  190. const regedit = require('regedit');
  191. export default {
  192. name: "headerTop",
  193. data(){
  194. return {
  195. sysInfo: {},
  196. vipUrl: '',
  197. loginUrl: '',
  198. memberUrl: '',
  199. settingModal: false,
  200. boot: false, // 开机启动
  201. closeModel: false,
  202. closeType: 2,
  203. numType: 1,
  204. versionType: 2,
  205. isRemember:true,
  206. //
  207. productName: pjson.softInfo.softName,
  208. imgUrl: this.$api.imgUrl,
  209. loginType: 1,
  210. loginModel: false, // 登录弹窗
  211. loginImg: '',
  212. loginExpire: 100,
  213. loginInterval: false, // 登录倒计时
  214. checkLoginInterval: false,
  215. isLogin: false,
  216. userInfo: {},
  217. authority: { //软件的会员权限
  218. isAuthority: false
  219. },
  220. memberModel: false,
  221. isClick: false, // 是否点击转换按钮
  222. vipModel: false, // 会员弹窗
  223. productInfo: {},
  224. productIndex: 4,
  225. payType: 1, // 支付方式 1微信 2支付宝
  226. checkPayInterval: false,
  227. order_no: '', //创建的订单号
  228. alipayUrl: '', // 支付宝
  229. payMoney: 0,
  230. clickVip: false,
  231. popupAdvInfo: [],
  232. vipAdvInfo: [],
  233. agreementInfo: [], // 会员协议
  234. agreeFlag: true,
  235. agreementModel: false,
  236. alipayDoc: '',
  237. limitModal: false, // 限时购买弹窗
  238. limitLogin: false, // 限时购买时的登录状态
  239. alibabaLoading: false,
  240. jdLoading: false,
  241. tbLoading: false,
  242. redLoading: false,
  243. cacheLoading: false,
  244. saveLoading: false,
  245. }
  246. },
  247. props: {
  248. },
  249. async mounted(){
  250. this.getAdv();
  251. this.checkLogin();
  252. if(this.$utils.getStorage('userInfo')){
  253. this.userInfo = this.$utils.getStorage('userInfo');
  254. }
  255. window.addEventListener('message', e => {
  256. if (e.origin === 'https://www.xingyousoft.com') {
  257. if(e.data.userInfo){ // 返回用户信息
  258. this.userInfo = e.data.userInfo;
  259. this.$utils.setStorage('userInfo', e.data.userInfo);
  260. this.loginModel = false;
  261. }
  262. if(e.data.officialToken != undefined){
  263. this.$utils.setStorage('token', e.data.officialToken);
  264. this.getUserInfo();
  265. this.loginModel = false;
  266. }
  267. if(e.data == 'paySuccess'){ // 支付成功
  268. this.vipModel = false;
  269. this.$notify({title: '成功',message: '支付成功',type: 'success'});
  270. this.getUserInfo();
  271. }
  272. if(e.data == 'next'){
  273. this.next();
  274. }
  275. if(e.data == 'openVip'){
  276. this.openVip();
  277. }
  278. }else{
  279. return;
  280. }
  281. }, false);
  282. //加载的时候会出现白屏,延迟加载解决白屏问题
  283. setTimeout(() => {
  284. ipcRenderer.send('close-loading-window', {isClose:true});
  285. }, 2000);
  286. // 判断是否设置开机启动
  287. await electronApi.call('getLoginItem').then((res)=>{
  288. if(res.openAtLogin){
  289. this.boot = true;
  290. }else{
  291. this.boot = false;
  292. }
  293. });
  294. if(fs.existsSync(path.join(os.tmpdir() , '../../Roaming/Microsoft/Windows/Start Menu/Programs/Startup/'+pjson.softInfo.softName+'.lnk'))){
  295. this.boot = true;
  296. }
  297. // 接收系统托盘命令 - 软件设置
  298. ipcRenderer.on('setting', (event, message) => {
  299. this.changeMenu('setting');
  300. })
  301. // 接收系统托盘命令 - 帮助中心
  302. ipcRenderer.on('help', (event, message) => {
  303. electronApi.openExternal("https://www.xingyousoft.com/help2");
  304. })
  305. },
  306. methods: {
  307. // 清空缓存
  308. clearCache(){
  309. this.$confirm('此操作将清除软件缓存, 后续账号需要重新登录,是否继续?', '提示', {
  310. confirmButtonText: '确定',
  311. cancelButtonText: '取消',
  312. type: 'warning'
  313. }).then(() => {
  314. this.cacheLoading = true;
  315. let closeFlag = true;
  316. setTimeout(() => {
  317. let path = os.tmpdir() + '\\' + 'chrome-data-capture';
  318. let path2 = os.tmpdir() + '\\' + 'chrome-data-capture-jd';
  319. try{
  320. this.deleteFolder(path, false);
  321. this.deleteFolder(path2, false);
  322. }catch(e){
  323. this.cacheLoading = false;
  324. if(e.toString().indexOf('operation not permitted') > -1){
  325. this.$notify.error({
  326. title: '提示',
  327. message: '请关闭浏览器后在执行清除缓存操作!'
  328. });
  329. closeFlag = false;
  330. return false;
  331. }
  332. }
  333. if(closeFlag){
  334. setTimeout(() => {
  335. this.$message({message: '缓存清除成功!', type: 'success'});
  336. this.$emit('clear-cache', true);
  337. this.cacheLoading = false;
  338. }, 2000);
  339. }
  340. }, 500);
  341. }).catch(() => {
  342. });
  343. },
  344. // 删除文件夹内容
  345. deleteFolder(folderPath, flag) {
  346. if (fs.existsSync(folderPath)) {
  347. fs.readdirSync(folderPath).forEach((file, index) => {
  348. var curPath = path.join(folderPath, file);
  349. if (fs.lstatSync(curPath).isDirectory()) {
  350. this.deleteFolder(curPath, true);
  351. } else {
  352. fs.unlinkSync(curPath);
  353. }
  354. });
  355. if(flag){
  356. fs.rmdirSync(folderPath);
  357. }
  358. }
  359. },
  360. // 点击去登录
  361. toLogin(type){
  362. let url = '';
  363. if(type == 'alibaba'){
  364. url = 'https://www.1688.com';
  365. }else if(type == 'jd'){
  366. url = 'https://passport.jd.com/new/login.aspx';
  367. }else if(type == 'tb'){
  368. url = 'https://login.taobao.com';
  369. }else if(type == 'red'){
  370. url = 'https://www.xiaohongshu.com';
  371. }
  372. this[type + 'Loading'] = true;
  373. setTimeout(() => {
  374. this[type + 'Loading'] = false;
  375. }, 2000)
  376. this.$emit('login-url', url);
  377. },
  378. softMini() { // 软件最小化
  379. ipcRenderer.send('min');
  380. },
  381. softMax() { // 软件最大化
  382. ipcRenderer.send('max');
  383. },
  384. softClose() { // 软件关闭
  385. let isRemember = this.$utils.getStorage('isRemember');
  386. if(isRemember == true){
  387. let type = this.$utils.getStorage('closeType');
  388. if(type == 2){
  389. ipcRenderer.send('exit');
  390. }else{
  391. ipcRenderer.send('tray');
  392. }
  393. }else{
  394. this.closeModel = true;
  395. }
  396. },
  397. saveClose(){
  398. if(this.isRemember == true){
  399. this.$utils.setStorage('closeType',this.closeType);
  400. }
  401. this.$utils.setStorage('isRemember', this.isRemember);
  402. if(this.closeType == 2){
  403. ipcRenderer.send('exit');
  404. }else{
  405. this.closeModel = false;
  406. ipcRenderer.send('tray');
  407. }
  408. },
  409. // 保存设置
  410. saveSetting(){
  411. this.saveLoading = true;
  412. let systemVersion = 10;
  413. if(os.release() && os.release().indexOf('.')){
  414. systemVersion = Number(os.release().split('.')[0]);
  415. }
  416. if(systemVersion < 10 && this.versionType == 2){ // win10以下版本,而且选择了最新版本时提示
  417. this.$confirm("检测到当前Windows系统不兼容最新版浏览器,是否继续选择最新版?", '提示', {
  418. type: 'warning'
  419. }).then(() => {
  420. this.$utils.setStorage('closeType', this.closeType);
  421. // this.$utils.setStorage('numType', this.numType);
  422. this.$utils.setStorage('versionType', this.versionType);
  423. this.$utils.setStorage('isRemember', true)
  424. ipcRenderer.send('boot', this.boot);
  425. setTimeout(() => {
  426. this.saveLoading = false;
  427. this.settingModal = false;
  428. }, 800)
  429. }).catch(() => {
  430. this.saveLoading = false;
  431. });
  432. }else{
  433. this.$utils.setStorage('closeType', this.closeType);
  434. // this.$utils.setStorage('numType', this.numType);
  435. this.$utils.setStorage('versionType', this.versionType);
  436. this.$utils.setStorage('isRemember', true)
  437. ipcRenderer.send('boot', this.boot);
  438. setTimeout(() => {
  439. this.saveLoading = false;
  440. this.settingModal = false;
  441. }, 800)
  442. }
  443. },
  444. //
  445. getAdv() {
  446. // 非会员广告接口
  447. this.$http.post(this.$api.target + '/api/api/m_position_list_byid', { id: pjson.softInfo.popupAdvId }).then((response) => {
  448. if (!response.data.error) {
  449. this.popupAdvInfo = response.data.result;
  450. }
  451. })
  452. electronApi.spawnExec(['cert.exe','token']).then(res => {
  453. this.sysInfo = JSON.parse(res.stdout.toString());
  454. this.$utils.setStorage('session', this.sysInfo.windows_uuid);
  455. 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;
  456. 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;
  457. if(process.env.NODE_ENV != "development"){ // 非开发环境运行
  458. let params = {
  459. type: 3,
  460. tag: '',
  461. product_version: pjson.version,
  462. windows_uuid: this.sysInfo.windows_uuid,
  463. os_platform: this.sysInfo.os_platform,
  464. os_version: this.sysInfo.os_version,
  465. cpu: this.sysInfo.cpu,
  466. statistics_flag: '',
  467. from: this.sysInfo.from,
  468. }
  469. // 使用日志
  470. // this.$http.post(this.$api.statistics + pjson.softInfo.softMid, params).then((response) => {
  471. // })
  472. }
  473. }).catch(err => {
  474. console.log(err);
  475. let windows_uuid = this.$utils.guid();
  476. if(this.$utils.getStorage('session')){
  477. windows_uuid = this.$utils.getStorage('session');
  478. }
  479. this.$utils.setStorage('session', windows_uuid);
  480. 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;
  481. 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;
  482. });
  483. },
  484. // 刷新登录二维码
  485. refreshCode() {
  486. this.clearLoginInterval();
  487. let data = {
  488. scene_str: pjson.softInfo.softMid + ':' + this.$utils.getStorage('session')
  489. };
  490. this.$http.post(this.$api.createQrcode, data).then((response) => {
  491. if (response.data.result) {
  492. this.loginImg = response.data.result.url;
  493. this.loginExpire = response.data.result.expire_seconds;
  494. this.loginInterval = setInterval(() => {
  495. this.loginExpire--;
  496. if (this.loginExpire <= 0) {
  497. this.clearLoginInterval();
  498. }
  499. }, 1000)
  500. this.checkLoginInterval = setInterval(() => {
  501. this.checkLogin();
  502. }, 3000)
  503. }
  504. });
  505. },
  506. // 继续试用 or 开始转换
  507. next() {
  508. if(this.isClick){ // 开始转换
  509. this.$emit('export-file', true);
  510. }else{ // 继续试用
  511. this.memberModel = false;
  512. }
  513. },
  514. // 开通会员
  515. openVip() {
  516. this.clickVip = true;
  517. this.memberModel = false;
  518. if (this.$utils.getStorage('token')) {
  519. this.vipModel = true;
  520. 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();
  521. } else {
  522. this.loginModel = true;
  523. }
  524. },
  525. // 检查微信是否登录
  526. checkLogin() {
  527. let data = {
  528. scene_str: pjson.softInfo.softMid + ':' + this.$utils.getStorage('session')
  529. };
  530. this.$http.post(this.$api.checkLogin, data).then((response) => {
  531. if (response.data.error) { // 未登录
  532. this.authority.isAuthority = false;
  533. this.userInfo = {};
  534. this.$utils.setStorage('token', '');
  535. this.$utils.setStorage('userInfo', '');
  536. if(!this.loginModel && !this.limitModal) {
  537. this.memberModel = true;
  538. }
  539. }else{ // 登录成功
  540. this.$utils.setStorage('token', response.data.result);
  541. this.loginModel = false;
  542. this.getUserInfo();
  543. if(this.limitModal){ // 限时优惠 已登录
  544. this.limitLogin = true;
  545. }
  546. if (this.clickVip) { // 点击开通会员 登陆后直接展示会员购买弹窗
  547. this.vipModel = true;
  548. 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();
  549. this.clickVip = false;
  550. }else{
  551. // this.getProductInfo();
  552. }
  553. }
  554. });
  555. },
  556. // 获取用户信息
  557. getUserInfo() {
  558. this.$http.post(this.$api.getUserInfo).then((response) => {
  559. if (!response.data.error) {
  560. this.userInfo = response.data.result;
  561. this.getAuthority();
  562. }
  563. });
  564. },
  565. // 清空登录有关定时器
  566. clearLoginInterval() {
  567. clearInterval(this.loginInterval);
  568. clearInterval(this.checkLoginInterval);
  569. },
  570. // 获取用户账单
  571. getAuthority() {
  572. this.$http.post(this.$api.userBill + pjson.softInfo.softMid).then((response) => {
  573. if (!response.data.error) {
  574. this.authority = response.data.result;
  575. let nowDate = new Date().getTime();
  576. if (nowDate <= new Date(this.authority.validity_end_time).getTime() || this.authority.validity_type == 2) {
  577. this.authority.isAuthority = true;
  578. } else {
  579. this.authority.isAuthority = false;
  580. if (!this.vipModel && !this.limitModal) {
  581. this.memberModel = true;
  582. }
  583. }
  584. this.$forceUpdate();
  585. }
  586. })
  587. },
  588. // 监听会员弹窗状态
  589. vipChange(e) {
  590. },
  591. // 监听显示购买弹窗状态
  592. limitChange(e){
  593. if (e) {
  594. if(!this.limitLogin && this.limitModal){
  595. this.refreshCode();
  596. }
  597. }else{
  598. clearInterval(this.checkPayInterval)
  599. }
  600. },
  601. // 监听登录弹窗状态
  602. loginChange(e) {
  603. if (e) {
  604. this.refreshCode();
  605. } else {
  606. this.clickVip = false;
  607. this.clearLoginInterval();
  608. }
  609. },
  610. // 选择支付方式
  611. selectPaytype(index) {
  612. this.payType = index; // 1微信支付 2支付宝支付
  613. if(this.limitModal){
  614. this.selectTerm(5);
  615. }else{
  616. this.selectTerm();
  617. }
  618. },
  619. // 生成微信支付二维码
  620. createQrcode(str) {
  621. document.getElementById('qrcode').innerHTML = ''
  622. let qrcode = new QRCode('qrcode', {
  623. width: 210,
  624. height: 210, // 高度
  625. text: str, // 二维码内容
  626. render: 'canvas', // 设置渲染方式(有两种方式 table和canvas,默认是canvas)
  627. background: '#f0f',
  628. foreground: '#ff0'
  629. })
  630. },
  631. // 选择会员期限创建订单
  632. selectTerm(index) {
  633. if (index) {
  634. this.productIndex = index;
  635. }
  636. this.payMoney = this.productInfo['price' + this.productIndex];
  637. let params = {
  638. product_type: 1,
  639. id: this.productInfo.id,
  640. type: this.productIndex
  641. };
  642. clearInterval(this.checkPayInterval);
  643. this.$http.post(this.$api.target + '/order/createOrder', params).then((response) => {
  644. if (response.data.result) {
  645. this.order_no = response.data.data;
  646. if (this.payType == 1) { // 微信支付
  647. this.wepay();
  648. } else {
  649. this.alipay();
  650. }
  651. } else {
  652. this.$message.error(response.data.msg);
  653. }
  654. });
  655. },
  656. // 微信支付
  657. wepay() {
  658. this.$http.post(this.$api.target + '/pay/wechatPay', { order_no: this.order_no }).then((res) => {
  659. if (res.data.result) {
  660. if (JSON.stringify(res.data.data) != '[]') {
  661. this.wxPayErcode = res.data.data.code_url
  662. this.createQrcode(res.data.data.code_url)
  663. this.checkWxPay()
  664. }
  665. }
  666. });
  667. },
  668. // 支付宝支付
  669. alipay() {
  670. this.$http.post(this.$api.target + '/pay/alipay', { order_no: this.order_no }).then((res) => {
  671. var content = res.data; //内容
  672. this.alipayDoc = content;
  673. this.checkWxPay();
  674. });
  675. },
  676. // 每2秒检测一次是否支付成功
  677. checkWxPay() {
  678. clearInterval(this.checkPayInterval);
  679. this.checkPayInterval = setInterval(() => {
  680. this.$http.post(this.$api.target + '/order/checkIsWXPay', { order_no: this.order_no, product_type: 1 }).then((res) => {
  681. if (res.data.result) {
  682. if (JSON.stringify(res.data.data) != '[]') {
  683. if (res.data.code == '1001') {
  684. clearInterval(this.checkPayInterval);
  685. this.vipModel = false;
  686. this.limitModal = false;
  687. this.getAuthority();
  688. this.$notify({title: '支付通知',message: res.data.msg,type: 'success'});
  689. }
  690. }
  691. }
  692. });
  693. }, 2000)
  694. // 5分钟后关闭
  695. // setTimeout(() => {
  696. // clearInterval(this.checkPayInterval)
  697. // }, 1000 * 300)
  698. },
  699. // 选择菜单
  700. changeMenu(e) {
  701. if (e === 'out') {
  702. this.$confirm("是否退出登录该账号?", '提示', {
  703. type: 'warning'
  704. }).then(() => {
  705. this.$http.post(this.$api.loginOut).then((response) => {
  706. if (!response.data.error) {
  707. this.userInfo = {};
  708. this.authority.isAuthority = false;
  709. this.$utils.setStorage('token', '');
  710. this.$utils.setStorage('userInfo', '');
  711. this.$message({message: '账号已退出',type: 'success'});
  712. // this.$refs.loginFrame.contentWindow.postMessage('out', '*');
  713. }
  714. });
  715. }).catch(() => {
  716. });
  717. } else if (e === 'vip') {
  718. this.openVip();
  719. } else if (e === 'update') {
  720. this.$emit('update-soft', true);
  721. } else if (e === 'setting'){
  722. this.settingModal = true;
  723. this.saveLoading = false;
  724. // 获取设置
  725. let closeType = this.$utils.getStorage('closeType');
  726. // let numType = this.$utils.getStorage('numType');
  727. let versionType = this.$utils.getStorage('versionType');
  728. if(closeType){
  729. this.closeType = closeType;
  730. }
  731. // if(numType){
  732. // this.numType = numType;
  733. // }
  734. if(versionType){
  735. this.versionType = versionType;
  736. }
  737. }
  738. },
  739. },
  740. }
  741. </script>
  742. <style lang="scss">
  743. .vip-banner{
  744. background-color: #eee;
  745. height: 60px;
  746. width: 100%;
  747. margin-bottom: 15px;
  748. }
  749. .adv-banner{
  750. height: 150px;
  751. width: 100%;
  752. }
  753. .login-cur{
  754. margin: 0 10px;
  755. display: inline-block;
  756. cursor: pointer;
  757. }
  758. .vip-modal .ivu-icon-ios-close{
  759. color: #f8f8f8 !important;
  760. }
  761. .member-dialog{
  762. .el-dialog__header{
  763. padding: 0;
  764. }
  765. .el-dialog__body{
  766. padding: 0;
  767. }
  768. }
  769. .member-dialog1{
  770. .el-dialog__headerbtn{
  771. top: 13px;
  772. }
  773. }
  774. .member-dialog2{
  775. border-radius: 20px !important;
  776. overflow: hidden;
  777. }
  778. .micon-list{
  779. padding: 20px 10px;
  780. background: linear-gradient(to bottom, #fdd6ca69, #ffffff);
  781. border-radius: 20px;
  782. }
  783. .micon-item{
  784. text-align: center;
  785. font-size: 14px;
  786. font-weight: 600;
  787. color: #ec6b44;
  788. }
  789. .micon-btn{
  790. text-align: center;
  791. padding-bottom: 20px;
  792. }
  793. .soft-mtitle{
  794. font-size: 16px;
  795. line-height: 40px;
  796. font-weight: 600;
  797. padding: 0 15px;
  798. }
  799. </style>