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