app.js
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-01-03 14:25:43
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-01-04 17:57:08
* @FilePath: \miniprogram\app.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// app.js
// 初始化sentry
// import sentryInit from "~/utils/sentryConfig/sentryInit";
// sentryInit();
import router from "./router/index.js";
import util from "./utils/util.js";
import eventbus from "./utils/evenbus";
// import USER from '~/api/usersApi/index'
import TRACK from "./utils/Track";
import Tracking from '~/utils/tracking'
const $Tracking = new Tracking()
import {
busassistantApi
} from './api/api'
// 判断小程序是否需要更新
import getUpdateManager from "./utils/lib/wxUpdateManager";
import {
setPageParams,
login
} from "~/utils/appFn/index";
import {
setSystem_info
} from "~/utils/cache/storageApi";
// 微信小程序异步使用 使用方法wx.pro+对应api即可 promisify 这个是配置单独某个api
// import { promisifyAll } from './utils/lib/wx-promise-pro'
// promisifyAll()
// 实例化对象存储
import {
Storage
} from "./utils/cache/storage";
const $Storage = new Storage();
import wxApi from "./utils/utils_wx";
const { createVersionConfig } = require('./utils/versionConfig.js')
import {
reportClick,
reportStop,
reportHide
} from './api/sopApi'
App({
onLaunch(options) {
/**挂载到wx对象 */
wx.$authStatus = false;
wx.$util = util;
wx.$router = router;
wx.$eventbus = eventbus;
wx.$storage = $Storage; /** 挂载全局缓存方法 */
wx.$api = wxApi;
wx.$imgUrl =
"https://img02.glsx.com.cn/weapp/resource/miniprogram-test/glsx/";
// wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/'
wx.$Track = new TRACK(options, {
onLoadFun: [
reportClick
],
onHideFun:[
reportHide
]
});
wx.$tracking = $Tracking
// wx.$imgUrl = 'https://img01.glsx.com.cn/weapp/resource/dj-shopmall/'
// 存储设备信息
wx.$versionConfig = createVersionConfig({
request: {
baseUrl: 'https://config-center-backend.glsx.com.cn/glsxAdmin/config'
}
})
setSystem_info();
const {
scene,
query: {
pageType
}
} = wx.getEnterOptionsSync(),
userInfo = $Storage.get("userInfo");
if (userInfo && userInfo.userType && ![1011, 1012, 1013].includes(scene)) {
if (
(options.path.includes("shopMall") ||
options.path.includes("packageShopmall")) &&
!options.path.includes("packageExpandedGold") &&
!pageType && !options.path.includes("GHUserLogin") && !options.path.includes("ghEquity") && options.path != "packageShopmall/packageMine/pages/integral/index/index"
) {
setTimeout(() => {
wx.reLaunch({
url: "/packageStoreAssistant/packageAuth/pages/authentication/loading/loading",
});
}, 100);
}
}
},
onShow(options) {
console.log(options)
const {
path
} = options;
getUpdateManager();
setPageParams(options);
const noPath = ["pages/tab", "pages/crowdfunding", "packageStoreAssistant", "pages/blank/blank", "packageShopmall/packageRescue/pages/accident/index/index", 'packageShopmall/packageExpandedGold/pages/activity/index/index', 'packageShopmall/packageMine/pages/integral/index/index']
try {
noPath.map(e => {
if (path.startsWith(e)) throw true
})
} catch (error) {
return
}
login()
},
// 获取公共数据
getBaseData() {
console.log("method")
return new Promise((resolve, reject) => {
busassistantApi.getDiscoverList().then(res => {
console.log(res, '555');
resolve(res.data)
})
})
},
/**兼容旧链接 */
onPageNotFound(res) {
console.log(res, "不存在的页面");
wx.reLaunch({
url: `/pages/pageNotFound/pageNotFound?res=${encodeURIComponent(
JSON.stringify(res)
)}`,
});
},
async getVersionInfo(request) {
if (request) this.globalData.versionData = null
const {
versionData
} = this.globalData
if (versionData) return versionData
else {
const res = await wx.$versionConfig.get({
moduleUrl: 'mini-merchant',
env: 'update'
})
this.globalData.versionData = res
return res
}
},
globalData: {
merchantId: "101430",
cheapGoodsList: [],
isLoadingOver: false,
pageParam: {
appearance: 1,
pageSize: 0,
pageCount: 3
},
versionData: null,
ROUTE_QUERY: {},
},
onHide() {
util.customerbehavior(2)
}
})