xiongzhu 5 年之前
父節點
當前提交
a0bbb1a655

+ 25 - 20
src/components/OrderCardDefault.vue

@@ -27,8 +27,9 @@
                         round
                         type="default"
                         @click.stop="cancelOrder"
-                        >取消订单</van-button
                     >
+                        取消订单
+                    </van-button>
                     <van-button
                         v-if="info.presaleOrderCanPay"
                         :color="$colors.prim"
@@ -40,19 +41,19 @@
                     </van-button>
                 </template>
                 <template v-else-if="info.status === '2'">
-                    <van-button v-if="info.canRefund" size="small" round type="default" @click.stop="toRefundOrder"
-                        >申请退款</van-button
-                    >
+                    <van-button v-if="info.canRefund" size="small" round type="default" @click.stop="toRefundOrder">
+                        申请退款
+                    </van-button>
                 </template>
                 <template v-else-if="info.status === '3'">
-                    <van-button size="small" round :color="$colors.prim" type="default" @click.stop="toCheckLogistics"
-                        >查看物流</van-button
-                    >
+                    <van-button size="small" round :color="$colors.prim" type="default" @click.stop="toCheckLogistics">
+                        查看物流
+                    </van-button>
                 </template>
                 <template v-else-if="info.status === '4'">
-                    <van-button v-if="info.canReturn" size="small" round type="default" @click.stop="toReturnOrder"
-                        >申请退货</van-button
-                    >
+                    <van-button v-if="info.canReturn" size="small" round type="default" @click.stop="toReturnOrder">
+                        申请退货
+                    </van-button>
 
                     <van-button
                         v-if="info.evaluationStatus === '0'"
@@ -61,15 +62,16 @@
                         :color="$colors.prim"
                         type="default"
                         @click.stop="toevaluation"
-                        >评价晒单</van-button
-                    >
-                    <van-button v-else size="small" round type="default" @click.stop="toevaluationDetail"
-                        >查看评价</van-button
                     >
+                        评价晒单
+                    </van-button>
+                    <van-button v-else size="small" round type="default" @click.stop="toevaluationDetail">
+                        查看评价
+                    </van-button>
 
-                    <van-button v-if="info.canRefund" size="small" round type="default" @click.stop="toRefundOrder"
-                        >申请退款</van-button
-                    >
+                    <van-button v-if="info.canRefund" size="small" round type="default" @click.stop="toRefundOrder">
+                        申请退款
+                    </van-button>
                 </template>
             </template>
             <template v-else>
@@ -79,16 +81,18 @@
                     round
                     type="default"
                     @click.stop="goDetail"
-                    >查看进度</van-button
                 >
+                    查看进度
+                </van-button>
                 <van-button
                     v-if="['2', '3', '5', '8', '9'].indexOf(info.status) !== -1"
                     size="small"
                     round
                     type="default"
                     @click.stop="goDetail"
-                    >查看结果</van-button
                 >
+                    查看结果
+                </van-button>
                 <van-button
                     v-if="info.status === '6'"
                     size="small"
@@ -96,8 +100,9 @@
                     type="default"
                     :color="$colors.prim"
                     @click.stop="goDetail"
-                    >填写物流信息</van-button
                 >
+                    填写物流信息
+                </van-button>
             </template>
         </div>
 

+ 36 - 1
src/mixins/Order.js

@@ -168,7 +168,42 @@ export default {
             this.goNext('/pages/order/backMoney?orderId=' + this.info.id + '&money=' + this.info.depositPrice);
         },
         //去支付
-        toPay() {},
+        toPay() {
+            this.$loading();
+            this.$http
+                .post('/applets/appletsPay', {
+                    orderCode: this.info.code,
+                    orderType: 1
+                })
+                .then(res => {
+                    console.log(res);
+                    let data = JSON.parse(res.data.respStr);
+                    console.log(data);
+                    wx.requestPayment({
+                        ...data.miniPayRequest,
+                        success: res => {
+                            console.log('pay success', res);
+                            this.$toast('支付成功', 'success');
+                            this.$emit('paySuccess');
+                        },
+                        fail(res) {
+                            console.log('pay fail', res);
+                        },
+                        complete: () => {
+                            this.$loading.close();
+                        }
+                    });
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.$loading.close();
+                    if (typeof e === 'string') {
+                        this.$toast(e);
+                    } else {
+                        this.$toast('请求支付失败');
+                    }
+                });
+        },
         cancelOrder() {
             this.goNext('/pages/order/cancelOrder?orderId=' + this.info.id);
         },

+ 34 - 4
src/mixins/OrderDefault.js

@@ -97,10 +97,40 @@ export default {
             }
         },
         toPay() {
-            let price = this.info.price;
-            if (this.info.orderType == '1') {
-                price = this.info.presalePrice;
-            }
+            this.$loading();
+            this.$http
+                .post('/applets/appletsPay', {
+                    orderCode: this.info.orderCode,
+                    orderType: 2
+                })
+                .then(res => {
+                    console.log(res);
+                    let data = JSON.parse(res.data.respStr);
+                    console.log(data);
+                    wx.requestPayment({
+                        ...data.miniPayRequest,
+                        success: res => {
+                            console.log('pay success', res);
+                            this.$toast('支付成功', 'success');
+                            this.$emit('paySuccess');
+                        },
+                        fail(res) {
+                            console.log('pay fail', res);
+                        },
+                        complete: () => {
+                            this.$loading.close();
+                        }
+                    });
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.$loading.close();
+                    if (typeof e === 'string') {
+                        this.$toast(e);
+                    } else {
+                        this.$toast('请求支付失败');
+                    }
+                });
         },
         cancelOrder() {
             this.goNext(`/pages/order/cancelOrderDefault?orderId=${this.info.id}`);

+ 4 - 0
src/mixins/OrderList.js

@@ -46,6 +46,10 @@ export default {
                 .catch(() => {
                     this.loading = false;
                 });
+        },
+        onPaySuccess() {
+            this.pageNum = 0;
+            this.getList();
         }
     }
 };

