238 lines
5.6 KiB
JavaScript
238 lines
5.6 KiB
JavaScript
// pages/member/rankingListSecond/rankingListSecond.js
|
|
var yz_pay = require("../../../../mycomponent/yz_pay/yz_pay");
|
|
var app = getApp();
|
|
Page({
|
|
behaviors: [yz_pay],
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
language: '',
|
|
value: '',
|
|
every_value: '',
|
|
transform_value: '',
|
|
title: '',
|
|
money: '',
|
|
pay_type: '',
|
|
converge_wechat_pay: false, // 显示汇聚按钮
|
|
weixinShow: false,
|
|
|
|
buttons: [],
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
this.initData();
|
|
this.getData();
|
|
this.getTitle();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
let language = wx.getStorageSync('langIndex');
|
|
this.setData({ 'language': language.en});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {},
|
|
getData() {
|
|
let urlStr = app.getNetAddresss('plugin.love.Frontend.Modules.Love.Controllers.recharge.page');
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: (res) => {
|
|
let resData = res.data;
|
|
if (resData.result === 1) {
|
|
this.setData({
|
|
value: resData.data.member_usable,
|
|
every_value: resData.data.recharge_rate_money,
|
|
transform_value: resData.data.recharge_rate_love,
|
|
converge_wechat_pay: resData.data.converge_wechat_pay,
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
|
|
getTitle() {
|
|
let that = this;
|
|
let urlStr = app.getNetAddresss('plugin.love.Frontend.Controllers.page.index');
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: (res) => {
|
|
let resData = res.data;
|
|
if (resData.result === 1) {
|
|
this.setData({
|
|
title: resData.data.love_name,
|
|
buttons: resData.data.buttons,
|
|
});
|
|
wx.setNavigationBarTitle({
|
|
title: resData.data.love_name ? (resData.data.love_name + '充值') : '充值'
|
|
});
|
|
for (let i = 0; i < that.data.buttons.length; i++) {
|
|
if (that.data.buttons[i]) {
|
|
that.setData({
|
|
['buttons[' + i + '].btclass']: that.btnclass(that.data.buttons[i].value)
|
|
});
|
|
}
|
|
}
|
|
if (resData.data.weixin == 1) {
|
|
this.setData({
|
|
weixinShow: true
|
|
});
|
|
}
|
|
} else {
|
|
wx.showToast({
|
|
title: resData.msg,
|
|
icon: 'none',
|
|
image: '',
|
|
duration: 1500,
|
|
mask: false
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
|
|
initData() {
|
|
this.value = '';
|
|
this.every_value = '';
|
|
this.transform_value = '';
|
|
this.title = '';
|
|
this.money = '';
|
|
this.pay_type = '';
|
|
},
|
|
|
|
// 充值
|
|
rechargeHandel(e) {
|
|
this.setData({
|
|
pay_type: e.currentTarget.dataset.val
|
|
});
|
|
if (!this.data.money) {
|
|
wx.showToast({
|
|
title: '充值数量不能为空',
|
|
icon: 'none',
|
|
duration: 1500
|
|
});
|
|
return;
|
|
}
|
|
let urlStr = app.getNetAddresss('plugin.love.Frontend.Modules.Love.Controllers.recharge.index');
|
|
urlStr += '&pay_way=' + this.data.pay_type;
|
|
urlStr += '&recharge_money=' + this.data.money;
|
|
urlStr += '&client_type=2';
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: (res) => {
|
|
console.log(res);
|
|
if (res.data.result === 1) {
|
|
this.rechargePay(this.data.pay_type, res, res.data.ordersn);
|
|
} else {
|
|
wx.showToast({
|
|
title: res.data.msg,
|
|
icon: 'none',
|
|
image: '',
|
|
duration: 1500,
|
|
mask: false
|
|
});
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
|
|
// 确认充值
|
|
confirm(e) {
|
|
let type = e.currentTarget.dataset.val;
|
|
if (this.data.money <= 0) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '金额不可低于0',
|
|
duration: 1500
|
|
});
|
|
return;
|
|
}
|
|
this.setData({
|
|
money: parseFloat(this.data.money),
|
|
pay_type: type
|
|
});
|
|
let urlStr = app.getNetAddresss('plugin.love.Frontend.Modules.Love.Controllers.recharge.index');
|
|
urlStr += '&client_type=2';
|
|
urlStr += '&app_type=wechat';
|
|
urlStr += '&pay_way=' + this.data.pay_type;
|
|
urlStr += '&recharge_money=' + this.data.money;
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: (resdata)=> {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
if (app._isTextEmpty(res.data.order_sn)) {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '参数错误',
|
|
duration: 1500
|
|
});
|
|
return false;
|
|
}
|
|
this.setData({
|
|
ordersn: res.data.order_sn
|
|
});
|
|
this.rechargePay(type, res, res.data.ordersn);
|
|
} else {
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: res.msg,
|
|
duration: 1500
|
|
});
|
|
}
|
|
},
|
|
fail: (res)=> {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
// 输入框被改变的时候
|
|
onChange(val) {
|
|
this.setData({
|
|
money: val.detail
|
|
});
|
|
}
|
|
});
|