Bladeren bron

积分加现金兑换商品联调

sunlupeng 1 jaar geleden
bovenliggende
commit
38b199cb82

+ 1 - 1
src/permission.js

@@ -4,7 +4,7 @@ import { getToken, setToken } from '@/utils/auth' // getToken from cookie
 import { lockStatus,unlock } from "@/api/allApi";
 //路由跳转之前
 router.beforeEach((to, _from, next) => {
-  // setToken('bb205f6fcd05bcdb30b645cbedf35fab');
+  setToken('543f99d84f6a8ba40265c98af3c397ca');
   const path = to.path;
   const Authorization = to.query.Authorization
   if (path.indexOf('auth') != -1 && Authorization) { 

+ 1 - 1
src/utils/request.js

@@ -6,7 +6,7 @@ let prodBaseURL = 'https://xiaoyou.dgtis.com/admin';//正式地址
 
 // let prodBaseURL = 'https://malltest.dgtis.com/admin';//阿里云地址
 
-let devBaseURL = 'https://xiaoyou.dgtis.com/admin';//测试地址
+let devBaseURL = 'https://malltest.dgtis.com/admin';//测试地址
 
 // create an axios instance
 const service = axios.create({

File diff suppressed because it is too large
+ 3 - 1
src/views/HomeView/PointsMall.vue


File diff suppressed because it is too large
+ 1 - 1
src/views/HomeView/PointsMall copy.vue


+ 100 - 64
src/views/HomeView/RedeemView.vue

@@ -25,12 +25,12 @@
                 </div>
                 <div class="goods-content">
                     <div class="goods-name">{{ data.name }}</div>
-                    <div class="goods-price">兑换积分:{{ data.price }} 
+                    <div class="goods-redeemPoints">兑换积分:{{ data.redeemPoints }} 
                         <!-- <span style="color: red;margin-left: 150px;">参 考 价:¥{{  data.hisPrice}}</span> -->
                     </div>
-                    <div class="goods-price">物品类别:{{ data.skuType==0 ? '积分商品' : '活动礼品' }}</div> 
-                    <div class="goods-price">兑换方式:{{ data.deliveryTypeName }}</div>
-                    <div class="goods-price">是否包邮:{{ data.freightType == '0' ? '不包邮' : '包邮' }}</div>
+                    <div class="goods-redeemPoints">物品类别:{{ data.skuType==0 ? '积分商品' : '活动礼品' }}</div> 
+                    <div class="goods-redeemPoints">兑换方式:{{ data.deliveryTypeName }}</div>
+                    <div class="goods-redeemPoints">是否包邮:{{ data.freightType == '0' ? '不包邮' : '包邮' }}</div>
                     <div class="footer">
                         <div class="left-info">
                             <span class="info-title">
@@ -154,8 +154,9 @@
                                 <el-input-number @change="changeCount" size="mini" v-model="skuCount" :step="1" :min="1"
                                     step-strictly></el-input-number>
                             </td>
-                            <td style="text-align: center">
-                                {{ data.price }} 积分
+                            <td style="text-align: center;">
+                                {{ data.redeemPoints }} 积分
+                                <span style="color: red;" v-if="money!='0'"> + {{ money }} 元</span>
                             </td>
                             <td style="text-align: center">
                                 <el-select size="small" clearable v-model="deliveryType" placeholder="请选择"
@@ -173,9 +174,9 @@
                                     </el-option>
                                 </el-select>
                             </td>
-                            <td style="text-align: center" class="finlly-price">
-                                {{ money ? userInfo.surplusIntegral : total }} 积分
-                                <span style="color: red;" v-if="money">+{{ money }}元</span>
+                            <td style="text-align: center" class="finlly-redeemPoints">
+                                {{ total }} 积分
+                                <span style="color: red;" v-if="money!='0'"> + {{ totalMoney }} 元</span>
                             </td>
                         </tr>
                     </tbody>
@@ -314,8 +315,12 @@
         <el-dialog title="结算明细" :visible.sync="dialogFormOrderInfo" width="300px">
             <div class="checklist">
                 <div class="listItem">
-                    <div class="itemName">商品积分</div>
-                    <div class="itemValue">{{ data.price }}</div>
+                    <div class="itemName">商品</div>
+                    <div class="itemValue">
+                        {{ data.redeemPoints }} 积分 
+                        <span style="color: red;" v-if="money!='0'"> + {{ money }} 元</span>
+                    </div>
+                    
                 </div>
                 <div class="listItem">
                     <div class="itemName">商品数量</div>
@@ -328,8 +333,8 @@
                 <div class="listItem">
                     <div class="itemName">合计</div>
                     <div class="itemValue">
-                        {{ money ? userInfo.surplusIntegral : total }}
-                        <span style="color: red;" v-if="money">+{{ money }}元</span>
+                        {{ total }} 积分
+                        <span style="color: red;"v-if="money">+ {{ totalMoney }}元</span>
                     </div>
                 </div>
             </div>
@@ -411,8 +416,12 @@
                     <div class="itemValue">{{ couponName }}</div>
                 </div>
                 <div v-if="activeName == 'goodsNotice'" class="listItem">
-                    <div class="itemName">商品积分</div>
-                    <div class="itemValue">{{ data.price }}</div>
+                    <div class="itemName">商品</div>
+                    <div class="itemValue">
+                        {{ data.redeemPoints }} 积分
+                        <span style="color: red;" v-if="money!='0'"> + {{ money }} 元</span>
+                    </div>
+                    
                 </div>
                 <div v-if="activeName == 'goodsNotice'" class="listItem">
                     <div class="itemName">商品数量</div>
@@ -432,8 +441,8 @@
                 </div>
                 <div v-if="activeName == 'goodsNotice'" class="listItem">
                     <div class="itemName">合计</div>
-                    <div class="itemValue">{{ money ? userInfo.surplusIntegral : total }}<span style="color: red;"
-                            v-if="money">+{{ money }}元</span></div>
+                    <div class="itemValue">{{ total }} 积分<span style="color: red;"
+                            v-if="money">+ {{ totalMoney }}元</span></div>
                 </div>
             </div>
             <span slot="footer" class="dialog-footer">
@@ -453,7 +462,7 @@
                     <div class="item-right">
                         <div class="up">
                             <div>应付金额</div>
-                            <div style="color: #fe2c55;margin-left: 8px;">¥ {{ money }}</div>
+                            <div style="color: #fe2c55;margin-left: 8px;">¥ {{ totalMoney }}</div>
                         </div>
                         <div class="down">
                             <img style="height: 18px;" src="../../assets/icon/weixinPay.png" alt="weixinpay">
@@ -511,6 +520,7 @@ export default {
             recharge: false,
             //充值金额
             money: undefined,
+            totalMoney: undefined,
             couponName: '',
             voucher: '',
             couponList: [],
@@ -604,16 +614,16 @@ export default {
         ...mapGetters(['userInfo'])
     },
     watch: {
-        total(val) {
-            let surplusIntegral = this.$store.getters.userInfo.surplusIntegral;
-            let money = (val - surplusIntegral) / 10;
-            if (money >= 0) {
-                this.money = money
-            } else {
-                this.money = 0
-            }
-            console.log(this.money);
-        },
+        // total(val) {
+        //     let surplusIntegral = this.$store.getters.userInfo.surplusIntegral;
+        //     let money = (val - surplusIntegral) / 10;
+        //     if (money >= 0) {
+        //         this.money = money
+        //     } else {
+        //         this.money = 0
+        //     }
+        //     console.log(this.money);
+        // },
         '$route' (to, from) {
             // 路由发生变化页面刷新
             this.$router.go(0);
@@ -643,8 +653,8 @@ export default {
         },
         handlePayWxQRcode() {  // 获取微信支付二维码
             getWxPayCode({    // 这里根据不同的后端接口去修改
-                integral: this.money * 10,
-                totalFee: this.money,
+                integral: this.totalMoney * 10,
+                totalFee: this.totalMoney,
             }).then(res => {
                 let data = res.data.data;
                 this.qrcode(data.payUrl);    // 例如:data.payUrl 的值为 "weixin://wxpay/bizpayurl?pr=......",根据这个值生成相对应的微信支付二维码
@@ -670,10 +680,11 @@ export default {
                         type: 'success',
                         message: '支付成功!'
                     });
-                    this.money = 0;
                     this.recharge = false;
                     clearInterval(this.timer);    // 清除定时器;   
                     clearInterval(this.timerPayWxQRcode);
+                    this.$store.dispatch("GetUserInfo");
+                    this.dialogMsgVisible = true;
                 }
             }).catch(err => {
                 console.log(err)
@@ -720,22 +731,23 @@ export default {
                     this.dialogVisible = true;
                 }
             } else {
-                if (this.money) {
-                    this.$confirm('积分不足,差额部分可用现金补齐,是否购买积分?', {
-                        confirmButtonText: '确定',
-                        cancelButtonText: '取消',
-                        type: 'warning'
-                    }).then(() => {
-                        this.recharge = true;
-                        this.$nextTick(function () {
-                            this.handlePayWxQRcode();
-                            // this.qrcode(this.payUrl);
-                        })
-
-                    }).catch(() => { });
-                } else {
-                    this.dialogVisible = true;
-                }
+                this.dialogVisible = true;
+                // if (this.money) {
+                //     this.$confirm('积分不足,差额部分可用现金补齐,是否购买积分?', {
+                //         confirmButtonText: '确定',
+                //         cancelButtonText: '取消',
+                //         type: 'warning'
+                //     }).then(() => {
+                //         this.recharge = true;
+                //         this.$nextTick(function () {
+                //             this.handlePayWxQRcode();
+                //             // this.qrcode(this.payUrl);
+                //         })
+
+                //     }).catch(() => { });
+                // } else {
+                //     this.dialogVisible = true;
+                // }
             }
         },
         handleChange(value) {
@@ -761,13 +773,14 @@ export default {
             this.reclaimAddr = '';
             this.disabled = true;
             if (val == "0" || val == "") {
-                this.total = this.data.price;
+                this.total = this.data.redeemPoints;
+                this.totalMoney = this.money;
                 this.skuCount = 1;
             }
             if (val == "1") {
                 debugger;
                 if (this.data.freightType == "0") {
-                    this.total = this.data.price * this.skuCount + 180;
+                    this.total = this.data.redeemPoints * this.skuCount + 180;
                     this.dialogFormOrderInfo = true;
                 }
                 if (this.address) {
@@ -776,12 +789,14 @@ export default {
                 }
             }
             if (val == "2" || val == "3") {
-                this.total = this.data.price;
+                this.total = this.data.redeemPoints;
+                this.totalMoney = this.money;
                 this.skuCount = 1;
                 this.disabled = false;
             }
             if (val == "4") {
-                this.total = this.data.price;
+                this.total = this.data.redeemPoints;
+                this.totalMoney = this.money;
                 this.skuCount = 1;
                 if (this.phoneNumber) {
                     this.disabled = false;
@@ -793,7 +808,8 @@ export default {
             this.reclaimAddr = '';
             this.disabled = true;
             if (val == "0" || val == "") {
-                this.total = this.data.price;
+                this.total = this.data.redeemPoints;
+                this.totalMoney = this.money;
                 this.skuCount = 1;
             }
             if (val == "1") {
@@ -803,12 +819,14 @@ export default {
                 }
             }
             if (val == "2" || val == "3") {
-                this.total = this.data.price;
+                this.total = this.data.redeemPoints;
+                this.totalMoney = this.money;
                 this.skuCount = 1;
                 this.disabled = false;
             }
             if (val == "4") {
-                this.total = this.data.price;
+                this.total = this.data.redeemPoints;
+                this.totalMoney = this.money;
                 this.skuCount = 1;
                 if (this.phoneNumber) {
                     this.disabled = false;
@@ -820,12 +838,15 @@ export default {
             setTab("exchange");
         },
         changeCount(val) {
-            this.total = this.data.price * val;
+            if(this.money){
+                this.totalMoney = ((this.money * 100) * val)/ 100;
+            }
+            this.total = this.data.redeemPoints * val;
             if (
                 this.deliveryType == "1" &&
                 this.data.freightType == "0"
             ) {
-                this.total = this.data.price * val + 180;
+                this.total = this.data.redeemPoints * val + 180;
             }
         },
         handleClose() {
@@ -849,7 +870,9 @@ export default {
                         this.street = this.contactInfo.street;
                         this.address = this.contactInfo.contactAddr;
                     }
-                    this.total = response.data.data.price;
+                    this.total = response.data.data.redeemPoints;
+                    this.money = response.data.data.wxPay;
+                    this.totalMoney = response.data.data.wxPay;
                     let imgs = response.data.data.imgs;
                     if (imgs) {
                         imgs.forEach(element => {
@@ -913,7 +936,7 @@ export default {
                     voucher: this.voucher,
                     skuId: this.data.skuId,
                     skuCount: this.skuCount,
-                    price: this.data.price,
+                    price: this.data.redeemPoints,
                     deliveryType: this.deliveryType,
                     contact: this.name,
                     contactPhone: this.phone,
@@ -931,7 +954,7 @@ export default {
                     voucher: this.voucher,
                     skuId: this.data.skuId,
                     skuCount: this.skuCount,
-                    price: this.data.price,
+                    price: this.data.redeemPoints,
                     deliveryType: this.deliveryType,
                     contactPhone: this.phoneNumber,
 
@@ -944,7 +967,7 @@ export default {
                     voucher: this.voucher,
                     skuId: this.data.skuId,
                     skuCount: this.skuCount,
-                    price: this.data.price,
+                    price: this.data.redeemPoints,
                     deliveryType: this.deliveryType,
                     reclaimAddr: this.reclaimAddr,
 
@@ -957,8 +980,19 @@ export default {
                 start(params)
                     .then((response) => {
                         console.log(response.data.data);
-                        this.$store.dispatch("GetUserInfo");
-                        this.dialogMsgVisible = true;
+                        if(response.data.data){
+                            this.recharge = true;
+                            this.$nextTick(function () {
+                                let data = response.data.data;
+                                this.qrcode(data.payUrl);    // 例如:data.payUrl 的值为 "weixin://wxpay/bizpayurl?pr=......",根据这个值生成相对应的微信支付二维码
+                                this.timer = setInterval(() => {    // 通过定时器每间隔一会去请求查询微信支付状态(具体参数根据项目需要而定)
+                                    this.handleQueryWxPayStatus(data.orderNo);
+                                }, 1000);
+                            })
+                        }else{
+                            this.$store.dispatch("GetUserInfo");
+                            this.dialogMsgVisible = true;
+                        }
                     })
                     .catch(() => { });
             } else {
@@ -1221,11 +1255,13 @@ img {
     padding: 2px 4px;
 }
 
-.table .finlly-price {
+.table .finlly-redeemPoints {
     font-weight: 500;
     font-size: 14px;
     line-height: 24px;
     color: #1e80ff;
+    /* color: red; */
+    
 }
 
 .footer {
@@ -1419,7 +1455,7 @@ img {
     font-weight: bold;
     line-height: 36px;
 }
-.goods-content .goods-price{
+.goods-content .goods-redeemPoints{
     font-size: 16px;
     line-height: 32px;
 }

+ 41 - 65
src/views/HomeView/RedeemView copy.vue

@@ -154,9 +154,8 @@
                                 <el-input-number @change="changeCount" size="mini" v-model="skuCount" :step="1" :min="1"
                                     step-strictly></el-input-number>
                             </td>
-                            <td style="text-align: center;">
+                            <td style="text-align: center">
                                 {{ data.price }} 积分
-                                <span style="color: red;" v-if="money">+ {{ money }}元</span>
                             </td>
                             <td style="text-align: center">
                                 <el-select size="small" clearable v-model="deliveryType" placeholder="请选择"
@@ -175,8 +174,8 @@
                                 </el-select>
                             </td>
                             <td style="text-align: center" class="finlly-price">
-                                {{ total }} 积分
-                                <span style="color: red;" v-if="money">+ {{ totalMoney }}元</span>
+                                {{ money ? userInfo.surplusIntegral : total }} 积分
+                                <span style="color: red;" v-if="money">+{{ money }}元</span>
                             </td>
                         </tr>
                     </tbody>
@@ -315,12 +314,8 @@
         <el-dialog title="结算明细" :visible.sync="dialogFormOrderInfo" width="300px">
             <div class="checklist">
                 <div class="listItem">
-                    <div class="itemName">商品</div>
-                    <div class="itemValue">
-                        {{ data.price }} 积分 
-                        <span style="color: red;" v-if="money">+ {{ money }}元</span>
-                    </div>
-                    
+                    <div class="itemName">商品积分</div>
+                    <div class="itemValue">{{ data.price }}</div>
                 </div>
                 <div class="listItem">
                     <div class="itemName">商品数量</div>
@@ -333,8 +328,8 @@
                 <div class="listItem">
                     <div class="itemName">合计</div>
                     <div class="itemValue">
-                        {{ total }} 积分
-                        <span style="color: red;"v-if="money">+ {{ totalMoney }}元</span>
+                        {{ money ? userInfo.surplusIntegral : total }}
+                        <span style="color: red;" v-if="money">+{{ money }}元</span>
                     </div>
                 </div>
             </div>
@@ -416,12 +411,8 @@
                     <div class="itemValue">{{ couponName }}</div>
                 </div>
                 <div v-if="activeName == 'goodsNotice'" class="listItem">
-                    <div class="itemName">商品</div>
-                    <div class="itemValue">
-                        {{ data.price }} 积分
-                        <span style="color: red;" v-if="money">+ {{ money }} 元</span>
-                    </div>
-                    
+                    <div class="itemName">商品积分</div>
+                    <div class="itemValue">{{ data.price }}</div>
                 </div>
                 <div v-if="activeName == 'goodsNotice'" class="listItem">
                     <div class="itemName">商品数量</div>
@@ -441,8 +432,8 @@
                 </div>
                 <div v-if="activeName == 'goodsNotice'" class="listItem">
                     <div class="itemName">合计</div>
-                    <div class="itemValue">{{ total }} 积分<span style="color: red;"
-                            v-if="money">+ {{ totalMoney }}元</span></div>
+                    <div class="itemValue">{{ money ? userInfo.surplusIntegral : total }}<span style="color: red;"
+                            v-if="money">+{{ money }}元</span></div>
                 </div>
             </div>
             <span slot="footer" class="dialog-footer">
@@ -462,7 +453,7 @@
                     <div class="item-right">
                         <div class="up">
                             <div>应付金额</div>
-                            <div style="color: #fe2c55;margin-left: 8px;">¥ {{ totalMoney }}</div>
+                            <div style="color: #fe2c55;margin-left: 8px;">¥ {{ money }}</div>
                         </div>
                         <div class="down">
                             <img style="height: 18px;" src="../../assets/icon/weixinPay.png" alt="weixinpay">
@@ -520,7 +511,6 @@ export default {
             recharge: false,
             //充值金额
             money: undefined,
-            totalMoney: undefined,
             couponName: '',
             voucher: '',
             couponList: [],
@@ -614,16 +604,16 @@ export default {
         ...mapGetters(['userInfo'])
     },
     watch: {
-        // total(val) {
-        //     let surplusIntegral = this.$store.getters.userInfo.surplusIntegral;
-        //     let money = (val - surplusIntegral) / 10;
-        //     if (money >= 0) {
-        //         this.money = money
-        //     } else {
-        //         this.money = 0
-        //     }
-        //     console.log(this.money);
-        // },
+        total(val) {
+            let surplusIntegral = this.$store.getters.userInfo.surplusIntegral;
+            let money = (val - surplusIntegral) / 10;
+            if (money >= 0) {
+                this.money = money
+            } else {
+                this.money = 0
+            }
+            console.log(this.money);
+        },
         '$route' (to, from) {
             // 路由发生变化页面刷新
             this.$router.go(0);
@@ -653,8 +643,8 @@ export default {
         },
         handlePayWxQRcode() {  // 获取微信支付二维码
             getWxPayCode({    // 这里根据不同的后端接口去修改
-                integral: this.totalMoney * 10,
-                totalFee: this.totalMoney,
+                integral: this.money * 10,
+                totalFee: this.money,
             }).then(res => {
                 let data = res.data.data;
                 this.qrcode(data.payUrl);    // 例如:data.payUrl 的值为 "weixin://wxpay/bizpayurl?pr=......",根据这个值生成相对应的微信支付二维码
@@ -680,7 +670,7 @@ export default {
                         type: 'success',
                         message: '支付成功!'
                     });
-                    this.totalMoney =  this.money;
+                    this.money = 0;
                     this.recharge = false;
                     clearInterval(this.timer);    // 清除定时器;   
                     clearInterval(this.timerPayWxQRcode);
@@ -730,23 +720,22 @@ export default {
                     this.dialogVisible = true;
                 }
             } else {
-                this.dialogVisible = true;
-                // if (this.money) {
-                //     this.$confirm('积分不足,差额部分可用现金补齐,是否购买积分?', {
-                //         confirmButtonText: '确定',
-                //         cancelButtonText: '取消',
-                //         type: 'warning'
-                //     }).then(() => {
-                //         this.recharge = true;
-                //         this.$nextTick(function () {
-                //             this.handlePayWxQRcode();
-                //             // this.qrcode(this.payUrl);
-                //         })
-
-                //     }).catch(() => { });
-                // } else {
-                //     this.dialogVisible = true;
-                // }
+                if (this.money) {
+                    this.$confirm('积分不足,差额部分可用现金补齐,是否购买积分?', {
+                        confirmButtonText: '确定',
+                        cancelButtonText: '取消',
+                        type: 'warning'
+                    }).then(() => {
+                        this.recharge = true;
+                        this.$nextTick(function () {
+                            this.handlePayWxQRcode();
+                            // this.qrcode(this.payUrl);
+                        })
+
+                    }).catch(() => { });
+                } else {
+                    this.dialogVisible = true;
+                }
             }
         },
         handleChange(value) {
@@ -773,7 +762,6 @@ export default {
             this.disabled = true;
             if (val == "0" || val == "") {
                 this.total = this.data.price;
-                this.totalMoney = this.money;
                 this.skuCount = 1;
             }
             if (val == "1") {
@@ -789,13 +777,11 @@ export default {
             }
             if (val == "2" || val == "3") {
                 this.total = this.data.price;
-                this.totalMoney = this.money;
                 this.skuCount = 1;
                 this.disabled = false;
             }
             if (val == "4") {
                 this.total = this.data.price;
-                this.totalMoney = this.money;
                 this.skuCount = 1;
                 if (this.phoneNumber) {
                     this.disabled = false;
@@ -808,7 +794,6 @@ export default {
             this.disabled = true;
             if (val == "0" || val == "") {
                 this.total = this.data.price;
-                this.totalMoney = this.money;
                 this.skuCount = 1;
             }
             if (val == "1") {
@@ -819,13 +804,11 @@ export default {
             }
             if (val == "2" || val == "3") {
                 this.total = this.data.price;
-                this.totalMoney = this.money;
                 this.skuCount = 1;
                 this.disabled = false;
             }
             if (val == "4") {
                 this.total = this.data.price;
-                this.totalMoney = this.money;
                 this.skuCount = 1;
                 if (this.phoneNumber) {
                     this.disabled = false;
@@ -837,9 +820,6 @@ export default {
             setTab("exchange");
         },
         changeCount(val) {
-            if(this.money){
-                this.totalMoney = ((this.money * 100) * val)/ 100;
-            }
             this.total = this.data.price * val;
             if (
                 this.deliveryType == "1" &&
@@ -870,8 +850,6 @@ export default {
                         this.address = this.contactInfo.contactAddr;
                     }
                     this.total = response.data.data.price;
-                    this.money = 12.34;
-                    this.totalMoney = 12.34;
                     let imgs = response.data.data.imgs;
                     if (imgs) {
                         imgs.forEach(element => {
@@ -1248,8 +1226,6 @@ img {
     font-size: 14px;
     line-height: 24px;
     color: #1e80ff;
-    /* color: red; */
-    
 }
 
 .footer {