2019-12-28 10:13:48 +08:00
|
|
|
import bin from "../../utils/bin"
|
|
|
|
Page({
|
2019-12-23 10:04:09 +08:00
|
|
|
data: {
|
2019-12-28 16:31:20 +08:00
|
|
|
money: "",
|
|
|
|
list: [],
|
|
|
|
number: 0,
|
|
|
|
show:false
|
2019-12-23 10:04:09 +08:00
|
|
|
},
|
2019-12-28 10:13:48 +08:00
|
|
|
onLoad(a) {
|
|
|
|
bin.request({
|
2019-12-28 16:31:20 +08:00
|
|
|
url: "User/validateOpenid"
|
|
|
|
}).then((res) => {
|
2019-12-28 10:13:48 +08:00
|
|
|
console.log(res)
|
2019-12-28 16:31:20 +08:00
|
|
|
if (res.data.code == 200) {
|
2019-12-28 10:13:48 +08:00
|
|
|
this.setData({
|
2019-12-28 16:31:20 +08:00
|
|
|
money: res.data.data.user_money
|
2019-12-28 10:13:48 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
bin.getuserid().then((userid) => {
|
|
|
|
bin.request({
|
|
|
|
url: "User/account",
|
|
|
|
urldata: {
|
2019-12-28 16:31:20 +08:00
|
|
|
user_id: userid,
|
|
|
|
page: 0
|
2019-12-28 10:13:48 +08:00
|
|
|
}
|
2019-12-28 16:31:20 +08:00
|
|
|
}).then((res) => {
|
2019-12-28 10:13:48 +08:00
|
|
|
console.log(res)
|
2019-12-28 16:31:20 +08:00
|
|
|
for (let i in res.data.result) {
|
2019-12-28 10:13:48 +08:00
|
|
|
let linshi = res.data.result[i].change_time.split(" ")
|
|
|
|
res.data.result[i].date = linshi[0]
|
|
|
|
res.data.result[i].time = linshi[1]
|
|
|
|
}
|
|
|
|
this.setData({
|
2019-12-28 16:31:20 +08:00
|
|
|
list: res.data.result
|
2019-12-28 10:13:48 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2019-12-28 16:31:20 +08:00
|
|
|
},
|
|
|
|
number(a) {
|
|
|
|
console.log(a)
|
|
|
|
this.setData({
|
|
|
|
number: a.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
recharge(){
|
|
|
|
if(this.data.number == 0){
|
|
|
|
wx.showToast({
|
|
|
|
title:"请输入充值金额",
|
|
|
|
icon:"none"
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
bin.getuserid().then((id)=>{
|
|
|
|
bin.request({
|
|
|
|
url:"User/user_recharge",
|
|
|
|
data:{
|
|
|
|
user_id:id,
|
|
|
|
account:this.data.number
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
|
|
|
let t =this;
|
|
|
|
console.log(res);
|
|
|
|
wx.requestPayment({
|
|
|
|
timeStamp:res.data.result.wdata.timeStamp + "",
|
|
|
|
nonceStr:res.data.result.wdata.nonceStr,
|
|
|
|
package:res.data.result.wdata.package,
|
|
|
|
signType: res.data.result.wdata.signType,
|
|
|
|
paySign:res.data.result.wdata.sign,
|
|
|
|
success(res){
|
|
|
|
// console.log(res)
|
|
|
|
wx.showToast({
|
|
|
|
title:"充值成功",
|
|
|
|
icon:"none"
|
|
|
|
})
|
|
|
|
t.setData({
|
|
|
|
show:false
|
|
|
|
})
|
|
|
|
t.onLoad()
|
|
|
|
},
|
|
|
|
fail(err){
|
|
|
|
wx.showToast({
|
|
|
|
title:"充值失败",
|
|
|
|
icon:"none"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
showrecharge(){
|
|
|
|
console.log(123)
|
|
|
|
this.setData({
|
|
|
|
show:true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onClose(){
|
|
|
|
this.setData({
|
|
|
|
show:false
|
|
|
|
})
|
2019-12-23 10:04:09 +08:00
|
|
|
}
|
2019-12-28 10:13:48 +08:00
|
|
|
})
|