263 lines
7.6 KiB
JavaScript
263 lines
7.6 KiB
JavaScript
|
|
var app = getApp()
|
||
|
|
var that=null
|
||
|
|
var sopenFrame=null
|
||
|
|
Page( {
|
||
|
|
data: {
|
||
|
|
loadingHidden:false,
|
||
|
|
umoney:0.00,
|
||
|
|
umoney0:0.00,
|
||
|
|
sxfmoney:0.00,
|
||
|
|
title:"您的余额",
|
||
|
|
savedisable:"",
|
||
|
|
savebutton:"确认",
|
||
|
|
mybalance:[],
|
||
|
|
Start: 0,
|
||
|
|
t:0
|
||
|
|
},
|
||
|
|
|
||
|
|
onLoad: function(options) {
|
||
|
|
that = this
|
||
|
|
if(options.t){
|
||
|
|
that.setData({
|
||
|
|
t:options.t
|
||
|
|
});
|
||
|
|
}
|
||
|
|
if(that.data.t==1){
|
||
|
|
wx.setNavigationBarTitle({
|
||
|
|
title: "兑换积分划转流量积分"
|
||
|
|
})
|
||
|
|
that.setData({
|
||
|
|
title:"您的积分"
|
||
|
|
});
|
||
|
|
}else if(that.data.t==2){
|
||
|
|
wx.setNavigationBarTitle({
|
||
|
|
title: "流量积分划转KSD"
|
||
|
|
})
|
||
|
|
that.setData({
|
||
|
|
title:"您的积分"
|
||
|
|
});
|
||
|
|
}else if(that.data.t==3){
|
||
|
|
wx.setNavigationBarTitle({
|
||
|
|
title: "KSD划转流量积分"
|
||
|
|
})
|
||
|
|
that.setData({
|
||
|
|
title:"您的KSD"
|
||
|
|
});
|
||
|
|
}else{
|
||
|
|
wx.setNavigationBarTitle({
|
||
|
|
title: "余额划转兑换积分"
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
that.rdata()
|
||
|
|
|
||
|
|
that.clearCache();//清本页缓存
|
||
|
|
|
||
|
|
that.getlist(0);
|
||
|
|
},rdata: function() {
|
||
|
|
var userId = wx.getStorageSync("userId")
|
||
|
|
var LoginId = wx.getStorageSync("LoginId")
|
||
|
|
var userInfodata = wx.getStorageSync("userInfo")
|
||
|
|
if(userId&&LoginId&&userInfodata){
|
||
|
|
var userdata = JSON.parse(userInfodata)
|
||
|
|
that.setData({
|
||
|
|
phone:userdata.Phone
|
||
|
|
})
|
||
|
|
var umoney = userdata.xjjye
|
||
|
|
var sxfmoney=0
|
||
|
|
if(that.data.t==1){
|
||
|
|
umoney = userdata.mfye
|
||
|
|
}
|
||
|
|
var TXEnable = userdata.ZHEnable;
|
||
|
|
|
||
|
|
if(TXEnable=="1"){
|
||
|
|
that.setData({
|
||
|
|
savebutton:"暂时不能划转",
|
||
|
|
savedisable:"disabled"
|
||
|
|
})
|
||
|
|
}
|
||
|
|
that.setData({
|
||
|
|
umoney:umoney,
|
||
|
|
sxfmoney:sxfmoney,
|
||
|
|
loadingHidden:true
|
||
|
|
})
|
||
|
|
|
||
|
|
//that.getje0()
|
||
|
|
|
||
|
|
}
|
||
|
|
}, // 下拉刷新
|
||
|
|
onPullDownRefresh: function () {
|
||
|
|
//在当前页面显示导航条加载动画
|
||
|
|
wx.showNavigationBarLoading();
|
||
|
|
//显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
|
||
|
|
wx.showLoading({
|
||
|
|
title: '刷新中...',
|
||
|
|
})
|
||
|
|
that.clearCache();
|
||
|
|
that.getlist(1);//第一次加载数据
|
||
|
|
},
|
||
|
|
|
||
|
|
// 页面上拉触底事件(上拉加载更多)
|
||
|
|
onReachBottom: function () {
|
||
|
|
that.setData({
|
||
|
|
loadingHidden:false
|
||
|
|
});
|
||
|
|
that.getlist(2);//后台获取新数据并追加渲染
|
||
|
|
},
|
||
|
|
|
||
|
|
// 清缓存
|
||
|
|
clearCache:function(){
|
||
|
|
that.setData({
|
||
|
|
loadingHidden:false,
|
||
|
|
Start: 0,
|
||
|
|
mybalance:[]
|
||
|
|
});
|
||
|
|
},getlist: function(gp) {
|
||
|
|
var userId = wx.getStorageSync("userId")
|
||
|
|
var LoginId = wx.getStorageSync("LoginId")
|
||
|
|
wx.request({
|
||
|
|
url: app.globalData.apiurl + "/xapiajax.ashx",
|
||
|
|
data: {
|
||
|
|
action:"getzhuanhuanlist",
|
||
|
|
Start:that.data.Start,
|
||
|
|
userId:(userId==null?"":userId),
|
||
|
|
LoginId:(LoginId==null?"":LoginId)
|
||
|
|
},
|
||
|
|
method:"GET",
|
||
|
|
dataType:"json",
|
||
|
|
header: {
|
||
|
|
"content-type": "application/json" // 默认值
|
||
|
|
},
|
||
|
|
success (res) {
|
||
|
|
if(res.data.status==1){
|
||
|
|
var tmpArr = null;
|
||
|
|
tmpArr = that.data.mybalance;
|
||
|
|
tmpArr.push.apply(tmpArr,res.data.data);
|
||
|
|
that.setData({
|
||
|
|
mybalance: tmpArr,
|
||
|
|
Start: that.data.Start+res.data.data.length,
|
||
|
|
loadingHidden:true
|
||
|
|
})
|
||
|
|
|
||
|
|
}
|
||
|
|
if(gp==1){
|
||
|
|
//隐藏loading 提示框
|
||
|
|
wx.hideLoading();
|
||
|
|
//隐藏导航条加载动画
|
||
|
|
wx.hideNavigationBarLoading();
|
||
|
|
//停止下拉刷新
|
||
|
|
wx.stopPullDownRefresh();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},getje0:function(e) {
|
||
|
|
var money0=0.00;
|
||
|
|
if(e.detail.value!=""){
|
||
|
|
money0=app.changeTwoDecimal_f(parseFloat(e.detail.value)*that.data.sxfmoney);
|
||
|
|
//money0=app.changeTwoDecimal_f(parseFloat(e.detail.value)-parseFloat(e.detail.value)*that.data.sxfmoney/100);
|
||
|
|
}
|
||
|
|
that.setData({
|
||
|
|
money0:money0
|
||
|
|
})
|
||
|
|
|
||
|
|
},withdrawal:function(e) {
|
||
|
|
var userId = wx.getStorageSync("userId")
|
||
|
|
var LoginId = wx.getStorageSync("LoginId")
|
||
|
|
var userInfodata = wx.getStorageSync("userInfo")
|
||
|
|
if(userId&&LoginId&&userInfodata){
|
||
|
|
var userInfo = JSON.parse(userInfodata)
|
||
|
|
|
||
|
|
var txje = e.detail.value.txje
|
||
|
|
var pwd = e.detail.value.txpwd
|
||
|
|
var b=true
|
||
|
|
|
||
|
|
if(b){
|
||
|
|
if(txje==null || txje==""){
|
||
|
|
b=false
|
||
|
|
wx.showToast({
|
||
|
|
title: "兑换数量不能为空!",
|
||
|
|
icon: "none",
|
||
|
|
duration: 3000
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(b){
|
||
|
|
if(pwd==null || pwd==""){
|
||
|
|
b=false
|
||
|
|
wx.showToast({
|
||
|
|
title: "安全密码不能为空!",
|
||
|
|
icon: "none",
|
||
|
|
duration: 3000
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if(b){
|
||
|
|
|
||
|
|
if(b){
|
||
|
|
if(that.data.savebutton=="请稍候..."){
|
||
|
|
b=false
|
||
|
|
wx.showToast({
|
||
|
|
title: "请稍候...",
|
||
|
|
icon: "none",
|
||
|
|
duration: 3000
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if(b){
|
||
|
|
that.setData({
|
||
|
|
savebutton:"请稍候..."
|
||
|
|
})
|
||
|
|
wx.request({
|
||
|
|
url: app.globalData.apiurl + "/xapiajax.ashx",
|
||
|
|
data: {
|
||
|
|
action:"zhuanhuan",
|
||
|
|
userId:(!userId?"":userId),
|
||
|
|
LoginId:(!LoginId?"":LoginId),
|
||
|
|
t:that.data.t,
|
||
|
|
pwd:pwd,
|
||
|
|
je:txje
|
||
|
|
},
|
||
|
|
method:"POST",
|
||
|
|
dataType:"json",
|
||
|
|
header: {
|
||
|
|
"content-type": "application/x-www-form-urlencoded" // 默认值
|
||
|
|
},
|
||
|
|
success (res) {
|
||
|
|
if(res.data.status==1){
|
||
|
|
wx.setStorageSync('userInfo', JSON.stringify(res.data.userInfo))
|
||
|
|
app.globalData.IFRefreshindex=1;
|
||
|
|
app.globalData.IFRefreshmy=1;
|
||
|
|
app.globalData.IFRefreshmybalance=1;
|
||
|
|
wx.showModal({
|
||
|
|
title: "操作提示",
|
||
|
|
content: res.data.msg,
|
||
|
|
showCancel:false,
|
||
|
|
success (res0) {
|
||
|
|
if (res0.confirm) {
|
||
|
|
|
||
|
|
wx.navigateBack({})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}else{
|
||
|
|
wx.showToast({
|
||
|
|
title: res.data.msg,
|
||
|
|
icon: "none",
|
||
|
|
duration: 3000
|
||
|
|
})
|
||
|
|
}
|
||
|
|
that.setData({
|
||
|
|
savebutton:"确认"
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
})
|