|
...
|
...
|
@@ -66,6 +66,7 @@ Page({ |
|
|
|
isMoreBtn:'',//再次预订按钮
|
|
|
|
isPaymenBtn:'',//支付定金按钮
|
|
|
|
isShareItem:'',//转发客人按钮
|
|
|
|
couponArr: [],//待领取的优惠券列表
|
|
|
|
},
|
|
|
|
tablestr: '',
|
|
|
|
urlsValue: [],
|
|
...
|
...
|
@@ -75,6 +76,7 @@ Page({ |
|
|
|
timers: null, // 动画定时器
|
|
|
|
n: 0,
|
|
|
|
modal:'',
|
|
|
|
couponModal: '',
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
...
|
...
|
@@ -102,6 +104,7 @@ Page({ |
|
|
|
wx.onUserCaptureScreen((res)=> {
|
|
|
|
this.showModal()
|
|
|
|
})
|
|
|
|
this.couponModal = this.selectComponent("#couponModal");
|
|
|
|
},
|
|
|
|
// 打开截屏弹框
|
|
|
|
showModal() {
|
|
...
|
...
|
@@ -111,6 +114,10 @@ Page({ |
|
|
|
closeModal() {
|
|
|
|
this.modal.closeModal()
|
|
|
|
},
|
|
|
|
// 关闭优惠券弹框
|
|
|
|
closeCouponModal() {
|
|
|
|
this.couponModal.closeModal()
|
|
|
|
},
|
|
|
|
// 页面滚动事件
|
|
|
|
onPageScroll: function (event) {
|
|
|
|
const scrollTop = event.scrollTop * 1 + this.screenHeight - 80; // 获取滚动的距离
|
|
...
|
...
|
@@ -456,9 +463,10 @@ Page({ |
|
|
|
uid
|
|
|
|
}).then((json) => {
|
|
|
|
if (json.ret == 200) {
|
|
|
|
console.log('staffinfostaffinfostaffinfo', json.data)
|
|
|
|
console.log('客户经理获取基本信息------', json.data)
|
|
|
|
this.setData({
|
|
|
|
staffinfo: json.data
|
|
|
|
staffinfo: json.data,
|
|
|
|
couponArr:[],
|
|
|
|
})
|
|
|
|
this.getSellerTemplateConfFun(sid);
|
|
|
|
}
|
|
...
|
...
|
@@ -579,7 +587,7 @@ Page({ |
|
|
|
let data = res.data
|
|
|
|
console.log('data', data);
|
|
|
|
let couponList = []
|
|
|
|
let themeColor, StyleType, titleType, themeSixteen, home, chef, marketing, coupon, reserve, swich_phone, is_comments, signboard, store;
|
|
|
|
let themeColor, StyleType, titleType, themeSixteen, home, chef, marketing, coupon, coupon_data_pay, coupon_data_free, reserve, swich_phone, is_comments, signboard, store;
|
|
|
|
chef = util.determine(data.chef);
|
|
|
|
reserve = util.determine(data.reserve);
|
|
|
|
marketing = util.determine(data.marketing);
|
|
...
|
...
|
@@ -598,29 +606,23 @@ Page({ |
|
|
|
if (marketing) {
|
|
|
|
marketing.logo = (marketing.logo && (!marketing.is_logo || marketing.is_logo!='0')) ? marketing.logo : '';
|
|
|
|
is_comments = marketing.is_comments ? marketing.is_comments : '';
|
|
|
|
coupon = marketing.coupon_data ? util.determine(marketing.coupon_data) : '';
|
|
|
|
coupon = (marketing.coupon_data && marketing.is_coupon == '1') ? util.determine(marketing.coupon_data) : '';
|
|
|
|
coupon_data_pay = (marketing.coupon_data_pay && marketing.is_coupon_pay == '1') ? util.determine(marketing.coupon_data_pay) : '';
|
|
|
|
marketing.coupon_data_payList = coupon_data_pay
|
|
|
|
coupon_data_free = (marketing.coupon_data_free && marketing.is_coupon_free == '1') ? util.determine(marketing.coupon_data_free) : '';
|
|
|
|
marketing.coupon_data_freeList = coupon_data_free
|
|
|
|
let info = marketing.coupon_data_comments ? util.determine(marketing.coupon_data_comments) : '';
|
|
|
|
let couponDataId = info && info.length > 0 ? info[0].id : {}
|
|
|
|
// 根据券ID获取评价赠送的券详情
|
|
|
|
if(couponDataId) this.getEvaluateFun(couponDataId)
|
|
|
|
}
|
|
|
|
// is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示
|
|
|
|
if (coupon && util.getType(coupon) == 'object') {
|
|
|
|
couponList.push({
|
|
|
|
id: coupon.id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (coupon && util.getType(coupon) == 'array') {
|
|
|
|
if (coupon.length > 0) {
|
|
|
|
coupon.forEach(item => {
|
|
|
|
couponList.push({
|
|
|
|
id: item.id
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取全部的优惠券(商家券、个人券、免费券、付费券)
|
|
|
|
couponList = this.addCoupons(coupon,couponList);
|
|
|
|
couponList = this.addCoupons(coupon_data_pay,couponList);
|
|
|
|
couponList = this.addCoupons(coupon_data_free,couponList);
|
|
|
|
// 根据券ID获取券详情
|
|
|
|
this.getActivityByIdFun(couponList, couponList.length)
|
|
|
|
this.getActivityByIdFun(couponList)
|
|
|
|
// 根据充值ID获取充值详情
|
|
|
|
if (marketing && marketing.is_recharge && marketing.is_recharge == '1' && marketing.recharge_data) {
|
|
|
|
this.getRechargeDetail(marketing.recharge_data.id)
|
|
...
|
...
|
@@ -742,13 +744,16 @@ Page({ |
|
|
|
})
|
|
|
|
},
|
|
|
|
// 点击商家有礼
|
|
|
|
gotoSellerGift(){
|
|
|
|
let url = util.http_build_query({
|
|
|
|
gotoSellerGift(e){
|
|
|
|
this.couponModal.closeModal()
|
|
|
|
const form = e.currentTarget.dataset['form'];
|
|
|
|
let url = util.http_build_query({
|
|
|
|
id: this.data.detail.id,
|
|
|
|
}, '/pages/reserve/sellerGift')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
form
|
|
|
|
}, '/pages/reserve/sellerGift')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 再次预订
|
|
|
|
secondbook() {
|
|
...
|
...
|
@@ -902,34 +907,172 @@ Page({ |
|
|
|
})
|
|
|
|
},
|
|
|
|
// 根据券ID获取券详情
|
|
|
|
getActivityByIdFun(ids, length) {
|
|
|
|
let coupon_dataList = [];
|
|
|
|
ids.forEach(i => {
|
|
|
|
App.Activity.GetActivityById({
|
|
|
|
id: i.id
|
|
|
|
}).then(res => {
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
let detail = res.data[0];
|
|
|
|
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
|
|
|
|
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
|
|
|
|
detail.use = detail.use ? util.determine(detail.use) : '';
|
|
|
|
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
|
|
|
|
let cash = detail.use.cash * 1;
|
|
|
|
let price = detail.price * 1;
|
|
|
|
detail.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
coupon_dataList.push(detail);
|
|
|
|
if (length === coupon_dataList.length) {
|
|
|
|
coupon_dataList = coupon_dataList.filter(item=>{return this.data.dataStr<(item.etime*1) && item.is_open == '1'})
|
|
|
|
console.log('邀请函--------------------优惠券',coupon_dataList);
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getActivityByIdFun(obj) {
|
|
|
|
App.Activity.GetActivityById({
|
|
|
|
id: obj.map(item => item.id).join(','),
|
|
|
|
}).then(res => {
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
let list = res.data.filter(item => {
|
|
|
|
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
|
|
|
|
})
|
|
|
|
list.forEach(detail => {
|
|
|
|
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
|
|
|
|
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
|
|
|
|
detail.arule = detail.arule ? util.determine(detail.arule) : '';
|
|
|
|
detail.use = detail.use ? util.determine(detail.use) : '';
|
|
|
|
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
|
|
|
|
let cash = detail.use.cash * 1;
|
|
|
|
let price = detail.price * 1;
|
|
|
|
detail.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
let num = detail.receiveNum;
|
|
|
|
if (num > 0) {
|
|
|
|
detail.receiveNumText = ''
|
|
|
|
if (num >= 0 && num <= 100) {
|
|
|
|
detail.receiveNumText = num.toString();
|
|
|
|
} else if (num >= 101 && num <= 199) {
|
|
|
|
detail.receiveNumText = '100+';
|
|
|
|
} else if (num >= 200 && num <= 299) {
|
|
|
|
detail.receiveNumText = '200+';
|
|
|
|
} else {
|
|
|
|
detail.receiveNumText = Math.floor(num / 100) * 100 + '+';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (detail.exp_date && detail.exp_date.week_data) {
|
|
|
|
let noon = this.hasConsecutiveSelect(detail.exp_date.week_data, '1').rArr.join('、')
|
|
|
|
let nig = this.hasConsecutiveSelect(detail.exp_date.week_data, '2').rArr.join('、')
|
|
|
|
if (noon) noon = '午餐:' + noon
|
|
|
|
if (nig) nig = '晚餐:' + nig
|
|
|
|
detail.noonText = noon;
|
|
|
|
detail.nigText = nig;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
let freeCoupons = list.filter(item => {
|
|
|
|
return item.is_type == '3'
|
|
|
|
})
|
|
|
|
// 免费券判断是否领取,弹框领取
|
|
|
|
if (freeCoupons.length > 0) {
|
|
|
|
let length = freeCoupons.length - 1
|
|
|
|
freeCoupons.forEach(i => {
|
|
|
|
this.getCoupon(i, freeCoupons[length].id, obj)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------优惠券', list);
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList: list,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取所有的券并且展示
|
|
|
|
addCoupons(coupons, couponList) {
|
|
|
|
if (coupons && util.getType(coupons) == 'object') {
|
|
|
|
couponList.push({
|
|
|
|
id: coupon.id,
|
|
|
|
number: coupon.number
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (coupons && util.getType(coupons) === 'array' && coupons.length > 0) {
|
|
|
|
coupons.forEach(item => {
|
|
|
|
couponList.push({
|
|
|
|
id: item.id,
|
|
|
|
number: item.number
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return couponList
|
|
|
|
},
|
|
|
|
// 弹框领取免费券
|
|
|
|
setcouponFun(arr) {
|
|
|
|
let str = arr.flatMap(item => Array(item.number).fill(item.id)).join(',');
|
|
|
|
console.log('弹框领取免费券id', str);
|
|
|
|
App.Activity.SetActivityAsReserve({
|
|
|
|
aid: str,
|
|
|
|
rid: this.id,
|
|
|
|
}).then((json) => {
|
|
|
|
if (json.ret != 200) {
|
|
|
|
wx.showToast({
|
|
|
|
title: res.msg,
|
|
|
|
duration: 2000,
|
|
|
|
mask: true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 免费券 0未领取 1已领取 获取未领取的组成数组couponArr
|
|
|
|
getCoupon(item, id, obj) {
|
|
|
|
let couponArr = this.data.couponArr;
|
|
|
|
let totalPrice = this.data.totalPrice;
|
|
|
|
App.Activity.ActivityListByOpenid({
|
|
|
|
aid: item.id
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
if (res.data.length == 0) {
|
|
|
|
couponArr.push(item)
|
|
|
|
}
|
|
|
|
if (item.id == id && couponArr.length > 0) {
|
|
|
|
couponArr.forEach(item => {
|
|
|
|
let match = obj.find(b => b.id === item.id);
|
|
|
|
if (match) {
|
|
|
|
item.number = match.number;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0);
|
|
|
|
this.setcouponFun(couponArr)
|
|
|
|
this.couponModal.showModal()
|
|
|
|
}
|
|
|
|
console.log('未领取的券列表-----------', couponArr);
|
|
|
|
this.setData({
|
|
|
|
couponArr,
|
|
|
|
totalPrice
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 处理优惠券不可用日期数据
|
|
|
|
hasConsecutiveSelect(arr, type) {
|
|
|
|
let firstTitle = null;
|
|
|
|
let lastTitle = null;
|
|
|
|
let rArr = []
|
|
|
|
let num = 0
|
|
|
|
for (let i = 0; i < arr.length; i++) {
|
|
|
|
let str = type == '1' ? arr[i].selectNoon : arr[i].selectNig
|
|
|
|
if (str) {
|
|
|
|
rArr.push(arr[i].title)
|
|
|
|
num++
|
|
|
|
if (num == 1) {
|
|
|
|
firstTitle = arr[i].title
|
|
|
|
}
|
|
|
|
if (num >= 5) {
|
|
|
|
lastTitle = arr[i].title
|
|
|
|
}
|
|
|
|
if (num >= 5 && i >= (arr.length - 1)) {
|
|
|
|
let fi = rArr.findIndex((item) => {
|
|
|
|
return item == firstTitle
|
|
|
|
})
|
|
|
|
rArr.splice(fi, num, firstTitle + '至' + lastTitle)
|
|
|
|
num = 0
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (num < 5) {
|
|
|
|
num = 0
|
|
|
|
firstTitle = null;
|
|
|
|
lastTitle = null;
|
|
|
|
} else {
|
|
|
|
let fi = rArr.findIndex((item) => {
|
|
|
|
return item == firstTitle
|
|
|
|
})
|
|
|
|
rArr.splice(fi, num, firstTitle + '至' + lastTitle)
|
|
|
|
num = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
rArr,
|
|
|
|
lastTitle,
|
|
|
|
firstTitle
|
|
|
|
};
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
...
|
...
|
|