一、main.js

 1 import Vue from 'vue'
 2 import App from './App'
 3 import router from './router'
 4 import Vuex from 'vuex'
 5 import store from './store'
 6 import axios from 'axios'
 7 import VueAwesomeSwiper from 'vue-awesome-swiper'
 8 import 'swiper/dist/css/swiper.css'
 9 // import VueSocketio from 'vue-socket.io'
10 
11 Vue.config.productionTip = false
12 Vue.use(Vuex)
13 // Vue.use(VueSocketio)
14 
15 
16 var ls_mac = "_ioBox_mac_code_key_";
17 var ls_proid = "_io_ioBox_pro_id_key_";
18 var ls_protitle = "_io_ioBox_title_key_";
19 
20 //检查mac地址缓存
21 var macCode = localStorage.getItem(ls_mac);
22 console.log("macCode",macCode)
23 if(!macCode){
24   console.log("macCode222",macCode)
25   //没有则生成mac,提交设备号
26   NWBridge && NWBridge.getMac((mac) => {
27       //alert(str);
28       macCode = mac;
29       localStorage.setItem(ls_mac,macCode);
30       ini && ini.setString('',macCode,()=>{},ini.fileName.macCode);
31     var zipFormData = new FormData();
32     console.log("macCode333",macCode)
33     zipFormData.append('mac',macCode);
34     zipFormData.append('title',"北京65box(抽奖)");
35 
36     return axios.post('http://iboxmanager.ioart.cn/Api/add/module/device/key/dac509bd90a82719a3569291e12c24a6f1af4bac/',zipFormData).then((res) => {
37       console.log("macCode444",res.data.error_code)
38       console.log("macCode555",res.data.error_code == 0)
39       if (res.data.error_code == 0) {
40 
41         NWBridge.checkUpdate();
42         //增加监听
43         autoUpdateSocket(macCode);
44       }
45     }).catch(function (error) {
46       console.log(error);
47     })
48 
49     }
50   );
51 }else{
52   //检查更新
53   NWBridge.checkUpdate();
54   //增加监听
55   autoUpdateSocket(macCode);
56 }
57 
58 
59 function autoUpdateSocket(mac) {
60   //监听 用于自动升级处理
61   var socket = io('http://msgsender.ioart.cn:2120');
62   //建立连接后
63   socket.on('connect', function() {
64     socket.emit('login',mac);
65   });
66   //接收通信
67   socket.on('coffeeorder', function(msg){
68     NWBridge.checkUpdate();
69   });
70 }
71 
72 
73 /* eslint-disable no-new */
74 new Vue({
75   el: '#app',
76   router,
77   store,
78   components: { App },
79   template: '<App/>'
80 })
View Code

相关文章:

  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-12-19
  • 2021-06-24
猜你喜欢
  • 2021-11-18
  • 2021-06-27
  • 2022-02-09
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
相关资源
相似解决方案