Commit 3993ffe8 by 程智春

修改优惠券格式化

parent 84fa9b90
......@@ -7,4 +7,8 @@ export default {
query_single_item_activity_list_by_ids(data) {
return requestPOST(`${process.env.OLSHOP_URL}/promotion/query_single_item_activity_list_by_ids`, data);
},
// 组件查询优惠券列表
queryCouponIdsList(data) {
return requestPOST(`${process.env.OLSHOP_URL}/promotion/query_coupon_detail_by_ids`, data )
},
};
\ No newline at end of file
......@@ -11,7 +11,7 @@
<template v-if="datas.componentData.style==4 && datas.componentData.sort == 1">
<div
class="coupon-box coupon-box9 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div class="coupon-sort9"
......@@ -75,7 +75,7 @@
<template v-if="datas.componentData.style==4 && datas.componentData.sort == 2">
<div
class="coupon-box coupon-box8 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div class="coupon-sort8"
......@@ -113,7 +113,7 @@
<template v-if="datas.componentData.style==4 && datas.componentData.sort == 3">
<div
class="coupon-box coupon-box7 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div class="coupon-sort7"
......@@ -147,7 +147,7 @@
<template v-if="datas.componentData.style==3 && datas.componentData.sort == 1">
<div
class="coupon-box coupon-box6 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div class="coupon-sort6"
......@@ -216,7 +216,7 @@
<template v-if="datas.componentData.style==3 && datas.componentData.sort == 2">
<div
class="coupon-box coupon-box5 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div class="coupon-sort5"
......@@ -255,7 +255,7 @@
<template v-if="datas.componentData.style==3 && datas.componentData.sort == 3">
<div
class="coupon-box coupon-box4 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div class="coupon-sort4"
......@@ -295,7 +295,7 @@
<template v-if="datas.componentData.style==1 && datas.componentData.sort == 3">
<div
class="coupon-box coupon-box1 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div
......@@ -332,7 +332,7 @@
<template v-if="datas.componentData.style==1 && datas.componentData.sort == 2">
<div
class="coupon-box coupon-box2 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div
......@@ -371,7 +371,7 @@
<template v-if="datas.componentData.style==1 && datas.componentData.sort == 1">
<div
class="coupon-box coupon-box3 clearfix"
v-for="(item,index) in datas.componentData.couponList"
v-for="(item,index) in couponList"
:key="index"
>
<div
......@@ -437,6 +437,7 @@
<script>
import coupon from '@/api/coupon'
const app = getApp();
export default {
name: "coupon",
props: {
......@@ -460,63 +461,50 @@ export default {
couponCode: 0, //优惠券code
couItem: "", //当前优惠券
showList: true, //展示优惠券组件
couponList : []
};
},
created(){
this.datas.componentData.couponList.forEach((item,index) => {
if((item.preferentialMoney-0)%1==0){
this.$set(this.datas.componentData.couponList[index],'preferentialMoney',parseInt(item.preferentialMoney))
}else{
this.$set(this.datas.componentData.couponList[index],'preferentialMoney',parseFloat(item.preferentialMoney))
}
if((item.preferentialDiscount-0)%1==0){
this.$set(this.datas.componentData.couponList[index],'preferentialDiscount',parseInt(item.preferentialDiscount))
}else{
this.$set(this.datas.componentData.couponList[index],'preferentialDiscount',parseFloat(item.preferentialDiscount))
}
this.$set(this.datas.componentData.couponList[index],'meetMoneyUse',parseFloat(item.meetMoneyUse).toFixed(2))
})
console.log(this.datas.componentData.couponList,'datas.componentData.couponList1111')
onReady(){
this.getList();
},
mounted() {
if (this.render) {
try {
this.$on('getEnvInfo',([val])=>{
console.log(val,'ggggggggggggg',typeof val)
this.api=val;
this.getList();
})
} catch (error) {}
} else {
}
},
components: {},
methods: {
getList() {
let query = this.datas.componentData.selectionIds;
this.api(query).then(res => {
if (res.code == 200&&res.data.length!=0) {
res.data.forEach(item => {
app.promoteApi.queryCouponIdsList(query).then(res => {
console.log(res.data.code == '200'&&res.data.data.length!=0)
console.log(res,'res..................')
if (res.data.code == '200'&&res.data.data.length!=0) {
res.data.data.forEach(item => {
if((item.preferentialMoney-0)%1==0){
item.preferentialMoney = parseInt(item.preferentialMoney)
}else{
item.preferentialMoney = parseFloat(item.preferentialMoney).toFixed(2)
}
if((item.preferentialDiscount-0)%1==0){
item.preferentialDiscount = parseInt(item.preferentialDiscount)
}else{
item.preferentialDiscount = parseFloat(item.preferentialDiscount).toFixed(2)
}
item.meetMoneyUse = parseFloat(item.meetMoneyUse).toFixed(2)
})
this.datas.componentData.couponList = res.data.filter((item,index)=>{return item.publicFlag != 0});
if(this.datas.componentData.couponList.length==0){
console.log(res.data.data,'res.datada.')
this.couponList = res.data.data.filter((item,index)=>{return item.publicFlag != 0});
if(this.couponList.length==0){
console.log('hideCoupon')
this.showList=false;
}
}else{
console.log('hideCoupon')
this.showList=false;
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment