zhengyiming
4 天以前 b80dfac43870bb6991228fc01d32b3d5e428283d
fix: 修改登录
17个文件已修改
144 ■■■■ 已修改文件
apps/bMiniApp/src/constants/app.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/stores/modules/user.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/subpackages/login/authorization/authorization.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/subpackages/login/components/LoginPageLayout/LoginPageLayout.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/subpackages/login/loginByForm/verificationCodeLoginForm.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/subpackages/login/registerForm/registerForm.vue 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/utils/request/index.ts 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/cMiniApp/src/constants/app.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/cMiniApp/src/stores/modules/user.ts 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/cMiniApp/src/subpackages/city/citySelect/citySelect.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/cMiniApp/src/subpackages/login/authorization/authorization.vue 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/cMiniApp/src/subpackages/login/components/LoginPageLayout/LoginPageLayout.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/cMiniApp/src/subpackages/login/registerForm/registerForm.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/cMiniApp/src/utils/request/index.ts 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
packages/utils/message.tsx 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pnpm-lock.yaml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/bMiniApp/src/constants/app.ts
@@ -2,5 +2,5 @@
export const AppLocalConfig = {
  userType: EnumUserType.Enterprise,
  clientType: EnumClientType.PcWeb,
  clientType: EnumClientType.Wxmp,
};
apps/bMiniApp/src/stores/modules/user.ts
@@ -97,15 +97,15 @@
    ) {
      try {
        let res: API.LoginCommandCallback = wxMiniAppUserLoginRes;
        if (!wxMiniAppUserLoginRes.isBindPhoneNumber) {
        if (!wxMiniAppUserLoginRes?.isBindPhoneNumber) {
          let bindRes = await authServices.bindWxmpUserInfo({
            encryptedData: detail.encryptedData,
            iv: detail.iv,
            sessionKey: wxMiniAppUserLoginRes.sessionKey,
          });
          res.accessToken = bindRes.accessToken;
          this.loginSuccess(res);
        }
        this.loginSuccess(res);
        return res;
      } catch (error) {
        console.log('error3: ', error);
apps/bMiniApp/src/subpackages/login/authorization/authorization.vue
@@ -112,7 +112,7 @@
        type: AppLocalConfig.userType,
      };
      wxMiniAppUserLoginRes.value = await authServices.wxmpLogin(params);
      if (wxMiniAppUserLoginRes.value.isBindPhoneNumber) {
      if (wxMiniAppUserLoginRes.value?.isBindPhoneNumber) {
        isAccount.value = true;
      }
    }
apps/bMiniApp/src/subpackages/login/components/LoginPageLayout/LoginPageLayout.vue
@@ -7,7 +7,7 @@
      <img :src="OssAssets.login.AuthBg" class="authorization-page-auth" />
    </template>
    <div class="authorization-page-title">欢迎使用工益赚</div>
    <div class="authorization-page-title">欢迎使用灵工达</div>
    <slot></slot>
  </PageLayout>
apps/bMiniApp/src/subpackages/login/loginByForm/accountLoginForm.vue
@@ -27,7 +27,7 @@
      </nut-form-item>
    </nut-form>
    <LargeButton class="login-btn" @click="handleLogin" :loading="form.loading">登录</LargeButton>
    <div class="go-register-btn" @click="goRegister">立即注册</div>
    <!-- <div class="go-register-btn" @click="goRegister">立即注册</div> -->
  </div>
</template>
apps/bMiniApp/src/subpackages/login/loginByForm/verificationCodeLoginForm.vue
@@ -27,7 +27,7 @@
      </nut-form-item>
    </nut-form>
    <LargeButton class="login-btn" @click="handleLogin" :loading="form.loading">登录</LargeButton>
    <div class="go-register-btn" @click="goRegister">立即注册</div>
    <!-- <div class="go-register-btn" @click="goRegister">立即注册</div> -->
  </div>
</template>
apps/bMiniApp/src/subpackages/login/registerForm/registerForm.vue
@@ -114,18 +114,18 @@
    if (state.policyChecked) {
      const { valid } = await formRef.value.validate();
      if (valid) {
        let params: API.PhoneMesssageCodeRegisterInput = {
          code: form.verificationCode,
          phoneNumber: form.phoneNumber,
        };
        let res = await accountServices.phoneMesssageCodeRegister(params);
        if (res) {
          Message.success('注册成功', {
            onClosed: () => {
              goLogin();
            },
          });
        }
        // let params: API.PhoneMesssageCodeRegisterInput = {
        //   code: form.verificationCode,
        //   phoneNumber: form.phoneNumber,
        // };
        // let res = await accountServices.phoneMesssageCodeRegister(params);
        // if (res) {
        //   Message.success('注册成功', {
        //     onClosed: () => {
        //       goLogin();
        //     },
        //   });
        // }
      }
    } else {
      noAccess();
apps/bMiniApp/src/utils/request/index.ts
@@ -10,6 +10,7 @@
/** 请求白名单,放置一些不需要token的接口(通过设置请求白名单,防止token过期后再请求造成的死循环问题) */
const whiteList = [RefreshTokenUrl];
const RefreshTokenBlackList = ['wxmpLogin'];
export function startLoading(showNavigationBarLoading: boolean) {
  if (showNavigationBarLoading) {
@@ -219,7 +220,10 @@
        const userStore = useUserStoreWithOut();
        if (response.headers['x-access-token']) {
        if (
          response.headers['x-access-token'] &&
          RefreshTokenBlackList.every((url) => !response.config.url?.includes(url))
        ) {
          const tokenInfo: API.LoginCommandCallback = {
            accessToken: response.headers['access-token'],
            refreshToken: response.headers['x-access-token'],
apps/cMiniApp/src/constants/app.ts
@@ -2,5 +2,5 @@
export const AppLocalConfig = {
  userType: EnumUserType.Personal,
  clientType: EnumClientType.PcWeb,
  clientType: EnumClientType.Wxmp,
};
apps/cMiniApp/src/stores/modules/user.ts
@@ -93,19 +93,17 @@
    // 手机号授权Code登录
    async getTokenByPhone(
      detail: ButtonProps.onGetPhoneNumberEventDetail,
      wxMiniAppUserLoginRes: any
      wxMiniAppUserLoginRes: API.LoginCommandCallback
    ) {
      try {
        let res: API.IdentityModelTokenCacheItem;
        if (!wxMiniAppUserLoginRes.accessToken) {
          let params: API.WxMiniAppPhoneLoginInput = {
            openId: wxMiniAppUserLoginRes.openId,
            sessionKey: wxMiniAppUserLoginRes.sessionKey,
        let res: API.LoginCommandCallback = wxMiniAppUserLoginRes;
        if (!wxMiniAppUserLoginRes?.isBindPhoneNumber) {
          let bindRes = await authServices.bindWxmpUserInfo({
            encryptedData: detail.encryptedData,
            iv: detail.iv,
            wxMiniApp: WxMiniAppEnum.C端小程序,
          };
          res = await accountServices.wxMiniAppPhoneAuthLogin(params);
            sessionKey: wxMiniAppUserLoginRes.sessionKey,
          });
          res.accessToken = bindRes.accessToken;
          this.loginSuccess(res);
        }
        return res;
apps/cMiniApp/src/subpackages/city/citySelect/citySelect.vue
@@ -61,11 +61,9 @@
  return _elevatorData;
});
console.log('elevatorData: ', elevatorData);
const clickItem = (key: string, item: any) => {
  console.log('item: ', item, getAreaByAreaCode(item.parentId).areaName);
  userStore.setLocationCity(item.name, getAreaByAreaCode(item.parentId).areaName);
  console.log('item: ', item, 1111);
  // userStore.setLocationCity(item.name, getAreaByAreaCode(item.parentId).areaName);
};
async function resetLocation() {
apps/cMiniApp/src/subpackages/login/authorization/authorization.vue
@@ -57,11 +57,10 @@
import { CommonEventFunction, ButtonProps } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useLoginedJump } from '@/hooks';
import * as accountServices from '@12333/services/api/Account';
import IconCaptcha from '@/assets/login/icon-btn-captcha.png';
import IconPassword from '@/assets/login/icon-btn-password.png';
import { LoginFormTabs } from '../constants';
import { WxMiniAppEnum } from '@12333/constants';
import * as authServices from '@12333/services/apiV2/auth';
defineOptions({
  name: 'authorization',
@@ -90,8 +89,8 @@
    RouterPath.authorization.includes(launchOptions.path) && launchOptions.scene === 1047 && uuid
);
const wxIndentityRes = ref<API.WxMiniAppIndentityInfo>();
const wxMiniAppUserLoginRes = ref<API.IdentityModelTokenCacheItem>();
const wxIndentityRes = ref<API.LoginCommandCallback>();
const wxMiniAppUserLoginRes = ref<API.LoginCommandCallback>();
const isAccount = ref(false);
@@ -99,21 +98,21 @@
  try {
    let loginRes = await Taro.login();
    if (isLoginByWeb.value) {
      const wxIndentity = await accountServices.getWxIndentity({
        code: loginRes.code,
        wxMiniApp: WxMiniAppEnum.C端小程序,
      });
      wxIndentityRes.value = wxIndentity;
      if (wxIndentityRes.value.userName) {
        isAccount.value = true;
      }
      // const wxIndentity = await authServices.wxmpLogin({
      //   code: loginRes.code,
      //   type: AppLocalConfig.userType,
      // });
      // wxIndentityRes.value = wxIndentity;
      // if (wxIndentityRes.value.isBindPhoneNumber) {
      //   isAccount.value = true;
      // }
    } else {
      const params: API.APIwxMiniAppUserLoginParams = {
      const params: API.WxmpLoginCommand = {
        code: loginRes.code,
        wxMiniApp: WxMiniAppEnum.C端小程序,
        type: AppLocalConfig.userType,
      };
      wxMiniAppUserLoginRes.value = await accountServices.wxMiniAppUserLogin(params);
      if (wxMiniAppUserLoginRes.value.accessToken) {
      wxMiniAppUserLoginRes.value = await authServices.wxmpLogin(params);
      if (wxMiniAppUserLoginRes.value?.isBindPhoneNumber) {
        isAccount.value = true;
      }
    }
@@ -126,14 +125,14 @@
    console.log('errMsg: ', errMsg, isLoginByWeb.value);
    if (errMsg === 'getPhoneNumber:ok') {
      if (isLoginByWeb.value) {
        let res = await userStore.wxMiniAppPhoneAuthLoginFromScan(
          ev.detail,
          wxIndentityRes.value,
          uuid
        );
        if (res) {
          handleLoginSuccess();
        }
        // let res = await userStore.wxMiniAppPhoneAuthLoginFromScan(
        //   ev.detail,
        //   wxIndentityRes.value,
        //   uuid
        // );
        // if (res) {
        //   handleLoginSuccess();
        // }
      } else {
        let res = await userStore.getTokenByPhone(ev.detail, wxMiniAppUserLoginRes.value);
        if (res) {
@@ -153,10 +152,10 @@
    if (state.policyChecked) {
      if (isLoginByWeb.value) {
        console.log('uuid: ', uuid);
        let res = await userStore.wxMiniAppUserLoginFromScan(wxIndentityRes.value, uuid);
        if (res) {
          handleLoginSuccess();
        }
        // let res = await userStore.wxMiniAppUserLoginFromScan(wxIndentityRes.value, uuid);
        // if (res) {
        //   handleLoginSuccess();
        // }
      } else {
        userStore.loginSuccess(wxMiniAppUserLoginRes.value);
        handleLoginSuccess();
apps/cMiniApp/src/subpackages/login/components/LoginPageLayout/LoginPageLayout.vue
@@ -7,7 +7,7 @@
      <img :src="OssAssets.login.AuthBg" class="authorization-page-auth" />
    </template>
    <div class="authorization-page-title">欢迎使用818平台</div>
    <div class="authorization-page-title">欢迎使用工易赚</div>
    <slot></slot>
  </PageLayout>
apps/cMiniApp/src/subpackages/login/registerForm/registerForm.vue
@@ -114,11 +114,11 @@
    if (state.policyChecked) {
      const { valid } = await formRef.value.validate();
      if (valid) {
        let params: API.PhoneMesssageCodeRegisterInput = {
          code: form.verificationCode,
        let params: API.RegisterPersonalUserCommand = {
          verifyCode: form.verificationCode,
          phoneNumber: form.phoneNumber,
        };
        let res = await accountServices.phoneMesssageCodeRegister(params);
        let res = await authServices.registerPersonalUser(params);
        if (res) {
          Message.success('注册成功', {
            onClosed: () => {
apps/cMiniApp/src/utils/request/index.ts
@@ -10,6 +10,7 @@
/** 请求白名单,放置一些不需要token的接口(通过设置请求白名单,防止token过期后再请求造成的死循环问题) */
const whiteList = [RefreshTokenUrl];
const RefreshTokenBlackList = ['wxmpLogin'];
export function startLoading(showNavigationBarLoading: boolean) {
  if (showNavigationBarLoading) {
@@ -219,7 +220,10 @@
        const userStore = useUserStoreWithOut();
        if (response.headers['x-access-token']) {
        if (
          response.headers['x-access-token'] &&
          RefreshTokenBlackList.every((url) => !response.config.url?.includes(url))
        ) {
          const tokenInfo: API.LoginCommandCallback = {
            accessToken: response.headers['access-token'],
            refreshToken: response.headers['x-access-token'],
packages/utils/message.tsx
@@ -51,6 +51,11 @@
                    resolve(1);
                  }}
                  confirmText={confirmText}
                  //@ts-ignore
                  onClickOverlay={() => {
                    onClose();
                    reject();
                  }}
                ></Model>
              ),
            }}
pnpm-lock.yaml
@@ -241,7 +241,7 @@
        version: 6.11.1
      senin-mini:
        specifier: ^1.0.12
        version: 1.0.12(@nutui/icons-vue-taro@0.0.9)(@nutui/nutui-taro@4.3.13)(@tanstack/vue-query@4.35.3)(@tarojs/components@3.6.20)(@tarojs/taro@3.6.20)(axios@1.4.0)(dayjs@1.11.6)(lodash@4.17.21)(vue@3.5.12)
        version: link:../../../../demo/modern-module/packages/senin-mini
      senior-request:
        specifier: ^1.0.3
        version: 1.0.3(axios@1.4.0)