app.js
1.73 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
//app.js
let fetchApi = require('./http/fetch-api.js');
let api = require('./http/api');
let config = require('./config');
let router = require('./router/index');
let store = require('./utils/stroage');
require('./http/mock-data');
App({
get: fetchApi.fetch,
post: (params) => {
params.method = 'post';
return fetchApi.fetch(params);
},
api: api,
config: config,
router: router,
store: store,
onLaunch: function () {
this.share()
},
globalData: {
indexInfo: null,
userInfo: null,
wxcode: store.getItem("wxcode"),
tlMemberCode: "",
giftInfo: null, // 来自 gift-shop
addressEditInfo: null, // 编辑时的临时对象
},
//重写分享方法
share: function () {
//监听路由切换
//间接实现全局设置分享内容
wx.onAppRoute(function (res) {
//获取加载的页面
let pages = getCurrentPages();
//获取当前页面的对象
let view = pages[pages.length - 1];
let data;
if (view) {
data = view.data;
if (!data.isOverShare) {
data.isOverShare = true;
view.onShareAppMessage = function (res) {
//分享配置
return {
title: '志亮·深士照明',
path: 'pages/index/index'
};
};
}
}
})
},
// 获取用户基本信息
queryIndex(query = {
auth: true
}) {
return new Promise((resolve, reject) => {
this.post({
url: this.api.member,
data: {},
loading: true,
}).then((result) => {
this.globalData.indexInfo = result;
// this.globalData.userInfo = result.userInfo;
resolve(result)
}).catch((err) => {
reject();
});
});
}
})