sunlupeng 2 年 前
コミット
f9ea67af76
3 ファイル変更153 行追加62 行削除
  1. 10 1
      src/api/allApi.js
  2. 33 10
      src/views/HomeView/PointsMall.vue
  3. 110 51
      src/views/HomeView/RedeemView.vue

+ 10 - 1
src/api/allApi.js

@@ -1,5 +1,14 @@
 import request from '@/utils/request'
 
+//用户没过期兑换卷列表
+export function couponList(query) {
+  return request({
+    url: '/coupon/user/list',
+    method: 'get',
+    params:query
+  })
+}
+
 // 每日问答-首页数据
 export function homeData(query) {
   return request({
@@ -220,7 +229,7 @@ export function start(query) {
 //福利券兑换
 export function kill(query) {
   return request({
-    url: '/mall-order/kill',
+    url: '/mall-order/coupon/start',
     method: 'post',
     data:query
   })

+ 33 - 10
src/views/HomeView/PointsMall.vue

@@ -117,11 +117,11 @@
                         <div class="prize-list">
                             <div v-for="(item, index) in giftList" :key="index" class="prize-card prize-item">
                                 <div class="img-container">
-                                    <el-image :src="item.imgUrl" v-if="item.imgUrl" :preview-src-list="[item.imgUrl]"
+                                    <el-image :src="item.imgUrl" v-if="item.imgUrl" :preview-src-list="item.imgUrls.length==0?[item.imgUrl]:item.imgUrls"
                                         class="prize-img"></el-image>
                                 </div>
                                 <div class="content">
-                                    <h3 :title="item.name" class="title">{{ item.name }}</h3>
+                                    <h3 style="color: #1e80ff;" :title="item.name" class="title" @click="handleClickGood(item.skuId)">{{ item.name }}</h3>
                                     <p class="desc"><span v-if="item.deliveryTypeName">{{ item.deliveryTypeName }}</span></p>
                                     <p class="redeem-info">
                                         <span title="福利券" class="price">
@@ -139,7 +139,7 @@
                                                     d="M375.466667 426.666667a51.2 51.2 0 0 1 51.2 51.2v273.066666a51.2 51.2 0 0 1-102.4 0v-273.066666a51.2 51.2 0 0 1 51.2-51.2z"
                                                     fill="#FFFFFF" p-id="1487"></path>
                                             </svg>
-                                            {{ item.title }}
+                                            兑换券
                                         </span>
                                         <span class="count">{{ item.stock }}库存</span>
                                     </p>
@@ -313,10 +313,21 @@ export default {
 
                     });
                     this.choseList = dataList;
-                    this.curChosed = dataList[0].welfareId;
-                    festivalList({ welfareId: this.curChosed }).then(response => {
+                    this.curChosed = dataList[0].actId;
+                    festivalList({ actId: this.curChosed }).then(response => {
                         console.log(response.data.data);
-                        this.giftList = response.data.data
+                        let list = response.data.data;
+                        list.forEach((element,index) => {
+                            let imgUrls = []
+                            if(element.imgs){
+                                for (let i in element.imgs) {
+                                    imgUrls.push(element.imgs[i].url)
+                                }
+                            } 
+                            list[index].imgUrls = imgUrls;
+                        });
+                        console.log(list);
+                        this.giftList = list;
                     })
                 }
             })
@@ -344,7 +355,7 @@ export default {
                 element.checked = false;
             });
             item.checked = true;
-            this.curChosed = item.welfareId;
+            this.curChosed = item.actId;
             this.getSecondList();
         },
         getNotice(val) {
@@ -389,9 +400,20 @@ export default {
             })
         },
         getSecondList() {
-            festivalList({ welfareId: this.curChosed }).then(response => {
+            festivalList({ actId: this.curChosed }).then(response => {
                 console.log(response.data.data);
-                this.giftList = response.data.data;
+                let list = response.data.data;
+                list.forEach((element,index) => {
+                    let imgUrls = []
+                    if(element.imgs){
+                        for (let i in element.imgs) {
+                            imgUrls.push(element.imgs[i].url)
+                        }
+                    } 
+                    list[index].imgUrls = imgUrls;
+                });
+                console.log(list);
+                this.giftList = list;
             })
         },
         handleClick(tab, event) {
@@ -409,7 +431,8 @@ export default {
                 path: '/home/pointsMall/redeem',
                 query: {
                     id: id,
-                    activeName: this.activeName
+                    name: this.activeName,
+                    type:this.curChosed,
                 }
             });
         },

+ 110 - 51
src/views/HomeView/RedeemView.vue

@@ -148,12 +148,20 @@
                 <table class="table">
                     <thead>
                         <tr>
-                            <th width="35%">兑换物品</th>
-                            <th style="text-align: center">消耗福利券</th>
-                            <th style="text-align: center">物品属性</th>
-                            <th style="text-align: center" width="20%">
+                            <th width="25%">兑换物品</th>
+                            <th style="text-align: center" width="15%">物品属性</th>
+                            <th style="text-align: center" width="15%">
+                                <span style="color: red">*</span>兑换券
+                            </th>
+                            <th style="text-align: center" width="15%">
                                 <span style="color: red">*</span>兑换方式
                             </th>
+                            <th v-if="deliveryType == '1' && data.freightType=='0'" style="text-align: center" width="15%">
+                               快递费
+                            </th>
+                            <th v-if="deliveryType == '0'" style="text-align: center" width="15%">
+                                <span style="color: red">*</span>领取地点
+                            </th>
                         </tr>
                     </thead>
                     <tbody>
@@ -161,29 +169,43 @@
                             <td>
                                 <div class="prize-info">
                                     <div class="prize-img-container">
-                                        <el-image :src="data.imgUrl" v-if="data.imgUrl" :preview-src-list="[data.imgUrl]"
+                                        <el-image :src="data.imgUrl" v-if="data.imgUrl" :preview-src-list="imgUrls.length==0?[data.imgUrl]:imgUrls"
                                             class="prize-img"></el-image>
                                     </div>
                                     <div class="prize-detail-info">
-                                        <h3 class="title">{{ data.name }}</h3>
+                                        <h3 style="color: #1e80ff;" class="title" @click="handleClickGood(data.skuDesc)">{{ data.name }}</h3>
                                         <!-- <p class="desc">
                                             <span v-if="data.location">{{ data.location }}</span>
                                         </p> -->
                                     </div>
                                 </div>
                             </td>
-                            <td style="text-align: center">{{ data.title }}</td>
+                            <td style="text-align: center">{{ data.productAttributeName }}</td>
                             <td style="text-align: center">
-                                {{ data.productAttributeName }}
+                                <el-select size="small" clearable v-model="voucher" placeholder="请选择" value-key="value"
+                                    @change="changeCouponList">
+                                    <el-option :key="item.voucher" v-for="item in couponList"
+                                        :label="item.couponName" :value="item.voucher">
+                                    </el-option>
+                                </el-select>
                             </td>
-                            <td style="text-align: center" class="finlly-price">
+                            <td style="text-align: center">
                                 <el-select size="small" clearable v-model="deliveryType" placeholder="请选择" value-key="value"
-                                    @change="changeDeliveryType">
+                                    @change="changeDeliveryTypeGift">
                                     <el-option :key="item.dictValue" v-for="item in deliveryTypeList"
                                         :label="item.dictLabel" :value="item.dictValue">
                                     </el-option>
                                 </el-select>
                             </td>
+                            <td v-if="deliveryType == '1' && data.freightType=='0'" style="text-align: center">180 积分</td>
+                            <td v-if="deliveryType == '0'" style="text-align: center">
+                                <el-select size="small" clearable v-model="reclaimAddr" placeholder="请选择" value-key="value"
+                                    @change="changeReclaimAddr">
+                                    <el-option :key="item.dictValue" v-for="item in reclaimAddrList" :label="item.dictLabel"
+                                        :value="item.dictValue">
+                                    </el-option>
+                                </el-select>
+                            </td>
                         </tr>
                     </tbody>
                 </table>
@@ -192,7 +214,7 @@
             <div class="footer">
                 <div class="right" v-if="data.stock != 0">
                     <div class="btn-line">
-                        <el-button :disabled="disabled" @click="dialogVisible = true" type="primary" round>确认兑换</el-button>
+                        <el-button :disabled="disabled" @click="handleClick" type="primary" round>确认兑换</el-button>
                     </div>
                 </div>
             </div>
@@ -319,17 +341,25 @@
                     <div class="itemName">商品名称</div>
                     <div class="itemValue">{{ data.name }}</div>
                 </div>
-                <div class="listItem">
+                <div v-if="activeName=='giftNotice'" class="listItem">
+                    <div class="itemName">商品属性</div>
+                    <div class="itemValue">{{ data.productAttributeName }}</div>
+                </div>
+                <div v-if="activeName=='giftNotice'" class="listItem">
+                    <div class="itemName">兑换卷</div>
+                    <div class="itemValue">{{ couponName }}</div>
+                </div>
+                <div v-if="activeName=='goodsNotice'" class="listItem">
                     <div class="itemName">商品积分</div>
                     <div class="itemValue">{{ data.price }}</div>
                 </div>
-                <div class="listItem">
+                <div v-if="activeName=='goodsNotice'" class="listItem">
                     <div class="itemName">商品数量</div>
                     <div class="itemValue">{{ skuCount }}</div>
                 </div>
-                <div v-if="deliveryType == '1' && data.productAttribute == 'exchange_logo'" class="listItem">
-                    <div class="itemName">快递积分</div>
-                    <div class="itemValue red">+180</div>
+                <div v-if="deliveryType == '1' && data.freightType == '0'" class="listItem">
+                    <div class="itemName">快递</div>
+                    <div class="itemValue red">+180 积分</div>
                 </div>
                 <div class="listItem">
                     <div class="itemName">兑换方式</div>
@@ -339,7 +369,7 @@
                     <div class="itemName">领取地点</div>
                     <div class="itemValue">{{ reclaimAddrName }}</div>
                 </div>
-                <div class="listItem">
+                <div v-if="activeName=='goodsNotice'" class="listItem">
                     <div class="itemName">合计</div>
                     <div class="itemValue">{{ total }}</div>
                 </div>
@@ -355,7 +385,7 @@
     </div>
 </template>
 <script>
-import { integralInfo, festivalInfo, start, kill } from "@/api/allApi";
+import { integralInfo, start, kill, couponList } from "@/api/allApi";
 import {regionData,codeToText,} from "element-china-area-data";
 import { setTab } from "@/utils/auth";
 import { debounce } from "@/utils/index";
@@ -375,6 +405,9 @@ export default {
             }
         };
         return {
+            couponName:'',
+            voucher:'',
+            couponList:[],
             skuDesc:'',
             dialogVisibleGoods:false,
             dialogVisible:false,
@@ -387,7 +420,8 @@ export default {
             deliveryType: "",
             deliveryTypeName:"",
             contactInfo: {},
-            activeName: this.$route.query.activeName,
+            activeName: this.$route.query.name,
+            activeType: this.$route.query.type,
             name: "",
             phone: "",
             addressArr: [],
@@ -460,26 +494,39 @@ export default {
     },
     created() {
         const skuId = this.$route.query.id;
-        const activeName = this.$route.query.activeName;
         this.dataForm.skuId = skuId;
-        this.getInfo(skuId, activeName);
+        this.getInfo(skuId);
+        this.getCouponList();
     },
     methods: {
+        changeCouponList(val){
+            this.couponName = this.couponList.find(item => item.voucher == val).couponName;
+        },
+        getCouponList(){
+            couponList({ actId: this.activeType })
+                    .then((response) => {
+                        this.couponList = response.data.data;
+                    });
+        },
         handleClickGood(val) {
             this.skuDesc = val;
             if(this.skuDesc){
                 this.dialogVisibleGoods = true;
             }
-            
-            // this.$router.push({
-            //     path: '/home/pointsMall/goodDetail',
-            //     query: {
-            //         id: id,
-            //     }
-            // });
         },
         handleClick(){
-            this.dialogVisible = true;
+            if(this.activeName=='giftNotice'){
+                if(!this.voucher){
+                    this.$message({
+                        message: '请选择兑换卷',
+                        type: 'warning'
+                    });
+                }else{
+                    this.dialogVisible = true;
+                }
+            }else{
+                this.dialogVisible = true;
+            }
         },
         handleChange(value) {
             console.log(value);
@@ -509,7 +556,7 @@ export default {
             }
             if (val == "1") {
                 debugger;
-                if (this.data.productAttribute == "exchange_logo") {
+                if (this.data.freightType == "0") {
                     this.total = this.data.price * this.skuCount + 180;
                     this.dialogFormOrderInfo = true;
                 }
@@ -532,6 +579,33 @@ export default {
             }
             this.deliveryTypeName = this.deliveryTypeList.find(item => item.dictValue == val).dictLabel;
         },
+        changeDeliveryTypeGift(val){
+            this.reclaimAddr = '';
+            this.disabled = true;
+            if (val == "0" || val == "") {
+                this.total = this.data.price;
+                this.skuCount = 1;
+            }
+            if (val == "1") {
+                if (this.address) {
+                    this.addressDetail = true;
+                    this.disabled = false;
+                }
+            }
+            if (val == "2" || val == "3") {
+                this.total = this.data.price;
+                this.skuCount = 1;
+                this.disabled = false;
+            }
+            if (val == "4") {
+                this.total = this.data.price;
+                this.skuCount = 1;
+                if (this.phoneNumber) {
+                    this.disabled = false;
+                }
+            }
+            this.deliveryTypeName = this.deliveryTypeList.find(item => item.dictValue == val).dictLabel;
+        },
         setTab() {
             setTab("exchange");
         },
@@ -539,7 +613,7 @@ export default {
             this.total = this.data.price * val;
             if (
                 this.deliveryType == "1" &&
-                this.data.productAttribute == "exchange_logo"
+                this.data.freightType == "0"
             ) {
                 this.total = this.data.price * val + 180;
             }
@@ -550,9 +624,8 @@ export default {
                 path: "/home/pointsMall",
             });
         },
-        getInfo(skuId, activeName) {
-            if (activeName == "goodsNotice") {
-                integralInfo({ skuId: skuId })
+        getInfo(skuId) {
+            integralInfo({ skuId: skuId })
                     .then((response) => {
                         this.data = response.data.data;
                         this.deliveryTypeList = response.data.data.dictDataList;
@@ -576,23 +649,6 @@ export default {
                         
                     })
                     .catch(() => { });
-            } else {
-                festivalInfo({ skuId: skuId })
-                    .then((response) => {
-                        this.data = response.data.data;
-                        this.contactInfo = response.data.data.contactInfo;
-                        this.deliveryTypeList = response.data.data.dictDataList;
-                        if (this.contactInfo) {
-                            this.name = this.contactInfo.contact;
-                            this.phone = this.contactInfo.contactPhone;
-                            this.addressArr = this.contactInfo.addressArr;
-                            this.addressStr = this.contactInfo.addressStr;
-                            this.street = this.contactInfo.street;
-                            this.address = this.contactInfo.contactAddr;
-                        }
-                    })
-                    .catch(() => { });
-            }
         },
         handleClickPhoneNumber() {
             this.dialogFormPhoneNumber = true;
@@ -642,6 +698,7 @@ export default {
             this.dialogVisible = false;
             if (this.deliveryType == "1") {
                 var params = {
+                    voucher:this.data.voucher,
                     skuId: this.data.skuId,
                     skuCount: this.skuCount,
                     price: this.data.price,
@@ -658,6 +715,7 @@ export default {
                 };
             } else if (this.deliveryType == "4") {
                 var params = {
+                    voucher:this.data.voucher,
                     skuId: this.data.skuId,
                     skuCount: this.skuCount,
                     price: this.data.price,
@@ -669,6 +727,7 @@ export default {
                 };
             } else {
                 var params = {
+                    voucher:this.data.voucher,
                     skuId: this.data.skuId,
                     skuCount: this.skuCount,
                     price: this.data.price,