zlisen 3 年 前
コミット
04d31cfbe0

+ 1
- 1
config/prod.js ファイルの表示

@@ -3,7 +3,7 @@ module.exports = {
3 3
     NODE_ENV: '"production"'
4 4
   },
5 5
   defineConstants: {
6
-    HOST: '"https://sgl-v2.njyunzhi.com"',
6
+    HOST: '"http://192.168.89.147:8080"',
7 7
   },
8 8
   mini: {},
9 9
   h5: {

+ 0
- 1
package.json ファイルの表示

@@ -36,7 +36,6 @@
36 36
   "author": "",
37 37
   "dependencies": {
38 38
     "@babel/runtime": "^7.7.7",
39
-    "@miniprogram-component-plus/tabs": "^1.0.0",
40 39
     "@tarojs/components": "3.3.2",
41 40
     "@tarojs/react": "3.3.2",
42 41
     "@tarojs/runtime": "3.3.2",

+ 345
- 153
src/components/CompoentsOrder/complete/index.jsx ファイルの表示

@@ -1,166 +1,358 @@
1
-import { useState } from "react";
1
+import react, { useState, useEffect } from "react";
2
+import Taro from "@tarojs/taro";
3
+import { getOrderSub, getQrcode } from "@/services/payOrder";
4
+import formatTime from "@/utils/formatTime";
5
+import image from "@/assets/icons/ProCard/8kb.jpg";
6
+import food from "@/assets/icons/ProCard/food.png";
7
+import ProCard_hot from "@/assets/icons/ProCard/ProCard_hot.png";
2 8
 
3
-import image from '@/assets/icons/ProCard/8kb.jpg'
4
-import food from '@/assets/icons/ProCard/food.png'
5
-import ProCard_hot from '@/assets/icons/ProCard/ProCard_hot.png'
9
+import Evaluation from "@/assets/icons/UserCenter/Evaluation.png";
10
+import Null from "@/assets/icons/UserCenter/null_logo.png";
11
+import QRcode from "@/assets/icons/UserCenter/QRcode.png";
6 12
 
7
-import Evaluation from '@/assets/icons/UserCenter/Evaluation.png'
8
-import Null from '@/assets/icons/UserCenter/null_logo.png'
9
-import QRcode from '@/assets/icons/UserCenter/QRcode.png'
10
-
11
-import Pay from '@/assets/icons/GuideCheck/Pay_logo.png'
12
-import starOn from '@/assets/icons/GuideCheck/starOn.png'
13
-import starOff from '@/assets/icons/GuideCheck/starOff.png'
13
+import Pay from "@/assets/icons/GuideCheck/Pay_logo.png";
14
+import starOn from "@/assets/icons/GuideCheck/starOn.png";
15
+import starOff from "@/assets/icons/GuideCheck/starOff.png";
14 16
 import AlreadyUsed from "../AlreadyUsed";
15
-import './style.less'
16
-
17
+import "./style.less";
17 18
 
18
-const scoreList = new Array(5).fill(0)
19
-const score = '3.9'
19
+const scoreList = new Array(5).fill(0);
20
+const score = "3.9";
20 21
 
22
+const dict = {
23
+  0: { status: 0 },
24
+  1: { status: 1 },
25
+  2: { isVerified: 1 },
26
+  3: { status: 9 },
27
+};
21 28
 export default (props) => {
29
+  const { type } = props;
30
+  const [list, setList] = useState([]);
31
+  const [IsPull, setPull] = useState(false);
32
+  const [pageNum, setNumber] = useState(1);
33
+  const [HasNextPage, setHasNextPage] = useState(true);
34
+
35
+  useEffect(() => {
36
+    getList();
37
+  }, [pageNum]);
38
+
39
+  const pageRefresh = () => {
40
+    // 页面下拉刷新回调
41
+    setPull(true);
42
+  };
43
+
44
+  const getList = () => {
45
+    setHasNextPage(false);
46
+
47
+    // let params = {};
48
+
49
+    // if (type === 1) {
50
+    // }
51
+    getOrderSub({
52
+      pageNum,
53
+      pageSize: 10,
54
+      ...(type !== undefined ? dict[type] : null),
55
+    }).then((res) => {
56
+      setList(
57
+        pageNum === 1 ? res.records || [] : list.concat(res.records || [])
58
+      );
59
+      setHasNextPage(res.current < res.pages);
60
+      setPull(false);
61
+    });
62
+  };
63
+
64
+  const pageLoadMore = () => {
65
+    // 页面上拉加载更多
66
+    if (HasNextPage) {
67
+      setNumber(pageNum + 1);
68
+    }
69
+  };
70
+
71
+  useEffect(() => {
72
+    // 下拉刷新触发
73
+    if (IsPull) {
74
+      if (pageNum === 1) {
75
+        getList();
76
+      } else {
77
+        setNumber(1);
78
+      }
79
+    }
80
+  }, [IsPull]);
81
+
82
+  //核销
83
+  const onWriteOff = (item) => {
84
+    Taro.scanCode({
85
+      onlyFromCamera: true,
86
+      success: (res) => {
87
+        if (res.path) {
88
+          getQrcode(res.result).then((result) => {
89
+            Taro.navigateTo({
90
+              url: `/${result.page}?${result.scene}`,
91
+            });
92
+          });
93
+        } else {
94
+          Taro.showToast({
95
+            title: "非当前小程序生成二维码",
96
+            icon: "none",
97
+            duration: 2000,
98
+          });
99
+        }
100
+      },
101
+      fail: (err) => {
102
+        console.log(err, "err");
103
+      },
104
+    });
105
+  };
106
+
22 107
   return (
23
-    <scroll-view scroll-y style='height: 90vh;'  >
24
-      <view className='complete-boxs' >
25
-        {/* 已使用 */}
26
-        <view className='OrderNumber' >订单编号:ABC123456789</view>
27
-        <view class='wrapper'>
28
-          <view class='left-complete-one'>
29
-            <image className='left-image-1' src={ProCard_hot}></image>
30
-            <view className='left-viewText'>
31
-              返现¥16.00
32
-            </view>
33
-            {/* 评分 */}
34
-            <view className='card-box-star'>
35
-              {
36
-                scoreList.map((_, index) => {
37
-                  console.log(index)
38
-                  const src = (index + '0.1') < score ? starOn : starOff
39
-                  return (
40
-                    <image className='card-star-image' key={index} src={src} />
41
-                  )
42
-                })
43
-              }
44
-              <text className='card-star-text' >{score}</text>
45
-            </view>
46
-            <view className='title-image'>
47
-              <image className='image-1' mode='scaleToFill' src={image}></image>
48
-              <image className='image-2' src={food}></image>
49
-            </view>
50
-            <view className='title-content'>
51
-              <view className='Pro-title'>
52
-                <view className='title-text'>【米啊糯】新街口店 <text className='title-money-2' >数量:1张</text></view>
108
+    <scroll-view
109
+      scroll-y
110
+      style="height: 90vh;"
111
+      refresher-enabled
112
+      refresher-triggered={IsPull}
113
+      onrefresherrefresh={pageRefresh}
114
+      refresher-background="#fff"
115
+      onscrolltolower={pageLoadMore}
116
+    >
117
+      <view className="complete-boxs">
118
+        {list.map((item, index) => {
119
+          /* 待支付 */
120
+          if (item.status === 0) {
121
+            return (
122
+              <view key={`${type}-${item.orderId}`}>
123
+                <view className="OrderNumber">订单编号:{item.orderId}</view>
124
+
125
+                <view class="wrapper">
126
+                  <view class="left-complete-one">
127
+                    <image className="left-image-1" src={ProCard_hot}></image>
128
+                    <view className="left-viewText">
129
+                      返现¥{item.cashback / 100}
130
+                    </view>
131
+                    <view className="title-image">
132
+                      <image
133
+                        className="image-1"
134
+                        mode="scaleToFill"
135
+                        src={item.poster || image}
136
+                      ></image>
137
+                      <image className="image-2" src={food}></image>
138
+                    </view>
139
+                    <view className="title-content">
140
+                      <view className="Pro-title">
141
+                        <view className="title-text">
142
+                          {item.packageDescription}
143
+                          <text className="title-money-2">
144
+                            数量:{item.amount}张
145
+                          </text>
146
+                        </view>
147
+                      </view>
148
+                      <text className="title-money">
149
+                        ¥{item.unitPrice / 100}元
150
+                      </text>
151
+                      <view className="title-time">
152
+                        有效期:{formatTime(item?.startTime, "yyyy/MM/dd")}-
153
+                        {formatTime(item.endTime, "yyyy/MM/dd")}
154
+                      </view>
155
+                    </view>
156
+                  </view>
157
+                  <view class="right-complete-two">
158
+                    <view
159
+                      className="right-content"
160
+                      onClick={() => {
161
+                        Taro.navigateTo({
162
+                          url: `/pages/PayOrder/index?orderId=${item.orderId}`,
163
+                        });
164
+                      }}
165
+                    >
166
+                      <image className="right-image" src={Pay} />
167
+                      <view className="right-title">支付</view>
168
+                    </view>
169
+                  </view>
170
+                </view>
53 171
               </view>
54
-              <text className='title-money' >¥6990元</text>
55
-              <view className='title-time' >核销时间:2021/06/21  12:00</view>
56
-            </view>
57
-          </view>
58
-          <view class='right-complete-two'>
59
-            <view className='right-content'>
60
-              <image className='right-image' src={Evaluation} />
61
-              <view className='right-title'>评价</view>
62
-            </view>
63
-          </view>
64
-        </view>
65
-        {/* 待核销 */}
66
-        <view className='OrderNumber'>订单编号:ABC123456789</view>
67
-        <view class='wrapper'>
68
-          <view class='left-complete-one'>
69
-            <image className='left-image-1' src={ProCard_hot}></image>
70
-            <view className='left-viewText'>
71
-              返现¥16.00
72
-            </view>
73
-            <view className='title-image'>
74
-              <image className='image-1' mode='scaleToFill' src={image}></image>
75
-              <image className='image-2' src={food}></image>
76
-            </view>
77
-            <view className='title-content'>
78
-              <view className='Pro-title'>
79
-                <view className='title-text'>【SEOUL·创意韩国料理】 <text className='title-money-2' >数量:1张</text></view>
172
+            );
173
+          }
174
+          /* 待核销 */
175
+          if (item.status === 1 && item.isVerified == 0) {
176
+            return (
177
+              <view key={`${type}-${item.orderId}`}>
178
+                <view className="OrderNumber">订单编号:{item.orderId}</view>
179
+                <view class="wrapper">
180
+                  <view class="left-complete-one">
181
+                    <image className="left-image-1" src={ProCard_hot}></image>
182
+                    <view className="left-viewText">
183
+                      返现¥{item.cashback / 100}
184
+                    </view>
185
+                    <view className="title-image">
186
+                      <image
187
+                        className="image-1"
188
+                        mode="scaleToFill"
189
+                        src={item.poster || image}
190
+                      ></image>
191
+                      <image className="image-2" src={food}></image>
192
+                    </view>
193
+                    <view className="title-content">
194
+                      <view className="Pro-title">
195
+                        <view className="title-text">
196
+                          {item.packageDescription}
197
+                          <text className="title-money-2">
198
+                            数量:{item.amount}张
199
+                          </text>
200
+                        </view>
201
+                      </view>
202
+                      <text className="title-money">
203
+                        ¥{item.unitPrice / 100}元
204
+                      </text>
205
+                      <view className="title-time">
206
+                        有效期:{formatTime(item?.startTime, "yyyy/MM/dd")}-
207
+                        {formatTime(item.endTime, "yyyy/MM/dd")}
208
+                      </view>
209
+                    </view>
210
+                  </view>
211
+                  <view class="right-complete-two">
212
+                    <view
213
+                      className="right-content"
214
+                      onClick={() => onWriteOff(item)}
215
+                    >
216
+                      <image className="right-image" src={QRcode} />
217
+                      <view className="right-title">扫码核销</view>
218
+                    </view>
219
+                  </view>
220
+                </view>
80 221
               </view>
81
-              <text className='title-money' >¥6990元</text>
82
-              <view className='title-time' >有效期:2021/06/21-2021/12/31</view>
83
-            </view>
84
-          </view>
85
-          <view class='right-complete-two'>
86
-            <view className='right-content'>
87
-              <image className='right-image' src={QRcode} />
88
-              <view className='right-title'>扫码核销</view>
89
-            </view>
90
-          </view>
91
-        </view>
92
-        {/* 待支付 */}
93
-        <view className='OrderNumber'>订单编号:ABC123456789</view>
94
-
95
-        <view class='wrapper'>
96
-          <view class='left-complete-one'>
97
-            <image className='left-image-1' src={ProCard_hot}></image>
98
-            <view className='left-viewText'>
99
-              返现¥16.00
100
-            </view>
101
-            <view className='title-image'>
102
-              <image className='image-1' mode='scaleToFill' src={image}></image>
103
-              <image className='image-2' src={food}></image>
104
-            </view>
105
-            <view className='title-content'>
106
-              <view className='Pro-title'>
107
-                <view className='title-text'>【SEOUL·创意韩国料理】 <text className='title-money-2' >数量:1张</text></view>
222
+            );
223
+          }
224
+          /* 已过期 */
225
+          if (item.status === 9) {
226
+            return (
227
+              <view key={`${type}-${item.orderId}`}>
228
+                <view className="OrderNumber">订单编号:{item.orderId}</view>
229
+                <view class="wrapper">
230
+                  <view class="left-complete-one">
231
+                    <image className="left-image-1" src={ProCard_hot}></image>
232
+                    <view className="left-viewText">
233
+                      返现¥{item.cashback / 100}
234
+                    </view>
235
+                    {/* 评分 */}
236
+                    <view className="card-box-star">
237
+                      {scoreList.map((_, index) => {
238
+                        const src = index + 1 <= item.score ? starOn : starOff;
239
+                        return (
240
+                          <image
241
+                            className="card-star-image"
242
+                            key={index}
243
+                            src={src}
244
+                          />
245
+                        );
246
+                      })}
247
+                      <text className="card-star-text">{item.score}</text>
248
+                    </view>
249
+                    <view className="title-image">
250
+                      <image
251
+                        className="image-1"
252
+                        mode="scaleToFill"
253
+                        src={item.poster || image}
254
+                      ></image>
255
+                      <image className="image-2" src={food}></image>
256
+                    </view>
257
+                    <view className="title-content">
258
+                      <view className="Pro-title">
259
+                        <view className="title-text">
260
+                          {item.packageDescription}
261
+                          <text className="title-money-2">
262
+                            数量:{item.amount}张
263
+                          </text>
264
+                        </view>
265
+                      </view>
266
+                      <text className="title-money">
267
+                        ¥{item.unitPrice / 100}元
268
+                      </text>
269
+                      <view className="title-time">
270
+                        有效期:{formatTime(item?.startTime, "yyyy/MM/dd")}-
271
+                        {formatTime(item.endTime, "yyyy/MM/dd")}
272
+                      </view>
273
+                    </view>
274
+                  </view>
275
+                  <view class="right-complete-two">
276
+                    <view className="right-content">
277
+                      <image className="right-image-2" src={Null} />
278
+                    </view>
279
+                  </view>
280
+                </view>
108 281
               </view>
109
-              <text className='title-money' >¥6990元</text>
110
-              <view className='title-time' >有效期:2021/06/21-2021/12/31</view>
111
-            </view>
112
-          </view>
113
-          <view class='right-complete-two'>
114
-            <view className='right-content'>
115
-              <image className='right-image' src={Pay} />
116
-              <view className='right-title'>支付</view>
117
-            </view>
118
-          </view>
119
-        </view>
120
-        {/* 已过期 */}
121
-        <view className='OrderNumber'>订单编号:ABC123456789</view>
122
-        <view class='wrapper'>
123
-          <view class='left-complete-one'>
124
-            <image className='left-image-1' src={ProCard_hot}></image>
125
-            <view className='left-viewText'>
126
-              返现¥16.00
127
-            </view>
128
-            {/* 评分 */}
129
-            <view className='card-box-star'>
130
-              {
131
-                scoreList.map((_, index) => {
132
-                  console.log(index)
133
-                  const src = (index + '0.1') < score ? starOn : starOff
134
-                  return (
135
-                    <image className='card-star-image' key={index} src={src} />
136
-                  )
137
-                })
138
-              }
139
-              <text className='card-star-text' >{score}</text>
140
-            </view>
141
-            <view className='title-image'>
142
-              <image className='image-1' mode='scaleToFill' src={image}></image>
143
-              <image className='image-2' src={food}></image>
144
-            </view>
145
-            <view className='title-content'>
146
-              <view className='Pro-title'>
147
-                <view className='title-text'>【SEOUL·创意韩国料理】 <text className='title-money-2' >数量:1张</text></view>
282
+            );
283
+          }
284
+          /* 已使用 */
285
+          if (item.isVerified == 1) {
286
+            return (
287
+              <view key={`${type}-${item.orderId}`}>
288
+                <view className="OrderNumber">订单编号:{item.orderId}</view>
289
+                <view class="wrapper">
290
+                  <view class="left-complete-one">
291
+                    <image className="left-image-1" src={ProCard_hot}></image>
292
+                    <view className="left-viewText">
293
+                      返现¥{item.cashback / 100}
294
+                    </view>
295
+                    {/* 评分 */}
296
+                    <view className="card-box-star">
297
+                      {scoreList.map((_, index) => {
298
+                        console.log(index);
299
+                        const src = index + 1 <= item.score ? starOn : starOff;
300
+                        return (
301
+                          <image
302
+                            className="card-star-image"
303
+                            key={index}
304
+                            src={src}
305
+                          />
306
+                        );
307
+                      })}
308
+                      <text className="card-star-text">{item.score}</text>
309
+                    </view>
310
+                    <view className="title-image">
311
+                      <image
312
+                        className="image-1"
313
+                        mode="scaleToFill"
314
+                        src={item.poster || image}
315
+                      ></image>
316
+                      <image className="image-2" src={food}></image>
317
+                    </view>
318
+                    <view className="title-content">
319
+                      <view className="Pro-title">
320
+                        <view className="title-text">
321
+                          {item.packageDescription}
322
+                          <text className="title-money-2">
323
+                            数量:{item.amount}张
324
+                          </text>
325
+                        </view>
326
+                      </view>
327
+                      <text className="title-money">
328
+                        ¥{item.unitPrice / 100}元
329
+                      </text>
330
+                      <view className="title-time">
331
+                        核销时间:{" "}
332
+                        {formatTime(item.verifiedDate, "yyyy/MM/dd hh:mm")}
333
+                      </view>
334
+                    </view>
335
+                  </view>
336
+                  <view class="right-complete-two">
337
+                    <view className="right-content">
338
+                      <image className="right-image" src={Evaluation} />
339
+                      <view className="right-title">评价</view>
340
+                    </view>
341
+                  </view>
342
+                </view>
148 343
               </view>
149
-              <text className='title-money' >¥6990元</text>
150
-              <view className='title-time' >有效期:2021/06/21-2021/12/31</view>
151
-            </view>
152
-          </view>
153
-          <view class='right-complete-two'>
154
-            <view className='right-content'>
155
-              <image className='right-image-2' src={Null} />
156
-            </view>
157
-          </view>
158
-        </view>
159
-        <view className='foot'>
160
-          已经到底了~
161
-        </view>
344
+            );
345
+          }
346
+        })}
347
+
348
+        <view className="foot">已经到底了~</view>
162 349
       </view>
163
-    </scroll-view >
350
+    </scroll-view>
351
+  );
352
+};
353
+
354
+//  {/* 待核销 */}
355
+
356
+//  {/* 待支付 */}
164 357
 
165
-  )
166
-}
358
+//  {/* 已过期 */}

