Bläddra i källkod

fix: 修复带启动参数进入小程序注册渠道号和实际订单渠道号不一致的问题

await 2 månader sedan
förälder
incheckning
695249f133
3 ändrade filer med 18 tillägg och 8 borttagningar
  1. 4 0
      src/apis/userApi.ts
  2. 9 4
      src/helper/userHelper.ts
  3. 5 4
      src/pages/user/components/LoginBox.tsx

+ 4 - 0
src/apis/userApi.ts

@@ -6,6 +6,10 @@ export  class WxLoginUsingGetParams {
         
                 /// 小程序获取的code
                  code!: string ;
+
+
+                /// 渠道号
+                channelCode!: string;
                 
 }
     

+ 9 - 4
src/helper/userHelper.ts

@@ -11,10 +11,12 @@ export default class UserHelper {
   /**
    * 用户微信登录
    * @param code 小程序获取的Code
+   * @param [channelCode] 渠道号
    */
-  public static async userWxLogin(code: string) {
+  public static async userWxLogin(code: string, channelCode: string = 'hrqbxcx') {
+
     let result = await UserApi.wxLoginUsingGet({
-      params: { code },
+      params: { code, channelCode },
       errorTips: true,
       loading: true,
     }).toData();
@@ -41,9 +43,12 @@ export default class UserHelper {
     return !!ReduxUtil.store.getState().userInfo;
   }
   
-  /**出登录 */
+  /**退出登录 */
   public static outLogin() {
-    Taro.clearStorageSync();
+    // 退出登录后应保留原本的渠道号, 不能清掉
+    // Taro.clearStorageSync();
+    Taro.removeStorageSync('USER_INFO')
+    Taro.removeStorageSync('TAB_MENU')
     ReduxUtil.dispatch(reduxActions.clearState());
     RouteUtil.reLaunch("/pages/bottomNavBar/index");
   }

+ 5 - 4
src/pages/user/components/LoginBox.tsx

@@ -21,6 +21,8 @@ import ctyptoUtil from "@/utils/crypto";
 const LoginBox = forwardRef((props, ref) => {
   const channelCode = StorageUtil.get(EStorage.channelCode) || "";
 
+  console.log("channelCode 这会儿是什么? ", channelCode)
+
   useImperativeHandle(ref, () => ({
     handleOpen() {
       handleOpen();
@@ -111,7 +113,7 @@ const LoginBox = forwardRef((props, ref) => {
     }
     if (
       e.detail.code &&
-      (await UserHelper.userWxLogin(e.detail.code)) === true
+      (await UserHelper.userWxLogin(e.detail.code, channelCode)) === true
     ) {
       handleClose();
       // indexInfoResult.data &&
@@ -168,8 +170,7 @@ const LoginBox = forwardRef((props, ref) => {
       setIsGetValidate(!isGetValidate);
       setTime(60); // 重置倒计时
       let obj = {
-        // channelCode: "jiheyanfa",
-        channelCode: "txxcx04",
+        channelCode: channelCode || "hrqbxcx",
         phone: ctyptoUtil.AesEncode(phone),
         sceneType: "register",
       };
@@ -228,7 +229,7 @@ const LoginBox = forwardRef((props, ref) => {
       return;
     }
     let obj = {
-      channelCode: "txxcx01",
+      channelCode: channelCode || "hrqbxcx",
       phone: ctyptoUtil.AesEncode(phone),
       sceneType: "register",
       uctrackid: "",