Procházet zdrojové kódy

优化活动页面分享

cnyuhao před 1 měsícem
rodič
revize
24f46afe15

Diff nebyl zobrazen, protože je příliš veliký
+ 46887 - 19718
package-lock.json


+ 3 - 2
package.json

@@ -51,8 +51,9 @@
51 51
     "@tarojs/shared": "3.5.7",
52 52
     "@tarojs/taro": "3.5.7",
53 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 57
     "taro-ui": "^3.3.0"
57 58
   },
58 59
   "devDependencies": {

+ 2 - 2
project.private.config.json

@@ -1,11 +1,11 @@
1 1
 {
2 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 4
   "setting": {
5 5
     "compileHotReLoad": false,
6 6
     "urlCheck": true
7 7
   },
8
-  "libVersion": "3.7.1",
8
+  "libVersion": "3.7.2",
9 9
   "condition": {
10 10
     "miniprogram": {
11 11
       "list": [

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

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