Browse Source

埋点防抖

cnyuhao 1 month ago
parent
commit
04207ed03f

+ 7 - 0
project.private.config.json

@@ -127,6 +127,13 @@
127
           "query": "",
127
           "query": "",
128
           "launchMode": "default",
128
           "launchMode": "default",
129
           "scene": null
129
           "scene": null
130
+        },
131
+        {
132
+          "name": "",
133
+          "pathName": "pages/memberSub/myPartner/index",
134
+          "query": "",
135
+          "launchMode": "default",
136
+          "scene": null
130
         }
137
         }
131
       ]
138
       ]
132
     }
139
     }

+ 9 - 0
src/common/debounce.js

@@ -0,0 +1,9 @@
1
+let lastTime = 0;
2
+export function isDebounce(delay = 300) {
3
+  const now = Date.now();
4
+  if (now - lastTime < delay) {
5
+    return false;
6
+  }
7
+  lastTime = now;
8
+  return true;
9
+}

+ 2 - 0
src/components/Modal/index.jsx

@@ -2,6 +2,7 @@ import { AtModal, AtModalContent } from "taro-ui";
2
 import { View, Image, Text } from "@tarojs/components";
2
 import { View, Image, Text } from "@tarojs/components";
3
 import { addLog } from "../../service";
3
 import { addLog } from "../../service";
4
 import { formatDate } from "../../common/time";
4
 import { formatDate } from "../../common/time";
5
+import { isDebounce } from "../../common/debounce";
5
 import "./index.less";
6
 import "./index.less";
6
 import Taro from "@tarojs/taro";
7
 import Taro from "@tarojs/taro";
7
 import selectStep from "../../images/productDetail/selectStep.png";
8
 import selectStep from "../../images/productDetail/selectStep.png";