+ 28 - 6
src/pages/coupe.vue

@@ -453,9 +453,11 @@ export default {
                     }
                 )
                 .then(res => {
-                    res.data = res.data.filter(
-                        i => i.showWebsiteFlag == 1 && !(typeof i.code === 'string' && i.code.startsWith('99999'))
-                    );
+                    if (process.env.NODE_ENV !== 'development') {
+                        res.data = res.data.filter(
+                            i => i.showWebsiteFlag == 1 && !(typeof i.code === 'string' && i.code.startsWith('99999'))
+                        );
+                    }
                     this.dealerList = res.data;
                 });
         },
@@ -566,15 +568,35 @@ export default {
                     }
                 )
                 .then(res => {
-                    this.$loading.close();
                     if (res.code === 200) {
-                        wx.redirectTo({
-                            url: '/pages/order/orderListCoupe'
+                        return this.$http.post('/applets/appletsPay', {
+                            orderCode: res.data.carOrderCode,
+                            orderType: 1
                         });
                     } else {
                         return Promise.reject(res.message);
                     }
                 })
+                .then(res => {
+                    this.$loading.close();
+                    console.log(res);
+                    let data = JSON.parse(res.data.respStr);
+                    console.log(data);
+                    wx.requestPayment({
+                        ...data.miniPayRequest,
+                        success(res) {
+                            console.log('pay success', res);
+                        },
+                        fail(res) {
+                            console.log('pay fail', res);
+                        },
+                        complete() {
+                            wx.redirectTo({
+                                url: '/pages/order/orderListCoupe'
+                            });
+                        }
+                    });
+                })
                 .catch(e => {
                     this.$loading.close();
                     if (typeof e === 'string') {

+ 5 - 3
src/pages/detail.vue

@@ -472,9 +472,11 @@ export default {
                     }
                 )
                 .then(res => {
-                    res.data = res.data.filter(
-                        i => i.showWebsiteFlag == 1 && !(typeof i.code === 'string' && i.code.startsWith('99999'))
-                    );
+                    if (process.env.NODE_ENV !== 'development') {
+                        res.data = res.data.filter(
+                            i => i.showWebsiteFlag == 1 && !(typeof i.code === 'string' && i.code.startsWith('99999'))
+                        );
+                    }
                     this.dealerList = res.data;
                 });
         },

+ 7 - 1
src/pages/order/orderList.vue

@@ -27,7 +27,13 @@
         <van-empty description="无数据" v-if="empty" />
 
         <div class="list">
-            <order-card v-for="item in list" :key="item.id" :info="item" :isBack="isBack"></order-card>
+            <order-card
+                v-for="item in list"
+                :key="item.id"
+                :info.sync="item"
+                :isBack="isBack"
+                @paySuccess="onPaySuccess"
+            ></order-card>
         </div>
     </div>
 </template>

+ 1 - 0
src/pages/order/orderListCoupe.vue

@@ -32,6 +32,7 @@
                 :backInfo="item"
                 :isBack="active === 2"
                 :info="active !== 2 ? item : item.carOrder"
+                @paySuccess="onPaySuccess"
             ></order-card>
         </div>
     </div>

+ 24 - 4
src/pages/submit.vue

@@ -184,15 +184,35 @@ export default {
                         { header: { 'Content-Type': 'application/json' } }
                     )
                     .then(res => {
-                        if (res.data.code === 200) {
-                            this.$loading.close();
-                            wx.redirectTo({
-                                url: '/pages/order/orderList'
+                        if (res.code === 200) {
+                            return this.$http.post('/applets/appletsPay', {
+                                orderCode: res.data.orderCode,
+                                orderType: 2
                             });
                         } else {
                             return Promise.reject(this.orderError[res.data.result]);
                         }
                     })
+                    .then(res => {
+                        this.$loading.close();
+                        console.log(res);
+                        let data = JSON.parse(res.data.respStr);
+                        console.log(data);
+                        wx.requestPayment({
+                            ...data.miniPayRequest,
+                            success(res) {
+                                console.log('pay success', res);
+                            },
+                            fail(res) {
+                                console.log('pay fail', res);
+                            },
+                            complete() {
+                                wx.redirectTo({
+                                    url: '/pages/order/orderList'
+                                });
+                            }
+                        });
+                    })
                     .catch(e => {
                         console.log(e);
                         this.$loading.close();

+ 4 - 4
yarn.lock

@@ -3143,10 +3143,10 @@ dashdash@^1.12.0:
   dependencies:
     assert-plus "^1.0.0"
 
-date-fns@^2.15.0:
-  version "2.15.0"
-  resolved "https://registry.npm.taobao.org/date-fns/download/date-fns-2.15.0.tgz?cache=0&sync_timestamp=1594999060129&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdate-fns%2Fdownload%2Fdate-fns-2.15.0.tgz#424de6b3778e4e69d3ff27046ec136af58ae5d5f"
-  integrity sha1-Qk3ms3eOTmnT/ycEbsE2r1iuXV8=
+date-fns@^2.16.1:
+  version "2.16.1"
+  resolved "https://registry.npm.taobao.org/date-fns/download/date-fns-2.16.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdate-fns%2Fdownload%2Fdate-fns-2.16.1.tgz#05775792c3f3331da812af253e1a935851d3834b"
+  integrity sha1-BXdXksPzMx2oEq8lPhqTWFHTg0s=
 
 de-indent@^1.0.2:
   version "1.0.2"