130 lines
4.2 KiB
JavaScript
130 lines
4.2 KiB
JavaScript
var e = getApp(), t = e.requirejs("core");
|
|
|
|
Page({
|
|
data: {
|
|
type: 0,
|
|
search: "",
|
|
ipic: "",
|
|
canMy: 99,
|
|
dialogflg: !1,
|
|
scd: 0,
|
|
timer: null,
|
|
lock: !1
|
|
},
|
|
onLoad: function(t) {
|
|
var a;
|
|
t.type || wx.switchTab({
|
|
url: "/pages/member/index/index"
|
|
}), "" != (a = e.getCache("transfer_account", "")) && (this.setData({
|
|
set: a
|
|
}), 2 == t.type ? 0 == a.service_recharge_price && "" == a.service_recharge_price || (1 == a.service_recharge_type ? this.setData({
|
|
service_charge: a.service_recharge_price + "%"
|
|
}) : this.setData({
|
|
service_charge: a.service_recharge_price
|
|
})) : this.setData({
|
|
service_charge: 0
|
|
})), this.setData({
|
|
type: t.type,
|
|
search: t.search,
|
|
avatar: t.avatar,
|
|
nickname: t.nickname,
|
|
mobile: t.mobile,
|
|
id: t.id,
|
|
credit: 0
|
|
}), this.getUserCredit(t.type), this.getSet(), wx.setNavigationBarTitle({
|
|
title: (2 == +t.type ? "余额" : "积分") + "转账"
|
|
}), "" != (a = e.getCache("transfer_account", "")) && this.setData({
|
|
set: a
|
|
});
|
|
},
|
|
onShow: function() {
|
|
this.setData({
|
|
lock: !1
|
|
});
|
|
},
|
|
resetAccount: function() {
|
|
wx.navigateBack({
|
|
delta: 2,
|
|
complete: function(e) {}
|
|
});
|
|
},
|
|
do: function(e) {
|
|
var a = this;
|
|
0 !== this.data.scd || this.data.lock || (a.setData({
|
|
lock: !0
|
|
}), t.get("transfer_account/transfer", {
|
|
type: this.data.type,
|
|
total: this.data.ipic,
|
|
to_userid: this.data.id
|
|
}, function(e) {
|
|
0 == e.error ? (a.setData({
|
|
lock: !1
|
|
}), wx.navigateTo({
|
|
url: "/pages/member/doresult/index?type=" + a.data.type
|
|
})) : a.setData({
|
|
lock: !1
|
|
});
|
|
}));
|
|
},
|
|
getUserCredit: function(e) {
|
|
var a = this;
|
|
t.get("member/getUserCredit", {}, function(t) {
|
|
1 == e ? a.setData({
|
|
credit: t.member.credit1,
|
|
sysset: t.sysset
|
|
}) : a.setData({
|
|
credit: t.member.credit2,
|
|
sysset: t.sysset
|
|
});
|
|
});
|
|
},
|
|
doMakeMy: function() {
|
|
0 === ("" + this.data.ipic).length ? wx.showToast({
|
|
title: "需要用户填写转账金额",
|
|
icon: "none",
|
|
duration: 2e3
|
|
}) : !isNaN(this.data.ipic) && parseFloat(this.data.ipic) <= parseFloat(this.data.credit) && (this.setData({
|
|
dialogflg: !0
|
|
}), this.readTimer());
|
|
},
|
|
endPrice: function(e) {
|
|
return (e = (e = (e = (e = e.replace(/[^\d.]/g, "")).replace(/\.{2,}/g, ".")).replace(".", "$#$").replace(/\./g, "").replace("$#$", ".")).replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3")).indexOf(".") < 0 && "" != e && (e = parseFloat(e)),
|
|
e;
|
|
},
|
|
ipt: function(t) {
|
|
var a = t.detail.value, i = a, r = e.getCache("transfer_account", "");
|
|
"" != r && 2 == this.data.type && (0 == r.service_recharge_price && "" == r.service_recharge_price || ((i = 1 == r.service_recharge_type ? a - a * r.service_recharge_price / 100 : a - r.service_recharge_price) < 0 && (i = 0),
|
|
i = Math.floor(100 * parseFloat(i)) / 100)), this.setData({
|
|
ipic: this.endPrice(a),
|
|
finalPrice: i
|
|
});
|
|
},
|
|
doHide: function() {
|
|
this.setData({
|
|
lock: !1,
|
|
dialogflg: !1
|
|
}), clearInterval(this.data.timer);
|
|
},
|
|
getSet: function() {
|
|
t.get("transfer_account/getSet", {}, function(e) {
|
|
console.log(e);
|
|
});
|
|
},
|
|
readTimer: function() {
|
|
var e = 10, t = this;
|
|
this.setData({
|
|
scd: e--
|
|
}), this.data.timer = setInterval(function() {
|
|
console.log("in" + e), t.setData({
|
|
scd: e--
|
|
}), -1 === e && (clearInterval(t.data.timer), t.setData({
|
|
lock: !1
|
|
}));
|
|
}, 1e3);
|
|
},
|
|
onUnload: function() {
|
|
clearInterval(this.data.timer), this.setData({
|
|
lock: !1
|
|
});
|
|
}
|
|
}); |