204 lines
4.1 KiB
JavaScript
204 lines
4.1 KiB
JavaScript
// packageB/member/handWithdraw/handWithdraw.js
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
show1: false,
|
|
member_integral: 0,
|
|
addressData: {},
|
|
radio: "1",
|
|
address: "",
|
|
cash: "",
|
|
address_id: "",
|
|
integral_name: ""
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
this.getData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
},
|
|
show1btn() {
|
|
this.setData({
|
|
show1: true
|
|
});
|
|
},
|
|
sureCash() {
|
|
if (!this.data.address) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '请选择提现地址',
|
|
duration: 1500
|
|
});
|
|
return;
|
|
}
|
|
if (!this.data.cash) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '请输入提现数额',
|
|
duration: 1500
|
|
});
|
|
return;
|
|
}
|
|
if (Number(this.data.cash) < 0) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '输入的提现数额需大于0',
|
|
duration: 1500
|
|
});
|
|
return;
|
|
}
|
|
if (Number(this.data.cash) > Number(this.data.member_integral)) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '输入的提现数额超过已有的消费积分',
|
|
duration: 1500
|
|
});
|
|
return;
|
|
}
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.integral.Frontend.Modules.Integral.Controllers.integral-manual-cash-withdrawal.index");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
change_value: this.data.cash,
|
|
address_id: this.data.address_id
|
|
},
|
|
success: (resdata)=> {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '提现成功',
|
|
duration: 1500
|
|
});
|
|
wx.navigateTo({
|
|
url: '/packageB/member/Integral_love/Integral_love',
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
cashBtn() {
|
|
let val = e.detail.value;
|
|
this.setData({
|
|
name: val
|
|
});
|
|
},
|
|
selectAddress(e) {
|
|
let item = e.currentTarget.dataset.item;
|
|
this.setData({
|
|
address: item.address,
|
|
address_id: item.id,
|
|
show1: false
|
|
});
|
|
},
|
|
onClose(e){
|
|
this.setData({
|
|
show1:false
|
|
});
|
|
},
|
|
toAdd(e) {
|
|
wx.navigateTo({
|
|
url: '/packageB/member/addressAdd/addressAdd',
|
|
});
|
|
},
|
|
getData() {
|
|
var that = this;
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.integral.Frontend.Modules.Integral.Controllers.integral-manual-cash-withdrawal.pageIndex");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: {
|
|
change_value: this.data.cash,
|
|
address_id: this.data.address_id
|
|
},
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
that.setData({
|
|
integral_name: res.data.integral_name,
|
|
member_integral: res.data.member_integral,
|
|
addressData: res.data.addressData
|
|
});
|
|
let addressData = that.data.addressData;
|
|
addressData.map((item, index, key) => {
|
|
if (item.is_default == 1) {
|
|
that.setData({
|
|
radio: item.id,
|
|
address: item.address,
|
|
address_id: item.id
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
});
|