header.vue 26 KB

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