Selaa lähdekoodia

专项&&我的小店分享绑定

viczhq 1 kuukausi sitten
vanhempi
commit
b02be8baa9

+ 11 - 9
src/api/request.js

@@ -37,16 +37,18 @@ export default async (options = { method: 'GET', data: {} }) => {
37 37
       },
38 38
       method: options.method.toUpperCase(),
39 39
     });
40
-    const { code,data, msg } = res.data;
40
+    const { code, data, msg } = res.data;
41 41
     switch (code) {
42 42
       case 200:
43 43
         return data;
44 44
       case 400:
45
-        Taro.showToast({
46
-          title: msg,
47
-          icon: 'none',
48
-          mask: true,
49
-        });
45
+        if (msg) {
46
+          Taro.showToast({
47
+            title: msg,
48
+            icon: 'none',
49
+            mask: true,
50
+          });
51
+        }
50 52
         return Promise.reject(msg);
51 53
       case 422:
52 54
         return Promise.reject(msg);
@@ -56,7 +58,7 @@ export default async (options = { method: 'GET', data: {} }) => {
56 58
           icon: 'none',
57 59
           mask: true,
58 60
         });
59
-        
61
+
60 62
         // 获取当前跳转到登录的页面路径
61 63
         const currentPages = Taro.getCurrentPages();
62 64
         const currentPage = currentPages[currentPages.length - 1];
@@ -65,13 +67,13 @@ export default async (options = { method: 'GET', data: {} }) => {
65 67
           Taro.setStorageSync('currentPage', currentPage.route);
66 68
           global.globalData.optionsData = currentPage.options || {};
67 69
         }
68
-        
70
+
69 71
         Taro.reLaunch({
70 72
           url: '/pages/login/index',
71 73
         });
72 74
         return Promise.reject(msg);
73 75
       default:
