|
@@ -42,14 +42,15 @@
|
|
|
<ie-button @click="handleLogin">登录</ie-button>
|
|
<ie-button @click="handleLogin">登录</ie-button>
|
|
|
<!-- #ifdef MP-WEIXIN -->
|
|
<!-- #ifdef MP-WEIXIN -->
|
|
|
<view class="flex items-center justify-center">
|
|
<view class="flex items-center justify-center">
|
|
|
- <uv-button v-if="!isAgree" :custom-style="customBtnStyle" :hover-effect="false" type="primary" @click="handleCheckAgree">
|
|
|
|
|
|
|
+ <uv-button v-if="!isAgree" :custom-style="customBtnStyle" :hover-effect="false" type="primary"
|
|
|
|
|
+ @click="handleCheckAgree">
|
|
|
<view class="mt-40 flex items-center justify-center gap-10">
|
|
<view class="mt-40 flex items-center justify-center gap-10">
|
|
|
<uv-icon name="weixin-circle-fill" color="#66dc79" size="26" />
|
|
<uv-icon name="weixin-circle-fill" color="#66dc79" size="26" />
|
|
|
<text class="text-28 text-primary">一键登录</text>
|
|
<text class="text-28 text-primary">一键登录</text>
|
|
|
</view>
|
|
</view>
|
|
|
</uv-button>
|
|
</uv-button>
|
|
|
- <uv-button v-else :custom-style="customBtnStyle" :hover-effect="false" :disabled="!isAgree" type="primary" text="手机号快捷登录"
|
|
|
|
|
- icon-color="white" open-type="getPhoneNumber|agreePrivacyAuthorization"
|
|
|
|
|
|
|
+ <uv-button v-else :custom-style="customBtnStyle" :hover-effect="false" :disabled="!isAgree" type="primary"
|
|
|
|
|
+ text="手机号快捷登录" icon-color="white" open-type="getPhoneNumber|agreePrivacyAuthorization"
|
|
|
@getphonenumber="handleGetPhoneNumber" @agreeprivacyauthorization="handleAgreePrivacyAuthorization"
|
|
@getphonenumber="handleGetPhoneNumber" @agreeprivacyauthorization="handleAgreePrivacyAuthorization"
|
|
|
@click="handleWxLogin">
|
|
@click="handleWxLogin">
|
|
|
<view class="mt-40 flex items-center justify-center gap-10">
|
|
<view class="mt-40 flex items-center justify-center gap-10">
|
|
@@ -83,7 +84,8 @@ import { useAppConfig } from '@/hooks/useAppConfig';
|
|
|
import { verifyCard } from '@/api/modules/user';
|
|
import { verifyCard } from '@/api/modules/user';
|
|
|
import { EnumBindScene, EnumSmsApiType, EnumUserType } from '@/common/enum';
|
|
import { EnumBindScene, EnumSmsApiType, EnumUserType } from '@/common/enum';
|
|
|
import { login, wxLogin } from '@/api/modules/login';
|
|
import { login, wxLogin } from '@/api/modules/login';
|
|
|
-import { LoginRequestDTO, UserInfo } from '@/types/user';
|
|
|
|
|
|
|
+import { LoginRequestDTO, MobileLoginResponseDTO, UserInfo } from '@/types/user';
|
|
|
|
|
+import { ApiResponse } from '@/types';
|
|
|
|
|
|
|
|
const { transferBack, transferTo, routes } = useTransferPage();
|
|
const { transferBack, transferTo, routes } = useTransferPage();
|
|
|
const userStore = useUserStore();
|
|
const userStore = useUserStore();
|
|
@@ -227,6 +229,7 @@ const handleGetPhoneNumber = async (e: any) => {
|
|
|
loginCode: code,
|
|
loginCode: code,
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
console.log('微信登录结果:', res)
|
|
console.log('微信登录结果:', res)
|
|
|
|
|
+ handleLoginResponse('wx', res);
|
|
|
}).finally(() => {
|
|
}).finally(() => {
|
|
|
loading.value = false;
|
|
loading.value = false;
|
|
|
uni.$ie.hideLoading();
|
|
uni.$ie.hideLoading();
|
|
@@ -241,43 +244,55 @@ const handleMobileLogin = async (params: LoginRequestDTO) => {
|
|
|
uni.$ie.showLoading();
|
|
uni.$ie.showLoading();
|
|
|
login(params).then((res) => {
|
|
login(params).then((res) => {
|
|
|
uni.$ie.hideLoading();
|
|
uni.$ie.hideLoading();
|
|
|
- if (res.data) {
|
|
|
|
|
- const { code, message } = res.data;
|
|
|
|
|
- if (code === 101) {
|
|
|
|
|
- console.log('registerInfo:', params)
|
|
|
|
|
- // 账号不存在,需要注册
|
|
|
|
|
- transferTo('/pagesSystem/pages/bind-profile/bind-profile', {
|
|
|
|
|
- data: {
|
|
|
|
|
- scene: EnumBindScene.REGISTER,
|
|
|
|
|
- userInfo: {},
|
|
|
|
|
- cardInfo: {},
|
|
|
|
|
- registerInfo: {
|
|
|
|
|
- ...params
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ handleLoginResponse('mobile', res, params);
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ uni.$ie.hideLoading();
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const handleLoginResponse = (type: 'wx' | 'mobile', res: ApiResponse<MobileLoginResponseDTO>, params: LoginRequestDTO & { openId?: string } = {}) => {
|
|
|
|
|
+ console.log('处理登录', res, params);
|
|
|
|
|
+ if (res.data) {
|
|
|
|
|
+ const { code, message, mobile, openId } = res.data;
|
|
|
|
|
+ if (code === 101) {
|
|
|
|
|
+ console.log('registerInfo:', params)
|
|
|
|
|
+ const pageOptions = {
|
|
|
|
|
+ scene: EnumBindScene.REGISTER,
|
|
|
|
|
+ userInfo: {},
|
|
|
|
|
+ cardInfo: {},
|
|
|
|
|
+ registerInfo: {
|
|
|
|
|
+ ...params
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ if (type === 'wx') {
|
|
|
|
|
+ pageOptions.registerInfo = {
|
|
|
|
|
+ ...pageOptions.registerInfo,
|
|
|
|
|
+ mobile,
|
|
|
|
|
+ openId
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- if (res.token) {
|
|
|
|
|
- userStore.login(res.token).then(({ success, userInfo }) => {
|
|
|
|
|
- if (success) {
|
|
|
|
|
- // transferBack(true);
|
|
|
|
|
|
|
+ // 账号不存在,需要注册
|
|
|
|
|
+ transferTo('/pagesSystem/pages/bind-profile/bind-profile', {
|
|
|
|
|
+ data: pageOptions
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (res.token) {
|
|
|
|
|
+ userStore.login(res.token).then(({ success, userInfo }) => {
|
|
|
|
|
+ if (success) {
|
|
|
|
|
+ // transferBack(true);
|
|
|
|
|
+ uni.$ie.showSuccess('登录成功');
|
|
|
|
|
+ setTimeout(() => {
|
|
|
transferTo(routes.pageIndex, {
|
|
transferTo(routes.pageIndex, {
|
|
|
type: 'reLaunch'
|
|
type: 'reLaunch'
|
|
|
});
|
|
});
|
|
|
- } else {
|
|
|
|
|
- uni.$ie.showToast('登录失败')
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }, 800);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.$ie.showToast('登录失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- }).catch(err => {
|
|
|
|
|
- console.log('登录失败', err)
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const handleLoginResponse = () => {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleCardLogin = (params: LoginRequestDTO) => {
|
|
const handleCardLogin = (params: LoginRequestDTO) => {
|