|
...
|
...
|
@@ -1002,15 +1002,31 @@ Page({ |
|
|
|
entry.sort((a, b) => a.id - b.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------评价赠送的优惠券', detail);
|
|
|
|
this.getDetailFun(detail)
|
|
|
|
this.setData({
|
|
|
|
couponData: detail,
|
|
|
|
titleList: entry,
|
|
|
|
activeTitle: entry.length > 0 ? entry[0].id : '',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 免费券显示是否领取
|
|
|
|
getDetailFun(detail) {
|
|
|
|
App.Activity.ActivityListByOpenid({
|
|
|
|
aid: detail.id,
|
|
|
|
sellerid:this.data.seller.sid,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
if(res.data.length>0){
|
|
|
|
detail.resultCoupon = '1';//显示已领取
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------评价赠送的优惠券', detail);
|
|
|
|
this.setData({
|
|
|
|
couponData: detail,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 根据券ID获取券详情
|
|
|
|
getActivityByIdFun(obj,setcoupon) {
|
|
|
|
App.Activity.GetActivityById({
|
|
...
|
...
|
@@ -1082,10 +1098,7 @@ Page({ |
|
|
|
}
|
|
|
|
// 免费券判断是否领取,弹框领取
|
|
|
|
if (freeCoupons.length > 0 && setcoupon != '1') {
|
|
|
|
let length = freeCoupons.length - 1
|
|
|
|
freeCoupons.forEach(i => {
|
|
|
|
this.getCoupon(i, freeCoupons[length].id, obj)
|
|
|
|
})
|
|
|
|
this.getCoupon(freeCoupons,obj,setcoupon)
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------优惠券', list);
|
|
|
|
this.setData({
|
|
...
|
...
|
@@ -1132,39 +1145,73 @@ Page({ |
|
|
|
})
|
|
|
|
},
|
|
|
|
// 免费券 0未领取 1已领取 获取未领取的组成数组couponArr
|
|
|
|
getCoupon(item, id, obj) {
|
|
|
|
let couponArr = this.data.couponArr;
|
|
|
|
let totalPrice = this.data.totalPrice;
|
|
|
|
App.Activity.ActivityListByOpenid({
|
|
|
|
aid: item.id,
|
|
|
|
getCoupon(arr,info,setcoupon) {
|
|
|
|
let str = arr.flatMap(item => Array(item.number).fill(item.id)).join(',');
|
|
|
|
App.Activity.ActivityListByOpenid({
|
|
|
|
aid: str,
|
|
|
|
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;
|
|
|
|
let couponArr = [];
|
|
|
|
let totalPrice = 0;
|
|
|
|
let coupon_dataList = this.data.coupon_dataList;
|
|
|
|
let list = res.data;
|
|
|
|
const strArray = str.split(',');
|
|
|
|
const result = strArray.filter(num => {
|
|
|
|
return!list.some(item => item.id === num);
|
|
|
|
});
|
|
|
|
console.log('待领取的券id',result);
|
|
|
|
if(result.length>0){
|
|
|
|
result.forEach(item=>{
|
|
|
|
let match = arr.find(b => b.id === item);
|
|
|
|
let obj = info.find(b => b.id === item);
|
|
|
|
console.log('待领取的券详情',match);
|
|
|
|
let record = {
|
|
|
|
id:'',
|
|
|
|
number:'',
|
|
|
|
grant_last:'',
|
|
|
|
price:'',
|
|
|
|
desc:'',
|
|
|
|
}
|
|
|
|
if (obj) {
|
|
|
|
record.number = obj.number;
|
|
|
|
}
|
|
|
|
if(match){
|
|
|
|
record.grant_last = match.grant_last*1*1;
|
|
|
|
record.id = match.id;
|
|
|
|
record.desc = match.desc;
|
|
|
|
record.price = match.price;
|
|
|
|
}
|
|
|
|
item.grant_last = item.grant_last*1*1
|
|
|
|
if(item.grant_last < 0 || item.grant_last == 0) couponArr.splice(index,1)
|
|
|
|
if(item.number>item.grant_last){
|
|
|
|
item.number = item.grant_last
|
|
|
|
if (record.number > record.grant_last && record.grant_last > 0) {
|
|
|
|
record.number = record.grant_last
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(couponArr.length>0){
|
|
|
|
// 只留下可领取数量大于0的
|
|
|
|
if(record.grant_last > 0 && record.number){
|
|
|
|
console.log('可领取的券',{...record});
|
|
|
|
couponArr.push({
|
|
|
|
...record
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if(couponArr.length>0 && setcoupon!='1'){
|
|
|
|
totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0);
|
|
|
|
this.setcouponFun(couponArr)
|
|
|
|
this.setData({
|
|
|
|
couponArr,
|
|
|
|
totalPrice,
|
|
|
|
})
|
|
|
|
this.couponModal.showModal()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list.forEach(item=>{
|
|
|
|
let idx = coupon_dataList.findIndex(b => b.id === item.id);
|
|
|
|
if (idx) {
|
|
|
|
coupon_dataList[idx].resultCoupon = '1';//显示已领取
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log('未领取的券列表-----------', couponArr);
|
|
|
|
this.setData({
|
|
|
|
couponArr,
|
|
|
|
totalPrice
|
|
|
|
coupon_dataList,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
...
|
...
|
|