张延森 3 лет назад
Родитель
Сommit
5ea1e2e056

+ 2
- 2
config/dev.js Просмотреть файл

@@ -3,8 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"development"'
4 4
   },
5 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 8
     // HOST: '"http://127.0.0.1:8081"',
9 9
     WSS_HOST: '"wss://xlk.njyz.tech"',
10 10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',

+ 8
- 1
src/components/ChatIcon/index.jsx Просмотреть файл

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

+ 0
- 3
src/layout/index.js Просмотреть файл

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

+ 1
- 1
src/pages/index/index.jsx Просмотреть файл

@@ -65,7 +65,7 @@ export default withLayout((props) => {
65 65
 
66 66
   return (
67 67
     <view className='Page Index'>
68
-      <ChatIcon></ChatIcon>
68
+      {/* <ChatIcon></ChatIcon> */}
69 69
       {/* <ShareToCircle visible></ShareToCircle> */}
70 70
       <ScrollView scroll-y>
71 71
         <view className='PageContent'>

+ 8
- 1
src/utils/chatDate.js Просмотреть файл

@@ -1,4 +1,5 @@
1 1
 
2
+import Taro from '@tarojs/taro'
2 3
 
3 4
 export const MILLISECONDS_A_SECOND = 1e3
4 5
 export const MILLISECONDS_A_MINUTE = 60 * MILLISECONDS_A_SECOND
@@ -16,12 +17,18 @@ export const diff = (dt1, dt2) => {
16 17
   return [bw, day, hour, min, sec]
17 18
 }
18 19
 
20
+let systemInfo = null;
21
+
19 22
 //例子 getDateFormat(new Date().valueOf(),true,'yyyy/M/d')
20 23
 export function formatDate(dt, fmt) {
21 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 32
   const date = new Date(dtStr)
26 33
 
27 34
   var o = {

+ 10
- 2
src/utils/subscribeMessage.js Просмотреть файл

@@ -1,4 +1,4 @@
1
-
1
+import Taro from '@tarojs/taro'
2 2
 import store from '../store'
3 3
 
4 4
 export const MESSAGE_TYPE = {
@@ -7,6 +7,14 @@ export const MESSAGE_TYPE = {
7 7
 
8 8
 export function showSubscribeMessage (messageType) {
9 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
 }