viczhq 1 月之前
父節點
當前提交
e0e120db55

+ 7 - 0
project.private.config.json

@@ -17,6 +17,13 @@
17 17
           "scene": null
18 18
         },
19 19
         {
20
+          "name": "pages/memberSub/partnerDetail/index",
21
+          "pathName": "pages/memberSub/partnerDetail/index",
22
+          "query": "",
23
+          "launchMode": "default",
24
+          "scene": null
25
+        },
26
+        {
20 27
           "name": "pages/memberSub/myPartner/index",
21 28
           "pathName": "pages/memberSub/myPartner/index",
22 29
           "query": "",

+ 60 - 0
src/common/time.js

@@ -0,0 +1,60 @@
1
+/**
2
+ * 日期时间处理工具函数
3
+ */
4
+
5
+// 格式化日期
6
+export function formatDate(date, format = 'YYYY-MM-DD HH:mm:ss') {
7
+  const d = date ? new Date(date) : new Date();
8
+  const year = d.getFullYear();
9
+  const month = String(d.getMonth() + 1).padStart(2, '0');
10
+  const day = String(d.getDate()).padStart(2, '0');
11
+  const hours = String(d.getHours()).padStart(2, '0');
12
+  const minutes = String(d.getMinutes()).padStart(2, '0');
13
+  const seconds = String(d.getSeconds()).padStart(2, '0');
14
+
15
+  return format
16
+    .replace('YYYY', year)
17
+    .replace('MM', month)
18
+    .replace('DD', day)
19
+    .replace('HH', hours)
20
+    .replace('mm', minutes)
21
+    .replace('ss', seconds);
22
+}
23
+
24
+// 获取当前时间戳
25
+export function getCurrentTimestamp() {
26
+  return Date.now();
27
+}
28
+
29
+// 获取指定日期的开始时间
30
+export function getStartOfDay(date) {
31
+  const d = new Date(date);
32
+  d.setHours(0, 0, 0, 0);
33
+  return d;
34
+}
35
+
36
+// 获取指定日期的结束时间
37
+export function getEndOfDay(date) {
38
+  const d = new Date(date);
39
+  d.setHours(23, 59, 59, 999);
40
+  return d;
41
+}
42
+
43
+// 计算两个日期之间的天数差
44
+export function getDaysDiff(date1, date2) {
45
+  const d1 = new Date(date1);
46
+  const d2 = new Date(date2);
47
+  const diffTime = Math.abs(d2 - d1);
48
+  return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
49
+}
50
+
51
+// 判断是否为同一天
52
+export function isSameDay(date1, date2) {
53
+  const d1 = new Date(date1);
54
+  const d2 = new Date(date2);
55
+  return (
56
+    d1.getFullYear() === d2.getFullYear() &&
57
+    d1.getMonth() === d2.getMonth() &&
58
+    d1.getDate() === d2.getDate()
59
+  );
60
+}

+ 35 - 13
src/components/Modal/index.jsx

@@ -1,26 +1,46 @@
1 1
 import { AtModal, AtModalContent } from "taro-ui";
2 2
 import { View, Image, Text } from "@tarojs/components";
3 3
 import { addLog } from "../../service";
4
+import { formatDate } from "../../common/time";
4 5
 import "./index.less";
5 6
 import Taro from "@tarojs/taro";
6 7
 import selectStep from "../../images/productDetail/selectStep.png";
7 8
 import xianyu from "../../images/productDetail/xianyu.png";
8 9
 import stepThree from "../../images/productDetail/stepThree.png";
9 10
 export default function Modal(props) {
10
-  const { productPromotion, isOpened, title, linkText } = props;
11
+  const { productPromotion, isOpened, title, linkText, id, shareUserId,isHighCommission,isSeckill } =
12
+    props;
11 13
   const handleCopyLink = () => {
12 14
     Taro.setClipboardData({
13 15
       data: productPromotion.short_tpwd,
14 16
     }).then(() => {
15 17
       Taro.showToast({
16
-        title: '口令已复制',
17
-        icon: 'success',
18
-      });
19
-      addLog({
20
-        log_type: 'click_to_purchase',
18
+        title: "口令已复制",
19
+        icon: "success",
21 20
       });
21
+      if (isHighCommission || isSeckill) {
22
+        const dayid = formatDate(new Date(), "YYYY-MM-DD");
23
+        let userId = "";
24
+        if (Taro.getStorageSync("loginInfo")) {
25
+          userId = Taro.getStorageSync("loginInfo").id;
26
+        }
27
+        let ext = "";
28
+        if (shareUserId) {
29
+          ext = JSON.stringify({
30
+            share_users_id: shareUserId,
31
+          });
32
+        }
33
+        addLog({
34
+          event_type: "buy_product_link",
35
+          event_type_title: "点击购买",
36
+          goods_id: Number(id),
37
+          ext,
38
+          dayid,
39
+          users_id: userId||0,
40
+        });
41
+      }
22 42
     });
23
-  }
43
+  };
24 44
   return (
25 45
     <AtModal isOpened={isOpened} closeOnClickOverlay={true}>
26 46
       <AtModalContent>
@@ -35,10 +55,8 @@ export default function Modal(props) {
35 55
                   <Text className="desc">点击复制口令</Text>
36 56
                 </View>
37 57
                 <View className="step-box">
38
-                    <View className="step-One">
39
-                        复制口令
40
-                    </View>
41
-                  <Image  className="step-img-one" src={selectStep} />
58
+                  <View className="step-One">复制口令</View>
59
+                  <Image className="step-img-one" src={selectStep} />
42 60
                 </View>
43 61
               </View>
44 62
               <View className="step-item">
@@ -57,13 +75,17 @@ export default function Modal(props) {
57 75
                   <Text className="desc">自动识别口令</Text>
58 76
                 </View>
59 77
                 <View className="step-box">
60
-                  <Image mode="heightFix" className="step-img-three" src={stepThree} />
78
+                  <Image
79
+                    mode="heightFix"
80
+                    className="step-img-three"
81
+                    src={stepThree}
82
+                  />
61 83
                 </View>
62 84
               </View>
63 85
             </View>
64 86
             {/* 复制口令 */}
65 87
             <View className="copy-link" onClick={handleCopyLink}>
66
-                复制口令
88
+              复制口令
67 89
             </View>
68 90
           </View>
69 91
         </View>

+ 31 - 3
src/components/index/ProductList/index.jsx

@@ -7,7 +7,8 @@ import React, {
7 7
 import { View, Text, Image, Button } from "@tarojs/components";
8 8
 import { AtCheckbox, AtActivityIndicator } from "taro-ui";
9 9
 import { setShareContent } from "../../../common/share";
10
-import { getShareJump } from "../../../service";
10
+import { formatDate } from "../../../common/time";
11
+import { getShareJump, addLog } from "../../../service";
11 12
 import Taro from "@tarojs/taro";
12 13
 import "./index.less";
13 14
 import ShareModal from "../../shareModal";
@@ -29,6 +30,7 @@ const ProductList = forwardRef((props, ref) => {
29 30
     onAddProduct, // 添加商品方法
30 31
     onDeleteProductSelect, // 删除商品选中id数组
31 32
     isNoMore, // 是否没有更多
33
+    shareUserId, // 分享用户id
32 34
   } = props;
33 35
 
34 36
   const [selectedProducts, setSelectedProducts] = useState([]); // 商品选择状态
@@ -64,7 +66,7 @@ const ProductList = forwardRef((props, ref) => {
64 66
       selectProduct(id);
65 67
     } else {
66 68
       Taro.navigateTo({
67
-        url: `/pages/indexSub/productDetail/index?id=${id}&&isHighCommission=${isHighCommission}&&isSeckill=${isSeckill}`,
69
+        url: `/pages/indexSub/productDetail/index?id=${id}&&isHighCommission=${isHighCommission}&&isSeckill=${isSeckill}&&shareUserId=${shareUserId}`,
68 70
       });
69 71
     }
70 72
   };
@@ -108,6 +110,22 @@ const ProductList = forwardRef((props, ref) => {
108 110
       });
109 111
     }
110 112
   }, [shareTitle]);
113
+  // 埋点
114
+  const handleLog = (id) => {
115
+    const dayid = formatDate(new Date(), "YYYY-MM-DD");
116
+    let userId = "";
117
+    if (Taro.getStorageSync("loginInfo")) {
118
+      userId = Taro.getStorageSync("loginInfo").id;
119
+    }
120
+    addLog({
121
+      event_type: "share_product_link",
122
+      event_type_title: "点击分享赚",
123
+      goods_id: Number(id),
124
+      ext: "",
125
+      dayid,
126
+      users_id: userId,
127
+    });
128
+  };
111 129
   // 分享商品
112 130
   const shareProduct = (product, e) => {
113 131
     e.stopPropagation(); // 防止事件穿透
@@ -117,15 +135,24 @@ const ProductList = forwardRef((props, ref) => {
117 135
       share_id: product.id,
118 136
     }).then((res) => {
119 137
       // 打开分享弹窗
138
+      let shareUserId = "";
139
+      if (Taro.getStorageSync("loginInfo")) {
140
+        shareUserId = Taro.getStorageSync("loginInfo").id;
141
+      }
120 142
       setShareContent({
121 143
         title: shareTitle || product.item_title,
122 144
         path: `/pages/indexSub/productDetail/index?id=${
123 145
           product.id
124
-        }&&isShare=${true}&&shareJump=${res.share_unique_value}`,
146
+        }&&isShare=${true}&&shareJump=${
147
+          res.share_unique_value
148
+        }&&isHighCommission=${isHighCommission}&&isSeckill=${isSeckill}&&shareUserId=${shareUserId}`,
125 149
         imageUrl: product.image_url,
126 150
       });
127 151
       setShareLink(res.share_unique_value);
128 152
       setShareModalOpened(true);
153
+      if (isHighCommission || isSeckill) {
154
+        handleLog(product.id);
155
+      }
129 156
     });
130 157
   };
131 158
   return (
@@ -265,6 +292,7 @@ ProductList.defaultProps = {
265 292
   isProductClassify: false,
266 293
   isSelectAll: false,
267 294
   isNoMore: false,
295
+  shareUserId: "",
268 296
   onAddProduct: () => {}, // 添加商品方法
269 297
   onDeleteProductSelect: () => {}, // 删除商品选中id数组
270 298
 };

+ 3 - 1
src/pages/index/index.jsx

@@ -66,8 +66,10 @@ export default class Index extends Component {
66 66
               Taro.pageScrollTo({
67 67
                 scrollTop: top - 40,
68 68
                 duration: 300,
69
+                complete:()=>{
70
+                  this.getProductList(true);
71
+                }
69 72
               });
70
-              this.getProductList(true);
71 73
             } else {
72 74
               console.warn("未找到 .product-list-wrap 元素");
73 75
             }

+ 59 - 16
src/pages/indexSub/highCommission/index.jsx

@@ -6,6 +6,7 @@ import seckillImg from "../../../images/seckill/heighTop.jpg";
6 6
 import ProductList from "../../../components/index/ProductList";
7 7
 import { getRecommendProductList, addLog } from "../../../service";
8 8
 import { getShareContent } from "../../../common/share";
9
+import { formatDate } from "../../../common/time";
9 10
 export default class Index extends Component {
10 11
   state = {
11 12
     productList: [], //推荐商品列表
@@ -16,17 +17,30 @@ export default class Index extends Component {
16 17
     isDirect: false, // 是否直接跳转
17 18
     isBanner: false, // 是否是banner跳转
18 19
     isShare: false, // 是否是分享跳转
20
+    shareUserId: "", // 分享用户id
19 21
   };
20 22
   componentDidMount() {
21
-    const { isDirect, isBanner, isShare } =
22
-    Taro.getCurrentInstance().router.params || "";
23
-    this.setState({
24
-      isDirect: isDirect || false,
25
-      isBanner: isBanner || false,
26
-      isShare: isShare || false,
27
-    },()=>{
28
-      this.handleLog(isDirect?'direct_to_fish_seckill':isBanner?'banner_to_fish_seckill':isShare?'share_to_fish_seckill':'direct_to_fish_seckill');
29
-    });
23
+    const { isDirect, isBanner, isShare, shareUserId } =
24
+      Taro.getCurrentInstance().router.params || "";
25
+    this.setState(
26
+      {
27
+        isDirect: isDirect || false,
28
+        isBanner: isBanner || false,
29
+        isShare: isShare || false,
30
+        shareUserId: shareUserId || "",
31
+      },
32
+      () => {
33
+        this.handleLog(
34
+          isDirect
35
+            ? "direct_to_high_commission"
36
+            : isBanner
37
+            ? "banner_to_high_commission"
38
+            : isShare
39
+            ? "share_to_high_commission"
40
+            : "direct_to_high_commission"
41
+        );
42
+      }
43
+    );
30 44
     this.getRecommendProductList();
31 45
   }
32 46
   // 获取推荐商品列表
@@ -48,20 +62,48 @@ export default class Index extends Component {
48 62
     }));
49 63
   };
50 64
   // 埋点
51
-  handleLog = (type) => {
52
-    console.log('type',type);
53
-    // addLog({
54
-    //   log_type: type,
55
-    // });
65
+  handleLog = (event_type) => {
66
+    const dayid = formatDate(new Date(), "YYYY-MM-DD");
67
+    const event_type_title =
68
+      event_type == "banner_to_high_commission"
69
+        ? "从 banner 跳转到高佣专项"
70
+        : event_type == "share_to_high_commission"
71
+        ? "从分享链接跳转到高佣专项"
72
+        : event_type == "direct_to_high_commission"
73
+        ? "直接点击进入高佣专项"
74
+        : "直接点击进入高佣专项";
75
+    let userId = "";
76
+    if (Taro.getStorageSync("loginInfo")) {
77
+      userId = Taro.getStorageSync("loginInfo").id;
78
+    }
79
+    // 构建ext对象,包含share_id
80
+    let ext = "";
81
+    if (this.state.shareUserId) {
82
+      ext = JSON.stringify({
83
+        share_users_id: this.state.shareUserId,
84
+      });
85
+    }
86
+    addLog({
87
+      users_id: userId||0,
88
+      goods_id: 0,
89
+      event_type_title,
90
+      event_type,
91
+      dayid,
92
+      ext,
93
+    });
56 94
   };
57 95
   // 配置分享内容
58 96
   onShareAppMessage() {
97
+    let shareUserId = "";
98
+    if (Taro.getStorageSync("loginInfo")) {
99
+      shareUserId = Taro.getStorageSync("loginInfo").id;
100
+    }
59 101
     const shareConfig = getShareContent();
60 102
     if (shareConfig.title == "默认分享标题") {
61 103
       return {
62 104
         title: "高佣专项",
63
-        path: "/pages/indexSub/highCommission/index?isShare=true",
64
-        imageUrl: '',
105
+        path: `/pages/indexSub/highCommission/index?isShare=true&shareUserId=${shareUserId}`,
106
+        imageUrl: "",
65 107
       };
66 108
     } else {
67 109
       return getShareContent();
@@ -88,6 +130,7 @@ export default class Index extends Component {
88 130
             productList={this.state.productList}
89 131
             loading={this.state.loading}
90 132
             isNoMore={this.state.isNoMore}
133
+            shareUserId={this.state.shareUserId}
91 134
           />
92 135
         </View>
93 136
       </View>

+ 56 - 21
src/pages/indexSub/productDetail/index.jsx

@@ -9,6 +9,7 @@ import {
9 9
   bindShareJump,
10 10
   addLog,
11 11
 } from "../../../service";
12
+import { formatDate } from "../../../common/time";
12 13
 import "./index.less";
13 14
 import Taro from "@tarojs/taro";
14 15
 import productDetailIcon from "../../../images/productDetail/productDetailIcon.png";
@@ -31,6 +32,7 @@ export default class Index extends Component {
31 32
     isSeckill: false, //是否是秒杀页面
32 33
     shareJump: "", //分享跳转标识
33 34
     shareTitle: "", //分享标题
35
+    shareUserId: "", //分享用户id
34 36
   };
35 37
   // 获取产品详情的方法
36 38
   fetchProductDetails = async (id) => {
@@ -64,7 +66,7 @@ export default class Index extends Component {
64 66
     Taro.hideShareMenu({
65 67
       menus: ["shareAppMessage", "shareTimeline"],
66 68
     });
67
-    const { id, isShare, isHighCommission, isSeckill, shareJump } =
69
+    const { id, isShare, isHighCommission, isSeckill, shareJump, shareUserId } =
68 70
       Taro.getCurrentInstance().router.params;
69 71
     this.setState(
70 72
       {
@@ -72,6 +74,7 @@ export default class Index extends Component {
72 74
         isShare,
73 75
         isHighCommission: isHighCommission === "true",
74 76
         isSeckill: isSeckill === "true",
77
+        shareUserId: shareUserId,
75 78
       },
76 79
       () => {
77 80
         // 获取分享跳转标识
@@ -86,9 +89,11 @@ export default class Index extends Component {
86 89
         if (session_key && shareJump) {
87 90
           this.bindShareJump(); //绑定分享跳转标识
88 91
         }
92
+        if (this.state.isHighCommission || this.state.isSeckill) {
93
+          this.handleLog("direct_to_product"); //埋点
94
+        }
89 95
       }
90 96
     );
91
-    this.handleLog("enter_product_detail"); //埋点
92 97
   }
93 98
   // 复制商品编号
94 99
   handleCopy = (text) => {
@@ -119,7 +124,37 @@ export default class Index extends Component {
119 124
       isOpened: "self",
120 125
     });
121 126
   };
122
-
127
+  // 埋点
128
+  handleLog = (event_type) => {
129
+    if (this.state.isHighCommission || this.state.isSeckill) {
130
+      const dayid = formatDate(new Date(), "YYYY-MM-DD");
131
+      const event_type_title =
132
+        event_type == "share_product_link"
133
+          ? "点击分享赚"
134
+          : event_type == "direct_to_product"
135
+          ? "进入商品详情页"
136
+          : "进入商品详情页";
137
+      let userId = "";
138
+      if (Taro.getStorageSync("loginInfo")) {
139
+        userId = Taro.getStorageSync("loginInfo").id;
140
+      }
141
+      // 构建ext对象,包含share_id
142
+      let ext = "";
143
+      if (this.state.shareUserId) {
144
+        ext = JSON.stringify({
145
+          share_users_id: this.state.shareUserId,
146
+        });
147
+      }
148
+      addLog({
149
+        users_id: userId || 0,
150
+        goods_id: Number(this.state.id),
151
+        event_type_title,
152
+        event_type,
153
+        dayid,
154
+        ext,
155
+      });
156
+    }
157
+  };
123 158
   // 分享
124 159
   openSharePopup = async () => {
125 160
     const res = await getShareJump({
@@ -130,7 +165,7 @@ export default class Index extends Component {
130 165
       shareJump: res.share_unique_value,
131 166
       isOpened: "share",
132 167
     });
133
-    this.handleLog("click_share_earn"); //埋点
168
+    this.handleLog("share_product_link"); //埋点
134 169
   };
135 170
   // 绑定分享跳转标识
136 171
   bindShareJump = async () => {
@@ -166,12 +201,6 @@ export default class Index extends Component {
166 201
       });
167 202
     }
168 203
   };
169
-  // 埋点
170
-  handleLog = (type) => {
171
-    // addLog({
172
-    //   log_type: type,
173
-    // });
174
-  };
175 204
   render() {
176 205
     const { productDetail } = this.state;
177 206
     return (
@@ -312,19 +341,25 @@ export default class Index extends Component {
312 341
           isOpened={this.state.isOpened == "self"}
313 342
           productPromotion={this.state.productPromotion}
314 343
           linkText={this.state.productPromotion.short_tpwd}
344
+          id={this.state.id}
345
+          shareUserId={this.state.shareUserId}
346
+          isHighCommission={this.state.isHighCommission}
347
+          isSeckill={this.state.isSeckill}
315 348
         />
316 349
         {/* 分享弹窗 */}
317
-        <ShareModal
318
-          onClose={() => {
319
-            this.setState({
320
-              isOpened: "",
321
-              shareTitle: productDetail.item_title,
322
-            });
323
-          }}
324
-          isOpened={this.state.isOpened == "share"}
325
-          product={this.state.productDetail}
326
-          onShareTitleChange={this.handleShareTitleChange}
327
-        />
350
+        {this.state.isOpened == "share" && (
351
+          <ShareModal
352
+            onClose={() => {
353
+              this.setState({
354
+                isOpened: "",
355
+                shareTitle: productDetail.item_title,
356
+              });
357
+            }}
358
+            isOpened={this.state.isOpened == "share"}
359
+            product={this.state.productDetail}
360
+            onShareTitleChange={this.handleShareTitleChange}
361
+          />
362
+        )}
328 363
       </View>
329 364
     );
330 365
   }

+ 38 - 14
src/pages/indexSub/seckillIndex/index.jsx

@@ -5,6 +5,7 @@ import Taro from "@tarojs/taro";
5 5
 import seckillImg from "../../../images/seckill/seckillTop.jpg";
6 6
 import ProductList from "../../../components/index/ProductList";
7 7
 import { getRecommendProductList, addLog } from "../../../service";
8
+import { formatDate } from "../../../common/time";
8 9
 import { getShareContent } from "../../../common/share";
9 10
 export default class Index extends Component {
10 11
   state = {
@@ -16,17 +17,17 @@ export default class Index extends Component {
16 17
     isDirect: false, // 是否直接跳转
17 18
     isBanner: false, // 是否是banner跳转
18 19
     isShare: false, // 是否是分享跳转
19
-    userId: "", // 用户id
20
+    shareUserId: "", // 分享用户id
20 21
   };
21 22
   componentDidMount() {
22
-    const { isDirect, isBanner, isShare, userId } =
23
+    const { isDirect, isBanner, isShare, shareUserId } =
23 24
       Taro.getCurrentInstance().router.params || "";
24 25
     this.setState(
25 26
       {
26 27
         isDirect: isDirect || false,
27 28
         isBanner: isBanner || false,
28 29
         isShare: isShare || false,
29
-        userId: userId || "",
30
+        shareUserId: shareUserId || "",
30 31
       },
31 32
       () => {
32 33
         this.handleLog(
@@ -61,25 +62,47 @@ export default class Index extends Component {
61 62
     }));
62 63
   };
63 64
   // 埋点
64
-  handleLog = (type) => {
65
-    console.log("type", type);
66
-
67
-    // addLog({
68
-    //   log_type: type,
69
-    // });
65
+  handleLog = (event_type) => {
66
+    const dayid = formatDate(new Date(), "YYYY-MM-DD");
67
+    const event_type_title =
68
+      event_type == "banner_to_fish_seckill"
69
+        ? "从banner 跳转到鱼市秒杀"
70
+        : event_type == "share_to_fish_seckill"
71
+        ? "从分享链接跳转到鱼市秒杀"
72
+        : event_type == "direct_to_fish_seckill"
73
+        ? "直接点击进入鱼市秒杀"
74
+        : "直接点击进入鱼市秒杀";
75
+    let userId = "";
76
+    if (Taro.getStorageSync("loginInfo")) {
77
+      userId = Taro.getStorageSync("loginInfo").id;
78
+    }
79
+    // 构建ext对象,包含share_id
80
+    let ext = "";
81
+    if (this.state.shareUserId) {
82
+      ext = JSON.stringify({
83
+        share_users_id: this.state.shareUserId,
84
+      });
85
+    }
86
+    addLog({
87
+      users_id: userId||0,
88
+      goods_id: 0,
89
+      event_type_title,
90
+      event_type,
91
+      dayid,
92
+      ext,
93
+    });
70 94
   };
71 95
   // 配置分享内容
72 96
   onShareAppMessage() {
73
-    const loginInfo = Taro.getStorageSync("loginInfo");
74
-    let userId = "";
75
-    if (loginInfo) {
76
-      userId = loginInfo.id;
97
+    let shareUserId = "";
98
+    if (Taro.getStorageSync("loginInfo")) {
99
+      shareUserId = Taro.getStorageSync("loginInfo").id;
77 100
     }
78 101
     const shareConfig = getShareContent();
79 102
     if (shareConfig.title == "默认分享标题") {
80 103
       return {
81 104
         title: "鱼市秒杀",
82
-        path: `/pages/indexSub/seckillIndex/index?isShare=true&userId=${userId}`,
105
+        path: `/pages/indexSub/seckillIndex/index?isShare=true&shareUserId=${shareUserId}`,
83 106
         imageUrl: "",
84 107
       };
85 108
     } else {
@@ -107,6 +130,7 @@ export default class Index extends Component {
107 130
             productList={this.state.productList}
108 131
             loading={this.state.loading}
109 132
             isNoMore={this.state.isNoMore}
133
+            shareUserId={this.state.shareUserId}
110 134
           />
111 135
         </View>
112 136
       </View>

+ 62 - 4
src/pages/memberSub/partnerDetail/index.jsx

@@ -1,8 +1,9 @@
1 1
 import { Component } from "react";
2 2
 import { View, Text, Image } from "@tarojs/components";
3 3
 import "./index.less";
4
-import { AtDivider } from "taro-ui";
4
+import { AtDivider,AtActivityIndicator } from "taro-ui";
5 5
 import level from "../../../images/partner/level.png";
6
+import Taro from "@tarojs/taro";
6 7
 import vip from "../../../images/earningsOrder/vip.png";
7 8
 export default class Index extends Component {
8 9
   state = {
@@ -32,6 +33,32 @@ export default class Index extends Component {
32 33
         actual_paid_fee: "358.00",
33 34
       },
34 35
     ],
36
+    page: 1, //页数
37
+    loading: false, //加载状态
38
+    totalPages: 1, // 添加总页数
39
+    isNoMore: false,
40
+  };
41
+  componentDidMount() {
42
+    // this.getOrderList();
43
+  }
44
+  // 获取收益订单列表
45
+  getOrderList = async (isRefresh) => {
46
+    const { page } = this.state;
47
+    this.setState({ loading: true });
48
+
49
+    const res = await getEarningsOrderList({
50
+      page,
51
+      page_size: 10,
52
+    });
53
+
54
+    this.setState((prevState) => ({
55
+      orderList: isRefresh
56
+        ? res.income_list
57
+        : [...prevState.orderList, ...res.income_list],
58
+      totalPages: res.total_pages,
59
+      loading: false,
60
+      isNoMore: res.total_pages <= page,
61
+    }));
35 62
   };
36 63
   // 复制
37 64
   handleCopy = async (text) => {
@@ -52,8 +79,18 @@ export default class Index extends Component {
52 79
       });
53 80
     }
54 81
   };
82
+  // 页面上拉触底
83
+  onReachBottom = () => {
84
+    const { page, totalPages, loading } = this.state;
85
+    if (page < totalPages && !loading) {
86
+      this.setState(
87
+        (prevState) => ({ page: prevState.page + 1 }),
88
+        () => this.getOrderList()
89
+      );
90
+    }
91
+  };
55 92
   render() {
56
-    const { orderList } = this.state;
93
+    const { orderList,loading,isNoMore } = this.state;
57 94
     return (
58 95
       <View className="index">
59 96
         <View className="container">
@@ -151,8 +188,29 @@ export default class Index extends Component {
151 188
             <AtDivider
152 189
               content="暂无成交订单"
153 190
               fontColor="#B5B5B5"
154
-            lineColor="#D8D8D8"
155
-          />
191
+              lineColor="#D8D8D8"
192
+            />
193
+          )}
194
+          {/* 加载中 */}
195
+          {loading && (
196
+            <View className="loading">
197
+              <AtActivityIndicator
198
+                content="加载中..."
199
+                isOpened={loading}
200
+                mode="center"
201
+                color="#fdf764"
202
+              />
203
+            </View>
204
+          )}
205
+          {/* 没有更多 */}
206
+          {isNoMore && (
207
+            <View className="no-more">
208
+              <AtDivider
209
+                fontSize={18}
210
+                fontColor="#949494"
211
+                content="我是有底线的"
212
+              />
213
+            </View>
156 214
           )}
157 215
         </View>
158 216
       </View>

+ 20 - 0
src/pages/memberSub/partnerDetail/index.less

@@ -116,6 +116,7 @@
116 116
         // 订单列表样式
117 117
         .order-list {
118 118
             margin-top: 24px;
119
+
119 120
             .at-divider {
120 121
                 height: 0;
121 122
                 margin-bottom: 18px;
@@ -129,9 +130,11 @@
129 130
                 box-sizing: border-box;
130 131
                 border-radius: 20px 20px 20px 20px;
131 132
                 box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.1);
133
+
132 134
                 &:last-child {
133 135
                     margin-bottom: 0;
134 136
                 }
137
+
135 138
                 .order-info {
136 139
                     display: flex;
137 140
                     justify-content: space-between;
@@ -272,4 +275,21 @@
272 275
             font-size: 22px;
273 276
         }
274 277
     }
278
+
279
+    // 加载中
280
+    .loading {
281
+        width: 100%;
282
+        position: relative;
283
+        height: 60px;
284
+    }
285
+
286
+    // 没有更多
287
+    .no-more {
288
+        padding: 0 33px;
289
+        box-sizing: border-box;
290
+
291
+        .at-divider__content {
292
+            background-color: #f9f9f9;
293
+        }
294
+    }
275 295
 }

+ 0 - 1
src/pages/memberSub/productClassify/index.jsx

@@ -98,7 +98,6 @@ export default class Index extends Component {
98 98
   onReachBottom = () => {
99 99
     const { page, totalPages, loading } = this.state;
100 100
     if (page < totalPages && !loading) {
101
-      console.log("触底了");
102 101
       this.setState(
103 102
         (prevState) => ({ page: prevState.page + 1 }),
104 103
         () => this.getBrowseShopProductList()

+ 1 - 6
src/pages/mine/index.jsx

@@ -32,14 +32,9 @@ export default class Index extends Component {
32 32
     });
33 33
   };
34 34
   componentDidShow(){
35
-    const userInfo = Taro.getStorageSync('userInfo')
36 35
     const session_key = Taro.getStorageSync('session_key')
37
-    if(!userInfo&&session_key){
36
+    if(session_key){
38 37
       this.getUserInfo()
39
-    }else{
40
-      this.setState({
41
-        userInfo: userInfo||{},
42
-      })
43 38
     }
44 39
   }
45 40
   // 获取用户信息

+ 8 - 1
src/pages/mineSub/infoEdit/index.jsx

@@ -77,7 +77,14 @@ export default class Index extends Component {
77 77
     });
78 78
     Taro.showToast({
79 79
       title: '修改成功',
80
-      icon: "none",
80
+      icon: 'none',
81
+      duration: 1000, // 显示持续时间,单位毫秒
82
+      success: () => {
83
+        // 等待 toast 显示完成后再返回上一页
84
+        setTimeout(() => {
85
+          Taro.navigateBack();
86
+        }, 1000);
87
+      }
81 88
     });
82 89
   };
83 90
   render() {

+ 1 - 1
src/service/index.js

@@ -190,7 +190,7 @@ export const login = data =>
190 190
   // 埋点
191 191
   export const addLog = data =>
192 192
   Request({
193
-    url: '/log/add_log',
193
+    url: '/user/user_goods_statistics',
194 194
     method: 'POST',
195 195
     data,
196 196
   })