@@ -11,6 +12,7 @@ export default function Modal(props) {
11
   const { productPromotion, isOpened, title, linkText, id, shareUserId,isHighCommission,isSeckill } =
12
   const { productPromotion, isOpened, title, linkText, id, shareUserId,isHighCommission,isSeckill } =
12
     props;
13
     props;
13
   const handleCopyLink = () => {
14
   const handleCopyLink = () => {
15
+    if (!isDebounce(500)) return; // 如果在300ms内重复触发,直接返回
14
     Taro.setClipboardData({
16
     Taro.setClipboardData({
15
       data: productPromotion.short_tpwd,
17
       data: productPromotion.short_tpwd,
16
     }).then(() => {
18
     }).then(() => {

+ 2 - 0
src/components/index/ProductList/index.jsx

@@ -17,6 +17,7 @@ import joinStoreAc from "../../../images/index/joinStoreAc.png";
17
 import saveMoneyBg from "../../../images/index/save-money.png";
17
 import saveMoneyBg from "../../../images/index/save-money.png";
18
 import shareEarnBg from "../../../images/index/share-earn.png";
18
 import shareEarnBg from "../../../images/index/share-earn.png";
19
 import seckillIcon from "../../../images/seckill/seckillIcon.png";
19
 import seckillIcon from "../../../images/seckill/seckillIcon.png";
20
+import { isDebounce } from '../../../common/debounce';
20
 const ProductList = forwardRef((props, ref) => {
21
 const ProductList = forwardRef((props, ref) => {
21
   const {
22
   const {
22
     productList, // 商品列表数据
23
     productList, // 商品列表数据
@@ -112,6 +113,7 @@ const ProductList = forwardRef((props, ref) => {
112
   }, [shareTitle]);
113
   }, [shareTitle]);
113
   // 埋点
114
   // 埋点
114
   const handleLog = (id) => {
115
   const handleLog = (id) => {
116
+    if (!isDebounce(500)) return; // 如果在300ms内重复触发,直接返回
115
     const dayid = formatDate(new Date(), "YYYY-MM-DD");
117
     const dayid = formatDate(new Date(), "YYYY-MM-DD");
116
     let userId = "";
118
     let userId = "";
117
     if (Taro.getStorageSync("loginInfo")) {
119
     if (Taro.getStorageSync("loginInfo")) {

+ 2 - 0
src/pages/indexSub/productDetail/index.jsx

@@ -10,6 +10,7 @@ import {
10
   addLog,
10
   addLog,
11
 } from "../../../service";
11
 } from "../../../service";
12
 import { formatDate } from "../../../common/time";
12
 import { formatDate } from "../../../common/time";
13
+import { isDebounce } from "../../../common/debounce";
13
 import "./index.less";
14
 import "./index.less";
14
 import Taro from "@tarojs/taro";
15
 import Taro from "@tarojs/taro";
15
 import productDetailIcon from "../../../images/productDetail/productDetailIcon.png";
16
 import productDetailIcon from "../../../images/productDetail/productDetailIcon.png";
@@ -126,6 +127,7 @@ export default class Index extends Component {
126
   };
127
   };
127
   // 埋点
128
   // 埋点
128
   handleLog = (event_type) => {
129
   handleLog = (event_type) => {
130
+    if (!isDebounce(500)) return; // 如果在300ms内重复触发,直接返回
129
     if (this.state.isHighCommission || this.state.isSeckill) {
131
     if (this.state.isHighCommission || this.state.isSeckill) {
130
       const dayid = formatDate(new Date(), "YYYY-MM-DD");
132
       const dayid = formatDate(new Date(), "YYYY-MM-DD");
131
       const event_type_title =
133
       const event_type_title =

+ 2 - 1
src/pages/member/index.jsx

@@ -18,6 +18,7 @@ export default class Index extends Component {
18
       users: { name: "去登录", icon: avatar },
18
       users: { name: "去登录", icon: avatar },
19
       earnings: { store_earnings_now: 0, store_earnings_all: 0 },
19
       earnings: { store_earnings_now: 0, store_earnings_all: 0 },
20
       draw_money: { store_earnings_now: 0 },
20
       draw_money: { store_earnings_now: 0 },
21
+      partner: { partner_direct_cnt: 0},
21
       order: { order_all: 0, order_promotion: 0, order_pay: 0, unissued_order_cnt: 0, on_arrival_order_cnt: 0, dead_order_cnt: 0 },
22
       order: { order_all: 0, order_promotion: 0, order_pay: 0, unissued_order_cnt: 0, on_arrival_order_cnt: 0, dead_order_cnt: 0 },
22
     }, //会员信息
23
     }, //会员信息
23
   };
24
   };
@@ -142,7 +143,7 @@ export default class Index extends Component {
142
             <View className="my-partner-content">
143
             <View className="my-partner-content">
143
               <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/myPartner/index` })} className="my-partner-item">
144
               <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/myPartner/index` })} className="my-partner-item">
144
                 <Text className="label">直接伙伴</Text>
145
                 <Text className="label">直接伙伴</Text>
145
-                <Text className="number">{vipInfo.partner?.direct_partner || 0}</Text>
146
+                <Text className="number">{vipInfo.partner?.partner_direct_cnt || 0}</Text>
146
               </View>
147
               </View>
147
               {/* <View className="my-partner-item">
148
               {/* <View className="my-partner-item">
148
                 <Text className="label">间接伙伴</Text>
149
                 <Text className="label">间接伙伴</Text>

+ 16 - 3
src/pages/memberSub/myPartner/index.jsx

@@ -2,11 +2,23 @@ import { Component } from "react";
2
 import { View, Text, Image } from "@tarojs/components";
2
 import { View, Text, Image } from "@tarojs/components";
3
 import level from "../../../images/partner/level.png";
3
 import level from "../../../images/partner/level.png";
4
 import { AtIcon } from "taro-ui";
4
 import { AtIcon } from "taro-ui";
5
+import { getMyPartnerList } from "../../../service";
5
 import "./index.less";
6
 import "./index.less";
6
 import Taro from "@tarojs/taro";
7
 import Taro from "@tarojs/taro";
7
 export default class Index extends Component {
8
 export default class Index extends Component {
8
-  state = {};
9
-
9
+  state = {
10
+    partnerList: [],
11
+  };
12
+  componentDidMount() {
13
+    this.getPartnerList(); // 获取我的伙伴列表
14
+  }
15
+  // 获取我的伙伴列表
16
+  getPartnerList = async () => {
17
+    const res = await getMyPartnerList();
18
+    this.setState({
19
+      partnerList: res,
20
+    });
21
+  }
10
   copyPhone = (phone) => {
22
   copyPhone = (phone) => {
11
     Taro.setClipboardData({
23
     Taro.setClipboardData({
12
       data: phone,
24
       data: phone,
@@ -21,12 +33,13 @@ export default class Index extends Component {
21
   }
33
   }
22
 
34
 
23
   render() {
35
   render() {
36
+    const { partnerList } = this.state;
24
     return (
37
     return (
25
       <View className="index">
38
       <View className="index">
26
         <View className="header"></View>
39
         <View className="header"></View>
27
         <View className="partner-number">
40
         <View className="partner-number">
28
           <Text className="partner-number-title">我的伙伴</Text>
41
           <Text className="partner-number-title">我的伙伴</Text>
29
-          <Text className="partner-number-count">0</Text>
42
+            <Text className="partner-number-count">{partnerList.all_partner_cnt}</Text>
30
         </View>
43
         </View>
31
         <View className="partner-list">
44
         <View className="partner-list">
32
           <View className="partner-item">
45
           <View className="partner-item">

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

@@ -5,6 +5,7 @@ import { AtDivider,AtActivityIndicator } from "taro-ui";
5
 import level from "../../../images/partner/level.png";
5
 import level from "../../../images/partner/level.png";
6
 import Taro from "@tarojs/taro";
6
 import Taro from "@tarojs/taro";
7
 import vip from "../../../images/earningsOrder/vip.png";
7
 import vip from "../../../images/earningsOrder/vip.png";
8
+import { getPartnerDetail } from "../../../service";
8
 export default class Index extends Component {
9
 export default class Index extends Component {
9
   state = {
10
   state = {
10
     orderList: [
11
     orderList: [
@@ -39,14 +40,14 @@ export default class Index extends Component {
39
     isNoMore: false,
40
     isNoMore: false,
40
   };
41
   };
41
   componentDidMount() {
42
   componentDidMount() {
42
-    // this.getOrderList();
43
+    this.getPartnerDetail(true);
43
   }
44
   }
44
   // 获取收益订单列表
45
   // 获取收益订单列表
45
-  getOrderList = async (isRefresh) => {
46
+  getPartnerDetail = async (isRefresh=false) => {
46
     const { page } = this.state;
47
     const { page } = this.state;
47
     this.setState({ loading: true });
48
     this.setState({ loading: true });
48
 
49
 
49
-    const res = await getEarningsOrderList({
50
+    const res = await getPartnerDetail({
50
       page,
51
       page,
51
       page_size: 10,
52
       page_size: 10,
52
     });
53
     });
@@ -85,7 +86,7 @@ export default class Index extends Component {
85
     if (page < totalPages && !loading) {
86
     if (page < totalPages && !loading) {
86
       this.setState(
87
       this.setState(
87
         (prevState) => ({ page: prevState.page + 1 }),
88
         (prevState) => ({ page: prevState.page + 1 }),
88
-        () => this.getOrderList()
89
+        () => this.getPartnerDetail()
89
       );
90
       );
90
     }
91
     }
91
   };
92
   };

+ 14 - 0
src/service/index.js

@@ -178,6 +178,20 @@ export const updateProductSort = data =>
178
     method: 'POST',
178
     method: 'POST',
179
     data,
179
     data,
180
   })
180
   })
181
+  // 获取我的伙伴信息列表
182
+  export const getMyPartnerList = data =>
183
+  Request({
184
+    url: '/vip/get_user_partner_list',
185
+    method: 'POST',
186
+    data,
187
+  })
188
+  // 获取伙伴详情
189
+  export const getPartnerDetail = data =>
190
+  Request({
191
+    url: '/vip/get_user_partner_detail',
192
+    method: 'POST',
193
+    data,
194
+  })
181
 // -----------------------------------------登录
195
 // -----------------------------------------登录
182
 // 登录
196
 // 登录
183
 export const login = data =>
197
 export const login = data =>