+ 2
- 1
src/components/foodCards/foodCards.jsx ファイルの表示

@@ -1,3 +1,4 @@
1
+import Taro from '@tarojs/taro'
1 2
 import Star from '@/components/Star/Star.jsx'
2 3
 import pay from '@/assets/icons/housemantj/pay.png'
3 4
 import msTip from '@/assets/icons/housemantj/foodtip.png'
@@ -61,7 +62,7 @@ const star=parseFloat(((detail.sweetScore+detail.environmentScore+detail.service
61 62
             </view>
62 63
           </view>
63 64
         </view>
64
-        <view className='fCright'>
65
+        <view className='fCright' onClick={()=>{Taro.navigateTo({ url: `/pages/PayOrder/index?packageId=${item.packageId}` });}}>
65 66
           <image src={pay} />
66 67
           <view>支付</view>
67 68
         </view>

+ 4
- 4
src/pages/MineUserAll/AllOrder/index.jsx ファイルの表示

@@ -96,10 +96,10 @@ export default withLayout((props) => {
96 96
         </mp-tabs>
97 97
       </view>
98 98
       {activeTab === 0 && <Complete />}
99
-      {activeTab === 1 && <TobePaid />}
100
-      {activeTab === 2 && <TobeWritten />}
101
-      {activeTab === 3 && <AlreadyUsed />}
102
-      {activeTab === 4 && <AlreadyExpired />}
99
+      {activeTab === 1 && <Complete type={0} />}
100
+      {activeTab === 2 && <Complete type={1} />}
101
+      {activeTab === 3 && <Complete type={2} />}
102
+      {activeTab === 4 && <Complete type={3} />}
103 103
     </view>
104 104
   )
105 105
 })

+ 249
- 141
src/pages/PayOrder/index.jsx ファイルの表示

@@ -1,183 +1,291 @@
1
-import withLayout from '@/layouts'
2
-import image from '@/assets/icons/ProCard/8kb.jpg'
3
-import { useState, useEffect } from 'react'
4
-import { Button, Radio, Input } from '@tarojs/components'
1
+import withLayout from "@/layouts";
2
+import image from "@/assets/icons/ProCard/8kb.jpg";
3
+import { useState, useEffect } from "react";
4
+import { Button, Checkbox, Input } from "@tarojs/components";
5 5
 
6
-import food from '@/assets/icons/ProCard/food.png'
7
-import ProCard_hot from '@/assets/icons/ProCard/ProCard_hot.png'
8
-import CustomNav from '@/components/CustomNav'
9
-import OrderMolded from '@/components/OrderMolded'
10
-import Popup from '@/components/Popup'
6
+import food from "@/assets/icons/ProCard/food.png";
7
+import ProCard_hot from "@/assets/icons/ProCard/ProCard_hot.png";
8
+import CustomNav from "@/components/CustomNav";
9
+import OrderMolded from "@/components/OrderMolded";
10
+import Popup from "@/components/Popup";
11 11
 
12
-import './style.less'
12
+import "./style.less";
13
+import Taro, { useDidShow } from "@tarojs/taro";
14
+import { getShopPackageDetail } from "@/services/home";
15
+import { saveOrder, getOrderSub, payOrder } from "@/services/payOrder";
16
+import formatTime from "@/utils/formatTime";
13 17
 
14 18
 export default withLayout((props) => {
15
-  const { router, person } = props
19
+  const { router, person } = props;
20
+  const { packageId, orderId } = props.router.params;
16 21
 
17
-  const [showDialog, setShowDialog] = useState(false)
22
+  const [payInfo,setPayInfo] = useState()
18 23
 
19
-  const [BuyNumber, setBuyNumber] = useState(1)
20
-  const [DisabledBool, setDisabledBool] = useState(false)
24
+  const [showDialog, setShowDialog] = useState(false);
25
+  // 是否已阅读协议
26
+  const [agreement, setAgreement] = useState(false);
27
+  // 总价 totalPrice
28
+  const [totalPrice, setTotalPrice] = useState({});
29
+  const [list, setList] = useState([]);
21 30
 
22
-  const ShowMoldeOn = () => {
23
-    setShowDialog(true)
24
-  }
25
-  const ButtonCancel = () => {
26
-    setShowDialog(false)
27
-  }
28
-  const ButtonOK = (e) => {
29
-    setShowDialog(false)
30
-
31
-  }
31
+  const [BuyNumber, setBuyNumber] = useState(1);
32
+  const [detail, setDetail] = useState({});
32 33
 
34
+  const [DisabledBool, setDisabledBool] = useState(false);
33 35
 
36
+  const ShowMoldeOn = (e) => {
37
+    if (packageId) {
38
+      setBuyNumber(e.amount || 1);
39
+      setDetail(e);
40
+      setShowDialog(true);
41
+    }
42
+  };
43
+  const ButtonCancel = () => {
44
+    setShowDialog(false);
45
+  };
46
+  const ButtonOK = (e) => {
47
+    setList(
48
+      list.map((x) =>
49
+        x.packageId == detail.packageId ? { ...x, amount: BuyNumber } : x
50
+      )
51
+    );
52
+    setShowDialog(false);
53
+  };
34 54
 
35 55
   const NumberAdd = () => {
36
-    setBuyNumber(BuyNumber + 1)
56
+    setBuyNumber(BuyNumber + 1);
37 57
     console.log(BuyNumber);
38
-
39
-  }
58
+  };
40 59
 
41 60
   const NumberCut = () => {
42
-    setBuyNumber(BuyNumber - 1)
61
+    if (DisabledBool) return;
62
+    setBuyNumber(BuyNumber - 1);
43 63
     console.log(BuyNumber);
44
-
45
-  }
64
+  };
46 65
 
47 66
   const onInput = (e) => {
48
-    let values = e.detail.value
49
-    setBuyNumber(values - 0)
50
-
67
+    let values = e.detail.value;
68
+    setBuyNumber(values - 0);
69
+  };
51 70
 
71
+  const requestPayment = (params) =>{
72
+    console.log(params,'requestPayment')
73
+    Taro.requestPayment({
74
+      ...params,
75
+      package: params.packageValue,
76
+      success: () => {
77
+        console.log("success");
78
+        setPayInfo()
79
+        Taro.showToast({
80
+          title: "支付成功",
81
+          icon: "none",
82
+          duration: 2000,
83
+        });
84
+      },
85
+      fail: (e) => {
86
+        console.log(e, "fail");
87
+        Taro.showToast({
88
+          title: "支付失败",
89
+          icon: "none",
90
+          duration: 2000,
91
+        });
92
+      },
93
+    });
52 94
   }
53 95
 
96
+  const onShowPay = (e) => {
97
+    if (agreement) {
98
+      if(payInfo){
99
+        requestPayment(payInfo)
100
+        return
101
+      }
102
+      if (packageId) {
103
+        saveOrder(
104
+          list.map((x) => {
105
+            return {
106
+              amount: x.amount || 1,
107
+              itemId: x.packageId,
108
+              price: x.actualPrice,
109
+            };
110
+          })
111
+        ).then((res) => {
112
+          setPayInfo(res)
113
+          requestPayment(res)
114
+        });
115
+      }
116
+      if (orderId) {
117
+        payOrder(orderId).then((res) => {
118
+          setPayInfo(res)
119
+          requestPayment(res)
120
+        });
121
+      }
122
+    } else {
123
+      Taro.showToast({
124
+        title: "请勾选《平台用户服务协议》",
125
+        icon: "none",
126
+        duration: 2000,
127
+      });
128
+    }
129
+  };
130
+
54 131
   useEffect(() => {
55
-    if (BuyNumber < 2) {
56
-      setDisabledBool(true)
132
+    if (packageId) {
133
+      getShopPackageDetail(packageId).then((res) => {
134
+        setList([res]);
135
+      });
136
+    }
137
+    if (orderId) {
138
+      getOrderSub({ pageNum: 1, pageSize: 999, orderId }).then((res) => {
139
+        setList(res.records);
140
+      });
141
+    }
142
+  }, [packageId, orderId]);
57 143
 
144
+  useEffect(() => {
145
+    if (BuyNumber < 2) {
146
+      setDisabledBool(true);
58 147
     } else {
59
-      setDisabledBool(false)
60
-
148
+      setDisabledBool(false);
61 149
     }
62
-  }, [BuyNumber])
150
+  }, [BuyNumber]);
63 151
 
64
-  return (
152
+  useEffect(() => {
153
+    let total = {
154
+      cashback: 0,
155
+      actualPrice: 0,
156
+      standardPrice: 0,
157
+    };
158
+    list.map((x) => {
159
+      total.cashback += x.cashback * (x.amount || 1);
160
+      total.actualPrice += (x.actualPrice || x.unitPrice) * (x.amount || 1);
161
+      total.standardPrice += x.standardPrice * (x.amount || 1);
162
+    });
163
+    setTotalPrice(total);
164
+  }, [list]);
65 165
 
66
-    <view class='container'>
67
-      <CustomNav title='订单' />
166
+  return (
167
+    <view class="container">
168
+      <CustomNav title="订单" />
68 169
       <Popup show={showDialog} maskClosable={false}>
69 170
         <OrderMolded />
70
-        <view className='item-center-Number' >
71
-          <view className='buy-num-minus' disabled={DisabledBool} onClick={NumberCut} >-</view>
72
-          <Input className='buy-num-input' type="number" min="1" onInput={onInput} value={BuyNumber} />
73
-          <view className='buy-num-add' onClick={NumberAdd} >+</view>
74
-        </view>
75
-        <view className='buy-button-box' >
76
-          <button className='button-Cancel' onClick={ButtonCancel} >取消</button>
77
-          <button className='button-OK' onClick={ButtonOK} >确定</button>
78
-        </view>
79
-      </Popup>
80
-      <view class='coupon-list'>
81
-        <view class='wrapper'>
82
-          <view class='left-complete-one'>
83
-            <image className='left-image-1' src={ProCard_hot}></image>
84
-            <view className='left-viewText'>
85
-              返现¥16.00
86
-            </view>
87
-            <view className='title-image'>
88
-              <image className='image-1' mode='scaleToFill' src={image}></image>
89
-              <image className='image-2' src={food}></image>
90
-            </view>
91
-            <view className='title-content'>
92
-              <view className='Pro-title'>
93
-                <view className='title-text'>【橘里橘气咖啡店】新鲜出炉啦!</view>
94
-              </view>
95
-              <text className='title-money' >¥6990元<text className='title-money-2'>门市价78元</text></text>
96
-              <view className='title-time' >有效期:2021/06/21-2021/12/31</view>
97
-            </view>
171
+        <view className="item-center-Number">
172
+          <view
173
+            className="buy-num-minus"
174
+            disabled={DisabledBool}
175
+            onClick={NumberCut}
176
+          >
177
+            -
98 178
           </view>
99
-          <view class='right-complete-two' onClick={ShowMoldeOn} >
100
-            <view className='right-content'>
101
-              <view className='right-number'>×{BuyNumber}</view>
102
-              <view className='right-title'>数量</view>
103
-            </view>
179
+          <Input
180
+            className="buy-num-input"
181
+            type="number"
182
+            min="1"
183
+            onInput={onInput}
184
+            value={BuyNumber}
185
+          />
186
+          <view className="buy-num-add" onClick={NumberAdd}>
187
+            +
104 188
           </view>
105 189
         </view>
106
-        <view class='wrapper'>
107
-          <view class='left-complete-one'>
108
-            <image className='left-image-1' src={ProCard_hot}></image>
109
-            <view className='left-viewText'>
110
-              返现¥16.00
111
-            </view>
112
-            <view className='title-image'>
113
-              <image className='image-1' mode='scaleToFill' src={image}></image>
114
-              <image className='image-2' src={food}></image>
115
-            </view>
116
-            <view className='title-content'>
117
-              <view className='Pro-title'>
118
-                <view className='title-text'>【橘里橘气咖啡店】新鲜出炉啦!</view>
119
-              </view>
120
-              <text className='title-money' >¥6990元<text className='title-money-2'>门市价78元</text></text>
121
-              <view className='title-time' >有效期:2021/06/21-2021/12/31</view>
122
-            </view>
123
-          </view>
124
-          <view class='right-complete-two'>
125
-            <view className='right-content'>
126
-              <view className='right-number'>×1</view>
127
-              <view className='right-title'>数量</view>
128
-            </view>
129
-          </view>
190
+        <view className="buy-button-box">
191
+          <button className="button-Cancel" onClick={ButtonCancel}>
192
+            取消
193
+          </button>
194
+          <button className="button-OK" onClick={ButtonOK}>
195
+            确定
196
+          </button>
130 197
         </view>
131
-
132
-        <view class='wrapper'>
133
-          <view class='left-complete-one'>
134
-            <image className='left-image-1' src={ProCard_hot}></image>
135
-            <view className='left-viewText'>
136
-              返现¥16.00
137
-            </view>
138
-            <view className='title-image'>
139
-              <image className='image-1' mode='scaleToFill' src={image}></image>
140
-              <image className='image-2' src={food}></image>
141
-            </view>
142
-            <view className='title-content'>
143
-              <view className='Pro-title'>
144
-                <view className='title-text'>【橘里橘气咖啡店】新鲜出炉啦!</view>
198
+      </Popup>
199
+      <view class="coupon-list">
200
+        {list?.map((item) => {
201
+          return (
202
+            <view class="wrapper">
203
+              <view class="left-complete-one">
204
+                <image className="left-image-1" src={ProCard_hot}></image>
205
+                <view className="left-viewText">
206
+                  返现¥{(item.cashback || 0) / 100}
207
+                </view>
208
+                <view className="title-image">
209
+                  <image
210
+                    className="image-1"
211
+                    mode="scaleToFill"
212
+                    src={item.poster}
213
+                  ></image>
214
+                  <image className="image-2" src={food}></image>
215
+                </view>
216
+                <view className="title-content">
217
+                  <view className="Pro-title">
218
+                    <view className="title-text">{item.description}</view>
219
+                  </view>
220
+                  <text className="title-money">
221
+                    ¥{(item.actualPrice || item.unitPrice || 0) / 100}元
222
+                    <text className="title-money-2">
223
+                      门市价{(item.standardPrice || 0) / 100}元
224
+                    </text>
225
+                  </text>
226
+                  <view className="title-time">
227
+                    有效期:{formatTime(item.startTime, "yyyy/MM/dd")}-
228
+                    {formatTime(item.endTime, "yyyy/MM/dd")}
229
+                  </view>
230
+                </view>
231
+              </view>
232
+              <view
233
+                class="right-complete-two"
234
+                onClick={() => ShowMoldeOn(item)}
235
+              >
236
+                <view className="right-content">
237
+                  <view className="right-number">×{item.amount || 1}</view>
238
+                  <view className="right-title">数量</view>
239
+                </view>
145 240
               </view>
146
-              <text className='title-money' >¥6990元<text className='title-money-2'>门市价78元</text></text>
147
-              <view className='title-time' >有效期:2021/06/21-2021/12/31</view>
148
-            </view>
149
-          </view>
150
-          <view class='right-complete-two'>
151
-            <view className='right-content'>
152
-              <view className='right-number'>×1</view>
153
-              <view className='right-title'>数量</view>
154 241
             </view>
155
-          </view>
156
-        </view>
157
-
242
+          );
243
+        })}
158 244
       </view>
159
-      <view className='view-button'>
160
-        <view className='Card-number-box'>
161
-          <view className='Card-number'>
162
-            <text style='left:29px;position: absolute; padding-top:20px'>手机号码:</text>
163
-            <text style='right:29px;position: absolute;padding-top:20px'>16161312125</text>
245
+      <view className="view-button">
246
+        <view className="Card-number-box">
247
+          <view className="Card-number">
248
+            <text style="left:29px;position: absolute; padding-top:20px">
249
+              手机号码:
250
+            </text>
251
+            <text style="right:29px;position: absolute;padding-top:20px">
252
+              {person.phone}
253
+            </text>
164 254
           </view>
165
-          <view className='Card-user'>
166
-            <Radio style='padding-left:20px; position: relative; top:24px;' value='我已阅读知晓并同意' >我已阅读知晓并同意 <text style='color:#274190;text-decoration:underline;font-weight:400'>《平台用户服务协议》</text></Radio>
255
+          <view className="Card-user">
256
+            <Checkbox
257
+              style="padding-left:20px; position: relative; top:24px;"
258
+              value="agreement"
259
+              checked={agreement}
260
+              onClick={() => {
261
+                setAgreement(!agreement);
262
+              }}
263
+            >
264
+              我已阅读知晓并同意
265
+              <text style="color:#274190;text-decoration:underline;font-weight:400">
266
+                《平台用户服务协议》
267
+              </text>
268
+            </Checkbox>
167 269
           </view>
168 270
         </view>
169
-        <view className='button-box-button-box'>
170
-          <view className='button-text-image' >
171
-            <text className='button-text-money-hot'>返现¥2.18</text>
172
-            <image className='button-image' src={ProCard_hot}>123123</image>
173
-            <view className='button-text-money'>门店市面价:230元</view>
271
+        <view className="button-box-button-box">
272
+          <view className="button-text-image">
273
+            <text className="button-text-money-hot">
274
+              返现¥{(totalPrice?.cashback || 0) / 100}
275
+            </text>
276
+            <image className="button-image" src={ProCard_hot}>
277
+              123123
278
+            </image>
279
+            <view className="button-text-money">
280
+              门店市面价:{(totalPrice?.standardPrice || 0) / 100}元
281
+            </view>
174 282
           </view>
175
-          <Button className='button-box-one'>¥170元 <text className='button-text-one'>支付订单</text> </Button>
283
+          <Button className="button-box-one" onClick={() => onShowPay()}>
284
+            ¥{(totalPrice?.actualPrice || 0) / 100}元
285
+            <text className="button-text-one">支付订单</text>
286
+          </Button>
176 287
         </view>
177
-
178 288
       </view>
179 289
     </view>
180
-
181
-
182
-  )
183
-})
290
+  );
291
+});

