Browse Source

优化活动页面分享

cnyuhao 1 month ago
parent
commit
24f46afe15

File diff suppressed because it is too large
+ 46887 - 19718
package-lock.json


+ 3 - 2
package.json

@@ -51,8 +51,9 @@
51
     "@tarojs/shared": "3.5.7",
51
     "@tarojs/shared": "3.5.7",
52
     "@tarojs/taro": "3.5.7",
52
     "@tarojs/taro": "3.5.7",
53
     "@tarojs/taro-h5": "3.5.7",
53
     "@tarojs/taro-h5": "3.5.7",
54
-    "react": "^18.0.0",
55
-    "react-dom": "^18.0.0",
54
+    "react": "^18.2.0",
55
+    "react-dom": "^18.2.0",
56
+    "react-native": "^0.73.11",
56
     "taro-ui": "^3.3.0"
57
     "taro-ui": "^3.3.0"
57
   },
58
   },
58
   "devDependencies": {
59
   "devDependencies": {

+ 2 - 2
project.private.config.json

@@ -1,11 +1,11 @@
1
 {
1
 {
2
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
2
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3
-  "projectname": "%E9%B1%BC%E5%B8%82",
3
+  "projectname": "fish_app",
4
   "setting": {
4
   "setting": {
5
     "compileHotReLoad": false,
5
     "compileHotReLoad": false,
6
     "urlCheck": true
6
     "urlCheck": true
7
   },
7
   },
8
-  "libVersion": "3.7.1",
8
+  "libVersion": "3.7.2",
9
   "condition": {
9
   "condition": {
10
     "miniprogram": {
10
     "miniprogram": {
11
       "list": [
11
       "list": [

+ 18 - 4
src/components/shareModal/index.jsx

@@ -3,36 +3,50 @@ import { View, Image, Text, Button, Input } from "@tarojs/components";
3
 import "./index.less";
3
 import "./index.less";
4
 import { useState, useEffect } from "react";
4
 import { useState, useEffect } from "react";
5
 
5
 
6
+// 分享模态框组件
6
 export default function shareModal(props) {
7
 export default function shareModal(props) {
7
-  const {  isOpened, onClose, product, onShareTitleChange } = props;
8
+  // 解构props,获取必要参数
9
+  const { isOpened, onClose, product, onShareTitleChange } = props;
10
+  // 分享标题状态管理
8
   const [shareTitle, setShareTitle] = useState('');
11
   const [shareTitle, setShareTitle] = useState('');
9
 
12
 
13
+  // 当商品信息更新时,设置分享标题
10
   useEffect(() => {
14
   useEffect(() => {
11
     if (product?.item_title) {
15
     if (product?.item_title) {
12
       setShareTitle(product.item_title);
16
       setShareTitle(product.item_title);
13
     }
17
     }
14
   }, [product]);
18
   }, [product]);
19
+
20
+  // 监听模态框开关状态
21
+  // 关闭时清空标题,打开时设置为商品标题
15
   useEffect(() => {
22
   useEffect(() => {
16
     if (!isOpened) {
23
     if (!isOpened) {
17
       setShareTitle('');
24
       setShareTitle('');
18
-    }else{
25
+    } else {
19
       setShareTitle(product.item_title);
26
       setShareTitle(product.item_title);
20
     }
27
     }
21
   }, [isOpened]);
28
   }, [isOpened]);
29
+
30
+  // 处理输入框内容变化
22
   const handleInputChange = (e) => {
31
   const handleInputChange = (e) => {
23
     const newTitle = e.detail.value;
32
     const newTitle = e.detail.value;
24
     setShareTitle(newTitle);
33
     setShareTitle(newTitle);
25
     onShareTitleChange?.(newTitle);
34
     onShareTitleChange?.(newTitle);
26
   }
35
   }
36
+
27
   return (
37
   return (
28
     <View className="share-modal">
38
     <View className="share-modal">
29
       <AtModal isOpened={isOpened} closeOnClickOverlay={true} onClose={onClose}>
39
       <AtModal isOpened={isOpened} closeOnClickOverlay={true} onClose={onClose}>
30
         <AtModalContent>
40
         <AtModalContent>
31
           {product && (
41
           {product && (
32
           <View className="container">
42
           <View className="container">
43
+            {/* 商品图片展示 */}
33
             <Image className="product-image" src={product.image_url} mode="aspectFill" />
44
             <Image className="product-image" src={product.image_url} mode="aspectFill" />
45
+            {/* 商品标题展示 */}
34
             <View className="title">{product.item_title}</View>
46
             <View className="title">{product.item_title}</View>
47
+            {/* 分享标题输入框 */}
35
             <Input onInput={handleInputChange} className="input" value={shareTitle} />
48
             <Input onInput={handleInputChange} className="input" value={shareTitle} />
49
+            {/* 分享按钮 */}
36
             <Button openType="share" onClick={onClose}>
50
             <Button openType="share" onClick={onClose}>
37
               <View className="share-button">
51
               <View className="share-button">
38
                 分享
52
                 分享
@@ -40,8 +54,8 @@ export default function shareModal(props) {
40
             </Button>
54
             </Button>
41
           </View>
55
           </View>
42
         )}
56
         )}
43
-      </AtModalContent>
44
-    </AtModal>
57
+        </AtModalContent>
58
+      </AtModal>
45
     </View>
59
     </View>
46
   );
60
   );
47
 }
61
 }

+ 2 - 3
src/pages/indexSub/highCommission/index.jsx

@@ -93,13 +93,12 @@ export default class Index extends Component {
93
     });
93
     });
94
   };
94
   };
95
   // 配置分享内容
95
   // 配置分享内容
96
-  onShareAppMessage() {
96
+  onShareAppMessage(res) {
97
     let shareUserId = "";
97
     let shareUserId = "";
98
     if (Taro.getStorageSync("loginInfo")) {
98
     if (Taro.getStorageSync("loginInfo")) {
99
       shareUserId = Taro.getStorageSync("loginInfo").id;
99
       shareUserId = Taro.getStorageSync("loginInfo").id;
100
     }
100
     }
101
-    const shareConfig = getShareContent();
102
-    if (shareConfig.title == "默认分享标题") {
101
+    if (res.from == "menu") {
103
       return {
102
       return {
104
         title: "高佣专项",
103
         title: "高佣专项",
105
         path: `/pages/indexSub/highCommission/index?isShare=true&shareUserId=${shareUserId}`,
104
         path: `/pages/indexSub/highCommission/index?isShare=true&shareUserId=${shareUserId}`,

+ 2 - 2
src/pages/indexSub/seckillIndex/index.jsx

@@ -93,13 +93,13 @@ export default class Index extends Component {
93
     });
93
     });
94
   };
94
   };
95
   // 配置分享内容
95
   // 配置分享内容
96
-  onShareAppMessage() {
96
+  onShareAppMessage(res) {
97
     let shareUserId = "";
97
     let shareUserId = "";
98
     if (Taro.getStorageSync("loginInfo")) {
98
     if (Taro.getStorageSync("loginInfo")) {
99
       shareUserId = Taro.getStorageSync("loginInfo").id;
99
       shareUserId = Taro.getStorageSync("loginInfo").id;
100
     }
100
     }
101
     const shareConfig = getShareContent();
101
     const shareConfig = getShareContent();
102
-    if (shareConfig.title == "默认分享标题") {
102
+    if (res.from == "menu") {
103
       return {
103
       return {
104
         title: "鱼市秒杀",
104
         title: "鱼市秒杀",
105
         path: `/pages/indexSub/seckillIndex/index?isShare=true&shareUserId=${shareUserId}`,
105
         path: `/pages/indexSub/seckillIndex/index?isShare=true&shareUserId=${shareUserId}`,