梁沛聪 6 年 前
コミット
0ed45add4c
共有4 個のファイルを変更した92 個の追加11 個の削除を含む
  1. 55
    4
      miniapp/app/pages/goodsDetail/index.js
  2. 7
    4
      miniapp/app/pages/goodsDetail/index.wxml
  3. 4
    0
      miniapp/app/pages/goodsDetail/index.wxss
  4. 26
    3
      miniapp/app/pages/order/index.js

+ 55
- 4
miniapp/app/pages/goodsDetail/index.js ファイルの表示

1
+const WxParse = require('../../wxParse/wxParse.js');
1
 const $ = global;
2
 const $ = global;
2
 
3
 
3
 new $.Page({
4
 new $.Page({
4
     data: {
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
     minusAmount() {
27
     minusAmount() {
9
         if (this.data.amount > 1) {
28
         if (this.data.amount > 1) {
54
             order_id,
73
             order_id,
55
             order_type
74
             order_type
56
         }).then((res) => {
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
+<import src="/wxParse/wxParse.wxml" />
1
 <view class="page">
2
 <view class="page">
2
     <view class="page-hd">
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
         <view class="goods-info">
6
         <view class="goods-info">
5
-            <view class="goods-name">belecoo贝丽可高景观婴儿推车可坐躺折叠双向四轮减震宝宝手推</view>
7
+            <view class="goods-name">{{detail.name}}</view>
6
             <view class="space-bt">
8
             <view class="space-bt">
7
                 <view>快递费:免邮费 广东广州</view>
9
                 <view>快递费:免邮费 广东广州</view>
8
-                <view>总销量120笔</view>
10
+                <view>总销量{{detail.sell_num}}笔</view>
9
             </view>
11
             </view>
10
             <view class="price">
12
             <view class="price">
11
                 <text class="unit">¥</text>{{unitPrice}}</view>
13
                 <text class="unit">¥</text>{{unitPrice}}</view>
19
         <view class="details">
21
         <view class="details">
20
             <view class="details-hd">商品详情</view>
22
             <view class="details-hd">商品详情</view>
21
             <view class="details-bd">
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
             </view>
26
             </view>
24
         </view>
27
         </view>
25
     </view>
28
     </view>

+ 4
- 0
miniapp/app/pages/goodsDetail/index.wxss ファイルの表示

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

+ 26
- 3
miniapp/app/pages/order/index.js ファイルの表示

20
                 res.data.forEach(e => {
20
                 res.data.forEach(e => {
21
                     e.orderText = orderTexts[e.status];
21
                     e.orderText = orderTexts[e.status];
22
                     if (e.order_type == 'product_order') {
22
                     if (e.order_type == 'product_order') {
23
-                        if (e.status == 0) 
23
+                        if (e.status == 0)
24
                             e.orderText = '待付款';
24
                             e.orderText = '待付款';
25
                         goods.push(e);
25
                         goods.push(e);
26
                     } else {
26
                     } else {
47
                 order_id: id,
47
                 order_id: id,
48
                 order_type: type
48
                 order_type: type
49
             }).then((res) => {
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…
キャンセル
保存