feat: 小程序登录支持切换到手机号验证码,补齐小写 phone 登录态

- ws-login: 小程序默认微信快捷登录,可切到手机号+验证码,或切回
- loginBySms: 同时存小写 phone,页面登录态统一读它
- .env: 审批服务指向 8.134.55.105
This commit is contained in:
2026-10-31 20:24:05 +08:00
parent 2a0571ad56
commit 98838f79ed
4 changed files with 55 additions and 16 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ VITE_APP_NAME=后台管理系统
VITE_SOCKET_URL=wss://server.gxwebsoft.com
VITE_SERVER_URL=https://gxtyzx-server.websoft.top/api
VITE_API_URL=https://gxtyzx-modules.websoft.top/api
VITE_THINK_URL=https://gxtyzx-api2.websoft.top/api
# 审批服务:部署在 8.134.55.105(经 nginx 80 端口反代)
VITE_THINK_URL=http://8.134.55.105/api
#VITE_THINK_URL=http://127.0.0.1:9099/api
+2 -1
View File
@@ -2,4 +2,5 @@ VITE_APP_NAME=后台管理系统
VITE_SOCKET_URL=wss://server.gxwebsoft.com
VITE_SERVER_URL=https://gxtyzx-server.websoft.top/api
VITE_API_URL=https://gxtyzx-modules.websoft.top/api
VITE_THINK_URL=https://gxtyzx-api2.websoft.top/api
# 审批服务:本次部署的 gxtyzx-api(经 nginx 80 端口反代)
VITE_THINK_URL=http://8.134.55.105/api
+2
View File
@@ -39,6 +39,8 @@ export async function loginBySms(data: LoginParam): Promise<string | undefined>
console.log('UserId: ', user.userId);
console.log('MerchantId: ', user.merchantId);
uni.setStorageSync('TenantId', user.tenantId)
// 页面登录态统一读小写 phone(user.vue 等),不能只存大写 Phone
uni.setStorageSync('phone', user.phone)
uni.setStorageSync('Phone', user.phone)
uni.setStorageSync('UserId', user.userId)
if (user.merchantId) {
@@ -15,25 +15,37 @@
</view>
<!-- #ifdef MP-WEIXIN -->
<view class="phone">
<template v-if="!disabled">
<button class="btn-normal" type="primary" @click="onAgreement">
<view class="wechat-auth-container">
<text class="title">手机号快捷登录</text>
</view>
</button>
<template v-if="!showLoginBySms">
<template v-if="!disabled">
<button class="btn-normal" type="primary" @click="onAgreement">
<view class="wechat-auth-container">
<text class="title">手机号快捷登录</text>
</view>
</button>
</template>
<template v-else>
<button class="btn-normal" type="primary" open-type="getPhoneNumber"
@getphonenumber="handelMpWeixinMobileLogin($event)">
<view class="wechat-auth-container">
<text class="title">手机号快捷登录</text>
</view>
</button>
</template>
<!-- 切换账号:改用手机号+验证码登录 -->
<view class="switch-login" @click="showLoginBySms = true">
<text>使用其他手机号登录</text>
</view>
</template>
<template v-else>
<button class="btn-normal" type="primary" open-type="getPhoneNumber"
@getphonenumber="handelMpWeixinMobileLogin($event)">
<view class="wechat-auth-container">
<text class="title">手机号快捷登录</text>
</view>
</button>
<view class="switch-login" @click="showLoginBySms = false">
<text>返回微信快捷登录</text>
</view>
</template>
</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="phone">
<!-- #ifdef H5 || MP-WEIXIN -->
<!-- 小程序端默认展示微信快捷登录,点「使用其他手机号登录」后展开本表单 -->
<view class="phone" v-if="showSmsForm">
<uni-forms ref="form" :modelValue="form" :rules="rules">
<uni-forms-item name="phone">
<uv-input placeholder="请输入手机号码" v-model="form.phone" maxlength="11" fontSize="22"
@@ -127,8 +139,10 @@ export default {
disabled: false,
statusBarHeight: 0,
showLoginBySms: false,
// 小程序端:先展示微信快捷登录,点「使用其他手机号登录」再展开验证码表单
tips: '获取验证码',
seconds: 60,
rules: {},
form: {
phone: '',
code: ''
@@ -136,6 +150,17 @@ export default {
top: uni.getSystemInfoSync().safeAreaInsets.top
};
},
computed: {
// H5 固定展示验证码表单;小程序端由切换按钮控制
showSmsForm() {
// #ifdef MP-WEIXIN
return this.showLoginBySms;
// #endif
// #ifndef MP-WEIXIN
return true;
// #endif
}
},
mounted() {
// #ifndef MP-WEIXIN
uni.getSystemInfo({
@@ -432,6 +457,16 @@ export default {
}
}
.switch-login {
margin-top: 24rpx;
text-align: center;
text {
font-size: 26rpx;
color: #0f80ff;
}
}
.close-wrap {
position: absolute;
left: 30rpx;