diff --git a/src/app.config.ts b/src/app.config.ts
index b58ead8..5e21e11 100644
--- a/src/app.config.ts
+++ b/src/app.config.ts
@@ -1,5 +1,7 @@
export default defineAppConfig({
pages: [
+
+ 'pages/home/index', //中转页
'pages/login/index/index',
'pages/login/verification/index',
diff --git a/src/components/UserInfo/index.tsx b/src/components/UserInfo/index.tsx
index 929c9b0..80df2d0 100644
--- a/src/components/UserInfo/index.tsx
+++ b/src/components/UserInfo/index.tsx
@@ -22,8 +22,8 @@ export interface UserInfo {
phone?: string;
gender?: string;
- latitude?: number,
- longitude?: number,
+ latitude?: string,
+ longitude?: string,
}
diff --git a/src/pages/home/index.config.ts b/src/pages/home/index.config.ts
new file mode 100644
index 0000000..ac965d0
--- /dev/null
+++ b/src/pages/home/index.config.ts
@@ -0,0 +1,7 @@
+export default definePageConfig({
+ navigationBarTitleText: '请等待',
+ enablePullDownRefresh: true,
+ backgroundTextStyle: 'dark',
+ navigationStyle: 'custom',
+ })
+
\ No newline at end of file
diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx
new file mode 100644
index 0000000..faca814
--- /dev/null
+++ b/src/pages/home/index.tsx
@@ -0,0 +1,21 @@
+import React from 'react';
+import { View, } from '@tarojs/components';
+import { check_login_status } from '../../services/loginService';
+import Taro from '@tarojs/taro';
+const HomePage: React.FC = () => {
+ let login_status = check_login_status()
+ if (login_status) {
+ Taro.redirectTo({ url: '/pages/list/index' })
+ }
+ else {
+ Taro.redirectTo({ url: '/pages/login/index/index' })
+ }
+
+ return (
+
+
+ )
+
+}
+
+export default HomePage;
\ No newline at end of file
diff --git a/src/pages/login/verification/index.tsx b/src/pages/login/verification/index.tsx
index 03f7680..c8cb116 100644
--- a/src/pages/login/verification/index.tsx
+++ b/src/pages/login/verification/index.tsx
@@ -134,7 +134,7 @@ const VerificationPage: React.FC = () => {
if (result.success) {
save_login_state(result.token!, result.user_info!)
- debugger
+
setTimeout(() => {
Taro.redirectTo({
url: '/pages/list/index'
diff --git a/src/pages/userInfo/edit/index.tsx b/src/pages/userInfo/edit/index.tsx
index bb89d43..16550ec 100644
--- a/src/pages/userInfo/edit/index.tsx
+++ b/src/pages/userInfo/edit/index.tsx
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro';
import './index.scss';
import { UserInfo } from '@/components/UserInfo';
import { UserService } from '@/services/userService';
+import {clear_login_state} from '@/services/loginService';
import { EditModal } from '@/components';
const EditProfilePage: React.FC = () => {
@@ -210,8 +211,8 @@ const EditProfilePage: React.FC = () => {
success: (res) => {
if (res.confirm) {
// 清除用户数据
- Taro.removeStorageSync('user_token');
- Taro.removeStorageSync('user_info');
+ clear_login_state();
+
Taro.reLaunch({
url: '/pages/login/index/index'
});
diff --git a/src/services/loginService.ts b/src/services/loginService.ts
index dae61f7..25c7d3f 100644
--- a/src/services/loginService.ts
+++ b/src/services/loginService.ts
@@ -4,8 +4,8 @@ import tokenManager from '../utils/tokenManager';
// 微信用户信息接口
export interface WechatUserInfo {
- user_id: string;
- username: string;
+ id: string;
+ nickname: string;
avatar: string;
gender: number;
city: string;
@@ -79,8 +79,8 @@ export const wechat_auth_login = async (phone_code?: string): Promise => {
- return new Promise((resolve, reject) => {
- Taro.getUserProfile({
- desc: '用于完善用户资料',
- success: (res) => {
- const profile = res.userInfo;
- const user_data: WechatUserInfo = {
- user_id: 'wx_' + Date.now(),
- username: profile.nickName || '微信用户',
- avatar: profile.avatarUrl || '',
- gender: profile.gender || 0,
- city: profile.city || '',
- province: profile.province || '',
- country: profile.country || ''
- };
- resolve(user_data);
- },
- fail: reject
- });
- });
-};
// 保存用户登录状态
export const save_login_state = (token: string, user_info: WechatUserInfo) => {
@@ -220,8 +199,9 @@ export const save_login_state = (token: string, user_info: WechatUserInfo) => {
expiresAt: expires_at
});
+
// 保存用户信息
- Taro.setStorageSync('user_info', user_info);
+ Taro.setStorageSync('user_info', JSON.stringify(user_info));
Taro.setStorageSync('is_logged_in', true);
Taro.setStorageSync('login_time', Date.now());
} catch (error) {
@@ -248,6 +228,8 @@ export const clear_login_state = () => {
export const check_login_status = (): boolean => {
try {
// 使用 tokenManager 检查令牌有效性
+
+
if (!tokenManager.hasValidToken()) {
clear_login_state();
return false;
@@ -297,7 +279,11 @@ export const get_token_status = () => {
// 获取用户信息
export const get_user_info = (): WechatUserInfo | null => {
try {
- return Taro.getStorageSync('user_info') || null;
+ let userinfo = Taro.getStorageSync('user_info')
+ if (userinfo) {
+ return JSON.parse(userinfo)
+ }
+ return null;
} catch (error) {
return null;
}
diff --git a/src/services/userService.ts b/src/services/userService.ts
index c26a0d7..459c8cb 100644
--- a/src/services/userService.ts
+++ b/src/services/userService.ts
@@ -20,8 +20,8 @@ interface UserDetailData {
language: string;
phone: string;
is_subscribed: string;
- latitude: number;
- longitude: number;
+ latitude: string;
+ longitude: string;
subscribe_time: string;
last_login_time: string;
create_time: string;
@@ -40,11 +40,12 @@ interface UpdateUserParams {
avatar_url: string;
gender: string;
phone: string;
- latitude?: number;
- longitude?: number;
+ latitude?: string;
+ longitude?: string;
city: string;
province: string;
country: string;
+
}
// 上传响应接口
@@ -105,8 +106,8 @@ interface BackendGameData {
end_time: string;
location_name: string | null;
location: string;
- latitude?: number;
- longitude?: number;
+ latitude?: string;
+ longitude?: string;
image_list?: string[];
description_tag?: string[];
venue_description_tag?: string[];