index.js
1.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
let App = getApp();
Page({
data: {
userInfo: {
id: 0,
avatar: '/assets/img/avatar.png',
nickname: '游客',
balance: 0,
score: 0,
level: 0,
group_id: 1,
mobile:"NoLoginData",
},
datanum:[],
},
onLoad: function (options) {
var that = this;
App.Log_after_fun(function (ret) {
if (App.globalData.userInfo) {
that.setData({ userInfo: App.globalData.userInfo });
}
});
},
onShow: function () {
//刷新 订单的数量信息
let that = this;
App._get('order/Get_order_num', {}, function (result) {
that.setData({
datanum: result.data
});
});
},
onGotUserInfo: function (e) {
console.log(e.detail.errMsg);
console.log(e.detail.userInfo);
console.log(e.detail.rawData);
if (e.detail.userInfo == undefined) {
return;
}
//这里先本地赋值;
App.globalData.userInfo.avatar = e.detail.userInfo.avatarUrl;
App.globalData.userInfo.nickname = e.detail.userInfo.nickName;
App.globalData.userInfo.mobile = App.globalData.userInfo.mobile == "NoLoginData" ? '' : App.globalData.userInfo.mobile;
//提交到 服务器
var token = wx.getStorageSync('token') || '';
var that = this;
wx.request({
url: App.api_url + 'user/Updata_user_hawk',
data: {
userInfo: e.detail.rawData,
mobile: App.globalData.userInfo.mobile,
token: token
},
method: 'post',
header: {
"Content-Type": "application/x-www-form-urlencoded",
},
success: function (lres) {
console.log(lres);
that.setData({ userInfo: App.globalData.userInfo });
}
});
},
})