fix(login): 微信登录获取手机号接口增加 authCode 参数

- 在 HeaderWithHook、Login、UserCard 组件中修改 handleGetPhoneNumber 方法
- 在 Taro.login 的 success 回调中添加 loginRes 参数
- 将 loginRes.code 作为 authCode 添加到请求数据中
- 此修改涉及多个文件,统一解决微信登录获取手机号的问题
This commit is contained in:
2025-09-05 14:20:16 +08:00
parent 1df0f7735c
commit 0dfe3934a4
4 changed files with 8 additions and 4 deletions

View File

@@ -97,12 +97,13 @@ function UserCard() {
const handleGetPhoneNumber = ({detail}: { detail: { code?: string, encryptedData?: string, iv?: string } }) => {
const {code, encryptedData, iv} = detail
Taro.login({
success: function () {
success: function (loginRes) {
if (code) {
Taro.request({
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
method: 'POST',
data: {
authCode: loginRes.code,
code,
encryptedData,
iv,

View File

@@ -73,12 +73,13 @@ const Header = (props: any) => {
const handleGetPhoneNumber = ({detail}: {detail: {code?: string, encryptedData?: string, iv?: string}}) => {
const {code, encryptedData, iv} = detail
Taro.login({
success: function () {
success: function (loginRes) {
if (code) {
Taro.request({
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
method: 'POST',
data: {
authCode: loginRes.code,
code,
encryptedData,
iv,

View File

@@ -41,12 +41,13 @@ const Login = (props: LoginProps) => {
const handleGetPhoneNumber = ({detail}: GetPhoneNumberEvent) => {
const {code, encryptedData, iv} = detail
Taro.login({
success: function () {
success: function (loginRes) {
if (code) {
Taro.request({
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
method: 'POST',
data: {
authCode: loginRes.code,
code,
encryptedData,
iv,

View File

@@ -100,12 +100,13 @@ function UserCard() {
const handleGetPhoneNumber = ({detail}: { detail: { code?: string, encryptedData?: string, iv?: string } }) => {
const {code, encryptedData, iv} = detail
Taro.login({
success: function () {
success: function (loginRes) {
if (code) {
Taro.request({
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
method: 'POST',
data: {
authCode: loginRes.code,
code,
encryptedData,
iv,