99 lines
2.1 KiB
JavaScript
99 lines
2.1 KiB
JavaScript
// page/component/new-pages/user/user.js
|
|
Page({
|
|
data: {
|
|
thumb: '',
|
|
nickname: '',
|
|
orders: [],
|
|
hasAddress: false,
|
|
address: {}
|
|
},
|
|
onLoad() {
|
|
var self = this;
|
|
wx.getUserProfile({
|
|
desc: '用于完善会员资料', // 这里必须声明用途
|
|
success: function (res) {
|
|
self.setData({
|
|
thumb: res.userInfo.avatarUrl,
|
|
nickname: res.userInfo.nickName
|
|
});
|
|
// 你可以将用户信息发送到后端或缓存到本地
|
|
},
|
|
fail: function (err) {
|
|
wx.showToast({
|
|
title: '用户拒绝了授权',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
/**
|
|
* 发起请求获取订单列表信息
|
|
*/
|
|
wx.request({
|
|
url: 'http://www.gdfengshuo.com/api/wx/orders.txt',
|
|
success(res) {
|
|
self.setData({
|
|
orders: res.data
|
|
})
|
|
}
|
|
})
|
|
},
|
|
/**
|
|
* 获取用户信息
|
|
*/
|
|
getUserProfile() {
|
|
var self = this;
|
|
wx.getUserProfile({
|
|
desc: '用于完善会员资料', // 这里必须声明用途
|
|
success: function (res) {
|
|
self.setData({
|
|
thumb: res.userInfo.avatarUrl,
|
|
nickname: res.userInfo.nickName
|
|
});
|
|
// 你可以将用户信息发送到后端或缓存到本地
|
|
},
|
|
fail: function (err) {
|
|
wx.showToast({
|
|
title: '用户拒绝了授权',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
},
|
|
onShow() {
|
|
var self = this;
|
|
/**
|
|
* 获取本地缓存 地址信息
|
|
*/
|
|
wx.getStorage({
|
|
key: 'address',
|
|
success: function (res) {
|
|
self.setData({
|
|
hasAddress: true,
|
|
address: res.data
|
|
})
|
|
}
|
|
})
|
|
},
|
|
/**
|
|
* 发起支付请求
|
|
*/
|
|
payOrders() {
|
|
wx.requestPayment({
|
|
timeStamp: 'String1',
|
|
nonceStr: 'String2',
|
|
package: 'String3',
|
|
signType: 'MD5',
|
|
paySign: 'String4',
|
|
success: function (res) {
|
|
console.log(res)
|
|
},
|
|
fail: function (res) {
|
|
wx.showModal({
|
|
title: '支付提示',
|
|
content: '<text>',
|
|
showCancel: false
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}) |