123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- // pages/packages/diffpackagedetail/diffpackagedetail.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- p_detailimg: '',
- p_code: '',
- p_packagename: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- this.setData({
- p_code: options.pid
- })
- var that = this
- wx.request({
- url: app.globalData.url + '/getPackageDetail',
- method: 'get',
- data: {
- p_code: options.pid
- },
- success: function(res) {
- that.setData({
- p_detailimg: res.data.p_detailimg,
- p_packagename: res.data.p_name
- })
- },
- fail() {
- app.timeOut()
- }
- })
- let _this = this;
- _this.setData({
- navH: app.globalData.navHeight
- })
- },
- bookingpackages: function(e) {
- var that = this
- if (app.globalData.userphone == null) {
- app.ifAuthorization();
- } else {
- //保存数据库
- var duedate = new Date();
- var year = duedate.getFullYear();
- var month = duedate.getMonth() + 1;
- var strDate = duedate.getDate();
- var seperator1 = "-";
- var date = new Date();
- var year = date.getFullYear();
- var month = ("0" + (date.getMonth() + 1)).slice(-2);;
- var strDate = ("0" + (date.getDate())).slice(-2);
- var hours = ("0" + (date.getHours())).slice(-2);
- var minutes = ("0" + (date.getMinutes())).slice(-2);
- var seconds = ("0" + (date.getSeconds())).slice(-2);
- var eh_time = year + '-' + month + '-' + strDate + ' ' + hours + ':' + minutes + ':' + seconds;
- wx.request({
- url: app.globalData.url + '/insertCustomerBooking',
- method: 'post',
- header: {
- "Content-Type": "application/x-www-form-urlencoded"
- },
- data: {
- bk_phone: app.globalData.userphone,
- bk_date: year + seperator1 + month + seperator1 + strDate,
- bk_type: 1,
- bk_desc: e.currentTarget.dataset.pname
- },
- success: function(res) {
- wx.hideLoading()
- if (res.data > 1) {
- wx.showToast({
- title: '亲,您今天已经预约过了',
- icon: 'none',
- duration: 1500
- })
- } else {
- wx.showToast({
- title: '预约成功!',
- icon: 'success',
- duration: 1500
- })
- // 发送消息
- wx.request({
- url: app.globalData.url + '/WXSendBookingMessage',
- method: 'post',
- header: {
- "Content-Type": "application/x-www-form-urlencoded"
- },
- data: {
- bk_phone: app.globalData.userphone,
- bk_type: 1,
- bk_date: eh_time,
- bk_desc: that.data.p_name
- }
- })
- }
- },
- fail() {
- app.timeOut()
- }
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|