mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-01 17:56:39 +08:00
Coupon API updated
This commit is contained in:
parent
672738daf3
commit
62986c45c9
@ -473,32 +473,27 @@ export const goodsmessage = (productCode) => {
|
||||
}
|
||||
|
||||
|
||||
//优惠券的查询
|
||||
export const getdiscount = (memberId,channelSecurity,mobile) => {
|
||||
var data = {
|
||||
memberId:memberId,
|
||||
mobile:mobile
|
||||
}
|
||||
return fetch('memberAddress?type=getAll', data, 'POST' )
|
||||
}
|
||||
//优惠券的查询
|
||||
export const getdiscount = (memberId,channelSecurity,mobile) => {
|
||||
var data = {
|
||||
memberId:memberId,
|
||||
mobile:mobile
|
||||
}
|
||||
return fetch('memberAddress?type=getAll', data, 'POST' )
|
||||
}
|
||||
|
||||
//可用的优惠券
|
||||
export const alldiscount = (memberId,channelSecurity,mobile) => {
|
||||
var data = {
|
||||
memberId:memberId,
|
||||
}
|
||||
return fetch('couponConfig?type=getAll', data, 'POST' )
|
||||
}
|
||||
//可用的优惠券
|
||||
export const alldiscount = (paramsObj) => {
|
||||
var data = paramsObj;
|
||||
return fetch('couponConfig?type=getAll', data, 'POST' )
|
||||
}
|
||||
|
||||
|
||||
//用户领取的优惠券
|
||||
export const getdraw = (mobile,states) => {
|
||||
var data = {
|
||||
mobile:mobile,
|
||||
status:states
|
||||
}
|
||||
return fetch('coupon?type=getAll', data, 'POST' )
|
||||
}
|
||||
//用户领取的优惠券
|
||||
export const getdraw = (paramsObj) => {
|
||||
var data = paramsObj;
|
||||
return fetch('coupon?type=getAll', data, 'POST' )
|
||||
}
|
||||
|
||||
|
||||
//微信支付
|
||||
|
@ -141,8 +141,14 @@ export default {
|
||||
methods: {
|
||||
...mapMutations(["changemessage","checkIsLogin"]),
|
||||
//获取用户领取的优惠券
|
||||
async userdraw(mobile,states) {
|
||||
let data = await getdraw(mobile,states);
|
||||
async userdraw(mobile) {
|
||||
//let curDate = new Date();
|
||||
let paramsToAPI = {
|
||||
mobile : mobile,
|
||||
//useStartDate : curDate.getYear()+'-'+curDate.getMonth()+'-'+curDate.getDate(),
|
||||
//productCodes : ''
|
||||
};
|
||||
let data = await getdraw(paramsToAPI);
|
||||
let _self = this;
|
||||
if(data){
|
||||
let list = [];
|
||||
@ -211,10 +217,16 @@ export default {
|
||||
if(coupon.fValidTo) {
|
||||
valDateToTime = new Date(coupon.fValidTo).getTime();
|
||||
}
|
||||
/*
|
||||
if(valDateFromTime && valDateToTime && curTime >= valDateFromTime && curTime <= valDateToTime && coupon.status == 0) {
|
||||
coupon.canUse=true;
|
||||
this.newlist.push(coupon);
|
||||
}
|
||||
*/
|
||||
if(valDateToTime && curTime <= valDateToTime && coupon.status == 0) {
|
||||
coupon.canUse=true;
|
||||
this.newlist.push(coupon);
|
||||
}
|
||||
break;
|
||||
case USED:
|
||||
if(coupon.status == 1) {
|
||||
|
@ -388,15 +388,29 @@ export default {
|
||||
},
|
||||
//获取用户领取的优惠券
|
||||
async userdraw(mobile) {
|
||||
let data = await getdraw(mobile);
|
||||
let _self = this;
|
||||
let curTime = new Date().getTime();
|
||||
let valDateFromTime=0;
|
||||
let valDateToTime=0;
|
||||
let dateChecked=true;
|
||||
let avaliableCouponNum = 0;
|
||||
let curDate = new Date();
|
||||
let productCodes = [];
|
||||
for(let itemInCart of this.goldmedal) {
|
||||
productCodes.push(itemInCart.productCode);
|
||||
}
|
||||
let paramsToAPI = {
|
||||
mobile : mobile,
|
||||
useStartDate : curDate.getFullYear()+'-'+(curDate.getMonth()+1)+'-'+curDate.getDate(),
|
||||
};
|
||||
if(productCodes)
|
||||
paramsToAPI.productCodes = productCodes.join(',');
|
||||
let data = await getdraw(paramsToAPI);
|
||||
let _self = this;
|
||||
let curTime = new Date().getTime();
|
||||
let valDateFromTime=0;
|
||||
let valDateToTime=0;
|
||||
let dateChecked=true;
|
||||
let avaliableCouponNum = 0;
|
||||
if (data) {
|
||||
this.drawlist=[];
|
||||
avaliableCouponNum = data.length;
|
||||
this.drawlist = data.data;
|
||||
/*
|
||||
for(let itemInCart of this.goldmedal) {
|
||||
let tmpIndex=0;
|
||||
for(let myCoupon of data.data) {
|
||||
@ -439,6 +453,7 @@ export default {
|
||||
tmpIndex++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if(avaliableCouponNum > 0) {
|
||||
this.curCoupon.couponName = '有 '+avaliableCouponNum+' 张优惠券可以使用';
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ export default {
|
||||
this.curItem.curGoodUrl = this.curItem.goodUrl.pc;
|
||||
}
|
||||
this.usermessage = this.$store.state.userInfo;
|
||||
if (this.usermessage !== "" || this.usermessage.data !== undefined) {
|
||||
//if (this.usermessage !== "" || this.usermessage.data !== undefined) {
|
||||
this.productCode = this.$route.query.productCode;
|
||||
_hmt.push([
|
||||
"_trackCustomEvent",
|
||||
@ -483,7 +483,7 @@ export default {
|
||||
"product_name": this.curItem.productName,
|
||||
}
|
||||
])
|
||||
}
|
||||
//}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(["changemessage","checkIsLogin"]),
|
||||
@ -562,8 +562,19 @@ export default {
|
||||
},
|
||||
|
||||
//获取所有的优惠券
|
||||
async alldrawlist(memberId) {
|
||||
let data = await alldiscount(memberId);
|
||||
async alldrawlist() {
|
||||
this.checkIsLogin();
|
||||
this.usermessage = this.$store.state.userInfo;
|
||||
let storeCode = '';
|
||||
if(this.usermessage && this.usermessage.data && this.usermessage.data.storeCode) {
|
||||
storeCode = this.usermessage.data.storeCode
|
||||
}
|
||||
let paramsToAPI={
|
||||
productCode:this.curItem.productCode,
|
||||
};
|
||||
if(storeCode)
|
||||
paramsToAPI.stroeCode = stroeCode;
|
||||
let data = await alldiscount(paramsToAPI);
|
||||
let userlist = [];
|
||||
let menulsit = [];
|
||||
if (data) {
|
||||
@ -574,9 +585,6 @@ export default {
|
||||
this.userlist.forEach((element, index) => {
|
||||
if (typeof element.productCodes == "string" || !element.productCodes) {
|
||||
userlist.push(element);
|
||||
// let s=element.productCodes.split(',');
|
||||
// console.log(s.indexOf(this.productCode) != -1 )
|
||||
// console.log('这是字符串')
|
||||
}
|
||||
});
|
||||
let menualist = [];
|
||||
@ -585,7 +593,7 @@ export default {
|
||||
let valDateToTime=0;
|
||||
let curTime = new Date().getTime();
|
||||
let dateChecked=true;
|
||||
|
||||
/*
|
||||
if(item.publishFrom && curTime < item.publishFrom) {
|
||||
dateChecked=false;
|
||||
}
|
||||
@ -614,6 +622,8 @@ export default {
|
||||
if(item.packageTypeIds!='1') {
|
||||
dateChecked=false;
|
||||
}
|
||||
*/
|
||||
|
||||
if(this.mainProduct && this.mainProduct.petType && item.petCategoryIds) {
|
||||
if(this.mainProduct.petType===0 && item.petCategoryIds!='1')
|
||||
dateChecked=false;
|
||||
@ -625,7 +635,7 @@ export default {
|
||||
if(item.petAgeTypeIds!=productToCouponAgeId)
|
||||
dateChecked=false;
|
||||
}
|
||||
|
||||
/*
|
||||
if(dateChecked && item.activityId!=10) {
|
||||
if(!item.productCodes) {
|
||||
menualist.push(item);
|
||||
@ -640,6 +650,12 @@ export default {
|
||||
} else {
|
||||
//Expired coupons
|
||||
}
|
||||
*/
|
||||
if(dateChecked) {
|
||||
menualist.push(item);
|
||||
} else {
|
||||
//Expired coupons
|
||||
}
|
||||
});
|
||||
this.usernewlist = menualist;
|
||||
}
|
||||
@ -755,7 +771,7 @@ export default {
|
||||
return;
|
||||
} else {
|
||||
//this.userdraw(this.usermessage.data.mobile);
|
||||
this.alldrawlist(this.usermessage.data.id);
|
||||
this.alldrawlist();
|
||||
this.dialogInfo1 = true;
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user