74
-        if(msg){
76
+        if (msg) {
75 77
           Taro.showToast({
76 78
             title: `${msg}`,
77 79
             icon: 'none',

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

@@ -68,7 +68,7 @@ export default class Index extends Component {
68 68
     Taro.hideShareMenu({
69 69
       menus: ["shareAppMessage", "shareTimeline"],
70 70
     });
71
-    const { id, isShare, isSeckill, shareJump, shareUserId,tagTitle } =
71
+    const { id, isShare, isSeckill, shareJump, shareUserId,tagTitle,shareType } =
72 72
       Taro.getCurrentInstance().router.params;
73 73
     let session_key = Taro.getStorageSync("session_key");
74 74
     let userInfo = Taro.getStorageSync("userInfo");
@@ -88,6 +88,11 @@ export default class Index extends Component {
88 88
             key: "shareJump",
89 89
             data: shareJump,
90 90
           });
91
+        shareType &&
92
+          Taro.setStorage({
93
+            key: "shareType",
94
+            data: shareType,
95
+          });
91 96
         this.fetchProductDetails(id); //获取产品详情
92 97
         this.getProductLikeList(); //获取猜你喜欢列表
93 98
         if (session_key && shareJump) {
@@ -191,6 +196,7 @@ export default class Index extends Component {
191 196
       share_unique_value: shareJump,
192 197
     });
193 198
     Taro.removeStorageSync("shareJump");
199
+    Taro.removeStorageSync("shareType");
194 200
   };
195 201
   // 设置分享标题
196 202
   handleShareTitleChange = (newTitle) => {
@@ -202,7 +208,7 @@ export default class Index extends Component {
202 208
   onShareAppMessage() {
203 209
     return {
204 210
       title: this.state.shareTitle || this.state.productDetail.item_title,
205
-      path: `/pages/indexSub/productDetail/index?id=${this.state.id}&&isShare=true&&isSeckill=${this.state.isSeckill}&&shareJump=${this.state.shareJump}&&tagTitle=${this.state.tagTitle}`,
211
+      path: `/pages/indexSub/productDetail/index?id=${this.state.id}&&isShare=true&&isSeckill=${this.state.isSeckill}&&shareJump=${this.state.shareJump}&&tagTitle=${this.state.tagTitle}&&shareType=1`,
206 212
       imageUrl: this.state.productDetail.images[0].img,
207 213
     };
208 214
   }

+ 42 - 7
src/pages/indexSub/seckillIndex/index.jsx

@@ -3,7 +3,12 @@ import { View, Image } from "@tarojs/components";
3 3
 import "./index.less";
4 4
 import Taro from "@tarojs/taro";
5 5
 import ProductList from "../../../components/index/ProductList";
6
-import { getRecommendProductList, addLog } from "../../../service";
6
+import {
7
+  getRecommendProductList,
8
+  addLog,
9
+  getShareJump,
10
+  bindShareJump,
11
+} from "../../../service";
7 12
 import { formatDate } from "../../../common/time";
8 13
 import { getShareContent } from "../../../common/share";
9 14
 export default class Index extends Component {
@@ -22,8 +27,9 @@ export default class Index extends Component {
22 27
     img: "", // 图片
23 28
   };
24 29
   componentDidMount() {
25
-    const { isDirect, isBanner, isShare, shareUserId, title, id } =
30
+    const { isDirect, isBanner, isShare, shareUserId, title, id, shareJump,shareType } =
26 31
       Taro.getCurrentInstance().router.params || "";
32
+    let session_key = Taro.getStorageSync("session_key");
27 33
     this.setState(
28 34
       {
29 35
         isDirect: isDirect || false,
@@ -48,6 +54,20 @@ export default class Index extends Component {
48 54
             : `direct_to_${this.state.id}_${this.state.title}`
49 55
         );
50 56
         this.getRecommendProductList();
57
+        // 获取分享跳转标识
58
+        shareJump &&
59
+          Taro.setStorage({
60
+            key: "shareJump",
61
+            data: shareJump,
62
+          });
63
+        shareType &&
64
+          Taro.setStorage({
65
+            key: "shareType",
66
+            data: shareType,
67
+          });
68
+        if (session_key && shareJump) {
69
+          this.bindShareJump(); //绑定分享跳转标识
70
+        }
51 71
       }
52 72
     );
53 73
   }
@@ -70,6 +90,16 @@ export default class Index extends Component {
70 90
       img: res.img,
71 91
     }));
72 92
   };
93
+  // 绑定分享跳转标识
94
+  bindShareJump = async () => {
95
+    let shareJump = Taro.getStorageSync("shareJump");
96
+    await bindShareJump({
97
+      share_type: 3,
98
+      share_unique_value: shareJump,
99
+    });
100
+    Taro.removeStorageSync("shareJump");
101
+    Taro.removeStorageSync("shareType");
102
+  };
73 103
   // 埋点
74 104
   handleLog = (event_type) => {
75 105
     const dayid = formatDate(new Date(), "YYYY-MM-DD");
@@ -108,11 +138,16 @@ export default class Index extends Component {
108 138
       shareUserId = Taro.getStorageSync("loginInfo").id;
109 139
     }
110 140
     if (res.from == "menu") {
111
-      return {
112
-        title: `${this.state.title}`,
113
-        path: `/pages/indexSub/seckillIndex/index?isShare=true&shareUserId=${shareUserId}&title=${this.state.title}&id=${this.state.id}`,
114
-        imageUrl: "",
115
-      };
141
+      return getShareJump({
142
+        share_type: 3,
143
+        share_id: this.state.id,
144
+      }).then((res) => {
145
+        return {
146
+          title: `${this.state.title}`,
147
+          path: `/pages/indexSub/seckillIndex/index?isShare=true&shareUserId=${shareUserId}&title=${this.state.title}&id=${this.state.id}&&shareJump=${res.share_unique_value}&&shareType=3`,
148
+          imageUrl: "",
149
+        };
150
+      });
116 151
     } else {
117 152
       return getShareContent();
118 153
     }

+ 27 - 25
src/pages/login/index.jsx

@@ -28,7 +28,7 @@ export default class Index extends Component {
28 28
       url: "/pages/mineSub/userSpecification/index",
29 29
     });
30 30
   };
31
-  
31
+
32 32
   // handleGetPhoneNumber = (e) => {
33 33
   //   if (e.detail.errMsg === "getPhoneNumber:ok") {
34 34
   //     // 处理获取到的手机号信息
@@ -67,34 +67,36 @@ export default class Index extends Component {
67 67
           icon: "none",
68 68
         });
69 69
 
70
-        // 先处理分享跳转
71
-        let shareJump = Taro.getStorageSync("shareJump");
72
-        if (shareJump) {
73
-          await bindShareJump({
74
-            share_unique_value: shareJump,
75
-            share_type: 1,
76
-          });
77
-          Taro.removeStorageSync("shareJump");
78
-          if (global.globalData.optionsData) {
79
-            delete global.globalData.optionsData.shareJump;
80
-          }
81
-        }
82
-
83 70
         // 再获取用户信息
84 71
         const userInfoRes = await getUserInfo();
85 72
         Taro.setStorageSync("userInfo", userInfoRes);
86
-
87
-        // 最后处理页面跳转
88
-        
89
-        let lastPage = Taro.getStorageSync("currentPage");
90
-        if (!lastPage || lastPage === "pages/mineSub/login/index") {
91
-          lastPage = "pages/index/index";
73
+        try {
74
+          // 先处理分享跳转
75
+          let shareJump = Taro.getStorageSync("shareJump");
76
+          let shareType = Taro.getStorageSync("shareType");
77
+          if (shareJump) {
78
+            await bindShareJump({
79
+              share_unique_value: shareJump,
80
+              share_type: shareType || 2,
81
+            });
82
+            Taro.removeStorageSync("shareJump");
83
+            Taro.removeStorageSync("shareType");
84
+            if (global.globalData.optionsData) {
85
+              delete global.globalData.optionsData.shareJump;
86
+            }
87
+          }
88
+        } finally {
89
+          // 最后处理页面跳转
90
+          let lastPage = Taro.getStorageSync("currentPage");
91
+          if (!lastPage || lastPage === "pages/mineSub/login/index") {
92
+            lastPage = "pages/index/index";
93
+          }
94
+          await Taro.reLaunch({
95
+            url: `/${lastPage}?${objToParam(global.globalData.optionsData)}`,
96
+          });
97
+          Taro.removeStorageSync("currentPage");
98
+          global.globalData.optionsData = {};
92 99
         }
93
-        await Taro.reLaunch({
94
-          url: `/${lastPage}?${objToParam(global.globalData.optionsData)}`,
95
-        });
96
-        Taro.removeStorageSync("currentPage");
97
-        global.globalData.optionsData = {};
98 100
       },
99 101
     });
