瀏覽代碼

代码更新

梁沛聪 6 年之前
父節點
當前提交
0ed45add4c

+ 55
- 4
miniapp/app/pages/goodsDetail/index.js 查看文件

@@ -1,9 +1,28 @@
1
+const WxParse = require('../../wxParse/wxParse.js');
1 2
 const $ = global;
2 3
 
3 4
 new $.Page({
4 5
     data: {
5
-        amount: 1,
6
-        unitPrice: 599
6
+        amount: 1
7
+    },
8
+    onLoad(options) {
9
+        const id = options.id;
10
+        if (id) {
11
+            $.wx.showToast({
12
+                title: '加载中'
13
+            }, 'loading');
14
+            $.request(`product/${id}`, 'GET', {}).then((res) => {
15
+                if (res.data) {
16
+                    $.wx.hideToast('loading');
17
+                    const article = res.data.info;
18
+                    this.setData({
19
+                        detail: res.data,
20
+                        unitPrice: res.data.price
21
+                    });
22
+                    WxParse.wxParse('article', 'html', article, this, 5)
23
+                }
24
+            });
25
+        }
7 26
     },
8 27
     minusAmount() {
9 28
         if (this.data.amount > 1) {
@@ -54,8 +73,40 @@ new $.Page({
54 73
             order_id,
55 74
             order_type
56 75
         }).then((res) => {
57
-            $.wx.hideToast('loading');
58
-
76
+            if (res.msg) {
77
+                const {
78
+                    timestamp,
79
+                    sign,
80
+                    noncestr
81
+                } = res.msg;
82
+                const pck = res.msg.package;
83
+                wx.requestPayment({
84
+                    timeStamp: timestamp + '',
85
+                    nonceStr: noncestr,
86
+                    package: pck,
87
+                    signType: 'MD5',
88
+                    paySign: sign,
89
+                    success(res) {
90
+                        console.log('支付成功', res);
91
+                        $.wx.showToast({
92
+                            title: '支付成功'
93
+                        });
94
+                    },
95
+                    fail() {
96
+                        $.wx.showToast({
97
+                            title: '支付失败'
98
+                        });
99
+                    },
100
+                    complete() {
101
+                        setTimeout(function () {
102
+                            $.router.goto({
103
+                                path: '/pages/order/index',
104
+                                type: $.ROUTER_TYPE.CLOSE_CURRENT
105
+                            })
106
+                        }, 2000);
107
+                    }
108
+                });
109
+            }
59 110
         });
60 111
     }
61 112
 });

+ 7
- 4
miniapp/app/pages/goodsDetail/index.wxml 查看文件

@@ -1,11 +1,13 @@
1
+<import src="/wxParse/wxParse.wxml" />
1 2
 <view class="page">
2 3
     <view class="page-hd">
3
-        <image class="goods-img" mode="widthFix" src="/img/demo/goods.png"></image>
4
+        <!-- <image class="goods-img" mode="widthFix" src="/img/demo/goods.png"></image> -->
5
+        <image class="goods-img" mode="widthFix" src="{{detail.photo}}"></image>
4 6
         <view class="goods-info">
5
-            <view class="goods-name">belecoo贝丽可高景观婴儿推车可坐躺折叠双向四轮减震宝宝手推</view>
7
+            <view class="goods-name">{{detail.name}}</view>
6 8
             <view class="space-bt">
7 9
                 <view>快递费:免邮费 广东广州</view>
8
-                <view>总销量120笔</view>
10
+                <view>总销量{{detail.sell_num}}笔</view>
9 11
             </view>
10 12
             <view class="price">
11 13
                 <text class="unit">¥</text>{{unitPrice}}</view>
@@ -19,7 +21,8 @@
19 21
         <view class="details">
20 22
             <view class="details-hd">商品详情</view>
21 23
             <view class="details-bd">
22
-                <image class="g" mode="widthFix" src="/img/demo/goods-detail.png" style="width: 100%;display: block;"></image>
24
+                <!-- <image class="g" mode="widthFix" src="/img/demo/goods-detail.png" style="width: 100%;display: block;"></image> -->
25
+                <template is="wxParse" data="{{wxParseData:article.nodes}}" />
23 26
             </view>
24 27
         </view>
25 28
     </view>

+ 4
- 0
miniapp/app/pages/goodsDetail/index.wxss 查看文件

@@ -66,4 +66,8 @@
66 66
 
67 67
 .booking {
68 68
     margin-top: 20rpx;
69
+}
70
+
71
+.page-hd {
72
+    font-size: 0;
69 73
 }

+ 26
- 3
miniapp/app/pages/order/index.js 查看文件

@@ -20,7 +20,7 @@ new $.Page({
20 20
                 res.data.forEach(e => {
21 21
                     e.orderText = orderTexts[e.status];
22 22
                     if (e.order_type == 'product_order') {
23
-                        if (e.status == 0) 
23
+                        if (e.status == 0)
24 24
                             e.orderText = '待付款';
25 25
                         goods.push(e);
26 26
                     } else {
@@ -47,8 +47,31 @@ new $.Page({
47 47
                 order_id: id,
48 48
                 order_type: type
49 49
             }).then((res) => {
50
-                $.wx.hideToast('loading');
51
-    
50
+                if (res.msg) {
51
+                    const {
52
+                        timestamp,
53
+                        sign,
54
+                        noncestr
55
+                    } = res.msg;
56
+                    const pck = res.msg.package;
57
+                    wx.requestPayment({
58
+                        timeStamp: timestamp + '',
59
+                        nonceStr: noncestr,
60
+                        package: pck,
61
+                        signType: 'MD5',
62
+                        paySign: sign,
63
+                        success(res) {
64
+                            console.log('支付成功', res);
65
+                            $.wx.hideToast('loading');
66
+
67
+                        },
68
+                        fail() {
69
+                            $.wx.showToast({
70
+                                title: '支付失败'
71
+                            });
72
+                        }
73
+                    });
74
+                }
52 75
             });
53 76
         }
54 77
     },

Loading…
取消
儲存