张延森 3 years ago
parent
commit
41260093c1

+ 15
- 5
src/components/ShareModal/index.jsx View File

1
-
1
+import classNames from 'classnames'
2
+import Taro from '@tarojs/taro'
3
+import { Button } from '@tarojs/components'
2
 import './style.scss'
4
 import './style.scss'
3
 
5
 
4
 export default (props) => {
6
 export default (props) => {
5
   const { visible = false } = props
7
   const { visible = false } = props
6
 
8
 
9
+  const shareTimeline = () => {
10
+    Taro.showToast({
11
+      title: '请点击右上角分享到朋友圈',
12
+      icon: 'none',
13
+      duration: 3000,
14
+    })
15
+  }
16
+
7
   return (
17
   return (
8
-    <view className={visible ? 'components ShareModal show' : 'components ShareModal'}>
18
+    <view className={classNames('components', 'ShareModal', { show: visible })}>
9
       <view>
19
       <view>
10
         <text>分享</text>
20
         <text>分享</text>
11
         <view>
21
         <view>
12
           <view>
22
           <view>
13
-            <view>
23
+            <view onClick={shareTimeline}>
14
               <text className='iconfont icon-pengyouquan'></text>
24
               <text className='iconfont icon-pengyouquan'></text>
15
               <text>朋友圈</text>
25
               <text>朋友圈</text>
16
             </view>
26
             </view>
17
-            <view>
27
+            <Button openType='share'>
18
               <text className='iconfont icon-weixin'></text>
28
               <text className='iconfont icon-weixin'></text>
19
               <text>好友或群</text>
29
               <text>好友或群</text>
20
-            </view>
30
+            </Button>
21
           </view>
31
           </view>
22
           <text>取消</text>
32
           <text>取消</text>
23
         </view>
33
         </view>

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

185
         </view>
185
         </view>
186
       </view>
186
       </view>
187
       <view className="PageBottom flex-h">
187
       <view className="PageBottom flex-h">
188
-        <view className="Share">
188
+        <button className="Share" open-type="share">
189
           <text className="iconfont icon-fenxiang"></text>
189
           <text className="iconfont icon-fenxiang"></text>
190
           <text>分享</text>
190
           <text>分享</text>
191
-        </view>
191
+        </button>
192
         <view className="Collect" onClick={handleFavor}>
192
         <view className="Collect" onClick={handleFavor}>
193
           <text
193
           <text
194
             className="iconfont icon-shoucang"
194
             className="iconfont icon-shoucang"

+ 5
- 0
src/pages/index/activityDetail/index.scss View File

193
     padding: 20px 30px;
193
     padding: 20px 30px;
194
     >.Share,
194
     >.Share,
195
     >.Collect {
195
     >.Collect {
196
+      line-height: inherit;
197
+      background: #fff;
196
       margin-left: 50px;
198
       margin-left: 50px;
199
+      &::after {
200
+        border: none;
201
+      }
197
       >text {
202
       >text {
198
         display: block;
203
         display: block;
199
         text-align: center;
204
         text-align: center;

+ 10
- 1
src/utils/hooks/useShare.js View File

1
-import React, { useRef } from 'react'
1
+import React, { useEffect, useRef } from 'react'
2
 import Taro, { useShareAppMessage } from '@tarojs/taro'
2
 import Taro, { useShareAppMessage } from '@tarojs/taro'
3
 import shareTracking from '@/utils/tracking/share'
3
 import shareTracking from '@/utils/tracking/share'
4
 
4
 
9
   shareRef.current = shareContent
9
   shareRef.current = shareContent
10
   trackRef.current = trackData
10
   trackRef.current = trackData
11
 
11
 
12
+  useEffect(() => {
13
+    if (shareContent?.title) {
14
+      Taro.showShareMenu({
15
+        withShareTicket: true,
16
+        menus: ['shareAppMessage', 'shareTimeline']
17
+      })
18
+    }
19
+  }, [shareContent?.title])
20
+
12
   useShareAppMessage((res) => {
21
   useShareAppMessage((res) => {
13
     const {
22
     const {
14
       title,
23
       title,