feat(dealer): 重构业务员申请页面并添加新功能
- 修改页面标题为"邀请注册"- 增加头像上传和昵称输入功能 - 添加获取微信昵称和手机号的功能- 优化表单布局和样式 - 移除审核状态相关代码
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import Taro from '@tarojs/taro';
|
||||
import {Button, Space} from '@nutui/nutui-react-taro'
|
||||
import {Space} from '@nutui/nutui-react-taro'
|
||||
import {TriangleDown} from '@nutui/icons-react-taro'
|
||||
import {Avatar, NavBar} from '@nutui/nutui-react-taro'
|
||||
import {getWxOpenId} from "@/api/layout";
|
||||
import {TenantId} from "@/config/app";
|
||||
// import {TenantId} from "@/config/app";
|
||||
import {getOrganization} from "@/api/system/organization";
|
||||
import {myUserVerify} from "@/api/system/userVerify";
|
||||
import {useShopInfo} from '@/hooks/useShopInfo';
|
||||
import {useUser} from '@/hooks/useUser';
|
||||
import {handleInviteRelation} from "@/utils/invite";
|
||||
// import {handleInviteRelation} from "@/utils/invite";
|
||||
import {View, Text} from '@tarojs/components'
|
||||
import MySearch from "./MySearch";
|
||||
import './Header.scss';
|
||||
@@ -18,14 +18,14 @@ import navTo from "@/utils/common";
|
||||
const Header = (props: any) => {
|
||||
// 使用新的useShopInfo Hook
|
||||
const {
|
||||
getWebsiteLogo
|
||||
getWebsiteLogo,
|
||||
getWebsiteName
|
||||
} = useShopInfo();
|
||||
|
||||
// 使用useUser Hook管理用户状态
|
||||
const {
|
||||
user,
|
||||
isLoggedIn,
|
||||
loginUser,
|
||||
fetchUserInfo
|
||||
} = useUser();
|
||||
|
||||
@@ -112,78 +112,78 @@ const Header = (props: any) => {
|
||||
}
|
||||
|
||||
/* 获取用户手机号 */
|
||||
const handleGetPhoneNumber = ({detail}: { detail: { code?: string, encryptedData?: string, iv?: string } }) => {
|
||||
const {code, encryptedData, iv} = detail
|
||||
Taro.login({
|
||||
success: (loginRes) => {
|
||||
if (code) {
|
||||
Taro.request({
|
||||
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
|
||||
method: 'POST',
|
||||
data: {
|
||||
authCode: loginRes.code,
|
||||
code,
|
||||
encryptedData,
|
||||
iv,
|
||||
notVerifyPhone: true,
|
||||
refereeId: 0,
|
||||
sceneType: 'save_referee',
|
||||
tenantId: TenantId
|
||||
},
|
||||
header: {
|
||||
'content-type': 'application/json',
|
||||
TenantId
|
||||
},
|
||||
success: async function (res) {
|
||||
if (res.data.code == 1) {
|
||||
Taro.showToast({
|
||||
title: res.data.message,
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
})
|
||||
return false;
|
||||
}
|
||||
// 登录成功
|
||||
const token = res.data.data.access_token;
|
||||
const userData = res.data.data.user;
|
||||
|
||||
// 使用useUser Hook的loginUser方法更新状态
|
||||
loginUser(token, userData);
|
||||
|
||||
// 处理邀请关系
|
||||
if (userData?.userId) {
|
||||
try {
|
||||
const inviteSuccess = await handleInviteRelation(userData.userId)
|
||||
if (inviteSuccess) {
|
||||
Taro.showToast({
|
||||
title: '邀请关系建立成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理邀请关系失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 显示登录成功提示
|
||||
Taro.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
})
|
||||
|
||||
// 不需要重新启动小程序,状态已经通过useUser更新
|
||||
// 可以选择性地刷新当前页面数据
|
||||
reload();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// const handleGetPhoneNumber = ({detail}: { detail: { code?: string, encryptedData?: string, iv?: string } }) => {
|
||||
// const {code, encryptedData, iv} = detail
|
||||
// Taro.login({
|
||||
// success: (loginRes) => {
|
||||
// if (code) {
|
||||
// Taro.request({
|
||||
// url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
|
||||
// method: 'POST',
|
||||
// data: {
|
||||
// authCode: loginRes.code,
|
||||
// code,
|
||||
// encryptedData,
|
||||
// iv,
|
||||
// notVerifyPhone: true,
|
||||
// refereeId: 0,
|
||||
// sceneType: 'save_referee',
|
||||
// tenantId: TenantId
|
||||
// },
|
||||
// header: {
|
||||
// 'content-type': 'application/json',
|
||||
// TenantId
|
||||
// },
|
||||
// success: async function (res) {
|
||||
// if (res.data.code == 1) {
|
||||
// Taro.showToast({
|
||||
// title: res.data.message,
|
||||
// icon: 'error',
|
||||
// duration: 2000
|
||||
// })
|
||||
// return false;
|
||||
// }
|
||||
// // 登录成功
|
||||
// const token = res.data.data.access_token;
|
||||
// const userData = res.data.data.user;
|
||||
//
|
||||
// // 使用useUser Hook的loginUser方法更新状态
|
||||
// loginUser(token, userData);
|
||||
//
|
||||
// // 处理邀请关系
|
||||
// if (userData?.userId) {
|
||||
// try {
|
||||
// const inviteSuccess = await handleInviteRelation(userData.userId)
|
||||
// if (inviteSuccess) {
|
||||
// Taro.showToast({
|
||||
// title: '邀请关系建立成功',
|
||||
// icon: 'success',
|
||||
// duration: 2000
|
||||
// })
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error('处理邀请关系失败:', error)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 显示登录成功提示
|
||||
// Taro.showToast({
|
||||
// title: '登录成功',
|
||||
// icon: 'success',
|
||||
// duration: 1500
|
||||
// })
|
||||
//
|
||||
// // 不需要重新启动小程序,状态已经通过useUser更新
|
||||
// // 可以选择性地刷新当前页面数据
|
||||
// reload();
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// console.log('登录失败!')
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
useEffect(() => {
|
||||
reload().then()
|
||||
@@ -214,23 +214,21 @@ const Header = (props: any) => {
|
||||
onClick={() => navTo(`/user/profile/profile`, true)}>
|
||||
<Avatar
|
||||
size="22"
|
||||
src={user?.avatar || Taro.getStorageSync('Avatar')}
|
||||
src={getWebsiteLogo()}
|
||||
/>
|
||||
<Text className={'text-white'}>{user?.nickname || Taro.getStorageSync('Nickname') || '已登录'}</Text>
|
||||
<Text className={'text-white'}>{getWebsiteName()}</Text>
|
||||
<TriangleDown className={'text-white'} size={9}/>
|
||||
</View>
|
||||
) : (
|
||||
<View style={{display: 'flex', alignItems: 'center'}}>
|
||||
<Button style={{color: '#ffffff'}} open-type="getPhoneNumber" onGetPhoneNumber={handleGetPhoneNumber}>
|
||||
<Space>
|
||||
<Avatar
|
||||
size="22"
|
||||
src={getWebsiteLogo()}
|
||||
/>
|
||||
<Text style={{color: '#ffffff'}}>未登录</Text>
|
||||
<TriangleDown size={9} className={'text-white'}/>
|
||||
</Space>
|
||||
</Button>
|
||||
<Space>
|
||||
<Avatar
|
||||
size="22"
|
||||
src={getWebsiteLogo()}
|
||||
/>
|
||||
<Text style={{color: '#ffffff'}}>{getWebsiteName()}</Text>
|
||||
<TriangleDown size={9} className={'text-white'}/>
|
||||
</Space>
|
||||
</View>
|
||||
)}>
|
||||
</NavBar>
|
||||
|
||||
Reference in New Issue
Block a user