Browse Source

埋点防抖

cnyuhao 4 weeks ago
parent
commit
04207ed03f

+ 7 - 0
project.private.config.json

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

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

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

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

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

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

@@ -18,6 +18,7 @@ export default class Index extends Component {
18 18
       users: { name: "去登录", icon: avatar },
19 19
       earnings: { store_earnings_now: 0, store_earnings_all: 0 },
20 20
       draw_money: { store_earnings_now: 0 },
21
+      partner: { partner_direct_cnt: 0},
21 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 143
             <View className="my-partner-content">
143 144
               <View onClick={() => Taro.navigateTo({ url: `/pages/memberSub/myPartner/index` })} className="my-partner-item">
144 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 147
               </View>
147 148
               {/* <View className="my-partner-item">
148 149
                 <Text className="label">间接伙伴</Text>

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

@@ -2,11 +2,23 @@ import { Component } from "react";
2 2
 import { View, Text, Image } from "@tarojs/components";
3 3
 import level from "../../../images/partner/level.png";
4 4
 import { AtIcon } from "taro-ui";
5
+import { getMyPartnerList } from "../../../service";
5 6
 import "./index.less";
6 7
 import Taro from "@tarojs/taro";
7 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 22
   copyPhone = (phone) => {
11 23
     Taro.setClipboardData({
12 24
       data: phone,
@@ -21,12 +33,13 @@ export default class Index extends Component {
21 33
   }
22 34
 
23 35
   render() {
36
+    const { partnerList } = this.state;
24 37
     return (
25 38
       <View className="index">
26 39
         <View className="header"></View>
27 40
         <View className="partner-number">
28 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 43
         </View>
31 44
         <View className="partner-list">
32 45
           <View className="partner-item">

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

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