|
...
|
...
|
@@ -66,6 +66,8 @@ Page({ |
|
|
|
roomimage: [], //包间信息列表
|
|
|
|
activeTitle: '1', //选择的标题 1优惠券 2充值 3评价
|
|
|
|
titleList: [], //优惠券、充值、评价标题数组
|
|
|
|
couponArr: [],//待领取的优惠券列表
|
|
|
|
couponList:[],//优惠券列表
|
|
|
|
},
|
|
|
|
tablestr: '', //桌位id拼接
|
|
|
|
screenHeight: '',
|
|
...
|
...
|
@@ -74,6 +76,7 @@ Page({ |
|
|
|
timers: null, // 动画定时器
|
|
|
|
n: 0,
|
|
|
|
modal: '',
|
|
|
|
couponModal: '',
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
...
|
...
|
@@ -105,6 +108,7 @@ Page({ |
|
|
|
wx.onUserCaptureScreen((res) => {
|
|
|
|
this.modal.showModal()
|
|
|
|
})
|
|
|
|
this.couponModal = this.selectComponent("#couponModal");
|
|
|
|
},
|
|
|
|
// 锚点定位
|
|
|
|
gotoModule(e) {
|
|
...
|
...
|
@@ -126,6 +130,11 @@ Page({ |
|
|
|
closeModal() {
|
|
|
|
this.modal.closeModal()
|
|
|
|
},
|
|
|
|
// 关闭优惠券弹框(更新已被领取数量)
|
|
|
|
closeCouponModal() {
|
|
|
|
this.getActivityByIdFun(this.data.couponList,'1')
|
|
|
|
this.couponModal.closeModal()
|
|
|
|
},
|
|
|
|
// 页面滚动事件
|
|
|
|
onPageScroll: function (event) {
|
|
|
|
if (event.scrollTop > 150) { //当页面滚动到某个位置时(这里设置为50),将导航栏背景颜色设置为白色
|
|
...
|
...
|
@@ -248,9 +257,11 @@ Page({ |
|
|
|
sellerid,
|
|
|
|
tableids: this.tablestr
|
|
|
|
}).then((json) => {
|
|
|
|
console.log('客户经理获取基本信息------', json.data)
|
|
|
|
if (json.ret == 200) {
|
|
|
|
this.setData({
|
|
|
|
roomimage: json.data
|
|
|
|
roomimage: json.data,
|
|
|
|
couponArr:[],
|
|
|
|
})
|
|
|
|
var urlsArr = [];
|
|
|
|
json.data.forEach((v, i) => {
|
|
...
|
...
|
@@ -601,7 +612,7 @@ Page({ |
|
|
|
}).then(res => {
|
|
|
|
let data = res.data
|
|
|
|
let couponList = []
|
|
|
|
let StyleType, home, chef, marketing, coupon, reserve, swich_phone, is_comments, signboard, store;
|
|
|
|
let StyleType, 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);
|
|
...
|
...
|
@@ -618,29 +629,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)
|
|
...
|
...
|
@@ -679,6 +684,7 @@ Page({ |
|
|
|
lite_style: data.lite_style,
|
|
|
|
timeList,
|
|
|
|
is_comments,
|
|
|
|
couponList,
|
|
|
|
isMoreBtn: marketing && marketing.is_online_book == '1' && this.data.options.onlineReserve == '1',
|
|
|
|
isShareItem: this.data.options.isOrder != '1' && marketing && marketing.is_transpond == '1',
|
|
|
|
isComments: is_comments == '1' && marketing && marketing.is_comments_coupon == '1',
|
|
...
|
...
|
@@ -728,9 +734,12 @@ Page({ |
|
|
|
})
|
|
|
|
},
|
|
|
|
// 点击商家有礼
|
|
|
|
gotoSellerGift() {
|
|
|
|
gotoSellerGift(e){
|
|
|
|
this.couponModal.closeModal()
|
|
|
|
const form = e.currentTarget.dataset['form'];
|
|
|
|
let url = util.http_build_query({
|
|
|
|
id: this.data.detail.id,
|
|
|
|
form
|
|
|
|
}, '/pages/reserve/sellerGift')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
...
|
...
|
@@ -898,19 +907,39 @@ Page({ |
|
|
|
id
|
|
|
|
}).then(res => {
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
let couponData = res.data[0]
|
|
|
|
couponData.use = couponData.use ? util.determine(couponData.use) : '';
|
|
|
|
couponData.exp_date = couponData.exp_date ? util.determine(couponData.exp_date) : '';
|
|
|
|
if ((couponData.use && (!couponData.use.is_cash || couponData.use.is_cash == '1'))) {
|
|
|
|
let cash = couponData.use.cash * 1;
|
|
|
|
let price = couponData.price * 1;
|
|
|
|
couponData.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
let detail = res.data[0]
|
|
|
|
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.grant_num*1-detail.grant_last*1;
|
|
|
|
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 + '+';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// showCoupon 代表赠送的券没过有效期 && 是开启状态
|
|
|
|
couponData.showCoupon = (this.data.dataStr < (couponData.etime * 1) && couponData.is_open == '1') ? '1' : '0';
|
|
|
|
console.log('邀请函--------------------评价赠送的优惠券', couponData);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0';
|
|
|
|
let entry = this.data.titleList
|
|
|
|
if ((!this.data.is_user_comments && this.data.isComments == '1' && couponData.showCoupon == '1') || (this.data.is_comments == '1' && (this.data.marketing.is_comments_coupon != '1' || couponData.showCoupon != '1'))) {
|
|
|
|
if ((!this.data.is_user_comments && this.data.isComments == '1' && detail.showCoupon == '1') || (this.data.is_comments == '1' && (this.data.marketing.is_comments_coupon != '1' || detail.showCoupon != '1'))) {
|
|
|
|
entry.push({
|
|
|
|
id: 3,
|
|
|
|
title: '评价反馈'
|
|
...
|
...
|
@@ -919,8 +948,9 @@ Page({ |
|
|
|
entry.sort((a, b) => a.id - b.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------评价赠送的优惠券', detail);
|
|
|
|
this.setData({
|
|
|
|
couponData: res.data[0],
|
|
|
|
couponData: detail,
|
|
|
|
titleList: entry,
|
|
|
|
activeTitle: entry.length > 0 ? entry[0].id : '',
|
|
|
|
})
|
|
...
|
...
|
@@ -928,50 +958,194 @@ 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];
|
|
|
|
getActivityByIdFun(obj,setcoupon) {
|
|
|
|
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.grant_num * 1 - detail.grant_last * 1;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
detail.stimeStr = util.unixtoTime(detail.stime, 'YYYY-MM-DD HH:II')
|
|
|
|
detail.etimeStr = util.unixtoTime(detail.etime, 'YYYY-MM-DD HH:II')
|
|
|
|
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'
|
|
|
|
})
|
|
|
|
let entry = this.data.titleList
|
|
|
|
if (this.data.hasValueCertificate && this.data.marketing.is_coupon == '1' && coupon_dataList.length > 0) {
|
|
|
|
entry.push({
|
|
|
|
id: 1,
|
|
|
|
title: '专属优惠券'
|
|
|
|
})
|
|
|
|
if (entry.length > 0) {
|
|
|
|
entry.sort((a, b) => a.id - b.id);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
let freeCoupons = list.filter(item => {
|
|
|
|
return item.is_type == '3'
|
|
|
|
})
|
|
|
|
let entry = this.data.titleList
|
|
|
|
if (this.data.hasValueCertificate && list.length > 0 && setcoupon != '1') {
|
|
|
|
entry.push({
|
|
|
|
id: 1,
|
|
|
|
title: '专属优惠券'
|
|
|
|
})
|
|
|
|
if (entry.length > 0) {
|
|
|
|
entry.sort((a, b) => a.id - b.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 免费券判断是否领取,弹框领取
|
|
|
|
if (freeCoupons.length > 0 && setcoupon != '1') {
|
|
|
|
let length = freeCoupons.length - 1
|
|
|
|
freeCoupons.forEach(i => {
|
|
|
|
this.getCoupon(i, freeCoupons[length].id, obj)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------优惠券', list);
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList: list,
|
|
|
|
titleList: entry,
|
|
|
|
activeTitle: entry.length > 0 ? entry[0].id : '',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取所有的券并且展示
|
|
|
|
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,
|
|
|
|
sellerid:this.data.seller.sid,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
if (res.data.length == 0) {
|
|
|
|
couponArr.push(item)
|
|
|
|
}
|
|
|
|
if (item.id == id && couponArr.length > 0) {
|
|
|
|
couponArr.forEach((item,index) => {
|
|
|
|
let match = obj.find(b => b.id === item.id);
|
|
|
|
if (match) {
|
|
|
|
item.number = match.number;
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------优惠券', coupon_dataList);
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList,
|
|
|
|
titleList: entry,
|
|
|
|
activeTitle: entry.length > 0 ? entry[0].id : '',
|
|
|
|
})
|
|
|
|
item.grant_num = item.grant_num*1
|
|
|
|
if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1)
|
|
|
|
if(item.number>item.grant_num){
|
|
|
|
item.number = item.grant_num
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(couponArr.length>0){
|
|
|
|
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
|
|
|
|
};
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
...
|
...
|
|