zlisen 3 years ago
parent
commit
08a20a58da

+ 3
- 9
src/components/CompoentsOrder/complete/index.jsx View File

43
 
43
 
44
   const getList = () => {
44
   const getList = () => {
45
     setHasNextPage(false);
45
     setHasNextPage(false);
46
-
47
-    // let params = {};
48
-
49
-    // if (type === 1) {
50
-    // }
51
     getOrderSub({
46
     getOrderSub({
52
       pageNum,
47
       pageNum,
53
       pageSize: 10,
48
       pageSize: 10,
84
     Taro.scanCode({
79
     Taro.scanCode({
85
       onlyFromCamera: true,
80
       onlyFromCamera: true,
86
       success: (res) => {
81
       success: (res) => {
82
+        console.log(res,'-------------')
87
         if (res.path) {
83
         if (res.path) {
88
-          getQrcode(res.result).then((result) => {
89
-            Taro.navigateTo({
90
-              url: `/${result.page}?${result.scene}`,
91
-            });
84
+          Taro.navigateTo({
85
+            url: `/${res.path}&validPackage=${item.packageId}`,
92
           });
86
           });
93
         } else {
87
         } else {
94
           Taro.showToast({
88
           Taro.showToast({

+ 34
- 13
src/pages/PayOrder/index.jsx View File

9
 import Popup from "@/components/Popup";
9
 import Popup from "@/components/Popup";
10
 import "./style.less";
10
 import "./style.less";
11
 import Taro, { useDidShow } from "@tarojs/taro";
11
 import Taro, { useDidShow } from "@tarojs/taro";
12
-import { getShopPackageDetail } from "@/services/home";
12
+import { getPackageDetail } from "@/services/home";
13
 import { saveOrder, getOrderSub, payOrder } from "@/services/payOrder";
13
 import { saveOrder, getOrderSub, payOrder } from "@/services/payOrder";
14
 import formatTime from "@/utils/formatTime";
14
 import formatTime from "@/utils/formatTime";
15
 
15
 
17
   const { router, person } = props;
17
   const { router, person } = props;
18
   const { packageId, orderId } = props.router.params;
18
   const { packageId, orderId } = props.router.params;
19
 
19
 
20
-  const [payInfo, setPayInfo] = useState()
20
+  const [payInfo, setPayInfo] = useState();
21
 
21
 
22
   const [showDialog, setShowDialog] = useState(false);
22
   const [showDialog, setShowDialog] = useState(false);
23
   // 是否已阅读协议
23
   // 是否已阅读协议
67
   };
67
   };
68
 
68
 
69
   const requestPayment = (params) => {
69
   const requestPayment = (params) => {
70
-    console.log(params, 'requestPayment')
70
+    console.log(params, "requestPayment");
71
+    Taro.hideLoading()
71
     Taro.requestPayment({
72
     Taro.requestPayment({
72
       ...params,
73
       ...params,
73
       package: params.packageValue,
74
       package: params.packageValue,
74
       success: () => {
75
       success: () => {
75
-        console.log("success");
76
-        setPayInfo()
76
+        setPayInfo();
77
+        Taro.redirectTo({
78
+          url: "/pages/MineUserAll/AllOrder/index",
79
+        });
77
         Taro.showToast({
80
         Taro.showToast({
78
           title: "支付成功",
81
           title: "支付成功",
79
           icon: "none",
82
           icon: "none",
89
         });
92
         });
90
       },
93
       },
91
     });
94
     });
92
-  }
95
+  };
93
 
96
 
94
   const onShowPay = (e) => {
97
   const onShowPay = (e) => {
95
     if (agreement) {
98
     if (agreement) {
96
       if (payInfo) {
99
       if (payInfo) {
97
-        requestPayment(payInfo)
98
-        return
100
+        requestPayment(payInfo);
101
+        return;
99
       }
102
       }
103
+      Taro.showLoading({
104
+        title: '支付中',
105
+      })
106
+
100
       if (packageId) {
107
       if (packageId) {
101
         saveOrder(
108
         saveOrder(
102
           list.map((x) => {
109
           list.map((x) => {
107
             };
114
             };
108
           })
115
           })
109
         ).then((res) => {
116
         ).then((res) => {
110
-          setPayInfo(res)
111
-          requestPayment(res)
117
+          setPayInfo(res);
118
+          requestPayment(res);
119
+        }).catch(()=>{
120
+          Taro.hideLoading()
121
+          Taro.showToast({
122
+            title: "支付失败",
123
+            icon: "none",
124
+            duration: 2000,
125
+          });
112
         });
126
         });
113
       }
127
       }
114
       if (orderId) {
128
       if (orderId) {
115
         payOrder(orderId).then((res) => {
129
         payOrder(orderId).then((res) => {
116
-          setPayInfo(res)
117
-          requestPayment(res)
130
+          setPayInfo(res);
131
+          requestPayment(res);
132
+        }).catch(()=>{
133
+          Taro.hideLoading()
134
+          Taro.showToast({
135
+            title: "支付失败",
136
+            icon: "none",
137
+            duration: 2000,
138
+          });
118
         });
139
         });
119
       }
140
       }
120
     } else {
141
     } else {
128
 
149
 
129
   useEffect(() => {
150
   useEffect(() => {
130
     if (packageId) {
151
     if (packageId) {
131
-      getShopPackageDetail(packageId).then((res) => {
152
+      getPackageDetail(packageId).then((res) => {
132
         setList([res]);
153
         setList([res]);
133
       });
154
       });
134
     }
155
     }

+ 8
- 1
src/pages/details/foodDetails/foodDetails.jsx View File

23
 
23
 
24
 export default withLayout((props) => {
24
 export default withLayout((props) => {
25
   const { router, person } = props
25
   const { router, person } = props
26
-  const { id } = props.router.params
26
+  const { id, validPackage} = props.router.params
27
+  useEffect(()=>{
28
+    if(id&&validPackage){
29
+      Taro.navigateTo({
30
+        url: `/pages/TobeShop/index&id=${id}&validPackage=${validPackage}`,
31
+      });
32
+    }
33
+  },[id,validPackage])
27
   //商铺基础信息
34
   //商铺基础信息
28
   const [detail, setDetail] = useState({})
35
   const [detail, setDetail] = useState({})
29
   //商铺套餐
36
   //商铺套餐

+ 7
- 0
src/services/home.js View File

60
 */
60
 */
61
 export const getShopPackageDetail = (id) => request(`/taShopPackage/${id}`)
61
 export const getShopPackageDetail = (id) => request(`/taShopPackage/${id}`)
62
 
62
 
63
+/**
64
+* 套餐详情2
65
+* @param {*} id 
66
+* @returns 
67
+*/
68
+export const getPackageDetail = (id) => request(`/package/${id}`)
69
+
63
 /**
70
 /**
64
 * 获取套餐定位
71
 * 获取套餐定位
65
 * @param {*} id 
72
 * @param {*} id 

+ 2
- 2
src/utils/request.js View File

52
 
52
 
53
           if (!skipError) {
53
           if (!skipError) {
54
             Taro.showToast({
54
             Taro.showToast({
55
-              title: message,
55
+              title: message||'网络异常',
56
               icon: 'none',
56
               icon: 'none',
57
             })
57
             })
58
           }
58
           }
59
 
59
 
60
-          reject(message.indexOf('java') > -1 ? '系统内部错误' : message)
60
+          reject(message?.indexOf('java') > -1 ? '系统内部错误' : message)
61
         }
61
         }
62
       },
62
       },
63
     
63