张延森 3 years ago
parent
commit
1474e8c44c

+ 2
- 1
src/components/CompoentsOrder/AlreadyUsed/index.jsx View File

15
 
15
 
16
 
16
 
17
 export default (props) => {
17
 export default (props) => {
18
-  const { showCutover, maskClosable, item, onClose } = props
18
+  const { showCutover, maskClosable, item, onClose, onFinish } = props
19
   const scoreList = new Array(5).fill(0)
19
   const scoreList = new Array(5).fill(0)
20
 
20
 
21
   const ButtonCancel = () => {
21
   const ButtonCancel = () => {
32
     else {
32
     else {
33
       saveEvaluate(evaluate.targetType, evaluate.targetId, evaluate).then((res) => {
33
       saveEvaluate(evaluate.targetType, evaluate.targetId, evaluate).then((res) => {
34
         console.log(res)
34
         console.log(res)
35
+        onFinish()
35
       })
36
       })
36
       onClose()
37
       onClose()
37
     }
38
     }

+ 0
- 2
src/components/CompoentsOrder/OrderCard/index.jsx View File

28
     }
28
     }
29
   }
29
   }
30
 
30
 
31
-
32
-
33
   //核销
31
   //核销
34
   const onWriteOff = (item) => {
32
   const onWriteOff = (item) => {
35
     Taro.scanCode({
33
     Taro.scanCode({

+ 24
- 38
src/components/CompoentsOrder/complete/index.jsx View File

1
 import React, { useState, useEffect } from "react";
1
 import React, { useState, useEffect } from "react";
2
 import Taro, { useDidShow, AtSwipeAction } from "@tarojs/taro";
2
 import Taro, { useDidShow, AtSwipeAction } from "@tarojs/taro";
3
 import { getOrderSub, deleteOrder } from "@/services/payOrder";
3
 import { getOrderSub, deleteOrder } from "@/services/payOrder";
4
+import { View } from "@tarojs/components";
4
 import NoData from '@/components/NoData'
5
 import NoData from '@/components/NoData'
5
 import SpinBox from "@/components/Spin/SpinBox";
6
 import SpinBox from "@/components/Spin/SpinBox";
6
 
7
 
8
 import AlreadyUsed from "../AlreadyUsed";
9
 import AlreadyUsed from "../AlreadyUsed";
9
 import OrderCard from '../OrderCard'
10
 import OrderCard from '../OrderCard'
10
 import "./style.less";
11
 import "./style.less";
11
-import { View } from "@tarojs/components";
12
-
13
-
14
 
12
 
15
 const dict = {
13
 const dict = {
16
   0: { status: 0, isVerified: 0 },
14
   0: { status: 0, isVerified: 0 },
22
   const { type } = props;
20
   const { type } = props;
23
   const [list, setList] = useState([]);
21
   const [list, setList] = useState([]);
24
   const [IsPull, setPull] = useState(false);
22
   const [IsPull, setPull] = useState(false);
25
-  const [pageNum, setNumber] = useState(1);
23
+  const [pageNum, setNumber] = useState({ pageNum: 1 });
26
   const [HasNextPage, setHasNextPage] = useState(true);
24
   const [HasNextPage, setHasNextPage] = useState(true);
27
   const [loading, setLoading] = useState(false)
25
   const [loading, setLoading] = useState(false)
28
 
26
 
29
   useDidShow(() => {
27
   useDidShow(() => {
30
-    setNumber(1)
28
+    setNumber({ pageNum: 1 })
31
   })
29
   })
32
 
30
 
33
   useEffect(() => {
31
   useEffect(() => {
34
     if (pageNum) {
32
     if (pageNum) {
35
       getList();
33
       getList();
36
     }
34
     }
37
-
38
   }, [pageNum]);
35
   }, [pageNum]);
39
 
36
 
40
-
41
-
42
   const getList = () => {
37
   const getList = () => {
43
     setLoading(true)
38
     setLoading(true)
44
     setHasNextPage(false);
39
     setHasNextPage(false);
45
     getOrderSub({
40
     getOrderSub({
46
-      pageNum,
41
+      ...pageNum,
47
       pageSize: 10,
42
       pageSize: 10,
48
       isVerified: '',
43
       isVerified: '',
49
       ...(type !== undefined ? dict[type] : null),
44
       ...(type !== undefined ? dict[type] : null),
63
   const pageLoadMore = () => {
58
   const pageLoadMore = () => {
64
     // 页面上拉加载更多
59
     // 页面上拉加载更多
65
     if (HasNextPage) {
60
     if (HasNextPage) {
66
-      setNumber(pageNum + 1);
61
+      const num = pageNum.pageNum + 1
62
+      setNumber({ pageNum: num });
67
     }
63
     }
68
   };
64
   };
69
 
65
 
76
   useEffect(() => {
72
   useEffect(() => {
77
     // 下拉刷新触发
73
     // 下拉刷新触发
78
     if (IsPull) {
74
     if (IsPull) {
79
-      if (pageNum === 1) {
75
+      if (pageNum.pageNum === 1) {
80
         getList();
76
         getList();
81
       } else {
77
       } else {
82
         setNumber(1);
78
         setNumber(1);
98
     })
94
     })
99
   }
95
   }
100
 
96
 
101
-  const button = [{
102
-    extClass: 'test-button',
103
-    src: ico_delete
104
-  }]
97
+  const handleFinishEvaluate = () => {
98
+    // 触发页面刷新
99
+    setNumber({ pageNum: 1 })
100
+    setShowCutover(false)
101
+  }
105
 
102
 
106
   return (
103
   return (
107
-    <View style={{ height: 'calc(100% - 46px)' }}>
104
+    <SpinBox loading={loading} style={{ height: 'calc(100% - 46px)' }}>
108
       <scroll-view
105
       <scroll-view
109
         scrollY
106
         scrollY
110
         style={{ height: '100%' }}
107
         style={{ height: '100%' }}
114
           list.length == 0 ?
111
           list.length == 0 ?
115
             <NoData /> :
112
             <NoData /> :
116
             <view className='complete-boxs'>
113
             <view className='complete-boxs'>
117
-              <AlreadyUsed showCutover={showCutover} maskClosable={showCutover} onClose={onClose} item={ite} />
114
+              <AlreadyUsed showCutover={showCutover} maskClosable={showCutover} onClose={onClose} onFinish={handleFinishEvaluate} item={ite} />
118
               {list.map((item, index) => {
115
               {list.map((item, index) => {
119
                 /* 待支付 */
116
                 /* 待支付 */
120
                 if (item.status === 0) {
117
                 if (item.status === 0) {
121
                   return (
118
                   return (
122
-                    <SpinBox loading={loading} className='index-container' >
123
-
124
-                      <view key={`${type}-${item.orderId}`}  >
125
-                        <OrderCard item={item} handeDelete={slideButtonTap} />
126
-                      </view>
127
-                    </SpinBox>
119
+                    <view key={`${type}-${item.orderId}`}  >
120
+                      <OrderCard item={item} handeDelete={slideButtonTap} />
121
+                    </view>
128
                   );
122
                   );
129
                 }
123
                 }
130
                 /* 已使用 */
124
                 /* 已使用 */
131
                 else if (item.isVerified == 1) {
125
                 else if (item.isVerified == 1) {
132
                   return (
126
                   return (
133
-                    <SpinBox loading={loading} className='index-container' >
134
-
135
-                      <view key={`${type}-${item.orderId}`}>
136
-                        <OrderCard item={item} setShowCutover={setShowCutover} show={show} />
137
-                      </view>
138
-                    </SpinBox>
139
-
127
+                    <view key={`${type}-${item.orderId}`}>
128
+                      <OrderCard item={item} setShowCutover={setShowCutover} show={show} />
129
+                    </view>
140
                   );
130
                   );
141
                 }
131
                 }
142
                 /* 待核销 */
132
                 /* 待核销 */
143
                 else {
133
                 else {
144
                   return (
134
                   return (
145
-                    <SpinBox loading={loading} className='index-container' >
146
-
147
-                      <view key={`${type}-${item.orderId}`}>
148
-                        <OrderCard item={item} />
149
-                      </view>
150
-                    </SpinBox>
151
-
135
+                    <view key={`${type}-${item.orderId}`}>
136
+                      <OrderCard item={item} />
137
+                    </view>
152
                   );
138
                   );
153
                 }
139
                 }
154
               })}
140
               })}
156
             </view>
142
             </view>
157
         }
143
         }
158
       </scroll-view>
144
       </scroll-view>
159
-    </View>
145
+    </SpinBox>
160
   )
146
   )
161
 };
147
 };

+ 8
- 2
src/pages/PayOrder/index.jsx View File

1
+import { useState, useEffect } from "react";
1
 import withLayout from "@/layouts";
2
 import withLayout from "@/layouts";
2
 import Taro, { useDidShow } from "@tarojs/taro";
3
 import Taro, { useDidShow } from "@tarojs/taro";
3
 import { getPackageDetail } from "@/services/home";
4
 import { getPackageDetail } from "@/services/home";
4
 import { saveOrder, getOrderSub, payOrder } from "@/services/payOrder";
5
 import { saveOrder, getOrderSub, payOrder } from "@/services/payOrder";
5
-import { useState, useEffect } from "react";
6
 import formatPrice from "@/utils/formatPrice";
6
 import formatPrice from "@/utils/formatPrice";
7
+import usePrevious from "@/utils/hooks/usePrevious";
7
 import { Button, Radio, View } from "@tarojs/components";
8
 import { Button, Radio, View } from "@tarojs/components";
8
 import InputNumber from "@/components/InputNumber";
9
 import InputNumber from "@/components/InputNumber";
9
 import AuthPage from '@/components/AuthPage'
10
 import AuthPage from '@/components/AuthPage'
26
   const [BuyNumber, setBuyNumber] = useState(1);
27
   const [BuyNumber, setBuyNumber] = useState(1);
27
   const [detail, setDetail] = useState({});
28
   const [detail, setDetail] = useState({});
28
   const [showDialog, setShowDialog] = useState(false);
29
   const [showDialog, setShowDialog] = useState(false);
30
+  // 监控金额变化
31
+  const preActPrice = usePrevious(totalPrice?.actualPrice || 0)
29
 
32
 
30
   const ShowMoldeOn = (e) => {
33
   const ShowMoldeOn = (e) => {
31
     if (packageId) {
34
     if (packageId) {
84
 
87
 
85
   const onShowPay = (e) => {
88
   const onShowPay = (e) => {
86
     if (agreement) {
89
     if (agreement) {
87
-      if (payInfo) {
90
+      const actPrice = totalPrice?.actualPrice || 0
91
+      const isOrderChanged = actPrice !== preActPrice
92
+
93
+      if (payInfo && !isOrderChanged) {
88
         requestPayment(payInfo);
94
         requestPayment(payInfo);
89
         return;
95
         return;
90
       }
96
       }

+ 1
- 1
src/pages/search/search.jsx View File

29
                 <CustomNav title='搜索' />
29
                 <CustomNav title='搜索' />
30
             </view>
30
             </view>
31
 
31
 
32
-            <SearchBar placeholder='请输入景区/城市搜索' onBlur={onSearch} />
32
+            <SearchBar placeholder='搜索景点/店铺' onBlur={onSearch} />
33
 
33
 
34
             <view className='content'>
34
             <view className='content'>
35
                 <view className='hotSearch'>热门搜索</view>
35
                 <view className='hotSearch'>热门搜索</view>

+ 1
- 1
src/pages/searchResult/searchResult.jsx View File

70
       </view>
70
       </view>
71
       <view className='index-container'>
71
       <view className='index-container'>
72
         <view className='search'>
72
         <view className='search'>
73
-          <input className='searchInput' placeholder='请输入景区/城市搜索' disabled onClick={onSearch} />
73
+          <input className='searchInput' placeholder='搜索景点/店铺' disabled onClick={onSearch} />
74
           <image className='searchicon' src={iconsearch} />
74
           <image className='searchicon' src={iconsearch} />
75
           <view className='lineSearch'></view>
75
           <view className='lineSearch'></view>
76
         </view><view className='index-tabs'>
76
         </view><view className='index-tabs'>

+ 14
- 2
src/utils/formatTime.js View File

1
-export default function formatTimes(date, fmt) {
2
-  var date = new Date(date);
1
+
2
+function getDateByStr(dtStr) {
3
+  if (!dtStr) return undefined;
4
+
5
+  const t = dtStr.split(/[-T :]/);
6
+  return new Date(t[0], t[1]-1, t[2], t[3] || 0, t[4] || 0, t[5] || 0)
7
+}
8
+
9
+export default function formatTimes(dt, fmt) {
10
+  if (!dt) return dt;
11
+
12
+  // 解决苹果手机不能正常初始化的问题
13
+  const date = typeof dt === 'string' ? getDateByStr(dt) : new Date(dt);
14
+
3
   var o = {
15
   var o = {
4
     "M+": date.getMonth() + 1, //月份
16
     "M+": date.getMonth() + 1, //月份
5
     "d+": date.getDate(), //日
17
     "d+": date.getDate(), //日

+ 9
- 0
src/utils/hooks/usePrevious.js View File

1
+import { useEffect, useRef } from "react";
2
+
3
+export default function usePrevious(value) {
4
+  const ref = useRef();
5
+  useEffect(() => {
6
+    ref.current = value;
7
+  });
8
+  return ref.current;
9
+}