Преглед изворни кода

Merge branch 'dev' of http://git.ycjcjy.com/shigongli/miniapp-v2 into dev

吃个甘蔗嚼一年 пре 3 година
родитељ
комит
4a3047f086

+ 1
- 1
src/components/ShopCommission/index.jsx Прегледај датотеку

@@ -15,7 +15,7 @@ export default (props) => {
15 15
     <view className='spreadCard'>
16 16
       <view className='spreadDate'>日期:<text>{formatTimes(item.createDate, "yyyy/MM/dd")}</text></view>
17 17
       <view className='card'>
18
-        <view className='spreadTime'>时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间:<text>{formatTimes(item.createDate, "yyyy/MM/dd hh:ss")}</text></view>
18
+        <view className='spreadTime'>时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间:<text>{formatTimes(item.createDate, "yyyy/MM/dd hh:mm")}</text></view>
19 19
         <view className='spreadMoney'>收入金额:<text>{(item.amount / 100).toFixed(2)}</text>元</view>
20 20
       </view>
21 21
     </view>

+ 1
- 1
src/components/ShopUnused/index.jsx Прегледај датотеку

@@ -19,7 +19,7 @@ export default (props) => {
19 19
     <view className='orderCard'>
20 20
       <view style={{ overflow: 'hidden' }}>
21 21
         <view className='orderId'>订单编号:{item.orderId}</view>
22
-        <view className='orderTime'>下单日期:{formatTimes(item.orderDate, 'yyyy-MM-dd hh:ss')}</view>
22
+        <view className='orderTime'>下单日期:{formatTimes(item.orderDate, 'yyyy-MM-dd hh:mm')}</view>
23 23
       </view>
24 24
       <view className='order'>
25 25
         <image className='orderImg' src={item.poster} mode='aspectFit' />

+ 1
- 1
src/hotel/pages/landlord/landlord.jsx Прегледај датотеку

@@ -46,7 +46,7 @@ export default withLayout((props) => {
46 46
   const handleTabChange = (e) => {
47 47
     const { index } = e.detail
48 48
     setCurrentTab(index)
49
-    withSubscribeMessage(TPL_MESSAGE_HOTEL_CHECK_IN)
49
+    withSubscribeMessage([TPL_MESSAGE_HOTEL_CHECK_IN])
50 50
   }
51 51
 
52 52
   useEffect(() => {

+ 1
- 1
src/pages/RoomOrder/index.jsx Прегледај датотеку

@@ -26,7 +26,7 @@ export default withLayout((props) => {
26 26
   const handleSubmit = (e) => {
27 27
 
28 28
     // 订阅消息
29
-    withSubscribeMessage(TPL_MESSAGE_HOTEL_CHECK_OUT, () => {
29
+    withSubscribeMessage([TPL_MESSAGE_HOTEL_CHECK_OUT], () => {
30 30
       for (let i = 0, len = formData.length; i < len; i++) {
31 31
         const item = formData[i];
32 32
         if (!item.customerName || !item.customerPhone) {

+ 1
- 1
src/pages/index/index.jsx Прегледај датотеку

@@ -43,7 +43,7 @@ export default withLayout((props) => {
43 43
     setCurrentTab(index)
44 44
 
45 45
     if (index === 1) {
46
-      withSubscribeMessage(TPL_MESSAGE_HOTEL_CHECK_OUT)
46
+      withSubscribeMessage([TPL_MESSAGE_HOTEL_CHECK_OUT])
47 47
     }
48 48
   }
49 49
   useEffect(() => {

+ 7
- 5
src/shop/pages/spread/spreadIndex.jsx Прегледај датотеку

@@ -4,7 +4,10 @@ import { useRouter } from '@tarojs/taro'
4 4
 import { getShopList, getShopMoney, getAccount, getVerifiedOrder, setGetVerifiedOrder } from '@/services/shopBoss'
5 5
 import { withSubscribeMessage } from '@/utils/subscribeMessage'
6 6
 import withLayout from '@/layouts'
7
-import { TPL_MESSAGE_SHOP_PAY_SUCCESS } from '@/utils/constants'
7
+import {
8
+  TPL_MESSAGE_SHOP_PAY_SUCCESS,
9
+  TPL_MESSAGE_SHOP_VERIFY_RESULT,
10
+} from '@/utils/constants'
8 11
 import tabList from './Shoptabbar'
9 12
 import ShopKeeper from '../../components/ShopKeeper/shopKeeper'
10 13
 import Sparead from '../../components/Sparead/spreadMoney'
@@ -38,18 +41,17 @@ export default withLayout((props) => {
38 41
       listRef.current.context.scrollTo({ top: 0 })
39 42
     }
40 43
 
41
-    withSubscribeMessage(TPL_MESSAGE_SHOP_PAY_SUCCESS)
44
+    withSubscribeMessage([TPL_MESSAGE_SHOP_PAY_SUCCESS, TPL_MESSAGE_SHOP_VERIFY_RESULT])
42 45
   }
43
-  const handelTypeOrder = () => {
44 46
 
47
+  const handelTypeOrder = () => {
45 48
     setAmountType('order')
46
-
47 49
   }
48 50
 
49 51
   const handelType = () => {
50 52
     setAmountType('commission')
51
-
52 53
   }
54
+
53 55
   //商铺列表
54 56
   useEffect(() => {
55 57
     getShopList().then((res) => {

+ 1
- 0
src/utils/constants.js Прегледај датотеку

@@ -2,3 +2,4 @@
2 2
 export const TPL_MESSAGE_HOTEL_CHECK_IN = "hotel_check_in";       // 民宿入住消息
3 3
 export const TPL_MESSAGE_HOTEL_CHECK_OUT = "hotel_check_out";     // 民宿离店消息
4 4
 export const TPL_MESSAGE_SHOP_PAY_SUCCESS = "shop_pay_success";   // 商铺下单成功通知
5
+export const TPL_MESSAGE_SHOP_VERIFY_RESULT = "shop_verify_result";   // 商铺下单成功通知

+ 8
- 2
src/utils/hooks/useRouter.js Прегледај датотеку

@@ -16,6 +16,13 @@ export default () => {
16 16
   const loginScene = Taro.getStorageSync('scene')
17 17
 
18 18
   useEffect(() => {
19
+    // 没有 token 说明没有登录
20
+    const token = Taro.getStorageSync('token')
21
+    if (!token) {
22
+      return;
23
+    }
24
+
25
+
19 26
     // 扫码进入
20 27
     if (scene) {
21 28
       if (scene === loginScene && qrCode) {
@@ -26,9 +33,7 @@ export default () => {
26 33
           parseQRFinished: true,
27 34
         }
28 35
         setToggleRefresh(Math.random().toString())
29
-        console.log('-----------qrCode---------------', qrCode)
30 36
       } else {
31
-        console.log('-----------getQrcode---------------', scene)
32 37
         getQrcode(scene).then((res) => {
33 38
           const qrParams = parseQueryString(res.scene) || {}
34 39
           routerRef.current.params = {
@@ -41,5 +46,6 @@ export default () => {
41 46
       }
42 47
     }
43 48
   }, [qrCode, scene])
49
+
44 50
   return routerRef.current
45 51
 }

+ 11
- 8
src/utils/subscribeMessage.js Прегледај датотеку

@@ -1,18 +1,21 @@
1 1
 import Taro from "@tarojs/taro";
2 2
 import store from "@/store"
3 3
 
4
-export function subscribeMessage(messageType) {
5
-  if (!messageType) return Promise.resolve();
4
+export function subscribeMessage(messageTypes) {
5
+  if (!messageTypes || messageTypes.length < 1) return Promise.resolve();
6 6
   
7 7
   const { messageTpls } = store.getModel('system').getState()
8 8
   if (!messageTpls || !messageTpls.length) return Promise.resolve();
9
-
9
+  
10 10
   return new Promise((resolve, reject) => {
11
-    const tpl = messageTpls.filter(x => x.messageType === messageType)[0] || {}
11
+    const tmplIds = messageTypes.map((messageType) => {
12
+      const tpl = messageTpls.filter(x => x.messageType === messageType)[0] || {}
13
+      return tpl.templateId;
14
+    }).filter(Boolean)
12 15
 
13
-    if (tpl.templateId) {
16
+    if (tmplIds && tmplIds.length > 0) {
14 17
       Taro.requestSubscribeMessage({
15
-        tmplIds: [tpl.templateId],
18
+        tmplIds,
16 19
         complete: () => resolve(),
17 20
       })
18 21
     } else {
@@ -21,8 +24,8 @@ export function subscribeMessage(messageType) {
21 24
   })
22 25
 }
23 26
 
24
-export function withSubscribeMessage(type, callback) {
25
-  subscribeMessage(type).then(() => {
27
+export function withSubscribeMessage(types, callback) {
28
+  subscribeMessage(types).then(() => {
26 29
     if (callback) {
27 30
       callback()
28 31
     }