| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import {
- ApiModel
- } from './utils/Api';
- import {
- evidence,
- update
- } from './utils/pay';
- App({
- onLaunch: function () {
- wx.getSystemInfo({
- success: e => {
- this.globalData.StatusBar = e.statusBarHeight;
- let custom = wx.getMenuButtonBoundingClientRect();
- this.globalData.Custom = custom;
- this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
- }
- })
- },
- initSocket() {
- let that = this;
- this.globalData.SocketTask = wx.connectSocket({
- url: this.globalData.http.baseUrl.replace("https", "wss").replace("http", "ws") + '/yos/webSocket/' + wx.getStorageSync('userMsg').token,
- complete: (res) => {
- console.log(res)
- }
- })
- //获取领域对应账户
- /* this.globalData.http.basic({
- "classname": "sysmanage.develop.optiontype.optiontype",
- "method": "optiontypeselect",
- "content": {
- "pageNumber": 1,
- "pageSize": 9999,
- "typename": "domainrelatedaccounts"
- }
- }).then(res => {
- console.log("查询领域对应列表", res)
- wx.setStorageSync('domainrelatedaccounts', res.msg == '成功' ? res.data : [])
- }) */
- console.log(this.globalData.http.baseUrl.replace("https", "wss").replace("http", "ws") + '/yos/webSocket/' + wx.getStorageSync('userMsg').token)
- this.globalData.SocketTask.onOpen(function (res) {
- that.globalData.socketEstablish = true;
- })
- this.globalData.SocketTask.onMessage(function (res) {
- that.globalData.socket.callback(res)
- let data = JSON.parse(res.data);
- if (data.message.type == 'pay') update();
- })
- this.globalData.SocketTask.onError(function (res) {
- that.globalData.socketEstablish = false;
- })
- this.globalData.SocketTask.onClose(function (res) {
- that.globalData.socketEstablish = false;
- })
- },
- onShow() {
- const updateManager = wx.getUpdateManager()
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- console.log("是否有新版本", res.hasUpdate)
- })
- updateManager.onUpdateReady(function () {
- wx.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- updateManager.onUpdateFailed(function () {
- // 新版本下载失败
- })
- },
- globalData: {
- http: new ApiModel, //挂载接口文件
- queryPer: require("./utils/queryPermissions"), //权限查询
- handleSelect: null, //处理选择结果函数
- collectCount: "", //购物车商品数量
- getCollectCount: null, // 获取购物车数量
- socketEstablish: false, //是否已经建立socket
- SocketTask: '', // Socket方法
- remindchangepassword_str: "",
- refreshData: null, //保存首页更新应用信息函数
- evidence
- },
- })
|