| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 | 
							- import { Component } from 'react'
 
- import { Provider } from 'react-redux'
 
- import configStore from './store'
 
- import './app.less'
 
- import 'taro-skeleton/dist/index.css'
 
- import Taro from "@tarojs/taro";
 
- import { getWxConfig } from './utils/servers/servers';
 
- import 'taro-ui/dist/style/components/drawer.scss';
 
- import 'taro-ui/dist/style/components/list.scss';
 
- const store = configStore()
 
- class App extends Component {
 
-   componentDidMount() {
 
-     //在页面加载完成的生命周期加入这段代码,Taro在componentDidMount生命周期中使用,原生在onLoad中使用
 
-     const updateManager = Taro.getUpdateManager()
 
-     updateManager.onCheckForUpdate(function (res) {
 
-       // 请求完新版本信息的回调
 
-       //console.log('请求完新版本信息的回调')
 
-       // console.log(res.hasUpdate);
 
-     })
 
-     updateManager.onUpdateReady(function () {
 
-       Taro.showModal({
 
-         title: '更新提示',
 
-         content: '新版本已经准备好,是否重启应用?',
 
-         success(res) {
 
-           if (res.confirm) {
 
-             // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
 
-             updateManager.applyUpdate()
 
-           }
 
-         }
 
-       })
 
-     })
 
-     updateManager.onUpdateFailed(function () {
 
-       // 新版本下载失败
 
-       console.log('新版本下载失败')
 
-       // errorReport(ERROREVENTS.VERSION_UPGRADE_FAILED, '新版本下载失败');
 
-     })
 
-   }
 
-   componentDidShow() {
 
-     Taro.eventCenter.on('getStorageSync', () => {
 
-       let token = Taro.getStorageSync('token');
 
-       if (token) {
 
-         this.getStorageSync();
 
-       }
 
-     })
 
-     let token = Taro.getStorageSync('token');
 
-     if (token) {
 
-       this.getStorageSync();
 
-     }
 
-     this.getWxConfig();
 
-   }
 
-   componentDidHide() {
 
-     Taro.closeSocket();
 
-   }
 
-   getWxConfig() {
 
-     getWxConfig({}).then(v => {
 
-       if (v.error.length === 0) {
 
-         Taro.setStorageSync("wxConfig", v.data || {});
 
-       } else {
 
-         Taro.showToast({
 
-           title: v.error[0].message,
 
-           icon: 'none'
 
-         })
 
-       }
 
-     }).catch((error) => {
 
-       console.log(error)
 
-     })
 
-   }
 
-   getStorageSync() {
 
-     let token = Taro.getStorageSync('token');
 
-     //建立连接
 
-     Taro.connectSocket({
 
-       header: {
 
-         'token': token,
 
-       },
 
-       // 生产
 
-       url: 'wss://bm.jishutao.com/webSocketServer',
 
-       // 本地
 
-       // url: 'wss://172.16.1.199:8080/webSocketServer'
 
-       // 测试
 
-       // url: 'wss://uat.jishutao.com/webSocketServer'
 
-     })
 
-     //连接成功
 
-     Taro.onSocketOpen(function () {
 
-       console.log('连接成功')
 
-     })
 
-     //接收数据
 
-     Taro.onSocketMessage(function (data) {
 
-       console.log('接收数据', data)
 
-       Taro.eventCenter.trigger('GoPuncsshIn', data)
 
-     })
 
-     //连接失败
 
-     Taro.onSocketError(function () {
 
-       console.log('websocket连接失败!');
 
-     })
 
-     //连接关闭
 
-     Taro.onSocketClose(function () {
 
-       console.log('websocket连接关闭!');
 
-     })
 
-   }
 
-   componentDidCatchError() { }
 
-   // 在 App 类中的 render() 函数没有实际作用
 
-   // 请勿修改此函数
 
-   render() {
 
-     return (
 
-       <Provider store={store}>
 
-         {this.props.children}
 
-       </Provider>
 
-     )
 
-   }
 
- }
 
- export default App
 
 
  |