Merge branch 'feat/liujie'
This commit is contained in:
@@ -44,15 +44,14 @@ function NTRPTestEntryCard(props: {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
init();
|
init();
|
||||||
}, [userInfo.id]);
|
}, [userInfo]);
|
||||||
|
|
||||||
const handleTest = useCallback(
|
const handleTest = useCallback(
|
||||||
function () {
|
function () {
|
||||||
// 没有绑定手机号,线条转登陆
|
// 没有绑定手机号,线条转登陆
|
||||||
if (!requireLoginWithPhone()) {
|
// if (!requireLoginWithPhone()) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EvaluateScene.list:
|
case EvaluateScene.list:
|
||||||
|
|||||||
@@ -1,29 +1,35 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from "react";
|
||||||
import { View, Text, Button, Image } from '@tarojs/components';
|
import { View, Text, Button, Image } from "@tarojs/components";
|
||||||
import Taro, { useRouter } from '@tarojs/taro';
|
import Taro, { useRouter } from "@tarojs/taro";
|
||||||
import { wechat_auth_login, save_login_state, check_login_status } from '@/services/loginService';
|
import {
|
||||||
import './index.scss';
|
wechat_auth_login,
|
||||||
|
save_login_state,
|
||||||
|
check_login_status,
|
||||||
|
} from "@/services/loginService";
|
||||||
|
import { useUserActions } from "@/store/userStore";
|
||||||
|
import "./index.scss";
|
||||||
|
|
||||||
const LoginPage: React.FC = () => {
|
const LoginPage: React.FC = () => {
|
||||||
const [is_loading, set_is_loading] = useState(false);
|
const [is_loading, set_is_loading] = useState(false);
|
||||||
const [agree_terms, set_agree_terms] = useState(false);
|
const [agree_terms, set_agree_terms] = useState(false);
|
||||||
const [show_terms_layer, set_show_terms_layer] = useState(false);
|
const [show_terms_layer, set_show_terms_layer] = useState(false);
|
||||||
const [pending_login_type, set_pending_login_type] = useState<'wechat' | 'phone' | null>(null); // 记录待执行的登录类型
|
const [pending_login_type, set_pending_login_type] = useState<
|
||||||
|
"wechat" | "phone" | null
|
||||||
|
>(null); // 记录待执行的登录类型
|
||||||
const [pending_phone_event, set_pending_phone_event] = useState<any>(null); // 记录微信登录的事件数据
|
const [pending_phone_event, set_pending_phone_event] = useState<any>(null); // 记录微信登录的事件数据
|
||||||
const { params: { redirect } } = useRouter();
|
const {
|
||||||
|
params: { redirect },
|
||||||
|
} = useRouter();
|
||||||
|
const { fetchUserInfo } = useUserActions();
|
||||||
|
|
||||||
|
|
||||||
// 执行微信登录的核心逻辑
|
// 执行微信登录的核心逻辑
|
||||||
const execute_wechat_login = async (e: any) => {
|
const execute_wechat_login = async (e: any) => {
|
||||||
// 检查是否获取到手机号
|
// 检查是否获取到手机号
|
||||||
if (!e.detail || !e.detail.code) {
|
if (!e.detail || !e.detail.code) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '获取手机号失败,请重试',
|
title: "获取手机号失败,请重试",
|
||||||
icon: 'none',
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -34,26 +40,27 @@ const LoginPage: React.FC = () => {
|
|||||||
const response = await wechat_auth_login(e.detail.code);
|
const response = await wechat_auth_login(e.detail.code);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
save_login_state(response.token!, response.user_info!);
|
save_login_state(response.token!, response.user_info!);
|
||||||
|
fetchUserInfo();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
Taro.redirectTo({ url: decodeURIComponent(redirect) });
|
Taro.redirectTo({ url: decodeURIComponent(redirect) });
|
||||||
} else {
|
} else {
|
||||||
Taro.redirectTo({ url: '/main_pages/index' });
|
Taro.redirectTo({ url: "/main_pages/index" });
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
} else {
|
} else {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: response.message,
|
title: response.message,
|
||||||
icon: 'none',
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '登录失败,请重试',
|
title: "登录失败,请重试",
|
||||||
icon: 'none',
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
set_is_loading(false);
|
set_is_loading(false);
|
||||||
@@ -64,13 +71,13 @@ const LoginPage: React.FC = () => {
|
|||||||
const handle_wechat_login = async (e: any) => {
|
const handle_wechat_login = async (e: any) => {
|
||||||
if (!agree_terms) {
|
if (!agree_terms) {
|
||||||
// 记录待执行的登录类型和事件数据
|
// 记录待执行的登录类型和事件数据
|
||||||
set_pending_login_type('wechat');
|
set_pending_login_type("wechat");
|
||||||
set_pending_phone_event(e);
|
set_pending_phone_event(e);
|
||||||
set_show_terms_layer(true);
|
set_show_terms_layer(true);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '请先同意用户协议',
|
title: "请先同意用户协议",
|
||||||
icon: 'none',
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -83,7 +90,7 @@ const LoginPage: React.FC = () => {
|
|||||||
const execute_phone_login = () => {
|
const execute_phone_login = () => {
|
||||||
// 跳转到验证码页面
|
// 跳转到验证码页面
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: `/login_pages/verification/index?redirect=${redirect}`
|
url: `/login_pages/verification/index?redirect=${redirect}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,12 +98,12 @@ const LoginPage: React.FC = () => {
|
|||||||
const handle_phone_login = async () => {
|
const handle_phone_login = async () => {
|
||||||
if (!agree_terms) {
|
if (!agree_terms) {
|
||||||
// 记录待执行的登录类型
|
// 记录待执行的登录类型
|
||||||
set_pending_login_type('phone');
|
set_pending_login_type("phone");
|
||||||
set_show_terms_layer(true);
|
set_show_terms_layer(true);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '请先同意用户协议',
|
title: "请先同意用户协议",
|
||||||
icon: 'none',
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -111,13 +118,13 @@ const LoginPage: React.FC = () => {
|
|||||||
set_show_terms_layer(false);
|
set_show_terms_layer(false);
|
||||||
|
|
||||||
// 根据待执行的登录类型,继续执行登录
|
// 根据待执行的登录类型,继续执行登录
|
||||||
if (pending_login_type === 'wechat' && pending_phone_event) {
|
if (pending_login_type === "wechat" && pending_phone_event) {
|
||||||
// 继续执行微信登录
|
// 继续执行微信登录
|
||||||
execute_wechat_login(pending_phone_event);
|
execute_wechat_login(pending_phone_event);
|
||||||
// 清空待执行状态
|
// 清空待执行状态
|
||||||
set_pending_login_type(null);
|
set_pending_login_type(null);
|
||||||
set_pending_phone_event(null);
|
set_pending_phone_event(null);
|
||||||
} else if (pending_login_type === 'phone') {
|
} else if (pending_login_type === "phone") {
|
||||||
// 继续执行手机号登录
|
// 继续执行手机号登录
|
||||||
execute_phone_login();
|
execute_phone_login();
|
||||||
// 清空待执行状态
|
// 清空待执行状态
|
||||||
@@ -131,9 +138,9 @@ const LoginPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 查看协议
|
// 查看协议
|
||||||
const handle_view_terms = (type: string = 'terms') => {
|
const handle_view_terms = (type: string = "terms") => {
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url: `/login_pages/terms/index?type=${type}`
|
url: `/login_pages/terms/index?type=${type}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -152,7 +159,7 @@ const LoginPage: React.FC = () => {
|
|||||||
<View className="background_image">
|
<View className="background_image">
|
||||||
<Image
|
<Image
|
||||||
className="bg_img"
|
className="bg_img"
|
||||||
src={require('@/static/login/login_bg.jpg')}
|
src={require("@/static/login/login_bg.jpg")}
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
/>
|
/>
|
||||||
<View className="bg_overlay"></View>
|
<View className="bg_overlay"></View>
|
||||||
@@ -162,29 +169,30 @@ const LoginPage: React.FC = () => {
|
|||||||
<View className="login_main_content">
|
<View className="login_main_content">
|
||||||
{/* 品牌区域 */}
|
{/* 品牌区域 */}
|
||||||
<View className="brand_section">
|
<View className="brand_section">
|
||||||
<View className="logo_container" >
|
<View className="logo_container"></View>
|
||||||
|
|
||||||
</View>
|
<View className="slogan_container"></View>
|
||||||
|
|
||||||
<View className="slogan_container">
|
|
||||||
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 登录按钮区域 */}
|
{/* 登录按钮区域 */}
|
||||||
<View className="login_section">
|
<View className="login_section">
|
||||||
{/* 微信快捷登录 */}
|
{/* 微信快捷登录 */}
|
||||||
<Button
|
<Button
|
||||||
className={`login_button wechat_button ${is_loading ? 'loading' : ''}`}
|
className={`login_button wechat_button ${
|
||||||
|
is_loading ? "loading" : ""
|
||||||
|
}`}
|
||||||
openType="getPhoneNumber"
|
openType="getPhoneNumber"
|
||||||
onGetPhoneNumber={handle_wechat_login}
|
onGetPhoneNumber={handle_wechat_login}
|
||||||
disabled={is_loading}
|
disabled={is_loading}
|
||||||
>
|
>
|
||||||
<View className="wechat_icon">
|
<View className="wechat_icon">
|
||||||
<Image className="wechat_logo" src={require('@/static/login/wechat_icon.svg')} />
|
<Image
|
||||||
|
className="wechat_logo"
|
||||||
|
src={require("@/static/login/wechat_icon.svg")}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Text className="button_text">
|
<Text className="button_text">
|
||||||
{is_loading ? '登录中...' : '微信授权登录'}
|
{is_loading ? "登录中..." : "微信授权登录"}
|
||||||
</Text>
|
</Text>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
@@ -194,7 +202,10 @@ const LoginPage: React.FC = () => {
|
|||||||
onClick={handle_phone_login}
|
onClick={handle_phone_login}
|
||||||
>
|
>
|
||||||
<View className="phone_icon">
|
<View className="phone_icon">
|
||||||
<Image className="phone_logo" src={require('@/static/login/phone_icon.svg')} />
|
<Image
|
||||||
|
className="phone_logo"
|
||||||
|
src={require("@/static/login/phone_icon.svg")}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Text className="button_text">手机号验证码登录</Text>
|
<Text className="button_text">手机号验证码登录</Text>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -202,7 +213,7 @@ const LoginPage: React.FC = () => {
|
|||||||
{/* 用户协议复选框 */}
|
{/* 用户协议复选框 */}
|
||||||
<View className="terms_checkbox_section">
|
<View className="terms_checkbox_section">
|
||||||
<View className="checkbox_container" onClick={handle_toggle_terms}>
|
<View className="checkbox_container" onClick={handle_toggle_terms}>
|
||||||
<View className={`checkbox ${agree_terms ? 'checked' : ''}`}>
|
<View className={`checkbox ${agree_terms ? "checked" : ""}`}>
|
||||||
{/* {agree_terms && <View className="checkmark"></View>} */}
|
{/* {agree_terms && <View className="checkmark"></View>} */}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -210,19 +221,19 @@ const LoginPage: React.FC = () => {
|
|||||||
<Text className="terms_text">我已阅读、理解并接受以下规定</Text>
|
<Text className="terms_text">我已阅读、理解并接受以下规定</Text>
|
||||||
<Text
|
<Text
|
||||||
className="terms_link"
|
className="terms_link"
|
||||||
onClick={() => handle_view_terms('terms')}
|
onClick={() => handle_view_terms("terms")}
|
||||||
>
|
>
|
||||||
《开场的条款和条件》
|
《开场的条款和条件》
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
className="terms_link"
|
className="terms_link"
|
||||||
onClick={() => handle_view_terms('binding')}
|
onClick={() => handle_view_terms("binding")}
|
||||||
>
|
>
|
||||||
《开场与微信号绑定协议》
|
《开场与微信号绑定协议》
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
className="terms_link"
|
className="terms_link"
|
||||||
onClick={() => handle_view_terms('privacy')}
|
onClick={() => handle_view_terms("privacy")}
|
||||||
>
|
>
|
||||||
《隐私权政策》
|
《隐私权政策》
|
||||||
</Text>
|
</Text>
|
||||||
@@ -245,19 +256,19 @@ const LoginPage: React.FC = () => {
|
|||||||
<View className="terms_list">
|
<View className="terms_list">
|
||||||
<Text
|
<Text
|
||||||
className="terms_item"
|
className="terms_item"
|
||||||
onClick={() => handle_view_terms('terms')}
|
onClick={() => handle_view_terms("terms")}
|
||||||
>
|
>
|
||||||
《开场的条款和条件》
|
《开场的条款和条件》
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
className="terms_item"
|
className="terms_item"
|
||||||
onClick={() => handle_view_terms('binding')}
|
onClick={() => handle_view_terms("binding")}
|
||||||
>
|
>
|
||||||
《开场与微信号绑定协议》
|
《开场与微信号绑定协议》
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
className="terms_item"
|
className="terms_item"
|
||||||
onClick={() => handle_view_terms('privacy')}
|
onClick={() => handle_view_terms("privacy")}
|
||||||
>
|
>
|
||||||
《隐私权政策》
|
《隐私权政策》
|
||||||
</Text>
|
</Text>
|
||||||
@@ -265,13 +276,11 @@ const LoginPage: React.FC = () => {
|
|||||||
|
|
||||||
{/* 同意按钮 */}
|
{/* 同意按钮 */}
|
||||||
<Button
|
<Button
|
||||||
className={`agree_button ${agree_terms ? 'agreed' : ''}`}
|
className={`agree_button ${agree_terms ? "agreed" : ""}`}
|
||||||
onClick={handle_agree_terms}
|
onClick={handle_agree_terms}
|
||||||
>
|
>
|
||||||
{agree_terms ? '已同意' : '同意并继续'}
|
{agree_terms ? "已同意" : "同意并继续"}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user