100 102
   };

+ 0 - 2
src/pages/memberSub/earningsDetail/index.jsx

@@ -13,8 +13,6 @@ export default class Index extends Component {
13 13
   // 获取收益详情
14 14
   getEarningsDetail = async () => {
15 15
     const res = await getEarningsDetail();
16
-    console.log(res);
17
-    
18 16
     this.setState({ earningsDetail: res });
19 17
   }
20 18
 

+ 37 - 18
src/pages/memberSub/storeManagement/index.jsx

@@ -67,21 +67,45 @@ export default class Index extends Component {
67 67
   };
68 68
 
69 69
   componentDidShow() {
70
-    const { router } = Taro.getCurrentInstance();
71
-    const params = router.params;
72
-
70
+    const { isManager, shopId, isShare, shareJump,shareType } =
71
+      Taro.getCurrentInstance().router.params || "";
72
+    let session_key = Taro.getStorageSync("session_key");
73 73
     this.setState(
74 74
       {
75
-        isManager: JSON.parse(params.isManager), //是否是店长
76
-        isShare: params.isShare || false, // 是否是分享进入
77
-        shopId: params.shopId || "", // 店铺id
75
+        isManager: JSON.parse(isManager), //是否是店长
76
+        isShare: isShare || false, // 是否是分享进入
77
+        shopId: shopId || "", // 店铺id
78 78
       },
79 79
       () => {
80 80
         this.getMyShopDetail(); //获取店铺详情
81 81
         this.getMyShopList(true); //获取店铺数据
82
+        // 获取分享跳转标识
83
+        shareJump &&
84
+          Taro.setStorage({
85
+            key: "shareJump",
86
+            data: shareJump,
87
+          });
88
+        shareType &&
89
+          Taro.setStorage({
90
+            key: "shareType",
91
+            data: shareType,
92
+          });
93
+        if (session_key && shareJump) {
94
+          this.bindShareJump(); //绑定分享跳转标识
95
+        }
82 96
       }
83 97
     );
84 98
   }
99
+  // 绑定分享跳转标识
100
+  bindShareJump = async () => {
101
+    let shareJump = Taro.getStorageSync("shareJump");
102
+    await bindShareJump({
103
+      share_type: 2,
104
+      share_unique_value: shareJump,
105
+    });
106
+    Taro.removeStorageSync("shareJump");
107
+    Taro.removeStorageSync("shareType");
108
+  };
85 109
   // 页面上拉触底
86 110
   onReachBottom = () => {
87 111
     const { page, totalPages, loading } = this.state;
@@ -101,18 +125,13 @@ export default class Index extends Component {
101 125
   // 配置分享内容
102 126
   onShareAppMessage() {
103 127
     const name = Taro.getStorageSync("userInfo").name;
104
-    return {
105
-      title: `${name}的店铺`,
106
-      path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false`,
107
-      imageUrl: "",
108
-    };
109 128
     return getShareJump({
110 129
       share_type: 2,
111 130
       share_id: this.state.shopDetail.id,
112 131
     }).then((res) => {
113 132
       return {
114
-        title: "店铺",
115
-        path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false&&shareJump=${res.share_unique_value}`,
133
+        title: `${name||'分享者'}的店铺`,
134
+        path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false&&shareJump=${res.share_unique_value}&&shareType=2`,
116 135
         imageUrl: "",
117 136
       };
118 137
     });
@@ -124,7 +143,7 @@ export default class Index extends Component {
124 143
         {/* 头部卡片 */}
125 144
         <View className="header-card">
126 145
           <Image className="bg-image" src={storeManagement} mode="widthFix" />
127
-          {/* 分享���铺 */}
146
+          {/* 分享铺 */}
128 147
           {!this.state.isShare && (
129 148
             <View className="share-shop">
130 149
               <Button onClick={this.handleShare} openType="share">
@@ -141,7 +160,7 @@ export default class Index extends Component {
141 160
                 mode="aspectFill"
142 161
                 src={shopDetail.img_icon}
143 162
               />
144
-              <View className="change-avatar-btn">更换头像</View>
163
+              {/* <View className="change-avatar-btn">更换头像</View> */}
145 164
             </View>
146 165
             <View className="info-content">
147 166
               <Text className="name">{shopDetail.store_name}</Text>
@@ -192,9 +211,9 @@ export default class Index extends Component {
192 211
           <View className="loading-container">
193 212
             <AtActivityIndicator
194 213
               content="加载中..."
195
-            isOpened={loading}
196
-            mode="center"
197
-            color="#fdf764"
214
+              isOpened={loading}
215
+              mode="center"
216
+              color="#fdf764"
198 217
             />
199 218
           </View>
200 219
         )}

+ 1 - 1
src/service/index.js

@@ -86,7 +86,7 @@ export const getUserAgreement = data =>
86 86
     method: 'POST',
87 87
     data,
88 88
   })
89
-// 获取分享跳转标识
89
+// 获取分享跳转标识(1:商品;2:店铺 3:专题页)
90 90
 export const getShareJump = data =>
91 91
   Request({
92 92
     url: '/user/get_not_oneself_store_detail',