huanggang %!s(int64=8) %!d(string=hai) anos
pai
achega
f7b584889f

+ 15 - 0
.babelrc

@@ -0,0 +1,15 @@
+{
+  "presets": [
+    ["env", { "modules": false }],
+    "stage-2",
+    "es2015"
+  ],
+  "plugins": ["transform-runtime","transform-vue-jsx"],
+  "comments": false,
+  "env": {
+    "test": {
+      "presets": ["env", "stage-2"],
+      "plugins": [ "istanbul" ]
+    }
+  }
+}

+ 4 - 2
src/components/address/addressList.vue

@@ -20,15 +20,17 @@
             link_add_address(){
                 this.$router.push('/add_address');
             },
-            check_address(name,tel,address){
+            check_address(name,tel,address,aid){
                 let address_name = name;
                 let address_tel = tel;
                 let user_address = address;
+                let address_id = aid;
                 if (this.$route.query.hasOwnProperty("need_goBack")) {
                     this.$store.commit('update_address', {
                         'name': address_name,
                         'mobile': address_tel,
-                        'address': user_address
+                        'address': user_address,
+                        'aid' : address_id
                     });
                     this.$router.go(-1);
                 }

+ 29 - 1
src/components/confirm_order/confirm_order.vue

@@ -81,7 +81,7 @@
             <div class="just_buy">
                 <flexbox>
                     <flexbox-item :span="4/6" style="text-align: center;line-height: 93px; font-size: 30px;">应付: <span class="letter_warn">¥ {{datas.payinfo['pay_cash_pred']}}</span></flexbox-item>
-                    <flexbox-item :span="2/6"  style="text-align: center;background:#EB4E4F;color: #fff;line-height: 93px; "><p>去付款</p></flexbox-item>
+                    <flexbox-item :span="2/6"  style="text-align: center;background:#EB4E4F;color: #fff;line-height: 93px; "><p @click="onBridgeReady">去付款</p></flexbox-item>
                 </flexbox>
             </div>
         </div>
@@ -157,6 +157,34 @@
         {
             link_address(){
                 this.$router.push({path:'/address/list',query:{need_goBack:true}});
+            },
+            onBridgeReady(){
+                let goods_id = this.$route.query["goods_id"];
+                let goods_num = this.$route.query['num'];
+                let iscart = this.$route.query["iscart"];
+                let cart_id = this.$route.query["cart_id"]?this.$route.query["cart_id"]:'';
+                let vat_hash = this.datas['payinfo'].vat_hash;
+                let offpay_hash = this.datas['payinfo'].offpay_hash;
+                let offpay_hash_batch = this.datas['payinfo'].offpay_hash_batch;
+                let address_id = this.datas['address'].address_id;
+                this.$http.jsonp(Api.step_second(cart_id,goods_id,goods_num,address_id,0,vat_hash,offpay_hash,offpay_hash_batch)).then(function(res){
+                    let param = res.body.datas.param.data;
+                    WeixinJSBridge.invoke(
+                        'getBrandWCPayRequest', {
+                            "appId": param.appid,     //公众号名称,由商户传入
+                            "timeStamp": param.timestamp,         //时间戳,自1970年以来的秒数
+                            "nonceStr": param.noncestr, //随机串
+                            "package": 'prepay_id='+param.prepayid,
+                            "signType": "MD5",         //微信签名方式:
+                            "paySign": param.sign //微信签名
+                        },
+                        function (res) {
+                            if (res.err_msg == "get_brand_wcpay_request:ok") {
+                                alert('支付成功');
+                            }     // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回    ok,但并不保证它绝对可靠。
+                        }
+                    );
+                });
             }
         },
         components:

+ 10 - 2
src/lib/api.js

@@ -1,8 +1,8 @@
 class Api {
 
     static host() {
-        //return "http://p.lrlz.com";
-        return "http://192.168.0.200";
+        return "http://p.lrlz.com";
+        // return "http://192.168.0.200";
     }
 
     static special(special_id) {
@@ -100,6 +100,14 @@ class Api {
         return this.host() + `/mobile/index.php?act=member_buy&op=step_first&curpage=1&ifcart=${ifcart}&cart_id=${goods_datas}&client_type=ajax`;
     }
 
+
+    static step_second(cart_ids, goods_id, goods_num, addr_id, inv_id, vat_hash, offpay_hash, offpay_hash_batch){
+        let ifcart = cart_ids !== '' ? true : false;
+        let iscart = ifcart ? 1 : 0;
+        let cartids = ifcart ? cart_ids : (goods_id + '|' + goods_num);
+        return this.host()+`/mobile/index.php?client_type=ajax&act=member_buy&op=step_second&payment=wxpay&usebonus=1&ifcart=${iscart}&cart_id=${cartids}&address_id=${addr_id}&invoice_id=${inv_id}&vat_hash=${vat_hash}&offpay_hash=${offpay_hash}&offpay_hash_batch=${offpay_hash_batch}`;
+    }
+
     static get_address() {
         return this.host() + '/mobile/index.php?act=app_update&op=area&curpage=1&client_type=ajax';
     }

+ 1 - 0
src/main.js

@@ -72,6 +72,7 @@ const store = new Vuex.Store({
             state.address.name = payload.name;
             state.address.mobile = payload.mobile;
             state.address.address = payload.address;
+            state.address.aid = payload.aid;
         },
         updateWxShareMsg(state,payload){
             state.wechatShareMsg.title = payload.title;