mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
Coupon flow refined
This commit is contained in:
parent
ab70862f63
commit
de8d67fc51
@ -4,12 +4,6 @@ body {
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
div[data-js-modal-menu] {
|
|
||||||
display:none;
|
|
||||||
}
|
|
||||||
aside div[data-js-modal-menu] {
|
|
||||||
display:block;
|
|
||||||
}
|
|
||||||
.el-message-box .el-button--primary{
|
.el-message-box .el-button--primary{
|
||||||
background-color: #e1001a !important;
|
background-color: #e1001a !important;
|
||||||
color:#fff;
|
color:#fff;
|
||||||
@ -532,7 +526,12 @@ picture {
|
|||||||
max-width: 768px;
|
max-width: 768px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
div[data-js-modal-menu] {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
aside div[data-js-modal-menu] {
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
html {
|
html {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,6 @@
|
|||||||
}
|
}
|
||||||
span {
|
span {
|
||||||
font-size: 45px;
|
font-size: 45px;
|
||||||
font-weight: bold;
|
|
||||||
}
|
}
|
||||||
strong {
|
strong {
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
|
@ -236,6 +236,7 @@ color: #333333;
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
align-items: baseline;
|
||||||
span {
|
span {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
@ -251,6 +252,10 @@ color: #333333;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.ts-right-arr {
|
||||||
|
line-height:1rem;
|
||||||
|
height:1.5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,6 +231,5 @@ import Myheader from "~/components/header.vue";
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
// 手机端
|
// 手机端
|
||||||
@import url("../../assets/css/global.less");
|
|
||||||
@import url("../../assets/css/discount.less");
|
@import url("../../assets/css/discount.less");
|
||||||
</style>
|
</style>
|
@ -8,7 +8,16 @@ ul li ol li em strong i {
|
|||||||
}
|
}
|
||||||
.settlement {
|
.settlement {
|
||||||
}
|
}
|
||||||
|
.rc-merchandise {
|
||||||
|
li {
|
||||||
|
align-items: baseline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.discountInfo {
|
||||||
|
i,em {
|
||||||
|
font-size:.875rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
.rc-discount {
|
.rc-discount {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -38,7 +47,7 @@ ul li ol li em strong i {
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
span {
|
span {
|
||||||
font-size: 26px;
|
font-size: 45px;
|
||||||
}
|
}
|
||||||
strong {
|
strong {
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
@ -418,7 +427,7 @@ ul li ol li em strong i {
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: self-end;
|
align-items: self-end;
|
||||||
|
text-align: right;
|
||||||
i {
|
i {
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
color: #333333;
|
color: #333333;
|
||||||
@ -430,6 +439,14 @@ ul li ol li em strong i {
|
|||||||
font-style: normal;
|
font-style: normal;
|
||||||
color: #e1001a;
|
color: #e1001a;
|
||||||
font-size: 26px;
|
font-size: 26px;
|
||||||
|
display:inline-block;
|
||||||
|
width:5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.discountInfo {
|
||||||
|
i,em {
|
||||||
|
font-size:1rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
|
@ -88,8 +88,12 @@
|
|||||||
<div class="rc-foot">
|
<div class="rc-foot">
|
||||||
<div class="rc-foo">
|
<div class="rc-foo">
|
||||||
<div>
|
<div>
|
||||||
|
<div class="discountInfo" v-if="discountAmount">
|
||||||
|
<i>优惠金额:</i>
|
||||||
|
<em>{{ discountAmount }}</em>
|
||||||
|
</div>
|
||||||
<i>合计金额:</i>
|
<i>合计金额:</i>
|
||||||
<em>{{ sumPrice }}</em>
|
<em>{{ discountedSumPrice }}</em>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-weight: bold">
|
<div style="font-weight: bold">
|
||||||
<span @click="preJiesuan()">提交订单</span>
|
<span @click="preJiesuan()">提交订单</span>
|
||||||
@ -147,7 +151,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog :visible.sync="dialogInfo1" class="pop_coupon">
|
<el-dialog :visible.sync="dialogInfo1" class="pop_coupon" :close-on-click-modal="false">
|
||||||
<div class="ts-no-data" v-if="drawlist.length<=0">您还没有优惠券,可在商品的详情页面中领取</div>
|
<div class="ts-no-data" v-if="drawlist.length<=0">您还没有优惠券,可在商品的详情页面中领取</div>
|
||||||
<div class="rs-dis">
|
<div class="rs-dis">
|
||||||
<div
|
<div
|
||||||
@ -157,18 +161,25 @@
|
|||||||
>
|
>
|
||||||
<img :src="userimage" alt="" />
|
<img :src="userimage" alt="" />
|
||||||
<div class="rc-contair">
|
<div class="rc-contair">
|
||||||
<div class="rc-left">
|
<div class="rc-left" :style='usercolor'>
|
||||||
<div v-if="item.couponAmount">
|
<div>
|
||||||
<i>¥</i><span>{{ item.couponAmount }}</span>
|
<i v-if="(item.couponTypeId!='4' && item.couponAmount>0)">
|
||||||
|
¥
|
||||||
|
</i>
|
||||||
|
<span>
|
||||||
|
{{item.couponTypeId=='4'?parseInt(((item.discount)*10))+'折':item.couponAmount}}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<strong>{{ item.couponName }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="rc-right">
|
<div class="rc-right">
|
||||||
<i>
|
<i :style='usercolor'>
|
||||||
{{ item.couponDesc }}
|
{{ item.couponName }}
|
||||||
</i>
|
</i>
|
||||||
<div v-show="item.validTo">
|
<div class="rc-userfont">
|
||||||
<span>有效期</span>
|
<strong>有效期</strong>
|
||||||
<em>{{ item.validTo }}</em>
|
<span>{{item.validFrom}}至</span>
|
||||||
|
<em>{{item.validTo}}</em>
|
||||||
</div>
|
</div>
|
||||||
<div class="rc-footer">
|
<div class="rc-footer">
|
||||||
<span @click="pickCoupon(item)">立即使用</span>
|
<span @click="pickCoupon(item)">立即使用</span>
|
||||||
@ -201,6 +212,7 @@ export default {
|
|||||||
path:'/personal/settlement'
|
path:'/personal/settlement'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
usercolor:{color:'#e1001a'},
|
||||||
userimage: require("../../assets/image/unused.png"),
|
userimage: require("../../assets/image/unused.png"),
|
||||||
curCoupon:{couponName:'未选择可用优惠券'},
|
curCoupon:{couponName:'未选择可用优惠券'},
|
||||||
drawlist:[],
|
drawlist:[],
|
||||||
@ -239,15 +251,72 @@ export default {
|
|||||||
promotion: "¥167.00",
|
promotion: "¥167.00",
|
||||||
payment: "¥0.00 ",
|
payment: "¥0.00 ",
|
||||||
},
|
},
|
||||||
|
discountAmount:0
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
// 总价计算
|
|
||||||
sumPrice() {
|
sumPrice() {
|
||||||
return this.goldmedal.reduce((pre, cur) => {
|
return this.goldmedal.reduce((pre, cur) => {
|
||||||
return pre + cur.buyCount * cur.productPrice;
|
return pre + cur.buyCount * cur.productPrice;
|
||||||
}, 0);
|
}, 0);
|
||||||
},
|
},
|
||||||
|
// 折扣计算
|
||||||
|
discountedSumPrice() {
|
||||||
|
let total = 0;
|
||||||
|
if(this.curCoupon.couponId) {
|
||||||
|
//Coupon Calculation
|
||||||
|
let couponUsed=false;
|
||||||
|
for(let itemInCart of this.goldmedal) {
|
||||||
|
if((!this.curCoupon.productCodes || 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 {
|
||||||
|
//Into coupon discount calculation
|
||||||
|
switch(this.curCoupon.couponTypeId) {
|
||||||
|
case 1: //Amount deduct
|
||||||
|
total = total + (itemInCart.productPrice * itemInCart.buyCount - this.curCoupon.couponAmount);
|
||||||
|
this.discountAmount = this.curCoupon.couponAmount;
|
||||||
|
couponUsed=true;
|
||||||
|
break;
|
||||||
|
case 2: //Amount deduct with minPrice restriction
|
||||||
|
case 6:
|
||||||
|
total = total + (itemInCart.productPrice * itemInCart.buyCount) - this.curCoupon.couponAmount;
|
||||||
|
this.discountAmount = this.curCoupon.couponAmount;
|
||||||
|
couponUsed=true;
|
||||||
|
break;
|
||||||
|
case 3: //Limited product % discount
|
||||||
|
case 4: //% discount
|
||||||
|
total = total + (itemInCart.productPrice * itemInCart.buyCount) * (1-this.curCoupon.discount);
|
||||||
|
this.discountAmount = (itemInCart.productPrice * itemInCart.buyCount) * this.curCoupon.discount;
|
||||||
|
couponUsed=true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
total += itemInCart.productPrice * itemInCart.buyCount;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//Into coupon discount calculation end
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
total += itemInCart.productPrice * itemInCart.buyCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Normal Calculation
|
||||||
|
total=this.goldmedal.reduce((pre, cur) => {
|
||||||
|
return pre + cur.buyCount * cur.productPrice;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
if(this.discountAmount)
|
||||||
|
this.discountAmount = this.discountAmount.toFixed(2);
|
||||||
|
if(!total)
|
||||||
|
total=0;
|
||||||
|
total = total.toFixed(2);
|
||||||
|
return total;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations(["checkIsLogin"]),
|
...mapMutations(["checkIsLogin"]),
|
||||||
@ -278,14 +347,34 @@ export default {
|
|||||||
async userdraw(mobile) {
|
async userdraw(mobile) {
|
||||||
let data = await getdraw(mobile);
|
let data = await getdraw(mobile);
|
||||||
let _self = this;
|
let _self = this;
|
||||||
|
let curTime = new Date().getTime();
|
||||||
|
let valDateFromTime=0;
|
||||||
|
let valDateToTime=0;
|
||||||
|
let dateChecked=true;
|
||||||
if (data) {
|
if (data) {
|
||||||
//TODO check status = 0
|
|
||||||
this.drawlist=[];
|
this.drawlist=[];
|
||||||
data.data.forEach((item) => {
|
for(let itemInCart of this.goldmedal) {
|
||||||
if(item.status==0) {
|
for(let myCoupon of data.data) {
|
||||||
_self.drawlist.push(item);
|
valDateFromTime=0;
|
||||||
|
valDateToTime=0;
|
||||||
|
dateChecked=true;
|
||||||
|
if(myCoupon.fValidFrom) {
|
||||||
|
valDateFromTime = new Date(myCoupon.fValidFrom).getTime();
|
||||||
|
}
|
||||||
|
if(myCoupon.fValidTo) {
|
||||||
|
valDateToTime = new Date(myCoupon.fValidTo).getTime();
|
||||||
|
}
|
||||||
|
if(valDateFromTime && curTime < valDateFromTime) {
|
||||||
|
dateChecked=false;
|
||||||
|
}
|
||||||
|
if(valDateToTime && curTime > valDateToTime) {
|
||||||
|
dateChecked=false;
|
||||||
|
}
|
||||||
|
if(dateChecked && myCoupon.status == 0 && (myCoupon.productCodes.indexOf(itemInCart.productCode)>-1 || !myCoupon.productCodes)) {
|
||||||
|
_self.drawlist.push(myCoupon);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pickCoupon(item){
|
pickCoupon(item){
|
||||||
@ -450,8 +539,8 @@ export default {
|
|||||||
let res = await generateOrderWX(postData);
|
let res = await generateOrderWX(postData);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
let userPayData = {
|
let userPayData = {
|
||||||
orderId: res.data,
|
orderId: res.data.orderNumber,
|
||||||
userprice: this.sumPrice,
|
userprice: parseFloat(res.data.orderAmount).toFixed(2),
|
||||||
userinformation:
|
userinformation:
|
||||||
postData[0].orderAddress.addressUserName +
|
postData[0].orderAddress.addressUserName +
|
||||||
" " +
|
" " +
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<el-col :span="6" class="ready_right">
|
<el-col :span="6" class="ready_right">
|
||||||
<div class="inline_right">
|
<div class="inline_right">
|
||||||
<p>付款金额:</p>
|
<p>付款金额:</p>
|
||||||
<p class="price">¥{{ userPayData.userprice }}</p>
|
<p class="price" v-if="userPayData.userprice">¥{{ userPayData.userprice }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline_right">
|
<div class="inline_right">
|
||||||
<p>收货信息:</p>
|
<p>收货信息:</p>
|
||||||
|
@ -208,8 +208,8 @@
|
|||||||
<FixRight></FixRight>
|
<FixRight></FixRight>
|
||||||
<Myfooter v-on:litentop="showmesg"></Myfooter>
|
<Myfooter v-on:litentop="showmesg"></Myfooter>
|
||||||
</div>
|
</div>
|
||||||
<el-dialog :visible.sync="dialogInfo1" @close="userclose" class="pop_coupon">
|
<el-dialog :visible.sync="dialogInfo1" @close="userclose" class="pop_coupon" :close-on-click-modal="false">
|
||||||
<div class="ts-no-data" v-if="usernewlist.length<=0">您还没有优惠券,可在商品的详情页面中领取</div>
|
<div class="ts-no-data" v-if="usernewlist.length<=0">目前还没有可用的优惠券</div>
|
||||||
<div class="rs-dis">
|
<div class="rs-dis">
|
||||||
<div
|
<div
|
||||||
class="rc-discount"
|
class="rc-discount"
|
||||||
@ -219,17 +219,24 @@
|
|||||||
<img :src="userimage" alt="" />
|
<img :src="userimage" alt="" />
|
||||||
<div class="rc-contair">
|
<div class="rc-contair">
|
||||||
<div class="rc-left">
|
<div class="rc-left">
|
||||||
<div v-if="item.couponAmount">
|
<div>
|
||||||
<i>¥</i><span>{{ item.couponAmount }}</span>
|
<i v-if="(item.couponTypeId!='4' && item.couponAmount>0)">
|
||||||
|
¥
|
||||||
|
</i>
|
||||||
|
<span>
|
||||||
|
{{item.couponTypeId=='4'?parseInt(((item.discount)*10))+'折':item.couponAmount}}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<strong>{{ item.couponName }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="rc-right">
|
<div class="rc-right">
|
||||||
<i>
|
<i>
|
||||||
{{ item.couponDesc }}
|
{{ item.couponName }}
|
||||||
</i>
|
</i>
|
||||||
<div v-show="item.validTo">
|
<div class="rc-userfont">
|
||||||
<span>有效期</span>
|
<strong>有效期</strong>
|
||||||
<em>{{ item.validTo }}</em>
|
<span>{{item.validFrom}}至</span>
|
||||||
|
<em>{{item.validTo}}</em>
|
||||||
</div>
|
</div>
|
||||||
<div class="rc-footer">
|
<div class="rc-footer">
|
||||||
<span @click="usergetconf(item)">立即领取</span>
|
<span @click="usergetconf(item)">立即领取</span>
|
||||||
@ -472,6 +479,7 @@ export default {
|
|||||||
|
|
||||||
userclose() {
|
userclose() {
|
||||||
this.userlist = [];
|
this.userlist = [];
|
||||||
|
this.dialogInfo1=false;
|
||||||
},
|
},
|
||||||
async userquery() {
|
async userquery() {
|
||||||
let data = await goodsmessage(this.productCode);
|
let data = await goodsmessage(this.productCode);
|
||||||
@ -518,7 +526,7 @@ export default {
|
|||||||
let alllist = [];
|
let alllist = [];
|
||||||
this.userlist = this.alldraw.data;
|
this.userlist = this.alldraw.data;
|
||||||
this.userlist.forEach((element, index) => {
|
this.userlist.forEach((element, index) => {
|
||||||
if (typeof element.productCodes == "string") {
|
if (typeof element.productCodes == "string" || !element.productCodes) {
|
||||||
userlist.push(element);
|
userlist.push(element);
|
||||||
// let s=element.productCodes.split(',');
|
// let s=element.productCodes.split(',');
|
||||||
// console.log(s.indexOf(this.productCode) != -1 )
|
// console.log(s.indexOf(this.productCode) != -1 )
|
||||||
@ -527,12 +535,36 @@ export default {
|
|||||||
});
|
});
|
||||||
let menualist = [];
|
let menualist = [];
|
||||||
userlist.filter((item) => {
|
userlist.filter((item) => {
|
||||||
|
let valDateFromTime=0;
|
||||||
|
let valDateToTime=0;
|
||||||
|
let curTime = new Date().getTime();
|
||||||
|
let dateChecked=true;
|
||||||
|
if(item.fValidFrom) {
|
||||||
|
valDateFromTime = new Date(item.fValidFrom).getTime();
|
||||||
|
}
|
||||||
|
if(item.fValidTo) {
|
||||||
|
valDateToTime = new Date(item.fValidTo).getTime();
|
||||||
|
}
|
||||||
|
if(valDateFromTime && curTime < valDateFromTime) {
|
||||||
|
dateChecked=false;
|
||||||
|
}
|
||||||
|
if(valDateToTime && curTime > valDateToTime) {
|
||||||
|
dateChecked=false;
|
||||||
|
}
|
||||||
|
if(dateChecked) {
|
||||||
|
if(!item.productCodes) {
|
||||||
|
menualist.push(item);
|
||||||
|
} else {
|
||||||
item.productCodes = item.productCodes.split(",");
|
item.productCodes = item.productCodes.split(",");
|
||||||
item.productCodes.forEach((element) => {
|
item.productCodes.forEach((element) => {
|
||||||
if (element == this.curItem.productCode && item.activityId !== 10) {
|
if (element == this.curItem.productCode && item.activityId !== 10) {
|
||||||
menualist.push(item);
|
menualist.push(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Expired coupons
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.usernewlist = menualist;
|
this.usernewlist = menualist;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user