2023-02-18 16:24:17 +08:00
|
|
|
const app = getApp()
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
height: '',
|
|
|
|
|
seckill_start: '请输入开始日期',
|
|
|
|
|
seckill_endx: '请输入结束日期',
|
|
|
|
|
time: 30 * 60 * 60 * 1000,
|
|
|
|
|
timeflag: 0,
|
|
|
|
|
userInfo: {},
|
|
|
|
|
item: {},
|
|
|
|
|
hasUserInfo: false,
|
|
|
|
|
date: '',
|
|
|
|
|
paymoney: 0,
|
|
|
|
|
phone: wx.getStorageSync('phone'),
|
|
|
|
|
uidFlag: wx.getStorageSync('uidFlag'),
|
|
|
|
|
goods_detail_img: [],
|
|
|
|
|
indicatorDots: true,
|
|
|
|
|
autoplay: true,
|
|
|
|
|
interval: 5000,
|
|
|
|
|
duration: 1300,
|
|
|
|
|
id: 0,
|
|
|
|
|
order_id: '',
|
|
|
|
|
timeData: {},
|
|
|
|
|
Height: "", //这是swiper要动态设置的高度属性
|
|
|
|
|
charge_phone: '',
|
|
|
|
|
is_ok_click: false,
|
|
|
|
|
clock: '',
|
|
|
|
|
address: '',
|
2023-04-25 23:33:40 +08:00
|
|
|
danjia: 1,
|
2023-03-29 00:00:43 +08:00
|
|
|
beizhu: '123456',
|
|
|
|
|
},
|
2023-03-12 21:05:54 +08:00
|
|
|
|
2023-03-18 20:59:50 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
// 确认支付
|
|
|
|
|
confirm_pay: async function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
if (!this.data.is_ok_click) {
|
|
|
|
|
that.setData({
|
|
|
|
|
is_ok_click: true
|
|
|
|
|
})
|
|
|
|
|
//你要执行的操作
|
|
|
|
|
this.payment()
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
that.setData({
|
|
|
|
|
is_ok_click: false
|
2023-02-18 16:24:17 +08:00
|
|
|
})
|
2023-03-29 00:00:43 +08:00
|
|
|
}, 10000) //阻止一秒点击多次
|
|
|
|
|
} else {
|
|
|
|
|
// wx.showToast({ title:'请勿重复操作!', icon: 'none' });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
//获取单价
|
|
|
|
|
getprice: function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.request({
|
|
|
|
|
url: app.globalData.url + '/system/config/configKey/price',
|
|
|
|
|
header: app.getRequestHeader(),
|
|
|
|
|
method: 'GET',
|
|
|
|
|
data: {},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
var resp = res.data;
|
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
that.setData({
|
|
|
|
|
special_offer: resp.data,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
//获取类型
|
|
|
|
|
getpriceType: function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.request({
|
|
|
|
|
url: app.globalData.url + '/system/config/configKey/priceType',
|
|
|
|
|
header: app.getRequestHeader(),
|
|
|
|
|
method: 'GET',
|
|
|
|
|
data: {},
|
|
|
|
|
success: (res) => {
|
|
|
|
|
var resp = res.data;
|
|
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
that.setData({
|
|
|
|
|
special_offer: resp.data,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
payment() {
|
|
|
|
|
if (this.data.seckill_start == "请输入开始日期") {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请输入开始日期',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (this.data.seckill_endx == "请输入结束日期") {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请输入结束日期',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.request({
|
|
|
|
|
url: app.globalData.url + '/system/order',
|
|
|
|
|
data: {
|
|
|
|
|
startTime: this.data.seckill_start,
|
|
|
|
|
endTime: this.data.seckill_endx,
|
|
|
|
|
bId: this.data.item.userId,
|
2023-04-25 23:33:40 +08:00
|
|
|
yuguMoney: this.data.paymoney,
|
|
|
|
|
price: this.data.danjia,//
|
|
|
|
|
priceType: "1",//1是按天
|
2023-03-29 00:00:43 +08:00
|
|
|
hospitalId: this.data.item.hospitalId,
|
|
|
|
|
cId: wx.getStorageSync('uid'),
|
2023-04-25 23:33:40 +08:00
|
|
|
remark: this.data.beizhu,
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
|
|
|
|
method: 'POST',
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
'Authorization': 'Bearer ' + app.getCache("token")
|
|
|
|
|
},
|
2023-03-12 21:05:54 +08:00
|
|
|
success(res) {
|
2023-03-29 00:00:43 +08:00
|
|
|
if (res.data.code == 200) {
|
|
|
|
|
that.setData({
|
|
|
|
|
order_id: res.data.data.orderId,
|
2023-03-12 21:05:54 +08:00
|
|
|
})
|
2023-03-29 00:00:43 +08:00
|
|
|
console.log('order_id==' + res.data.data.orderId)
|
|
|
|
|
app.console(that.data.order_id + "======要传的order_id")
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/shopping/pages/paysuccess/paysuccess?' + "order_id=" + that.data.order_id,
|
|
|
|
|
});
|
|
|
|
|
// console.log('timeStamp==' + res.data.data.timeStamp)
|
|
|
|
|
// console.log('nonceStr==' + res.data.data.nonceStr)
|
|
|
|
|
// console.log('package==' + res.data.data.package)
|
|
|
|
|
// console.log('signType==' + res.data.data.signType)
|
|
|
|
|
// console.log('paySign==' + res.data.data.paySign)
|
|
|
|
|
// wx.requestPayment({
|
|
|
|
|
// timeStamp: res.data.data.timeStamp,
|
|
|
|
|
// nonceStr: res.data.data.nonceStr,
|
|
|
|
|
// package: res.data.data.package,
|
|
|
|
|
// signType: res.data.data.signType,
|
|
|
|
|
// paySign: res.data.data.paySign,
|
|
|
|
|
// success(res) {
|
|
|
|
|
// console.log('支付成功');
|
|
|
|
|
// app.console(that.data.order_id + "======要传的order_id")
|
|
|
|
|
// wx.navigateTo({
|
|
|
|
|
// url: '/shopping/pages/paysuccess/paysuccess?' + "order_id=" + that.data.order_id,
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// fail(res) {
|
|
|
|
|
// console.log('支付失败');
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: res.data.msg,
|
|
|
|
|
icon: 'error',
|
|
|
|
|
duration: 2000
|
2023-03-12 21:05:54 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
bindDateChange: function (e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
seckill_start: e.detail.value
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
bindDateChangetwo: function (e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
seckill_endx: e.detail.value,
|
|
|
|
|
})
|
|
|
|
|
var day = this.checkDate()
|
|
|
|
|
this.setData({
|
|
|
|
|
paymoney: this.data.danjia * day
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
checkDate: function () {
|
|
|
|
|
//日期格式化
|
|
|
|
|
var start_date = new Date(this.data.seckill_start.replace(/-/g, "/"));
|
|
|
|
|
var end_date = new Date(this.data.seckill_endx.replace(/-/g, "/"));
|
|
|
|
|
//转成毫秒数,两个日期相减
|
|
|
|
|
var ms = end_date.getTime() - start_date.getTime();
|
|
|
|
|
//转换成天数
|
|
|
|
|
var day = parseInt(ms / (1000 * 60 * 60 * 24));
|
|
|
|
|
//do something
|
|
|
|
|
console.log("day = ", day);
|
|
|
|
|
return day + 1
|
|
|
|
|
},
|
|
|
|
|
onClickLeft() {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
onChange(e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
timeData: e.detail,
|
|
|
|
|
});
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad: function (e) {
|
|
|
|
|
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
|
|
|
|
|
this.setData({
|
|
|
|
|
statusBarHeight: statusBarHeight,
|
|
|
|
|
height: 46 + statusBarHeight,
|
|
|
|
|
});
|
|
|
|
|
var that = this;
|
|
|
|
|
let item = JSON.parse(e.item);
|
|
|
|
|
that.setData({
|
|
|
|
|
item: item
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 拨打电话
|
|
|
|
|
*/
|
|
|
|
|
callphone() {
|
|
|
|
|
wx.makePhoneCall({
|
|
|
|
|
phoneNumber: this.data.charge_phone,
|
|
|
|
|
})
|
|
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady: function () {
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
|
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow: function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
this.getprice();
|
|
|
|
|
this.getpriceType();
|
|
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide: function () {
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload: function () {
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh: function () {
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom: function () {
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage: function () {
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
|
|
|
|
login: function (e) {
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
},
|
2023-02-18 16:24:17 +08:00
|
|
|
|
2023-03-29 00:00:43 +08:00
|
|
|
})
|