You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
3.3 KiB
156 lines
3.3 KiB
var app = getApp();
|
|
import WxValidate from '../../utils/WxValidate';
|
|
var netUtil = require("../../utils/requestUtil.js"); //require引入
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
userInfo: null,
|
|
imgList: [],
|
|
qrcode: '',
|
|
vip_level_c: [],
|
|
price: 0,
|
|
count: 5,
|
|
name: '普通会员',
|
|
vip_level: 0,
|
|
pay_type_list: [],
|
|
pay_type: 1,
|
|
pay_src: ''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
var userInfo = wx.getStorageSync('userInfo')
|
|
var global_config = wx.getStorageSync('global_config')
|
|
if (userInfo) {
|
|
console.log(userInfo)
|
|
this.setData({
|
|
userInfo: userInfo,
|
|
vip_level_c: global_config.vip_level,
|
|
pay_type_list: global_config.pay_type,
|
|
pay_src: global_config.pay_type[1].src
|
|
})
|
|
|
|
}
|
|
console.log(this.data)
|
|
//验证
|
|
this.initValidate()
|
|
},
|
|
//支付切换
|
|
payChange(e) {
|
|
var pay_type_list = this.data.pay_type_list
|
|
this.setData({
|
|
pay_src: pay_type_list[e.detail.value].src
|
|
})
|
|
},
|
|
//会员级别切换
|
|
PickerChange(e) {
|
|
var vip_level_c = this.data.vip_level_c
|
|
//操作价格
|
|
this.setData({
|
|
name: vip_level_c[e.detail.value].name,
|
|
count: vip_level_c[e.detail.value].count,
|
|
price: vip_level_c[e.detail.value].price,
|
|
vip_level: e.detail.value
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
|
|
formSubmit: function (e) {
|
|
const params = e.detail.value
|
|
//执行入库
|
|
var self = this
|
|
wx.showModal({
|
|
title: '信息确认',
|
|
content: '请确认信息是否正确,且已支付完成?',
|
|
success(obj) {
|
|
if (obj.confirm) {
|
|
self.updateData(params);
|
|
} else if (obj.cancel) {
|
|
console.log(2)
|
|
}
|
|
}
|
|
})
|
|
|
|
},
|
|
|
|
//插入用户数据
|
|
updateData: function (data) {
|
|
var self = this;
|
|
var method_url = 'index/order/add';
|
|
var url = app.globalData.requestUrl + method_url;
|
|
netUtil.sendPost(url, data)
|
|
.then((res) => {
|
|
console.log(res)
|
|
if (res.statusCode == 200 && res.data.code == 200) {
|
|
wx.showToast({
|
|
title: '订单提交成功,已进入审核模式!!!',
|
|
icon: 'success',
|
|
duration: 2000,
|
|
success: function () {
|
|
wx.navigateTo({
|
|
url: '/pages/member/order',
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: res.data.msg,
|
|
icon: 'none',
|
|
duration: 3000
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
showModal: function (e) {
|
|
console.log(e);
|
|
wx.showToast({
|
|
title: e.msg,
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
},
|
|
initValidate() {
|
|
// 验证字段的规则
|
|
const rules = {
|
|
phone: {
|
|
required: true,
|
|
},
|
|
qrcode: {
|
|
required: true,
|
|
}
|
|
}
|
|
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
const messages = {
|
|
phone: {
|
|
required: "请输入小区名称",
|
|
},
|
|
qrcode: {
|
|
required: "请上传二维码",
|
|
}
|
|
}
|
|
|
|
// 创建实例对象
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
},
|
|
|
|
})
|