first commit
This commit is contained in:
768
衣莎项目/源码/YiShaXiYi/user/appointment/appointment.js
Normal file
768
衣莎项目/源码/YiShaXiYi/user/appointment/appointment.js
Normal file
@@ -0,0 +1,768 @@
|
||||
// user/appointment/appointment.js
|
||||
const app = getApp();
|
||||
const regeneratorRuntime = app.loadAsync()
|
||||
const model = app.loadModel("index")
|
||||
const http = app.loadHttp()
|
||||
const util = app.loadUtils("util")
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
system: app.globalData.system, //设备相关信息
|
||||
pageTitle: "一键下单", //头部标题
|
||||
isBack: true,//显示返回
|
||||
visible: false,//弹出层
|
||||
somList: [],
|
||||
date_list: [],//预约时间列表
|
||||
bigIndex: 0,//大分类选中
|
||||
somIndex: null,//小分类选中
|
||||
address: "",//选中的收货地址
|
||||
remarks: "",//备注
|
||||
isPlaceOrder: false,//防止重复提交
|
||||
postage: {},//邮费
|
||||
shopList: {
|
||||
shopCart: [], //购物车商品数据
|
||||
orderPrice: null, //商品总价
|
||||
ordinaryPrice: null, //普通衣物的价格
|
||||
workPrice: null, //工服衣物的价格
|
||||
totalPrice: null, //扣除优惠+邮费的价格
|
||||
postageMoney: null, //邮费
|
||||
wxMoney: null,//微信该支付的钱
|
||||
total: null, //底部显示的合计
|
||||
},
|
||||
isPay: [true, true],//0下标是微信支付 1下标是卡支付
|
||||
isPayp: 2,//1卡支付 2微信支付
|
||||
giftCard: {},//会员卡信息
|
||||
coupon: {},//优惠券
|
||||
isgiftCard: "",//拼接的卡劵信息方便操作
|
||||
groupType: -1,//如果不是0就是团体用户,0 或 -1 是非广大用户
|
||||
type: 1,//1是团体用户普通洗 2是洗工服
|
||||
groupData: {},//团体用户折扣优惠数据信息
|
||||
take_type: 1,//门店自取1 单位自取2
|
||||
branchList: [], //支行列表
|
||||
branchIndex: 0,// 当前用户选择的支行下标
|
||||
takeTypeOrd: 1,//普通用户 自送门店1 上门取件2
|
||||
addList: [], // 门店列表
|
||||
addIndex: -1, //当前用户选择的门店下标
|
||||
timeFreight: '', //如果团体客户在预约时间内则免运费
|
||||
isCoupon: true, //是否显示优惠卷
|
||||
coilingCode: '', //用户输入的卷码
|
||||
formSource: 0,// 订单来源 如果不是0则显示码卷输入
|
||||
freightTips: true, // true 显示 实付xx,false 3月底免运费
|
||||
isCurtains: 0 // // 0 不是窗帘套餐, 1 是窗帘套餐
|
||||
},
|
||||
// 获取默认收货人
|
||||
async getConsignee() {
|
||||
let token = await util.token()
|
||||
if (!token) return;
|
||||
let res = await http.http.request2({ url: `${http.api.defaultUserAddress}`, method: "POST" })
|
||||
let add = res.data.data
|
||||
if (!!add.id) {
|
||||
add.all = add.provinceName + add.cityName + add.countryName + add.detail
|
||||
this.setData({
|
||||
address: add
|
||||
})
|
||||
}
|
||||
},
|
||||
// 获取支行列表
|
||||
async groupBranchList() {
|
||||
let res = await http.http.request2({ url: http.api.groupBranchList, method: 'POST' })
|
||||
res.data.data.forEach((v,i)=>{
|
||||
if(v.id == app.globalData.userInfo.group_branch){
|
||||
this.setData({
|
||||
branchIndex: i
|
||||
})
|
||||
}
|
||||
})
|
||||
this.setData({
|
||||
branchList: res.data.data
|
||||
})
|
||||
},
|
||||
// 选择其他支行
|
||||
pickerChange(e) {
|
||||
this.setData({
|
||||
branchIndex: parseInt(e.detail.value),
|
||||
timeFreight: '',
|
||||
bigIndex: 0,//大分类选中
|
||||
somIndex: null,//小分类选中
|
||||
})
|
||||
this.getMaketime()
|
||||
this.calculation()
|
||||
},
|
||||
/**
|
||||
* 获取全部门店列表
|
||||
*/
|
||||
async getStoreList() {
|
||||
let data = await model.storage.getSetting("position")
|
||||
let res = await http.http.request1({
|
||||
url: `${http.api.disShopList}`, method: "POST", data: {
|
||||
pick_door: 1
|
||||
}
|
||||
})
|
||||
|
||||
let rel = res.data.data;
|
||||
this.setData({
|
||||
addList: [...rel]
|
||||
})
|
||||
},
|
||||
// 门店选择
|
||||
pickerChangeOrd(e){
|
||||
this.setData({
|
||||
addIndex: parseInt(e.detail.value)
|
||||
})
|
||||
this.calculation()
|
||||
},
|
||||
// 获取邮费
|
||||
async postage() {
|
||||
let url = '';
|
||||
if (this.data.groupType !== 0 && this.data.type == 2) {
|
||||
url = http.api.newPostage
|
||||
} else {
|
||||
url = http.api.postage
|
||||
}
|
||||
let res = await http.http.request2({ url: url, method: "POST", data: { type: 2 } })
|
||||
this.setData({
|
||||
postage: res.data.data
|
||||
})
|
||||
},
|
||||
// 获取光大用户会员卡
|
||||
async getGuangDa() {
|
||||
let res = await http.http.request2({ url: http.api.guangDa, method: "POST", data: { group_type: this.data.groupType } })
|
||||
this.setData({
|
||||
giftCard: res.data.data
|
||||
})
|
||||
},
|
||||
//弹出层开启关闭
|
||||
onClose() {
|
||||
this.setData({
|
||||
visible: !this.data.visible
|
||||
})
|
||||
},
|
||||
// 选中大分类
|
||||
bigSelect(e) {
|
||||
let index = e.currentTarget.dataset.index
|
||||
this.setData({
|
||||
bigIndex: index,
|
||||
somList: this.data.date_list[index].time_list
|
||||
})
|
||||
},
|
||||
// 选中小分类
|
||||
somSelect(e) {
|
||||
let index = e.currentTarget.dataset.index
|
||||
let item = e.currentTarget.dataset.item
|
||||
if (item.type == '今日休息') {
|
||||
wx.showToast({
|
||||
title: '每周四休息,给您带来不便,敬请谅解',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
return
|
||||
} else if (item.type == '2') {
|
||||
wx.showToast({
|
||||
title: '当前时间段已过,请重新选择',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
somIndex: item,
|
||||
timeFreight: parseInt(item.post_desc) > 0 ? parseInt(item.post_desc) : 0
|
||||
})
|
||||
this.onClose()
|
||||
if(this.data.take_type == 2){
|
||||
this.calculation()
|
||||
}
|
||||
},
|
||||
// 获取收货地址并且赋值到页面
|
||||
async getAdd() {
|
||||
let data = await model.storage.getSetting("address")
|
||||
if (!!data) {
|
||||
model.storage.deleteStorage('address')
|
||||
data.all = data.provinceName + data.cityName + data.countyName + data.detailInfo
|
||||
this.setData({
|
||||
address: data || ""
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 获取预约时间
|
||||
* 并把小分类赋值
|
||||
*/
|
||||
async getMaketime() {
|
||||
let data = {}
|
||||
// isCurtains 如果为1,请求窗帘的活动时间,如果为 0 请求普通衣物和套餐时间
|
||||
data.is_appoint_time = this.data.isCurtains;
|
||||
if(this.data.take_type == 2){
|
||||
data.bind_id = this.data.branchList[this.data.branchIndex].id
|
||||
if(this.data.type == 1){
|
||||
data.bind_wash_type = 2
|
||||
}else{
|
||||
data.bind_wash_type = 1
|
||||
}
|
||||
}
|
||||
let time = await http.http.request1({ url: `${http.api.getTime}`, method: "POST", data:data })
|
||||
this.setData({
|
||||
date_list: time.data.data.date_list,
|
||||
somList: time.data.data.date_list[0].time_list
|
||||
})
|
||||
},
|
||||
// 团体用户折扣优惠数据信息
|
||||
async groupDiscountInfo() {
|
||||
let res = await http.http.request2({ url: http.api.groupDiscountInfo, method: "POST" })
|
||||
this.setData({
|
||||
groupData: res.data.data
|
||||
})
|
||||
},
|
||||
// 团体是否门店自取
|
||||
async tapTakeType(e) {
|
||||
this.setData({
|
||||
take_type: e.currentTarget.dataset.type,
|
||||
bigIndex: 0,//大分类选中
|
||||
somIndex: null,//小分类选中
|
||||
timeFreight: ''
|
||||
})
|
||||
this.getMaketime()
|
||||
this.calculation()
|
||||
// 1 自送门店 3月底免运费
|
||||
// if (this.data.take_type == 1) {
|
||||
// this.setData({
|
||||
// freightTips: true
|
||||
// })
|
||||
// }
|
||||
},
|
||||
// 普通用户门店自取和上门取件选择
|
||||
async tapTakeTypeOrdinary(e) {
|
||||
|
||||
this.setData({
|
||||
takeTypeOrd: e.currentTarget.dataset.type,
|
||||
bigIndex: 0,//大分类选中
|
||||
somIndex: null,//小分类选中
|
||||
timeFreight: ''
|
||||
})
|
||||
this.getMaketime()
|
||||
this.calculation()
|
||||
// 1 自送门店 3月底免运费
|
||||
// if (this.data.takeTypeOrd == 2) {
|
||||
// this.setData({
|
||||
// freightTips: true
|
||||
// })
|
||||
// }
|
||||
},
|
||||
// 提交下单
|
||||
async placeOrder(e) {
|
||||
// 防止重复提交
|
||||
if (this.data.isPlaceOrder) {
|
||||
return
|
||||
}
|
||||
let formId = e.detail.formId
|
||||
let m = this.data
|
||||
let add = m.address
|
||||
|
||||
if (add == "" && this.data.take_type == 1 && (this.data.groupType !== 0 && this.data.groupType !== -1)) {
|
||||
model.msg.dataMsg({
|
||||
content: "请选择收货地址",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (add == "" && this.data.takeTypeOrd == 2 && (this.data.groupType == 0 || this.data.groupType == -1)) {
|
||||
model.msg.dataMsg({
|
||||
content: "请选择收货地址",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (m.somIndex == null && (this.data.takeTypeOrd == 2 || ((this.data.groupType != 0 && this.data.groupType != -1)))) {
|
||||
model.msg.dataMsg({
|
||||
content: "请选择上门时间",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.data.addIndex == -1 && this.data.takeTypeOrd == 1 && (this.data.groupType == 0 || this.data.groupType == -1)) {
|
||||
model.msg.dataMsg({
|
||||
content: "请选择门店",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
let data = {
|
||||
status: 1,
|
||||
accept_time: '',
|
||||
address_id: "",
|
||||
remarks: m.remarks,
|
||||
form_id: formId,
|
||||
form: this.data.formSource,
|
||||
code_num: this.data.coilingCode,
|
||||
wx_info: {
|
||||
name: add.userName,
|
||||
tel: add.telNumber,
|
||||
address: `${add.provinceName},${add.cityName},${add.countyName},${add.detailInfo}`
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否是自送门店,如果是 logic_type = 1
|
||||
if (this.data.takeTypeOrd == 1) {
|
||||
data.logic_type = 3
|
||||
} else {
|
||||
data.logic_type = 1
|
||||
}
|
||||
|
||||
// 如果普通用户上门取件或团体客户上门取件则,在下单时加上地址id
|
||||
if(this.data.takeTypeOrd == 2 || this.data.take_type == 1) {
|
||||
data.address_id = add.id
|
||||
}
|
||||
|
||||
// 光大用户
|
||||
if (this.data.groupType != 0 && this.data.groupType != -1 ) {
|
||||
data.logic_type = 1
|
||||
}
|
||||
// 普通用户门店自取
|
||||
if (this.data.addIndex !== -1 && this.data.takeTypeOrd == 1 && (this.data.groupType == 0 || this.data.groupType == -1)) {
|
||||
data.accept_shop_id = this.data.addList[this.data.addIndex].id
|
||||
}
|
||||
if (this.data.takeTypeOrd == 2 || (this.data.groupType !== 0 && this.data.groupType !== -1)) {
|
||||
data.accept_time = (`${m.date_list[m.bigIndex].date} ${m.somIndex.time}`).replace(/(^\s*)|(\s*$)/g, "")
|
||||
}
|
||||
this.setData({
|
||||
isPlaceOrder: true
|
||||
})
|
||||
setTimeout(() => {
|
||||
this.setData({
|
||||
isPlaceOrder: false
|
||||
})
|
||||
}, 200)
|
||||
let res = await http.http.request2({ url: `${http.api.quickReserva}`, method: "POST", data: data })
|
||||
if (res.data.status == 1) {
|
||||
model.msg.dataMsg({
|
||||
content: res.data.msg,
|
||||
type: "none"
|
||||
})
|
||||
// 500ms后跳转首页
|
||||
setTimeout(() => {
|
||||
wx.redirectTo({
|
||||
url: "/user/appointment/paid/paid"
|
||||
})
|
||||
}, 500)
|
||||
return
|
||||
}
|
||||
},
|
||||
changeSearch(e) {
|
||||
this.setData({
|
||||
remarks: e.detail.value
|
||||
})
|
||||
},
|
||||
// 码卷
|
||||
changeCode(e) {
|
||||
this.setData({
|
||||
coilingCode: e.detail.value
|
||||
})
|
||||
},
|
||||
// 订单各种金额计算
|
||||
calculation() {
|
||||
let orderPrice = 0, ordinaryPrice = 0, workPrice = 0, totalPrice = 0, postageMoney = 0, wxMoney = 0, total = 0, shopCart = this.data.shopList.shopCart, take_type= this.data.take_type;
|
||||
let groupType = this.data.groupType
|
||||
let coupon = this.data.coupon.price || 0
|
||||
// 不打折的钱
|
||||
let is_discountAll = 0
|
||||
//如果选中的商品有is_special字段并且等于2则改成true
|
||||
//如果等于true则免运费
|
||||
let is_specialAll = false
|
||||
// 邮费配置团体用户的折扣
|
||||
let groupData = this.data.groupData
|
||||
shopCart.forEach((v, i) => {
|
||||
orderPrice += parseFloat(v.price) * v.num
|
||||
// 如果有套餐不给使用优惠卷
|
||||
if (v.is_discount == 2){
|
||||
this.setData({
|
||||
isCoupon: false
|
||||
})
|
||||
}
|
||||
// 如果is_special等于2则代表免运费
|
||||
if (v.is_special == 2) {
|
||||
// 如果有套餐衣物,那么现实3月底不要运费的提示信息
|
||||
this.setData({ freightTips: false });
|
||||
is_specialAll = true
|
||||
}
|
||||
// 这部分钱是不需要打折的钱
|
||||
if (v.is_discount == 2){
|
||||
is_discountAll += parseFloat(v.price) * v.num
|
||||
}
|
||||
if (v.type == 2) {
|
||||
ordinaryPrice += parseFloat(v.price) * v.num
|
||||
} else if (v.type == 1) {
|
||||
workPrice += parseFloat(v.price) * v.num
|
||||
}
|
||||
});
|
||||
// 如果groupType不是0则是团体用户
|
||||
if (groupType !== 0) {
|
||||
totalPrice = (((ordinaryPrice - is_discountAll) * groupData.wx_discount / 100) + workPrice + is_discountAll)
|
||||
// 计算光大用户的专属折扣
|
||||
ordinaryPrice = ((ordinaryPrice - is_discountAll) * groupData.wx_discount / 100)
|
||||
total = totalPrice
|
||||
} else {
|
||||
// 商品总价
|
||||
totalPrice = ordinaryPrice + workPrice
|
||||
// 加上优惠卷
|
||||
total = totalPrice - coupon
|
||||
ordinaryPrice = 0.00
|
||||
// 计算普通用户选择会员卡和优惠券后的价格
|
||||
if (this.data.giftCard.price) {
|
||||
total = ((total - is_discountAll) * (this.data.giftCard.price * 0.1)) + is_discountAll
|
||||
}
|
||||
}
|
||||
// 计算邮费
|
||||
// 团体客户计算运费
|
||||
if (groupType !== 0) {
|
||||
// 团体用户普通洗
|
||||
if (this.data.type == 1) {
|
||||
postageMoney = this.postageTwo(total, is_specialAll)
|
||||
wxMoney = wxMoney + postageMoney
|
||||
} else if (this.data.type == 2) {
|
||||
// 团体用户工服洗计算
|
||||
postageMoney = this.postageOne(total)
|
||||
}
|
||||
} else {
|
||||
// 正常用户运费计算
|
||||
postageMoney = this.postageThree(total, is_specialAll)
|
||||
}
|
||||
|
||||
// shopList.total 做三元运算判断,防止支付金额出现负数.
|
||||
this.setData({
|
||||
'shopList.orderPrice': orderPrice.toFixed(2),
|
||||
'shopList.ordinaryPrice': ordinaryPrice.toFixed(2),
|
||||
'shopList.workPrice': workPrice.toFixed(2),
|
||||
'shopList.totalPrice': (totalPrice + postageMoney).toFixed(2),
|
||||
'shopList.postageMoney': postageMoney.toFixed(2),
|
||||
'shopList.wxMoney': ordinaryPrice.toFixed(2),
|
||||
'shopList.total': (total + postageMoney).toFixed(2) <= 0 ? 0 : (total + postageMoney).toFixed(2)
|
||||
})
|
||||
},
|
||||
// 团体客户清洗工服的邮费计算
|
||||
postageOne(total){
|
||||
let postageMoney = 0;
|
||||
// 邮费配置团体用户的折扣
|
||||
// 因为团体客户使用专属卡洗衣所以,运费从专属配置中获取
|
||||
let groupData = this.data.groupData
|
||||
|
||||
// 正常判断总价是否大于收取运费的阈值
|
||||
if ((total >= groupData.satisfy_money)) {
|
||||
postageMoney = 0
|
||||
} else {
|
||||
// 这一步中如果时间上不收取运费 并且是单位取件则不收取运费
|
||||
if ((this.data.timeFreight <= 0 && this.data.take_type == 2)){
|
||||
postageMoney = 0
|
||||
}else{
|
||||
postageMoney = groupData.postage_money
|
||||
}
|
||||
}
|
||||
return postageMoney
|
||||
},
|
||||
// 团体客户清洗普通衣物邮费计算
|
||||
//
|
||||
postageTwo(total, suit){
|
||||
let postageMoney = 0;
|
||||
// 邮费配置
|
||||
let postage = this.data.postage;
|
||||
|
||||
// 正常判断总价是否大于收取运费的阈值
|
||||
if ((total >= postage.satisfy_money) || suit) {
|
||||
postageMoney = 0
|
||||
} else {
|
||||
// 如果是单位取件 并且 时间上是免运费 就不收运费
|
||||
if ((this.data.timeFreight <= 0 && this.data.take_type == 2) || suit > 0){
|
||||
postageMoney = 0
|
||||
}else{
|
||||
postageMoney = postage.postage_money
|
||||
}
|
||||
}
|
||||
return postageMoney
|
||||
},
|
||||
// 普通客户清洗衣物的邮费计算
|
||||
postageThree(total, suit){
|
||||
let postageMoney = 0;
|
||||
// 邮费配置
|
||||
let postage = this.data.postage;
|
||||
|
||||
// 正常判断总价是否大于收取运费的阈值 如果是门店自取不收取客户运费
|
||||
if (total >= postage.satisfy_money || suit || this.data.takeTypeOrd == 1) {
|
||||
postageMoney = 0
|
||||
} else {
|
||||
postageMoney = postage.postage_money
|
||||
}
|
||||
return postageMoney
|
||||
},
|
||||
// 获取卡劵
|
||||
async getGiftCard() {
|
||||
let giftCard = await model.storage.getSetting("giftCard")
|
||||
if (!!giftCard) {
|
||||
model.storage.deleteStorage('giftCard')
|
||||
this.setData({
|
||||
giftCard: giftCard,
|
||||
isgiftCard: giftCard.title + " " + giftCard.price + '折',
|
||||
isPayp: 1
|
||||
})
|
||||
}
|
||||
this.calculation()
|
||||
},
|
||||
// 获取优惠券
|
||||
async getCoupon() {
|
||||
let coupon = await model.storage.getSetting("coupon")
|
||||
if (!!coupon) {
|
||||
model.storage.deleteStorage('coupon')
|
||||
this.setData({
|
||||
coupon: coupon
|
||||
})
|
||||
}
|
||||
this.calculation()
|
||||
},
|
||||
// 选择支付方式
|
||||
selectPay(e) {
|
||||
let type = e.currentTarget.dataset.type
|
||||
let url = e.currentTarget.dataset.url
|
||||
if (type == 2) {
|
||||
this.setData({
|
||||
isgiftCard: "",
|
||||
giftCard: {},
|
||||
isPayp: type
|
||||
})
|
||||
this.calculation()
|
||||
} else if (type == 1) {
|
||||
wx.navigateTo({
|
||||
url: url
|
||||
})
|
||||
}
|
||||
},
|
||||
// 用户支付
|
||||
async payment(e) {
|
||||
let formId = e.detail.formId
|
||||
let m = this.data
|
||||
let add = m.address
|
||||
|
||||
if (add == "" && this.data.take_type == 1 && (this.data.groupType !== 0 && this.data.groupType !== -1)) {
|
||||
model.msg.dataMsg({
|
||||
content: "请选择收货地址",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (add == "" && this.data.takeTypeOrd == 2 && (this.data.groupType == 0 || this.data.groupType == -1)) {
|
||||
model.msg.dataMsg({
|
||||
content: "请选择收货地址",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (m.somIndex == null && (this.data.takeTypeOrd == 2 || ((this.data.groupType != 0 && this.data.groupType != -1)))) {
|
||||
model.msg.dataMsg({
|
||||
content: "请选择上门时间",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.data.addIndex == -1 && this.data.takeTypeOrd == 1 && (this.data.groupType == 0 || this.data.groupType == -1)){
|
||||
model.msg.dataMsg({
|
||||
content: "请选择门店",
|
||||
type: "warning"
|
||||
})
|
||||
return
|
||||
}
|
||||
// 如果是光大用户切礼卡中钱不足则提示
|
||||
if (this.data.groupType !== 0 && this.data.type == 2 && parseFloat(this.data.giftCard.money) < this.data.shopList.workPrice) {
|
||||
model.msg.dataMsg({
|
||||
content: "礼卡中余额不足不能清洗工服,请重新下单清洗普通衣物",
|
||||
type: "warning",
|
||||
duration: 3
|
||||
})
|
||||
return
|
||||
}
|
||||
let pro_id = '', pro_id_count = '';
|
||||
let data = {
|
||||
status: 1,
|
||||
accept_time: '',
|
||||
address_id: "",
|
||||
remarks: m.remarks,
|
||||
form_id: formId,
|
||||
wx_info: {
|
||||
name: add.userName,
|
||||
tel: add.telNumber,
|
||||
address: `${add.provinceName},${add.cityName},${add.countyName},${add.detailInfo}`
|
||||
},
|
||||
take_type: this.data.groupType == 39 ? this.data.take_type : 1
|
||||
};
|
||||
|
||||
// 判断是否是自送门店,如果是 logic_type = 1
|
||||
if (this.data.takeTypeOrd == 1) {
|
||||
data.logic_type = 3
|
||||
} else {
|
||||
data.logic_type = 1
|
||||
}
|
||||
|
||||
// 如果普通用户上门取件或团体客户上门取件则,在下单时加上地址id
|
||||
if(this.data.takeTypeOrd == 2 || this.data.take_type == 1) {
|
||||
data.address_id = add.id
|
||||
}
|
||||
|
||||
// 光大用户
|
||||
if (this.data.groupType != 0 && this.data.groupType != -1) {
|
||||
data.logic_type = 1
|
||||
}
|
||||
|
||||
|
||||
m.shopList.shopCart.forEach((v, i) => {
|
||||
pro_id += v.id + ','
|
||||
pro_id_count += v.num + ','
|
||||
})
|
||||
data.pro_id = pro_id.replace(/^(\s|,)+|(\s|,)+$/g, '')
|
||||
data.pro_id_count = pro_id_count.replace(/^(\s|,)+|(\s|,)+$/g, '')
|
||||
if(this.data.take_type == 2 && this.data.groupType == 39){
|
||||
data.brand_id = this.data.branchList[this.data.branchIndex].id
|
||||
}
|
||||
// 普通用户门店自取
|
||||
if (this.data.addIndex !== -1 && this.data.takeTypeOrd == 1 && (this.data.groupType == 0 || this.data.groupType == -1)){
|
||||
data.accept_shop_id = this.data.addList[this.data.addIndex].id
|
||||
}
|
||||
if (this.data.takeTypeOrd == 2 || (this.data.groupType !== 0 && this.data.groupType !== -1)){
|
||||
data.accept_time = (`${m.date_list[m.bigIndex].date} ${m.somIndex.time}`).replace(/(^\s*)|(\s*$)/g, "")
|
||||
}
|
||||
let res = await http.http.request2({ url: http.api.newQReserva, method: "POST", data: data })
|
||||
let payInfo = {
|
||||
orderID: res.data.data.order_id,
|
||||
userCouponID: 0,
|
||||
userCardID: 0
|
||||
}
|
||||
// 光大用户
|
||||
if (this.data.groupType !== 0 && this.data.groupType !== -1) {
|
||||
payInfo.payType = 3
|
||||
payInfo.userCardID = this.data.giftCard.id
|
||||
if(this.data.take_type == 2){
|
||||
payInfo.bindId = this.data.branchList[this.data.branchIndex].id
|
||||
}
|
||||
} else {
|
||||
// 普通用户
|
||||
payInfo.payType = this.data.isPayp
|
||||
// 卡
|
||||
if (this.data.isPayp == 1) {
|
||||
payInfo.userCardID = this.data.giftCard.id
|
||||
}
|
||||
// 优惠券
|
||||
if (!!this.data.coupon.id) {
|
||||
payInfo.userCouponID = this.data.coupon.id
|
||||
}
|
||||
}
|
||||
let rel = await model.payment.pay(http.api.preShopOrder, payInfo)
|
||||
if (rel == 1) {
|
||||
// 500ms后跳转首页
|
||||
setTimeout(() => {
|
||||
wx.redirectTo({
|
||||
url: "/user/appointment/paid/paid"
|
||||
})
|
||||
}, 500)
|
||||
return
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: async function (options) {
|
||||
let isTel = app.globalData.userInfo.telnum
|
||||
if (isTel == "点击授权手机号" || isTel == '') {
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
return 1
|
||||
}
|
||||
|
||||
this.data.isCurtains = options.isCurtains
|
||||
// console.log("options.isCurtains: ", this.data.isCurtains)
|
||||
// 如果有值,则代表从别的小程序过来的
|
||||
if (!!options.from){
|
||||
this.setData({
|
||||
formSource: options.from
|
||||
})
|
||||
// 存储用户来源,在登录时使用
|
||||
model.storage.setStorage("from", options.from)
|
||||
}
|
||||
Promise.all([this.getMaketime(),this.getConsignee(),this.groupBranchList(),this.postage(),this.getStoreList()])
|
||||
.then( async (res)=>{
|
||||
if (!!options.shopCart) {
|
||||
let shopCart = JSON.parse(options.shopCart)
|
||||
this.setData({
|
||||
'shopList.shopCart': shopCart,
|
||||
groupType: parseInt(options.group_type),
|
||||
type: parseInt(options.type)
|
||||
})
|
||||
if (options.group_type !== '0') {
|
||||
// 如果是团体用户默认选中单位取件
|
||||
this.setData({
|
||||
take_type: 2
|
||||
})
|
||||
// 如果是团体客户重新调一次时间 因为团体默认单位取件
|
||||
this.getMaketime()
|
||||
// 获取团体卡
|
||||
this.getGuangDa()
|
||||
await this.groupDiscountInfo()
|
||||
}
|
||||
// 订单各种金额计算
|
||||
this.calculation()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
this.getAdd()
|
||||
if (this.data.groupType != -1) {
|
||||
this.getGiftCard()
|
||||
this.getCoupon()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user