+ 1
- 1
src/services/home.js ファイルの表示

@@ -58,7 +58,7 @@ export const getIndexType = (params) => request('/tdType', { params })
58 58
  * @param {*} id 
59 59
  * @returns 
60 60
  */
61
- export const getShopPackageDetail = (id) => request(`/taShopPackage/${id}`)
61
+ export const getShopPackageDetail = (id) => request(`/package/${id}`)
62 62
  
63 63
  /**
64 64
  * 获取套餐定位

+ 30
- 1
src/services/payOrder.js ファイルの表示

@@ -1,4 +1,33 @@
1 1
 //支付订单模块
2 2
 import request from '@/utils/request'
3 3
 //套餐订单列表用哪个接口
4
-//订单详情,订单修改数量
4
+//订单详情,订单修改数量
5
+
6
+  /**
7
+ * 生成订单
8
+ * @param {*} data 
9
+ * @returns 
10
+ */
11
+   export const saveOrder = (data) => request('/order', { method: 'post', data })
12
+
13
+   /**
14
+ * 获取子订单列表
15
+ * @param {*} data
16
+ * @returns 
17
+ */
18
+ export const getOrderSub = (data) => request('/orderSub', { data })
19
+
20
+   /**
21
+ * 订单项目发起支付
22
+ * @param {*} id 
23
+ * @returns 
24
+ */
25
+    export const payOrder = (id) => request(`/order/${id}/pay`, { method: 'post' })
26
+
27
+   /**
28
+ * 获取子订单列表
29
+ * @param {*} id
30
+ * @returns 
31
+ */
32
+    export const getQrcode = (id) => request(`/qrcode/${id}`)
33
+    

+ 16
- 0
src/utils/formatTime.js ファイルの表示

@@ -0,0 +1,16 @@
1
+export default function formatTimes(date, fmt) {
2
+  var date = new Date(date);
3
+  var o = {
4
+    "M+": date.getMonth() + 1, //月份
5
+    "d+": date.getDate(), //日
6
+    "h+": date.getHours(), //小时
7
+    "m+": date.getMinutes(), //分
8
+    "s+": date.getSeconds(), //秒
9
+    "q+": Math.floor((date.getMonth() + 3) / 3), //季度
10
+    "S": date.getMilliseconds() //毫秒
11
+  };
12
+  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
13
+  for (var k in o)
14
+    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
15
+  return fmt;
16
+};