mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-01 17:56:39 +08:00
Coupon displaying updated
This commit is contained in:
parent
cf90ce9009
commit
fd0f024346
@ -269,7 +269,6 @@ export default {
|
||||
methods: {
|
||||
...mapMutations(["checkIsLogin"]),
|
||||
discountedSumPrice() {
|
||||
let total = 0;
|
||||
if(this.curCoupon.productCodes)
|
||||
this.finalAmount = this.qualifiedProductDiscount();
|
||||
else
|
||||
@ -283,6 +282,15 @@ export default {
|
||||
if(this.curCoupon.minPrice && this.curCoupon.minPrice > this.sumPrice) {
|
||||
checkResult = false;
|
||||
}
|
||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity > 0) {
|
||||
let totalItemNum = 0;
|
||||
let tmpShoppingCartList = this.arrSort(this.goldmedal);
|
||||
for(let itemInCart of tmpShoppingCartList) {
|
||||
totalItemNum += itemInCart.buyCount;
|
||||
}
|
||||
if(this.curCoupon.minQuantity > totalItemNum)
|
||||
checkResult = false;
|
||||
}
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > this.sumPrice) {
|
||||
checkResult = false;
|
||||
}
|
||||
@ -304,26 +312,30 @@ export default {
|
||||
qualifiedProductDiscount(){
|
||||
this.discountedItemIndex = 0;
|
||||
let total = 0;
|
||||
let totalItemNum = 0;
|
||||
let couponUsed = false;
|
||||
let tmpShoppingCartList = this.arrSort(this.goldmedal);
|
||||
let qualifiedProductAmount = 0;
|
||||
let skipQualifiedProductAmountCalculating = false;
|
||||
|
||||
let checkResult = true;
|
||||
for(let itemInCart of tmpShoppingCartList) {
|
||||
if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
qualifiedProductAmount += (itemInCart.productPrice * itemInCart.buyCount);
|
||||
totalItemNum += itemInCart.buyCount;
|
||||
}
|
||||
}
|
||||
if(this.curCoupon.minPrice && this.curCoupon.minPrice > qualifiedProductAmount) {
|
||||
checkResult = false;
|
||||
}
|
||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity > totalItemNum) {
|
||||
checkResult = false;
|
||||
}
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) {
|
||||
checkResult = false;
|
||||
}
|
||||
|
||||
for(let itemInCart of tmpShoppingCartList) {
|
||||
if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1 && !couponUsed) {
|
||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity>itemInCart.buyCount) {
|
||||
//Check minQuantity
|
||||
total+=(itemInCart.buyCount * itemInCart.productPrice);
|
||||
} else if(this.curCoupon.minPrice && this.curCoupon.minPrice > (itemInCart.buyCount * itemInCart.productPrice)) {
|
||||
//Check minPrice
|
||||
total+=(itemInCart.buyCount * itemInCart.productPrice);
|
||||
} else {
|
||||
if(this.curCoupon.productCodes && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1 && !couponUsed && checkResult) {
|
||||
//Into coupon discount calculation
|
||||
switch(this.curCoupon.couponTypeId) {
|
||||
case 1: //Amount deduct
|
||||
@ -356,17 +368,23 @@ export default {
|
||||
break;
|
||||
case 3: //Limited product % discount
|
||||
case 4: //% discount
|
||||
if(this.curCoupon.discount && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
total = total + (itemInCart.productPrice * itemInCart.buyCount) * ( 1 - this.curCoupon.discount );
|
||||
this.discountAmount = (itemInCart.productPrice * itemInCart.buyCount) * this.curCoupon.discount;
|
||||
this.discountedProductCode = itemInCart.productCode;
|
||||
couponUsed=true;
|
||||
skipQualifiedProductAmountCalculating = true;
|
||||
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) {
|
||||
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
}
|
||||
break;
|
||||
default:
|
||||
total += itemInCart.productPrice * itemInCart.buyCount;
|
||||
break;
|
||||
}
|
||||
//Into coupon discount calculation end
|
||||
}
|
||||
} else {
|
||||
if(skipQualifiedProductAmountCalculating && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||
|
||||
@ -375,6 +393,11 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!couponUsed) {
|
||||
this.discountAmount = 0;
|
||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||
total = this.sumPrice;
|
||||
}
|
||||
return total;
|
||||
},
|
||||
arrSort(arr) {
|
||||
@ -436,16 +459,13 @@ export default {
|
||||
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) {
|
||||
valDateFromTime=0;
|
||||
valDateToTime=0;
|
||||
dateChecked=true;
|
||||
/* */
|
||||
if(myCoupon.fValidFrom) {
|
||||
//Fix ios date issue
|
||||
myCoupon.fValidFrom = myCoupon.fValidFrom.replace(/-/g, '/');
|
||||
@ -487,6 +507,10 @@ export default {
|
||||
tmpIndex++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
avaliableCouponNum = data.length;
|
||||
this.drawlist = data.data;
|
||||
|
||||
if(avaliableCouponNum > 0) {
|
||||
this.curCoupon.couponName = '有 '+avaliableCouponNum+' 张优惠券可以使用';
|
||||
|
@ -215,75 +215,16 @@ export default {
|
||||
|
||||
goldmedal: [
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
ordernumber: "",
|
||||
orderstype: 1,
|
||||
usereat: "专属升级奖励",
|
||||
usereat: "",
|
||||
ordernum: 0,
|
||||
num: "5kg",
|
||||
specification: "1",
|
||||
buttontitle: "立即支付",
|
||||
userprice: "167.00",
|
||||
catimage: require("../../assets/image/rc-win.png"),
|
||||
},
|
||||
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
|
||||
usereat: "每年4次免积分产品试吃",
|
||||
ordernum: 0,
|
||||
buttontitle: "再次购买",
|
||||
catimage: require("../../assets/image/usereat.png"),
|
||||
orderstype: 2,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "尊享订单免邮服务(指点商品)",
|
||||
ordernum: 0,
|
||||
buttontitle: "取消订单",
|
||||
catimage: require("../../assets/image/usercar.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "365天专属养宠工具",
|
||||
ordernum: 1,
|
||||
catimage: require("../../assets/image/rc-growth.png"),
|
||||
orderstype: 1,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "10年专业团队1v1咨询",
|
||||
ordernum: 2,
|
||||
catimage: require("../../assets/image/consult.png"),
|
||||
orderstype: 2,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "行业大咖专业养宠知识",
|
||||
ordernum: 3,
|
||||
catimage: require("../../assets/image/rc-book.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
ordernumber: "1111111111111111111",
|
||||
usereat: "爱宠生活定制活动高级养宠宝典",
|
||||
ordernum: 3,
|
||||
catimage: require("../../assets/image/userself.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
{
|
||||
usereat: "每年积分兑换1次价值288元的免费体检及100元医院绝育券",
|
||||
ordernum: 4,
|
||||
catimage: require("../../assets/image/rc-health.png"),
|
||||
orderstype: 3,
|
||||
userprice: "167.00",
|
||||
},
|
||||
num: "",
|
||||
specification: "",
|
||||
buttontitle: "",
|
||||
userprice: "",
|
||||
catimage: '',
|
||||
}
|
||||
],
|
||||
};
|
||||
},
|
||||
@ -322,6 +263,9 @@ export default {
|
||||
this.receiving=[];
|
||||
this.pending=[];
|
||||
for (let i = 0; i < this.goldmedal.length; i++) {
|
||||
|
||||
if(!this.goldmedal[i].orderDetailList)
|
||||
continue;
|
||||
this.useralllist.push(this.goldmedal[i].orderDetailList[0]);
|
||||
this.alllist.push(this.goldmedal[i].orderDetailList[0])
|
||||
this.allmessage.push(this.goldmedal[i].orderDetailList[0])
|
||||
@ -334,14 +278,16 @@ export default {
|
||||
this.pending.push(this.goldmedal[i].orderDetailList[0]);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < this.goldmedal.length; i++) {
|
||||
this.useralllist[i].orderNumber = this.goldmedal[i].orderNumber;
|
||||
this.useralllist[i].status = this.goldmedal[i].status;
|
||||
this.useralllist[i].addressUserName = this.goldmedal[i].addressUserName;
|
||||
this.useralllist[i].phoneNumber = this.goldmedal[i].addressPhoneNumber;
|
||||
this.useralllist[i].salesAmount = this.goldmedal[i].salesAmount;
|
||||
this.useralllist[i].lengthnum=this.goldmedal[i].orderDetailList.length;
|
||||
this.useralllist[i].paytype=this.goldmedal[i].paytype;
|
||||
for (let y = 0; y < this.goldmedal.length; y++) {
|
||||
if(!this.goldmedal[y].orderDetailList)
|
||||
continue;
|
||||
this.useralllist[y].orderNumber = this.goldmedal[y].orderNumber;
|
||||
this.useralllist[y].status = this.goldmedal[y].status;
|
||||
this.useralllist[y].addressUserName = this.goldmedal[y].addressUserName;
|
||||
this.useralllist[y].phoneNumber = this.goldmedal[y].addressPhoneNumber;
|
||||
this.useralllist[y].salesAmount = this.goldmedal[y].salesAmount;
|
||||
this.useralllist[y].lengthnum=this.goldmedal[y].orderDetailList.length;
|
||||
this.useralllist[y].paytype=this.goldmedal[y].paytype;
|
||||
}
|
||||
if(this.userstype==1){
|
||||
this.useralllist=this.obligation
|
||||
@ -456,10 +402,9 @@ export default {
|
||||
this.activeIndex = index;
|
||||
if(item.title=='待付款'){
|
||||
list=this.obligation
|
||||
}
|
||||
else if(item.title=='待收货'){
|
||||
} else if(item.title=='待收货'){
|
||||
list=this.receiving
|
||||
}else if(item.title=='待发货'){
|
||||
} else if(item.title=='待发货'){
|
||||
this.useralllist=this.pending
|
||||
list=this.pending
|
||||
}
|
||||
|
@ -109,7 +109,7 @@
|
||||
|
||||
</div>
|
||||
<div class="rc-button" v-if="!userbuy && curItem.curGoodUrl && curItem.curGoodUrl.length>5">
|
||||
<a :href="curItem.curGoodUrl" target='_blank' class="ts-standard-btn">立即购买</a>
|
||||
<a @click="goBuyRxgoods(curItem)" class="ts-standard-btn">立即购买</a>
|
||||
</div>
|
||||
|
||||
|
||||
@ -280,7 +280,7 @@
|
||||
<span @click="usertanchu(curItem, 1)">立即购买</span>
|
||||
</div>
|
||||
<div class="rc-button rc-md-down " v-if="!userbuy && curItem.goodUrl && curItem.goodUrl.length>5">
|
||||
<a :href="curItem.goodUrl" target='_blank' class="ts-standard-btn">立即购买</a>
|
||||
<a @click="goBuyRxgoods(curItem)" class="ts-standard-btn">立即购买</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -510,7 +510,27 @@ export default {
|
||||
}
|
||||
])
|
||||
},
|
||||
goBuyRxgoods() {
|
||||
this.checkIsLogin();
|
||||
let _self = this;
|
||||
let memberId = '';
|
||||
if (this.$store.state.userInfo && this.$store.state.userInfo.data !== undefined) {
|
||||
memberId = this.$store.state.userInfo.data.id;
|
||||
}
|
||||
_hmt.push([
|
||||
'_trackCustomEvent',
|
||||
'buy_rxgoods',
|
||||
{
|
||||
'member_id': memberId, // 会员ID,文本类型
|
||||
'product_name': this.curItem.productName, // 商品名称,文本类型
|
||||
'product_id': this.curItem.productCode // 商品ID,文本类型
|
||||
}
|
||||
])
|
||||
|
||||
setTimeout(function(){
|
||||
window.open(_self.curItem.curGoodUrl, '_blank');
|
||||
},1000);
|
||||
},
|
||||
//获取用户领取的优惠券
|
||||
async getconf(memberId, couponId) {
|
||||
let data = await getConfig(memberId, couponId);
|
||||
|
Loading…
Reference in New Issue
Block a user