Files
coupon/pages/peizhen/peizhendetail.js
2023-05-27 22:34:57 +08:00

377 lines
8.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
task: {
phone: '',
phonedisplay: false,
placeholder: '请输入联系方式'
},
//普通选择器:(普通数组)
// array: ['请选择医院', '西京医院', '省人民医院', '红会医院'],
objectArray: [{
text: '请选择医院',
value: 10
},
{
text: '第四军医大学西京医院',
value: 2
},
{
text: '陕西省人民医院',
value: 3
},
{
text: '西安市高新医院',
value: 1
},
],
objectIndex: 0, //默认显示位置
show: true,
height: '',
seckill_start: '请输入开始日期',
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: '',
danjia: 0.01, //单位为元
beizhu: '',
name: '',
jzphone: ''
},
inputtaskphone(e) {
if (e.detail.value != '') {
if (!(/^1[3456789]\d{9}$/.test(e.detail.value))) {
this.setData({
phonedisplay: true,
placeholder: '',
'task.phone': ''
})
}
}
},
focus() {
this.setData({
phonedisplay: false,
placeholder: '请输入联系方式',
'task.phone': ''
})
},
bindNameInput: function (e) {
this.setData({
name: e.detail.value
})
},
bindPhoneInput: function (e) {
this.setData({
jzphone: e.detail.value
})
},
bindAdressInput: function (e) {
this.setData({
address: e.detail.value
})
},
// 确认支付
confirm_payy: async function () {
// wx.showToast({
// title: '点击了',
// icon: 'none'
// });
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
})
}, 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,
});
}
}
});
},
onClose() {
this.setData({
show: false
});
},
onSelect(event) {
console.log(event.detail);
},
isPhone(value) {
if (!/^1(3|4|5|7|8)\d{9}$/.test(value)) {
return false
} else {
return true
}
},
payment() {
if (this.data.objectIndex == 0) {
wx.showToast({
title: '请输选择医院',
icon: 'none'
});
return
}
if (this.data.jzphone == '') {
wx.showToast({
title: '请输入就诊人电话',
icon: 'none'
});
return
}
var regtel = new RegExp('(^1[3|4|5|7|8][0-9]{9}$)', 'g');
if (!regtel.exec(this.data.jzphone )) {
wx.showToast({
title: '手机号码格式不正确!',
icon: 'none'
});
return
}
if (this.data.seckill_start == "请输入开始日期") {
wx.showToast({
title: '请输入开始日期',
icon: 'none'
});
return
}
var that = this;
wx.request({
url: app.globalData.url + '/system/order/insertOrderPz',
data: {
bId: "1", //陪护人员id
cId: wx.getStorageSync('uid'), //患者id
yuguMoney: this.data.item.price, //金额
yuliu9: "2", //订单大类1-陪护 2-陪诊
yuliu10: this.data.item.ordertype, //订单类型1-全程陪诊2-诊前约号3-送取报告4-待办问诊
hospitalId: this.data.objectArray[this.data.objectIndex].value,
startTime: this.data.seckill_start,
yuliu11: this.data.jzphone, //患者电话
yuliu12: this.data.beizhu, //特殊要求
yuliu13: this.data.address, //送达地址
yuliu14: "610526198701180018" //患者身份证号
},
method: 'POST',
header: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + app.getCache("token")
},
success(res) {
if (res.data.code == 200) {
that.setData({
order_id: res.data.data.orderId,
})
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,
});
} else {
wx.showToast({
title: res.data.msg,
icon: 'error',
duration: 2000
})
}
}
})
},
bindDateChange: function (e) {
this.setData({
seckill_start: e.detail.value
})
},
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,
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (e) {
var statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
this.setData({
statusBarHeight: statusBarHeight,
height: 46 + statusBarHeight,
});
// var that = this;
// this.setData({
// servername: e.servername
// })
// console.log('servername==' + this.data.servername)
var that = this;
let item = JSON.parse(e.item);
that.setData({
item: item
});
console.log("进入订单详情的title==" + that.data.item.title)
},
/**
* 拨打电话
*/
callphone() {
wx.makePhoneCall({
phoneNumber: this.data.charge_phone,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var that = this;
this.getprice();
this.getpriceType();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
login: function (e) {
},
//普通选择器2
bindPickerChange2: function (e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
objectIndex: e.detail.value
})
console.log('picker发送选择改变医院的id值为', this.data.objectArray[this.data.objectIndex].value)
},
})