honghaitzz11 6 anni fa
parent
commit
98300dc316

+ 4 - 0
www/webapp/scg/src/lib/baseUrl.js

@@ -73,6 +73,10 @@ const serviceModule = {
     url: 'api/shop/delAddress',
     method: 'post'
   },
+  pay: {
+    url: 'o2o/order/pay',
+    method: 'post'
+  }
 };
 const ApiSetting = { ...serviceModule };
 

+ 6 - 0
www/webapp/scg/src/router/index.js

@@ -7,6 +7,7 @@ import login from 'views/login/index';
 import address from 'views/address/index';
 import addressEdit from 'views/address/edit';
 import addressPosition from 'views/address/position';
+import pay from 'views/pay/index';
 
 Vue.use(Router);
 
@@ -26,6 +27,11 @@ export default new Router({
       name: 'order',
       component: order,
     },
+    {
+      path: '/pay',
+      name: 'pay',
+      component: pay,
+    },
     {
       path: '/mine',
       name: 'mine',

+ 16 - 1
www/webapp/scg/src/store.js

@@ -22,7 +22,8 @@ export default new Vuex.Store({
     ifLogin: '',
     name: Name,
     addressRouter: {},
-    addressInformation: {}
+    addressInformation: {},
+    order: {}
   },
   getters: {
     getUserInfo: state => state.userInfo,
@@ -90,6 +91,17 @@ export default new Vuex.Store({
           this.commit('dialog', '地址删除成功!');
         });
     },
+    pay(state) {
+      const that = state;
+      http(ApiSetting.pay, {
+        user_id: userID(),
+        order_id: that.order.order_id,
+        pay_channel: 'wx_pub'
+      })
+        .then(res => {
+          console.log(res);
+        });
+    },
     dialog(state, msg) {
       this.dispatch('getUserInfo');
       const dialog = Dialog.$create({
@@ -115,6 +127,9 @@ export default new Vuex.Store({
     },
     delAddress({ commit }) {
       commit('delAddress');
+    },
+    pay({ commit }) {
+      commit('pay');
     }
   },
 });

+ 1 - 0
www/webapp/scg/src/views/address/index.vue

@@ -47,6 +47,7 @@
           this.$router.push({ name: 'mine' });
           return;
         }
+        console.log(this.addressRouter);
         this.$router.push({ name: this.addressRouter.from });
       },
       edit(address) {

+ 15 - 10
www/webapp/scg/src/views/order/index.vue

@@ -40,7 +40,7 @@
                 <div class="order-footer" v-if="item.label !== '已取消'">
                   <div class="control one" v-if="order.status===0">
                     <cube-button :outline="true">取消订单</cube-button>
-                    <cube-button :primary="true">立即支付</cube-button>
+                    <cube-button @click="pay(order)" :primary="true">立即支付</cube-button>
                   </div>
                   <div class="control two" v-if="order.status === 1 || order.status === 2 || order.status === 3 || order.status === 4 || order.status === 5">
                     <cube-button :primary="true">确认完成</cube-button>
@@ -123,16 +123,21 @@
           user_id: this.$store.state.user_id,
           type: status,
           page: 1
-        }).then(res => {
-          // console.log(status - 1);
-          if (res.length > 0 && status === 2) {
-            console.log(res[0].order_time_str);
-          }
-          this.$nextTick(() => {
-            this.tabs[index].data = res;
-            this.refresh();
+        })
+          .then(res => {
+            // console.log(status - 1);
+            if (res.length > 0 && status === 2) {
+              console.log(res[0].order_time_str);
+            }
+            this.$nextTick(() => {
+              this.tabs[index].data = res;
+              this.refresh();
+            });
           });
-        });
+      },
+      pay(order) {
+        this.$store.state.order = order;
+        this.$router.push({ name: 'pay' });
       },
       refresh() {
         // 代理better-scroll的refresh方法

+ 36 - 0
www/webapp/scg/src/views/pay/index.vue

@@ -0,0 +1,36 @@
+<template>
+  <div class="pay-wrapper" v-if="order !== ''">
+    收银台
+    <cube-button @click="pay">测试</cube-button>
+  </div>
+</template>
+<script>
+  export default {
+    name: 'pay',
+    data() {
+      return {
+        order: ''
+      };
+    },
+    created() {
+      if (JSON.stringify(this.$store.state.order) === '{}') {
+        this.$router.go(-1);
+      } else {
+        this.order = this.$store.state.order;
+      }
+    },
+    methods: {
+      pay() {
+        let payInfo = {
+          user_id: config.userId,
+          order_id: this.$route.query.orderInfo.id,
+          pay_channel: 'wx_pub'
+        };
+        axios.post('o2o/order/pay', qs.stringify(payInfo))
+          .then(res => {
+            this.pay(res, payInfo.order_id, this.$route.query.orderInfo);
+          });
+      }
+    }
+  };
+</script>