Quellcode durchsuchen

处理分享和产品筛选

viczhq vor 4 Tagen
Ursprung
Commit
4653c8f8dd
2 geänderte Dateien mit 84 neuen und 87 gelöschten Zeilen
  1. 45 46
      src/pages/login/index.jsx
  2. 39 41
      src/pages/memberSub/productManagement/index.jsx

+ 45 - 46
src/pages/login/index.jsx

@@ -2,7 +2,7 @@ import { Component } from "react";
2 2
 import { View, Image, Button } from "@tarojs/components";
3 3
 import Taro from "@tarojs/taro";
4 4
 import { AtCheckbox } from "taro-ui";
5
-import { login,getUserInfo,bindShareJump } from "../../service";
5
+import { login, getUserInfo, bindShareJump } from "../../service";
6 6
 import { objToParam } from "../../common/toParams";
7 7
 import "./index.less";
8 8
 import logo1 from "../../images/logo1.png";
@@ -35,8 +35,8 @@ export default class Index extends Component {
35 35
   // };
36 36
   login = () => {
37 37
     Taro.showLoading({
38
-      title: '正在登录',
39
-    })
38
+      title: "正在登录",
39
+    });
40 40
     if (!this.state.isChecked) {
41 41
       Taro.showToast({
42 42
         title: "请先同意协议",
@@ -46,50 +46,49 @@ export default class Index extends Component {
46 46
     }
47 47
     Taro.getUserProfile({
48 48
       desc: "获取用户信息",
49
-      success: (userInfo) => {
50
-        Taro.login({
51
-          success: (res) => {
52
-            login({
53
-              code: res.code,
54
-              head_img:userInfo.avatarUrl,
55
-              name:userInfo.nickName,
56
-            }).then((res) => {
57
-              Taro.setStorageSync('session_key', res.session_key)
58
-              Taro.setStorageSync('loginInfo', res)
59
-              Taro.hideLoading()
60
-              Taro.showToast({
61
-                title: '登录成功',
62
-                icon: 'none',
63
-              })
64
-              // 获取个人信息
65
-              getUserInfo().then(res => {
66
-                Taro.setStorageSync('userInfo', res)
67
-              })
68
-              // 绑定分享跳转标识
69
-              let shareJump = Taro.getStorageSync('shareJump')
70
-              if(shareJump){
71
-                bindShareJump({
72
-                  share_unique_value: shareJump,
73
-                  share_type:1
74
-                }).then(res => {
75
-                  Taro.removeStorageSync('shareJump')
76
-                  if (global.globalData.optionsData) {
77
-                    delete global.globalData.optionsData.shareJump
78
-                  }
79
-                })
80
-              }
81
-              let lastPage = Taro.getStorageSync('currentPage')
82
-              if (lastPage == 'pages/mineSub/login/index') {
83
-                lastPage = 'pages/index/index'
84
-              }
85
-              Taro.reLaunch({
86
-                url: `/${lastPage}?${objToParam(global.globalData.optionsData)}`
87
-              })
88
-              Taro.removeStorageSync('currentPage')
89
-              global.globalData.optionsData = {}
90
-            });
91
-          },
49
+      success: async (userInfo) => {
50
+        const loginRes = await Taro.login();
51
+        const res = await login({
52
+          code: loginRes.code,
53
+          head_img: userInfo.avatarUrl,
54
+          name: userInfo.nickName,
55
+        });
56
+
57
+        Taro.setStorageSync("session_key", res.session_key);
58
+        Taro.setStorageSync("loginInfo", res);
59
+        Taro.hideLoading();
60
+        Taro.showToast({
61
+          title: "登录成功",
62
+          icon: "none",
63
+        });
64
+
65
+        // 先处理分享跳转
66
+        let shareJump = Taro.getStorageSync("shareJump");
67
+        if (shareJump) {
68
+          await bindShareJump({
69
+            share_unique_value: shareJump,
70
+            share_type: 1,
71
+          });
72
+          Taro.removeStorageSync("shareJump");
73
+          if (global.globalData.optionsData) {
74
+            delete global.globalData.optionsData.shareJump;
75
+          }
76
+        }
77
+
78
+        // 再获取用户信息
79
+        const userInfoRes = getUserInfo();
80
+        Taro.setStorageSync("userInfo", userInfoRes);
81
+
82
+        // 最后处理页面跳转
83
+        let lastPage = Taro.getStorageSync("currentPage");
84
+        if (lastPage == "pages/mineSub/login/index") {
85
+          lastPage = "pages/index/index";
86
+        }
87
+        await Taro.reLaunch({
88
+          url: `/${lastPage}?${objToParam(global.globalData.optionsData)}`,
92 89
         });
90
+        Taro.removeStorageSync("currentPage");
91
+        global.globalData.optionsData = {};
93 92
       },
94 93
     });
95 94
   };

+ 39 - 41
src/pages/memberSub/productManagement/index.jsx

@@ -1,6 +1,6 @@
1 1
 import React, { Component, createRef } from "react";
2 2
 import { View, Picker, Image, Text } from "@tarojs/components";
3
-import { AtTabs, AtTabsPane, AtCheckbox } from "taro-ui";
3
+import { AtTabs, AtCheckbox } from "taro-ui";
4 4
 import Taro from "@tarojs/taro";
5 5
 import "./index.less";
6 6
 import {
@@ -23,9 +23,9 @@ export default class Index extends Component {
23 23
     isManagementStatus: false, //是否是管理状态
24 24
     current: 0, //tabs坐标
25 25
     isSelectAll: false, //是否全选
26
-    selectedOption: "首页", //商品默认名称
26
+    selectedOption: "", //商品默认名称
27 27
     tabList: [{ title: "在售中 (0)" }], //tabs标题
28
-    options: ["首页"], //商品下拉选项
28
+    options: [""], //商品下拉选项
29 29
     checkedList: [""], //全选
30 30
     checkboxOption: [
31 31
       {
@@ -51,6 +51,7 @@ export default class Index extends Component {
51 51
     this.setState(
52 52
       {
53 53
         options: arr,
54
+        selectedOption: res[0].name,
54 55
       },
55 56
       () => {
56 57
         this.getMyShopList(true);
@@ -236,46 +237,43 @@ export default class Index extends Component {
236 237
             tabList={this.state.tabList}
237 238
             current={this.state.current}
238 239
             scroll
239
-          >
240
-            <AtTabsPane current={this.state.current} index={0}>
241
-              {/* 内容 */}
242
-              <View className="tabs-content">
243
-                {/* 商品下拉分类 */}
244
-                <View className="product-category">
245
-                  <Picker
246
-                    mode="selector"
247
-                    range={this.state.options}
248
-                    onChange={this.handleSelectOption}
249
-                  >
250
-                    <View className="product-category-left">
251
-                      {this.state.selectedOption}
252
-                      <Image
253
-                        className="selectIcon"
254
-                        src={selectIcon}
255
-                        mode="aspectFit"
256
-                      />
257
-                    </View>
258
-                  </Picker>
259
-                  <View className="product-category-right">
260
-                    前6款商品将推荐给直属会员
261
-                  </View>
262
-                </View>
263
-                {/* 商品列表 */}
264
-                {this.state.productList && (
265
-                  <ProductList
266
-                    ref={this.childComponentRef} // 将 ref 传递给子组件
267
-                    productList={this.state.productList}
268
-                    isSelectAll={this.state.isSelectAll}
269
-                    isManagement={true}
270
-                    isManagementStatus={this.state.isManagementStatus}
271
-                    loading={this.state.loading}
272
-                    onDeleteProductSelect={this.onDeleteProductSelect}
273
-                    isNoMore={this.state.isNoMore}
240
+          ></AtTabs>
241
+          {/* 内容 */}
242
+          <View className="tabs-content">
243
+            {/* 商品下拉分类 */}
244
+            <View className="product-category">
245
+              <Picker
246
+                mode="selector"
247
+                range={this.state.options}
248
+                onChange={this.handleSelectOption}
249
+              >
250
+                <View className="product-category-left">
251
+                  {this.state.selectedOption}
252
+                  <Image
253
+                    className="selectIcon"
254
+                    src={selectIcon}
255
+                    mode="aspectFit"
274 256
                   />
275
-                )}
257
+                </View>
258
+              </Picker>
259
+              <View className="product-category-right">
260
+                前6款商品将推荐给直属会员
276 261
               </View>
277
-            </AtTabsPane>
278
-          </AtTabs>
262
+            </View>
263
+            {/* 商品列表 */}
264
+            {this.state.productList && (
265
+              <ProductList
266
+                ref={this.childComponentRef} // 将 ref 传递给子组件
267
+                productList={this.state.productList}
268
+                isSelectAll={this.state.isSelectAll}
269
+                isManagement={true}
270
+                isManagementStatus={this.state.isManagementStatus}
271
+                loading={this.state.loading}
272
+                onDeleteProductSelect={this.onDeleteProductSelect}
273
+                isNoMore={this.state.isNoMore}
274
+              />
275
+            )}
276
+          </View>
279 277
         </View>
280 278
         {/* 底部购买模块 */}
281 279
         {!this.state.isManagementStatus ? (