panhui 4 лет назад
Родитель
Сommit
96d9956ae2

+ 8 - 0
src/main/nine-space/src/router/index.js

@@ -287,6 +287,14 @@ const routes = [
             title: '第九空间'
         }
     },
+    {
+        path: '/couponList',
+        name: 'couponList',
+        component: () => import('../views/order/CouponList.vue'),
+        meta: {
+            title: '第九空间'
+        }
+    },
     {
         path: '/givesubmit',
         name: 'givesubmit',

+ 5 - 1
src/main/nine-space/src/store/index.js

@@ -5,7 +5,8 @@ export default createStore({
     state: {
         finished: false,
         userInfo: null,
-        firstUrl: ''
+        firstUrl: '',
+        couponInfo: null
     },
     mutations: {
         setFinished(state, finished) {
@@ -16,6 +17,9 @@ export default createStore({
         },
         setFirstUrl(state, url) {
             state.firstUrl = url;
+        },
+        setCouponInfo(state, couponInfo) {
+            state.couponInfo = couponInfo;
         }
     },
     actions: {

+ 26 - 6
src/main/nine-space/src/views/Submit.vue

@@ -21,6 +21,10 @@
                 <div class="text1">GAS费用</div>
                 <div class="text2">¥{{ gas }}</div>
             </div>
+            <div class="info" @click="$router.push('/couponList')">
+                <div class="text1">优惠券</div>
+                <div class="text2">{{ couponInfo ? '已选择兑换券' : '选择兑换券' }}</div>
+            </div>
 
             <van-field type="text" label="订单留言" placeholder="选填" v-model="message" />
 
@@ -56,6 +60,7 @@
 const path = require('path');
 import { add } from 'mathjs';
 import product from '../mixins/product';
+import { mapState } from 'vuex';
 let inWeixin = /micromessenger/i.test(navigator.userAgent);
 export default {
     name: 'Submit',
@@ -90,12 +95,24 @@ export default {
     },
     computed: {
         money() {
-            if (this.info.price) {
-                return add(this.info.price, this.gas);
-            } else {
-                return 0;
+            let money = 0;
+            if (this.info.price && !this.couponInfo) {
+                money = add(this.info.price, money);
+            }
+            if (this.gas && (!this.couponInfo || this.couponInfo.needGas)) {
+                money = add(money, this.gas);
             }
+
+            return money;
+        },
+        ...mapState(['couponInfo'])
+    },
+    beforeRouteLeave(to, from, next) {
+        console.log(to);
+        if (to.path !== '/couponList') {
+            this.$store.commit('setCouponInfo', null);
         }
+        next();
     },
     mounted() {
         this.$http.get('/sysConfig/get/gas_fee').then(res => {
@@ -110,7 +127,6 @@ export default {
                 this.info = res;
                 setTimeout(() => {
                     this.$toast.clear();
-                    this.bs.value.refresh();
                 }, 100);
 
                 // this.$http('/sysConfig/get/gas_fee')
@@ -146,8 +162,12 @@ export default {
     methods: {
         submit() {
             this.$toast.loading('加载中');
+            let url = '/order/create?collectionId=' + this.$route.query.id + '&qty=1';
+            if (this.couponInfo) {
+                url += '&couponId=' + this.couponInfo.id;
+            }
             this.$http
-                .post('/order/create?collectionId=' + this.$route.query.id + '&qty=1')
+                .post(url)
                 .then(res => {
                     this.$toast.clear();
                     this.orderId = res.id;

+ 2 - 2
src/main/nine-space/src/views/order/CouponList.vue

@@ -19,7 +19,7 @@
                     <img v-else class="icon" src="../../assets/icon_gouxuan_huise.png" alt="" />
                 </div>
             </template>
-            <van-empty v-if="empty" description="没有任何藏品哦~" />
+            <van-empty v-if="empty" description="暂无兑换券哦~" />
         </van-list>
     </div>
 </template>
@@ -49,7 +49,7 @@ export default {
         },
         beforeData() {
             return {
-                query: { userId: this.$store.state.userInfo.id }
+                query: { userId: this.$store.state.userInfo.id, used: false }
             };
         }
     }