张延森 преди 3 години
родител
ревизия
41260093c1
променени са 4 файла, в които са добавени 32 реда и са изтрити 8 реда
  1. 15
    5
      src/components/ShareModal/index.jsx
  2. 2
    2
      src/pages/index/activityDetail/index.jsx
  3. 5
    0
      src/pages/index/activityDetail/index.scss
  4. 10
    1
      src/utils/hooks/useShare.js

+ 15
- 5
src/components/ShareModal/index.jsx Целия файл

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

+ 2
- 2
src/pages/index/activityDetail/index.jsx Целия файл

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

+ 5
- 0
src/pages/index/activityDetail/index.scss Целия файл

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

+ 10
- 1
src/utils/hooks/useShare.js Целия файл

@@ -1,4 +1,4 @@
1
-import React, { useRef } from 'react'
1
+import React, { useEffect, useRef } from 'react'
2 2
 import Taro, { useShareAppMessage } from '@tarojs/taro'
3 3
 import shareTracking from '@/utils/tracking/share'
4 4
 
@@ -9,6 +9,15 @@ export default function useShare(shareContent, trackData) {
9 9
   shareRef.current = shareContent
10 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 21
   useShareAppMessage((res) => {
13 22
     const {
14 23
       title,