Files
venue_wx/pages/myAccount/index.js
2021-05-27 22:43:12 +08:00

176 lines
3.1 KiB
JavaScript

// pages/myAccount/index.js
const app = getApp();
import {
getCurrentPageUrl
} from './../../utils/util.js'
Page({
/**
* 页面的初始数据
*/
data: {
selectIndex: 0,
member: {},
recharges: [],
isWxLogin: false,
gohome: true,
isUnClick: false,
options: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
options: options
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
this.getData();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
return {
title: '智慧云馆'
}
},
// 余额提现
pushWithdraw() {
wx.navigateTo({
url: '/pages/withdrawal/index?money=' + this.data.member.money,
})
},
// 我的账单
pushBills() {
wx.navigateTo({
url: '/pages/myBills/index',
})
},
// 选择充值金额
selectPrice(e) {
let index = e.currentTarget.dataset.index;
this.setData({
selectIndex: index
})
},
// 点击微信支付
clickBuy() {
if (this.data.isUnClick) {
return;
}
this.data.isUnClick = true;
app.$api.orderRecharge({
rechargeId: this.data.recharges[this.data.selectIndex].id
}).then(res => {
app.$pay.wxPay(res.pay).then(res => {
if (this.data.options.isPass == 1) {
wx.redirectTo({
url: '/pages/facialCapturing/index?isPass=' + 1,
})
} else {
this.getData();
this.data.isUnClick = false;
}
}, err => {
this.data.isUnClick = false;
})
}, err => {
if (err.data.err_code == 30022) {
this.setData({
isWxLogin: true,
})
}
this.data.isUnClick = false;
})
},
// 获取数据
getData() {
wx.showLoading({
title: '加载中...',
mask: true,
})
app.$api.recharges({}).then(res => {
this.setData({
member: res.member,
recharges: res.recharges
})
}, err => {});
},
// 取消授权登录
cancelDeleteDialog() {
this.setData({
isWxLogin: false
})
},
// 授权微信
getUserInfo(e) {
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
app.$pay.payWxLoing(res).then(res => {
wx.showToast({
title: '绑定成功',
duration: 2000,
})
this.setData({
isWxLogin: false
})
}, err => {
this.setData({
isWxLogin: false
})
})
}
});
}
})