forked from iamdarcy/hioshop-miniprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
47 lines (47 loc) · 1.25 KB
/
app.js
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
var util = require('utils/util.js');
var api = require('config/api.js');
App({
data: {
deviceInfo: {}
},
onLaunch: function () {
this.data.deviceInfo = wx.getSystemInfoSync();
console.log(this.data.deviceInfo);
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: (res) => {
util.request(api.AuthLoginByWeixin, {
code: res.code
}, 'POST').then(function (res) {
if (res.errno === 0) {
let userInfo = res.data.userInfo;
wx.setStorageSync('token', res.data.token);
wx.setStorageSync('userInfo', userInfo);
}
});
},
});
let that = this;
wx.getSystemInfo({ // 获取页面的有关信息
success: function (res) {
wx.setStorageSync('systemInfo', res)
var ww = res.windowWidth;
var hh = res.windowHeight;
that.globalData.ww = ww;
that.globalData.hh = hh;
}
});
},
globalData: {
userInfo: {
nickname: '点我登录',
username: '点击登录',
avatar: 'http://lucky-icon.meiweiyuxian.com/hio/default_avatar_big.png'
},
token: '',
}
})