Commit d3a4d12ce3b73c90441bb7d814b8678d6f9d6517

Authored by pengye
1 parent 173319b8

邀请函、商家有礼、商家详情券列表展示已领取、未领取,获取用户对应商家的券列表接口调整

Showing 26 changed files with 771 additions and 324 deletions
... ... @@ -936,9 +936,23 @@ Page({
detail.nigText = nig;
}
detail.showCoupon = (this.data.dataStr < (detail.etime * 1) && detail.is_open == '1') ? '1' : '0';
this.getDetailFun(detail)
}
})
},
// 免费券显示是否领取
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
couponData: detail,
})
}
})
... ... @@ -1002,10 +1016,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({
... ... @@ -1050,39 +1061,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;
}
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
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
// 只留下可领取数量大于0的
if(record.grant_last > 0 && record.number){
console.log('可领取的券',{...record});
couponArr.push({
...record
})
}
});
if(couponArr.length>0){
})
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,
})
}
})
... ...
... ... @@ -108,7 +108,7 @@
<view class="font24r couponBtn">立即抢购</view>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood">已领取</view>
<view class="font24r orderingFood">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ... @@ -191,7 +191,7 @@
<view class="font24r couponBtn">立即抢购</view>
</view>
<view class="btnBox" wx:if="{{couponData.is_type == '3'}}" >
<view class="font24r orderingFood">已领取</view>
<view class="font24r orderingFood">{{couponData.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{couponData.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{couponData.receiveNumText}}</text>张</view>
... ...
... ... @@ -987,15 +987,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({
... ... @@ -1067,10 +1083,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({
... ... @@ -1117,39 +1130,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,
})
}
})
... ...
... ... @@ -145,7 +145,7 @@
<view class="font24r couponBtn">立即抢购</view>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood">已领取</view>
<view class="font24r orderingFood">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ... @@ -234,7 +234,7 @@
<view class="font24r couponBtn">立即抢购</view>
</view>
<view class="btnBox" wx:if="{{couponData.is_type == '3'}}" >
<view class="font24r orderingFood">已领取</view>
<view class="font24r orderingFood">{{couponData.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{couponData.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{couponData.receiveNumText}}</text>张</view>
... ...
... ... @@ -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,
})
}
})
... ...
... ... @@ -189,7 +189,7 @@
<view class="font24r couponBtn">立即抢购</view>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood">已领取</view>
<view class="font24r orderingFood">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ... @@ -272,7 +272,7 @@
<view class="font24r couponBtn">立即抢购</view>
</view>
<view class="btnBox" wx:if="{{couponData.is_type == '3'}}" >
<view class="font24r orderingFood">已领取</view>
<view class="font24r orderingFood">{{couponData.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{couponData.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{couponData.receiveNumText}}</text>张</view>
... ...
... ... @@ -991,10 +991,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({
... ... @@ -1039,39 +1036,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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -119,7 +119,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -946,10 +946,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({
... ... @@ -994,39 +991,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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -125,7 +125,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -947,10 +947,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({
... ... @@ -995,39 +992,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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -108,7 +108,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -945,10 +945,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({
... ... @@ -993,39 +990,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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -106,7 +106,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -902,10 +902,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({
... ... @@ -950,39 +947,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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -128,7 +128,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -946,10 +946,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({
... ... @@ -994,39 +991,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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -121,7 +121,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -945,10 +945,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({
... ... @@ -993,39 +990,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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -118,7 +118,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -978,11 +978,8 @@ Page({
return item.is_type == '3'
})
// 免费券判断是否领取,弹框领取
if (freeCoupons.length > 0 && setcoupon!='1') {
let length = freeCoupons.length - 1
freeCoupons.forEach(i => {
this.getCoupon(i, freeCoupons[length].id, obj)
})
if (freeCoupons.length > 0) {
this.getCoupon(freeCoupons,obj,setcoupon)
}
console.log('邀请函--------------------优惠券', list);
this.setData({
... ... @@ -1023,43 +1020,77 @@ Page({
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,
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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -123,7 +123,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -259,6 +259,13 @@ Page({
detail.nigText = nig;
}
})
let freeCoupons = list.filter(item => {
return item.is_type == '3'
})
// 显示已领取
if (freeCoupons.length > 0) {
this.getCoupon(freeCoupons,obj)
}
console.log('邀请函--------------------优惠券', list);
this.setData({
coupon_dataList: list,
... ... @@ -266,6 +273,28 @@ Page({
}
})
},
// 免费券显示已领取
getCoupon(arr) {
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) {
let coupon_dataList = this.data.coupon_dataList;
let list = res.data;
list.forEach(item=>{
let idx = coupon_dataList.findIndex(b => b.id === item.id);
if (idx) {
coupon_dataList[idx].resultCoupon = '1';//显示已领取
}
})
this.setData({
coupon_dataList,
})
}
})
},
// 获取所有的券并且展示
addCoupons(coupons, couponList) {
if (coupons && util.getType(coupons) == 'object') {
... ...
... ... @@ -39,7 +39,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...
... ... @@ -308,10 +308,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({
... ... @@ -356,39 +353,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,
sellerid:this.data.sid,
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;
}
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(match){
record.grant_last = match.grant_last*1*1;
record.id = match.id;
record.desc = match.desc;
record.price = match.price;
}
});
if(couponArr.length>0){
if (record.number > record.grant_last && record.grant_last > 0) {
record.number = record.grant_last
}
// 只留下可领取数量大于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,
})
}
})
... ...
... ... @@ -54,7 +54,7 @@
</block>
</view>
<view class="btnBox" wx:if="{{item.is_type == '3'}}" >
<view class="font24r orderingFood orderingFood1">已领取</view>
<view class="font24r orderingFood orderingFood1">{{item.resultCoupon == '1'?'已领取':'立即领取'}}</view>
<view class="grantNum" wx:if="{{item.receiveNumText}}">
<view class="font24r">已被领取</view>
<view class="font24r"><text>{{item.receiveNumText}}</text>张</view>
... ...