Files
coupon/pages/appointmentDetails/appointmentDetails.js
2023-02-22 23:52:12 +08:00

201 lines
5.4 KiB
JavaScript

var dateTimePicker = require('../../utils/dateTimePicker.js');
const uilt = require('../../utils/util.js');
var Token = require('../../utils/util.js');
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
dateTimeArray1: null,
dateTime1: null,
fromBox:false,
infor:{},
store:[],
store_id:'',
appointment_time:'',
name:'',
phone:wx.getStorageSync('phone'),
id:''//优惠券id
},
yuyue(e){
console.log(e.currentTarget.dataset)
this.setData({
fromBox:true,
store_id:e.currentTarget.dataset.id
})
},
mengcheng(){
this.setData({
fromBox:false
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 获取完整的年月日 时分秒,以及默认显示的数组
var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
// 精确到分的处理,将数组的秒去掉
var lastArray = obj1.dateTimeArray.pop();
var lastTime = obj1.dateTime.pop();
console.log(options)
this.setData({
id:options.id,
dateTimeArray1: obj1.dateTimeArray,
dateTime1: obj1.dateTime
})
this.getCouponDetail(options.id)
},
changeDateTime1(e) {
this.setData({ dateTime1: e.detail.value });
},
changeDateTimeColumn1(e) {
var arr = this.data.dateTime1, dateArr = this.data.dateTimeArray1;
arr[e.detail.column] = e.detail.value;
dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
this.setData({
dateTimeArray1: dateArr
});
console.log(this.data.dateTimeArray1)
},
nameChang(e){
this.setData({
name: e.detail.value
})
},
phoneChang(e){
this.setData({
phone: e.detail.value
})
},
// 点击预约提交信息
appointment(){
var that=this;
var appointment_time;
var appointment_time=that.data.dateTimeArray1[0][that.data.dateTime1[0]]+'-'+that.data.dateTimeArray1[1][that.data.dateTime1[1]]+"-"+that.data.dateTimeArray1[2][that.data.dateTime1[2]]+' '+that.data.dateTimeArray1[3][that.data.dateTime1[3]]+':'+that.data.dateTimeArray1[4][that.data.dateTime1[4]];
console.log(that.data.name)
wx.request({
url: app.globalData.url + '/device/CouponWechat/submitAppointment',
data: {
uid:wx.getStorageSync('uid'),
token:wx.getStorageSync('token'),
version_number:app.globalData.version_number,
id:that.data.id,
store_id:that.data.store_id,
appointment_time:appointment_time,
name:that.data.name,
phone:that.data.phone
},
method: 'POST',
header: { 'content-type': 'application/x-www-form-urlencoded' },
success(res) {
console.log(res)
if(res.data.result.erro=='0'){
that.setData({
fromBox:false
})
wx.showToast({
title: '预约成功',
icon: 'success',
duration: 1000,
success(){
wx.switchTab({
url: '../cardBag/cardBag.wxml'
})
}
})
}else{
Token.token()
that.getCouponDetail(that.data.id)
}
}
})
},
// 获取优惠券详情
getCouponDetail(id){
var that=this;
wx.request({
url: app.globalData.url + '/app/Goddesswechat/selectCouponDetail',
data: {
uid:wx.getStorageSync('uid'),
token:wx.getStorageSync('token'),
version_number:app.globalData.version_number,
id:id
},
method: 'POST',
header: { 'content-type': 'application/x-www-form-urlencoded' },
success(res) {
console.log(res)
if(res.data.infor.full_minus){
res.data.infor.full=res.data.infor.full_minus.split("-")[0];
res.data.infor.minus=res.data.infor.full_minus.split("-")[1];
}
if(res.data.erro=='0'){
that.setData({
infor:res.data.infor,
store:res.data.store
})
}else{
Token.token()
that.getCouponDetail(that.data.id)
}
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})