feat:管理后台系统设置页面 + 小程序登录页条件渲染

This commit is contained in:
2026-06-27 10:27:14 +08:00
parent 9131203d1c
commit e3b21cac3e
6 changed files with 247 additions and 4 deletions
+17 -4
View File
@@ -30,13 +30,13 @@
<text v-else>微信一键登录</text>
</view>
<view class="login-divider">
<view class="login-divider" v-if="loginConfig.smsLoginEnabled">
<view></view>
<text>或使用手机号登录</text>
<view></view>
</view>
<view class="form">
<view class="form" v-if="loginConfig.smsLoginEnabled">
<view class="input-group">
<text class="input-label">手机号码</text>
<input
@@ -73,6 +73,7 @@
</view>
<view
v-if="loginConfig.smsLoginEnabled"
class="btn-primary login-btn"
:class="{ disabled: !canSubmit || loading }"
@click="handleLogin"
@@ -92,7 +93,7 @@
<script setup>
import { ref, computed, onMounted } from 'vue'
import { useAppStore } from '../../stores/app.js'
import { getSmsCode } from '../../services/auth.js'
import { getSmsCode, getLoginConfig } from '../../services/auth.js'
const store = useAppStore()
@@ -100,11 +101,21 @@ const statusBarHeight = ref(uni.getStorageSync('statusBarHeight') || 20)
const safeAreaTop = ref(uni.getStorageSync('safeAreaTop') || 20)
const safeAreaBottom = ref(uni.getStorageSync('safeAreaBottom') || 0)
onMounted(() => {
onMounted(async () => {
const windowInfo = uni.getWindowInfo()
statusBarHeight.value = windowInfo.statusBarHeight || 20
safeAreaTop.value = windowInfo.safeAreaInsets?.top || windowInfo.statusBarHeight || 20
safeAreaBottom.value = windowInfo.safeAreaInsets?.bottom || 0
try {
const res = await getLoginConfig()
if (res.data) {
loginConfig.value = res.data
}
} catch (e) {
// 接口失败时默认只显示微信登录
loginConfig.value = { wechatLoginEnabled: true, smsLoginEnabled: false }
}
})
const phone = ref('')
@@ -114,6 +125,8 @@ const activeMethod = ref('')
const countdown = ref(60)
const isCountingDown = ref(false)
const loginConfig = ref({ wechatLoginEnabled: true, smsLoginEnabled: false })
const canSubmit = computed(() => {
return phone.value.length === 11 && code.value.length === 6
})
+10
View File
@@ -16,6 +16,15 @@ export const getSmsCode = async (phone) => {
return response
}
/**
* 获取登录方式配置
* @returns {Promise<Object>} 登录方式配置
*/
export const getLoginConfig = async () => {
const response = await get('/auth/loginConfig')
return response
}
/**
* 用户登录(手机号 + 验证码)
* @param {Object} params - 登录参数
@@ -134,6 +143,7 @@ export const checkPhone = async (phone) => {
}
export default {
getLoginConfig,
getSmsCode,
login,
wechatLogin,