first commit
This commit is contained in:
250
衣莎项目/源码/YiShaXiYi/user/recharge/recharge.js
Normal file
250
衣莎项目/源码/YiShaXiYi/user/recharge/recharge.js
Normal file
@@ -0,0 +1,250 @@
|
||||
// user/recharge/recharge.js
|
||||
const app = getApp();
|
||||
const regeneratorRuntime = app.loadAsync()
|
||||
const model = app.loadModel("index")
|
||||
const http = app.loadHttp()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
system: app.globalData.system, //设备相关信息
|
||||
pageTitle: "充值", //头部标题
|
||||
isBack: true,//显示返回
|
||||
isLoading: true,//加载显示关闭
|
||||
rechargeList: [],//金额列表
|
||||
rechargeSelect: 0,//当前选中
|
||||
money: {},//用户充值的余额
|
||||
userInfo: {},//用户信息
|
||||
cardInfo: [],//用户卡列表
|
||||
id: "",//当前选中的会员卡id
|
||||
card_id: "",//不知道是什么id
|
||||
current_scroll: '1',//tab当前选中值
|
||||
isCart: true,//
|
||||
formData:'',
|
||||
formData1:''
|
||||
},
|
||||
handleChangeScroll({ detail }) {
|
||||
this.setData({
|
||||
current_scroll: detail.key,
|
||||
money: {},
|
||||
cardInfo: [],
|
||||
rechargeList: [],
|
||||
isCart: false
|
||||
});
|
||||
this.getUserCard()
|
||||
},
|
||||
// 选择金额
|
||||
selectRech(e) {
|
||||
let index = e.currentTarget.dataset.index
|
||||
this.setData({
|
||||
rechargeSelect: index,
|
||||
money: this.data.rechargeList[index]
|
||||
})
|
||||
},
|
||||
// 自定义金额
|
||||
moneyInput(e) {
|
||||
let value = e.detail.value
|
||||
this.setData({
|
||||
'money.money': value
|
||||
})
|
||||
},
|
||||
// 充值
|
||||
async userRecharge() {
|
||||
if (this.data.id == "") {
|
||||
wx.showToast({
|
||||
title: '请选择需要充值的卡',
|
||||
icon: 'none',
|
||||
duration: 1200
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.data.money.money == "") {
|
||||
wx.showToast({
|
||||
title: '请填写充值金额',
|
||||
icon: 'none',
|
||||
duration: 1200
|
||||
})
|
||||
return
|
||||
}
|
||||
let data = {
|
||||
total_money: this.data.money.money,
|
||||
card_id: this.data.id,
|
||||
coupon_id: this.data.money.coupon_id,
|
||||
num: this.data.money.num,
|
||||
type: this.data.current_scroll
|
||||
}
|
||||
model.payment.pay(http.api.userRecharge, data)
|
||||
},
|
||||
// 获取用户卡列表
|
||||
async getUserCard() {
|
||||
let res = await http.http.request2({ url: `${http.api.userCard}/${this.data.current_scroll}`, method: "POST" })
|
||||
if (res.data.data.length > 0) {
|
||||
this.setData({
|
||||
cardInfo: res.data.data,
|
||||
isLoading: false,
|
||||
id: res.data.data[0].id,
|
||||
card_id: res.data.data[0].card_id
|
||||
})
|
||||
this.rechargeMoney()
|
||||
} else {
|
||||
this.setData({
|
||||
isLoading: false,
|
||||
isCart: true
|
||||
})
|
||||
}
|
||||
},
|
||||
// 获取用户信息显示用
|
||||
async getUserInfo() {
|
||||
let res = await model.storage.getSetting("userInfo")
|
||||
this.setData({
|
||||
userInfo: res
|
||||
})
|
||||
},
|
||||
// 选择充值的会员卡
|
||||
selectCard(e) {
|
||||
this.setData({
|
||||
id: e.currentTarget.dataset.id,
|
||||
card_id: e.currentTarget.dataset.cardid
|
||||
})
|
||||
this.rechargeMoney()
|
||||
},
|
||||
// 获取充值金额列表
|
||||
async rechargeMoney() {
|
||||
let res = await http.http.request2({ url: `${http.api.rechargeMoney}`, method: "POST", data: { card_id: this.data.card_id } })
|
||||
let rel = res.data.data
|
||||
rel.push({ money: 0 })
|
||||
this.setData({
|
||||
rechargeList: rel,
|
||||
money: rel[0],
|
||||
isCart: true
|
||||
})
|
||||
},
|
||||
// 加入会员跳转
|
||||
joinVip(e) {
|
||||
let url = e.currentTarget.dataset.url
|
||||
wx.navigateTo({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
// 用户卡充值
|
||||
verifyRechargeCard(e) {
|
||||
var that = this
|
||||
if (!e.detail.value.card_num) {
|
||||
wx.showToast({
|
||||
title: '请输入卡号',
|
||||
icon: 'none',
|
||||
duration: 1200
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!e.detail.value.card_password) {
|
||||
wx.showToast({
|
||||
title: '请输入密码',
|
||||
icon: 'none',
|
||||
duration: 1200
|
||||
})
|
||||
return
|
||||
}
|
||||
let data = {
|
||||
card_num: e.detail.value.card_num,
|
||||
card_password: e.detail.value.card_password,
|
||||
form_id: e.detail.formId
|
||||
}
|
||||
wx.showModal({
|
||||
title: '是否确定领取充值卡',
|
||||
content: '点击确定领取',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
http.http.request2({ url: `${http.api.verifyRechargeCard}`, method: "POST", data: data })
|
||||
.then(res => {
|
||||
if (res.data.status == 1) {
|
||||
wx.showToast({
|
||||
title: '领取成功',
|
||||
icon: 'none',
|
||||
duration: 1200
|
||||
})
|
||||
that.setData({
|
||||
formData:'',
|
||||
formData1:''
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// 电话
|
||||
tel(){
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: '4000551071'
|
||||
})
|
||||
},
|
||||
// 查看大图
|
||||
bigImg(){
|
||||
wx.previewImage({
|
||||
current: 'http://cdn.yishaxiyi.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190904101132.png', // 当前显示图片的http链接
|
||||
urls: ['http://cdn.yishaxiyi.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190904101132.png'] // 需要预览的图片http链接列表
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.setData({
|
||||
current_scroll: options.index || 1
|
||||
})
|
||||
this.getUserCard()
|
||||
this.getUserInfo()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user