Your Name 3 years ago
parent
commit
fa3ace1fd6

+ 1
- 1
config/dev.js View File

@@ -4,7 +4,7 @@ module.exports = {
4 4
   },
5 5
   defineConstants: {
6 6
     // HOST: '"https://xlk.njyz.tech"',
7
-    HOST: '"http://127.0.0.1:8567"',
7
+    HOST: '"http://127.0.0.1:8081"',
8 8
     WSS_HOST: '"wss://xlk.njyz.tech"',
9 9
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
10 10
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',

+ 1
- 1
config/prod.js View File

@@ -10,7 +10,7 @@ module.exports = {
10 10
     OSS_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
11 11
     OSS_FAST_PATH: '"https://xlk-assets.oss-accelerate.aliyuncs.com/"',
12 12
     ICON_FONT: '"https://yz-websit.oss-cn-hangzhou.aliyuncs.com/xlk/css/iconfont.ttf"',
13
-    Version: '"V0.0.26-20210808"'
13
+    Version: '"V0.0.27-20210808"'
14 14
   },
15 15
   mini: {},
16 16
   h5: {

+ 1
- 1
project.config.json View File

@@ -2,7 +2,7 @@
2 2
 	"miniprogramRoot": "dist/",
3 3
 	"projectname": "miniapp",
4 4
 	"description": "",
5
-	"appid": "wxc96058d57e77f373",
5
+	"appid": "wxe44244d1a5ea3364",
6 6
 	"setting": {
7 7
 		"urlCheck": false,
8 8
 		"es6": false,

+ 30
- 4
src/components/ShareToCircle/index.jsx View File

@@ -1,14 +1,40 @@
1
+
2
+import { useEffect, useState } from 'react'
3
+import Taro from '@tarojs/taro'
1 4
 import classNames from 'classnames'
2 5
 import './style.scss'
3 6
 
4 7
 export default (props) => {
5
-  const { visible = false, close = () => {} } = props
8
+  const { visible = false, onClose = () => {} } = props
9
+  const [style, setStyle] = useState({ right: '50px' })
10
+
11
+  useEffect(() => {
12
+    Taro.nextTick(() => {
13
+      // https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html
14
+      const bound = Taro.getMenuButtonBoundingClientRect()
15
+
16
+      Taro.getStorage({
17
+        key: 'systemInfo',
18
+        success: (res) => {
19
+          const { screenWidth } = res.data
20
+          // 胶囊右边距
21
+          const marginRight = screenWidth - bound.right
22
+          // 提示的右边距
23
+          const right = bound.width / 2 + marginRight
24
+          //
25
+          setStyle({ right: `${right}px` })
26
+        }
27
+      }) || {};
28
+
29
+      // 需要依据 bound 来调整位置
30
+    })
31
+  }, [])
6 32
 
7 33
   return (
8
-    <view className={classNames('components', 'ShareToCircle', { show: visible })}>
9
-      <view>
34
+    <view className={classNames('components', 'ShareToCircle', { show: visible })} onClick={onClose}>
35
+      <view style={style}>
10 36
         <text>从这里“分享到朋友圈”~</text>
11
-        <text className='iconfont icon-guanbi1' onClick={close}></text>
37
+        <text className='iconfont icon-guanbi1' onClick={onClose}></text>
12 38
       </view>
13 39
     </view>
14 40
   )

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

@@ -10,6 +10,7 @@ import AuthPage from '@/components/Auth/AuthPage'
10 10
 import Spin from '@/components/Spin/Spin2'
11 11
 import FixedConsultant from '@/components/FixedConsultant'
12 12
 import FirstScreen from '@/components/FirstScreen'
13
+import ShareToCircle from '@/components/ShareToCircle'
13 14
 import { report as reportCustomer } from '@/utils/customer'
14 15
 import nav2Target from '@/utils/nav2Target'
15 16
 import { ROLE_CODE } from '@/constants/user'
@@ -28,6 +29,7 @@ export default (ChildComponent) => (props) => {
28 29
   const page = routes.filter((r) => (router.path.indexOf(r.page) > -1))[0]
29 30
   const [loading, setLoading] = useState(false)
30 31
   const [authPhone, authAvatar, authPage] = useAuth(person, page)
32
+  const [shareTimelineVisible, setShareTimelineVisible] = useState(false)
31 33
 
32 34
   const { id } = router.params
33 35
   const showConsultant = page.shortcut && page.shortcut.consultant
@@ -44,6 +46,8 @@ export default (ChildComponent) => (props) => {
44 46
     nav2Target(screenInfo)
45 47
   }
46 48
 
49
+  const showShareTimeline = (visible) => setShareTimelineVisible(visible)
50
+
47 51
   // 报备客户
48 52
   useEffect(() => {
49 53
     reportCustomer(person, consultant, false).catch(() => {})
@@ -81,20 +85,32 @@ export default (ChildComponent) => (props) => {
81 85
 
82 86
   return (
83 87
     <>
88
+      {/* 菊花转 */}
84 89
       <Overlay visible={loading} style={{background: '#fff'}}>
85 90
         <Loading />
86 91
       </Overlay>
92
+
93
+      {/* 授权手机 */}
87 94
       <Overlay visible={authPhone} aligin='bottom'>
88 95
         <View className='auth-wrapper'>
89 96
           <AuthPhone consultant={consultant} router={router} page={page} />
90 97
         </View>
91 98
       </Overlay>
99
+
100
+      {/* 授权头像 */}
92 101
       <Overlay visible={!authPhone && authAvatar} aligin='bottom'>
93 102
         <View className='auth-wrapper'>
94 103
           <AuthAvatar />
95 104
         </View>
96 105
       </Overlay>
106
+
107
+      {/* 授权头像-全屏 */}
97 108
       { authPage && <AuthPage /> }
109
+
110
+      {/* 显示分享朋友圈 */}
111
+      <ShareToCircle visible={shareTimelineVisible} onClose={() => setShareTimelineVisible(false)} />
112
+
113
+      {/* 页面内容 */}
98 114
       <Spin size={32} spinning={spinning} />
99 115
       {
100 116
         person && !!person.personId && (
@@ -106,14 +122,19 @@ export default (ChildComponent) => (props) => {
106 122
             city={city}
107 123
             shareContent={shareContent}
108 124
             trackData={trackData}
125
+            showShareTimeline={showShareTimeline}
109 126
             {...props}
110 127
             {...extInfo}
111 128
           />
112 129
         )
113 130
       }
131
+
132
+      {/* 当前置业顾问 */}
114 133
       {
115 134
         !!showConsultant && (<FixedConsultant consultant={consultant} />)
116 135
       }
136
+
137
+      {/* 开屏广告 */}
117 138
       <FirstScreen
118 139
         info={screenInfo}
119 140
         visible={screenVisible}

+ 2
- 6
src/pages/index/activityDetail/index.jsx View File

@@ -12,7 +12,6 @@ import {
12 12
   Button
13 13
 } from '@tarojs/components';
14 14
 import Disclaimer from '@/components/Disclaimer';
15
-import ShareToCircle from '@/components/ShareToCircle'
16 15
 import { useSelector } from 'react-redux';
17 16
 import {
18 17
   signupActivity,
@@ -53,7 +52,7 @@ const activityStatusDict = {
53 52
 };
54 53
 
55 54
 export default withLayout((props) => {
56
-  const { router, shareContent, trackData, person, page } = props;
55
+  const { router, shareContent, trackData, person, page, showShareTimeline } = props;
57 56
   const { id } = router.params;
58 57
 
59 58
   const user = useSelector((state) => state.user);
@@ -64,8 +63,6 @@ export default withLayout((props) => {
64 63
   const [selectorChecked, setSelectorChecked] = useState('1');
65 64
   const [selector, setSelector] = useState('');
66 65
 
67
-  const [ShowShareLayer, setShowShareLayer] = useState(false)
68
-
69 66
   const buildingId = detail?.buildingId;
70 67
 
71 68
   const [btnText, btnDisabled] = useStatus(detail)
@@ -214,7 +211,7 @@ export default withLayout((props) => {
214 211
             <text>分享</text>
215 212
             <Button open-type='share' className='ShareBtn'>分享</Button>
216 213
           </view>
217
-          <view onClick={() => { setShowShareLayer(true) }}>
214
+          <view onClick={() => showShareTimeline(true)}>
218 215
             <text className='iconfont icon-pengyouquan1' style='font-size: 32rpx'></text>
219 216
             <text>朋友圈</text>
220 217
           </view>
@@ -242,7 +239,6 @@ export default withLayout((props) => {
242 239
     <>
243 240
       {detail && (
244 241
         <view className='Page activityDetail flex-v'>
245
-          <ShareToCircle visible={ShowShareLayer} close={() => { setShowShareLayer(false) }}></ShareToCircle>
246 242
           <view className='flex-item'>
247 243
             <view>
248 244
               <ScrollView scroll-y>

+ 2
- 1
src/pages/index/newsDetail/index.config.js View File

@@ -1,3 +1,4 @@
1 1
 export default {
2
-  navigationBarTitleText: '资讯详情'
2
+  navigationBarTitleText: '资讯详情',
3
+  enableShareAppMessage: true
3 4
 }

+ 19
- 38
src/pages/index/newsDetail/index.jsx View File

@@ -2,19 +2,20 @@ import { useState, useEffect } from "react";
2 2
 import Taro from "@tarojs/taro";
3 3
 import withLayout from "@/layout";
4 4
 import { ScrollView, Image, RichText, WebView } from "@tarojs/components";
5
+import useParams from '@/utils/hooks/useParams'
5 6
 import useFavor from "@/utils/hooks/useFavor";
6 7
 import { queryNewsDetail } from "@/services/news";
7 8
 import { formatDate } from "@/utils/chatDate";
9
+import useShare from "@/utils/hooks/useShare";
8 10
 import "@/assets/css/iconfont.css";
9 11
 import "./index.scss";
10 12
 
11 13
 export default withLayout((props) => {
12
-  const { trackData } = props
14
+  const { router, shareContent, person, trackData, page, showShareTimeline } = props
13 15
   const { id } = props.router.params;
14 16
 
17
+  const paramsRef = useParams({person, from: `${page.type}_share`})
15 18
   const [data, setData] = useState(null);
16
-  const [IsPull, setPull] = useState(false);
17
-  const [PullTimer, setPullTimer] = useState(null);
18 19
 
19 20
 
20 21
   const [isSave, handleFavor] = useFavor(data?.isSave, {
@@ -22,23 +23,17 @@ export default withLayout((props) => {
22 23
     buildingId: data?.buildingId,
23 24
     ...trackData,
24 25
   });
25
-
26
-  const PageRefresh = () => {
27
-    // 页面下拉刷新回调
28
-    setPull(true);
29
-  };
30
-
31
-  useEffect(() => {
32
-    // 下拉刷新触发
33
-    if (IsPull) {
34
-      clearTimeout(PullTimer);
35
-      setPullTimer(
36
-        setTimeout(() => {
37
-          setPull(false);
38
-        }, 2000)
39
-      );
40
-    }
41
-  }, [IsPull]);
26
+  
27
+  const fullTrackData = { ...trackData, buildingId: data?.buildingId };
28
+  
29
+  useShare(
30
+    {
31
+      title: shareContent.shareContentTitle || data?.newsName,
32
+      path: `${router.path}?${paramsRef.current}`,
33
+      image: shareContent.shareContentImg,
34
+    },
35
+    fullTrackData
36
+  );
42 37
 
43 38
   const getData = (params) => {
44 39
     Taro.showLoading();
@@ -49,14 +44,6 @@ export default withLayout((props) => {
49 44
     });
50 45
   };
51 46
 
52
-  const shareTimeline = () => {
53
-    Taro.showToast({
54
-      title: '请点击右上角分享到朋友圈',
55
-      icon: 'none',
56
-      duration: 3000,
57
-    })
58
-  }
59
-
60 47
   useEffect(() => {
61 48
     if (id) {
62 49
       getData(id);
@@ -68,13 +55,7 @@ export default withLayout((props) => {
68 55
       {data && (data.newsDetailType === '0' ? <WebView src={data.newsDetail} /> : <>
69 56
         <view className='flex-item'>
70 57
           <view>
71
-            <ScrollView
72
-              scroll-y
73
-              refresher-enabled
74
-              refresher-triggered={IsPull}
75
-              onrefresherrefresh={PageRefresh}
76
-              refresher-background='#fff'
77
-            >
58
+            <ScrollView scrollY>
78 59
               <view className='PageContent'>
79 60
                 <view className='Info'>
80 61
                   <view>
@@ -99,9 +80,9 @@ export default withLayout((props) => {
99 80
           </view>
100 81
         </view>
101 82
         <view className='Bottom'>
102
-          <view>
103
-            <text onClick={shareTimeline} className='iconfont icon-pengyouquan1'></text>
104
-            <text onClick={shareTimeline}>分享朋友圈</text>
83
+          <view onClick={() => showShareTimeline(true)}>
84
+            <text className='iconfont icon-pengyouquan1'></text>
85
+            <text>分享朋友圈</text>
105 86
           </view>
106 87
           <view>
107 88
             <text className='iconfont icon-shoucang' style={isSave ? { color: 'red' } : undefined} onClick={handleFavor}></text>