张延森 3 years ago
parent
commit
5ea1e2e056

+ 2
- 2
config/dev.js View File

3
     NODE_ENV: '"development"'
3
     NODE_ENV: '"development"'
4
   },
4
   },
5
   defineConstants: {
5
   defineConstants: {
6
-    HOST: '"https://xlk.njyz.tech"',
7
-    // HOST: '"https://xlj.newlandsh.com"',
6
+    // HOST: '"https://xlk.njyz.tech"',
7
+    HOST: '"https://xlj.newlandsh.com"',
8
     // HOST: '"http://127.0.0.1:8081"',
8
     // HOST: '"http://127.0.0.1:8081"',
9
     WSS_HOST: '"wss://xlk.njyz.tech"',
9
     WSS_HOST: '"wss://xlk.njyz.tech"',
10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',

+ 8
- 1
src/components/ChatIcon/index.jsx View File

1
 import { useEffect, useState } from 'react'
1
 import { useEffect, useState } from 'react'
2
 import Taro from '@tarojs/taro'
2
 import Taro from '@tarojs/taro'
3
 import { MovableArea, MovableView } from '@tarojs/components'
3
 import { MovableArea, MovableView } from '@tarojs/components'
4
+import { showSubscribeMessage, MESSAGE_TYPE } from '@/utils/subscribeMessage'
4
 import './style.scss'
5
 import './style.scss'
5
 
6
 
6
 export default function ChatIcon(props) {
7
 export default function ChatIcon(props) {
8
   const [PageX] = useState(Taro.getSystemInfoSync().windowWidth - 20)
9
   const [PageX] = useState(Taro.getSystemInfoSync().windowWidth - 20)
9
   const [PageY] = useState(Taro.getSystemInfoSync().windowHeight - 20)
10
   const [PageY] = useState(Taro.getSystemInfoSync().windowHeight - 20)
10
 
11
 
12
+  const handleClick = () => {
13
+    showSubscribeMessage(MESSAGE_TYPE.NOTICE).then((res) => {
14
+      //
15
+    })
16
+  }
17
+
11
   return (
18
   return (
12
-    <MovableArea className='components ChatIcon'>
19
+    <MovableArea className='components ChatIcon' onClick={handleClick}>
13
       <MovableView className='MoveItem' x={PageX} y={PageY} direction='all'>text</MovableView>
20
       <MovableView className='MoveItem' x={PageX} y={PageY} direction='all'>text</MovableView>
14
     </MovableArea>
21
     </MovableArea>
15
   )
22
   )

+ 0
- 3
src/layout/index.js View File

13
 import ShareToCircle from '@/components/ShareToCircle'
13
 import ShareToCircle from '@/components/ShareToCircle'
14
 import { report as reportCustomer } from '@/utils/customer'
14
 import { report as reportCustomer } from '@/utils/customer'
15
 import nav2Target from '@/utils/nav2Target'
15
 import nav2Target from '@/utils/nav2Target'
16
-import { showSubscribeMessage } from '@/utils/subscribeMessage'
17
 import { ROLE_CODE } from '@/constants/user'
16
 import { ROLE_CODE } from '@/constants/user'
18
 import useAuth from './useAuth'
17
 import useAuth from './useAuth'
19
 import useScreen from './useScreen'
18
 import useScreen from './useScreen'
62
     })
61
     })
63
   }
62
   }
64
 
63
 
65
-  showSubscribeMessage()
66
-
67
   // 报备客户
64
   // 报备客户
68
   useEffect(() => {
65
   useEffect(() => {
69
     if (isSinglePage) return;
66
     if (isSinglePage) return;

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

65
 
65
 
66
   return (
66
   return (
67
     <view className='Page Index'>
67
     <view className='Page Index'>
68
-      <ChatIcon></ChatIcon>
68
+      {/* <ChatIcon></ChatIcon> */}
69
       {/* <ShareToCircle visible></ShareToCircle> */}
69
       {/* <ShareToCircle visible></ShareToCircle> */}
70
       <ScrollView scroll-y>
70
       <ScrollView scroll-y>
71
         <view className='PageContent'>
71
         <view className='PageContent'>

+ 8
- 1
src/utils/chatDate.js View File

1
 
1
 
2
+import Taro from '@tarojs/taro'
2
 
3
 
3
 export const MILLISECONDS_A_SECOND = 1e3
4
 export const MILLISECONDS_A_SECOND = 1e3
4
 export const MILLISECONDS_A_MINUTE = 60 * MILLISECONDS_A_SECOND
5
 export const MILLISECONDS_A_MINUTE = 60 * MILLISECONDS_A_SECOND
16
   return [bw, day, hour, min, sec]
17
   return [bw, day, hour, min, sec]
17
 }
18
 }
18
 
19
 
20
+let systemInfo = null;
21
+
19
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
22
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
20
 export function formatDate(dt, fmt) {
23
 export function formatDate(dt, fmt) {
21
   if (!dt) return dt;
24
   if (!dt) return dt;
22
 
25
 
26
+  if (!systemInfo) {
27
+    systemInfo = Taro.getSystemInfoSync()
28
+  }
29
+
23
   // 解决苹果手机不能正常初始化的问题
30
   // 解决苹果手机不能正常初始化的问题
24
-  const dtStr = typeof dt === 'string' ? dt.replace(/-/g, "/") : dt;
31
+  const dtStr = systemInfo.system.indexOf('iOS') > -1 && typeof dt === 'string' ? dt.replace(/-/g, "/") : dt;
25
   const date = new Date(dtStr)
32
   const date = new Date(dtStr)
26
 
33
 
27
   var o = {
34
   var o = {

+ 10
- 2
src/utils/subscribeMessage.js View File

1
-
1
+import Taro from '@tarojs/taro'
2
 import store from '../store'
2
 import store from '../store'
3
 
3
 
4
 export const MESSAGE_TYPE = {
4
 export const MESSAGE_TYPE = {
7
 
7
 
8
 export function showSubscribeMessage (messageType) {
8
 export function showSubscribeMessage (messageType) {
9
   const { user } = store.getState()
9
   const { user } = store.getState()
10
-  const { miniApp } = (user || {}).userInfo || {}
10
+  const { miniApp = {} } = (user || {}).userInfo || {}
11
 
11
 
12
+  const tmplIds = (miniApp.tpls || []).filter(x => x.tplType === messageType).map(x => x.tplId)
13
+  if (tmplIds.length > 0) {
14
+    return new Promise((resolve) => {
15
+      Taro.requestSubscribeMessage({ tmplIds, fail: (e) => { console.error(e) }, complete: resolve })
16
+    })
17
+  } else {
18
+    return Promise.resolve()
19
+  }
12
 }
20
 }