继续修改登录,已完成账户密码登录

This commit is contained in:
liaodeyun 2025-11-27 17:32:06 +08:00
parent 0f9a78b64c
commit 92d05778b9
5 changed files with 1027 additions and 1078 deletions

View File

@ -8,7 +8,7 @@ const config = {
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称
name: "ruoyi-app-vue3", name: "天然气工具箱",
// 应用版本 // 应用版本
version: "1.1.0", version: "1.1.0",
// 应用logo // 应用logo

View File

@ -261,15 +261,6 @@
"root": "pages_system/pages", "root": "pages_system/pages",
"pages": [{ "pages": [{
"path": "dict/index"
},
{
"path": "dict/data",
"style": {
"navigationBarTitleText": "计算工具"
}
},
{
"path": "register/index", "path": "register/index",
"style": { "style": {
"navigationBarTitleText": "注册", "navigationBarTitleText": "注册",
@ -278,7 +269,7 @@
} }
}, },
{ {
"path": "forgot/index", "path": "forget/index",
"style": { "style": {
"navigationBarTitleText": "忘记密码", "navigationBarTitleText": "忘记密码",
"navigationStyle": "custom" "navigationStyle": "custom"

View File

@ -1,25 +1,16 @@
<template> <template>
<view class="login-container"> <view class="login-container">
<view class="login-header"> <view class="login-header">
<image class="logo" src="/static/logo.png" mode="aspectFit"></image>
<text class="app-name">{{ appName }}</text> <text class="app-name">{{ appName }}</text>
</view> </view>
<view class="login-content"> <view class="login-content">
<!-- 登录方式切换 --> <!-- 登录方式切换 -->
<view class="login-tabs"> <view class="login-tabs">
<view <view class="tab-item" :class="{ active: activeTab === 'account' }" @click="switchTab('account')">
class="tab-item"
:class="{ active: activeTab === 'account' }"
@click="switchTab('account')"
>
账号登录 账号登录
</view> </view>
<view <view class="tab-item" :class="{ active: activeTab === 'phone' }" @click="switchTab('phone')">
class="tab-item"
:class="{ active: activeTab === 'phone' }"
@click="switchTab('phone')"
>
手机登录 手机登录
</view> </view>
</view> </view>
@ -28,41 +19,23 @@
<view v-if="activeTab === 'account'" class="login-form"> <view v-if="activeTab === 'account'" class="login-form">
<view class="form-item"> <view class="form-item">
<text class="label">账号</text> <text class="label">账号</text>
<input <input v-model="accountForm.username" class="input" placeholder="请输入用户名/手机号/邮箱"
v-model="accountForm.username" placeholder-class="placeholder" />
class="input"
placeholder="请输入用户名/手机号/邮箱"
placeholder-class="placeholder"
/>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="label">密码</text> <text class="label">密码</text>
<input <input v-model="accountForm.password" class="input" password placeholder="请输入密码"
v-model="accountForm.password" placeholder-class="placeholder" @confirm="handleAccountLogin" />
class="input"
password
placeholder="请输入密码"
placeholder-class="placeholder"
@confirm="handleAccountLogin"
/>
</view> </view>
<view class="form-item" v-if="accountForm.showCaptcha"> <view class="form-item">
<text class="label">验证码</text> <text class="label">验证码</text>
<view class="captcha-input"> <view class="captcha-input">
<input <input v-model="accountForm.code" class="input" placeholder="请输入验证码"
v-model="accountForm.code" placeholder-class="placeholder" />
class="input" <image :src="accountForm.captchaImg" class="captcha-img" @click="getCaptcha" mode="aspectFit">
placeholder="请输入验证码" </image>
placeholder-class="placeholder"
/>
<image
:src="accountForm.captchaImg"
class="captcha-img"
@click="getCaptcha"
mode="aspectFit"
></image>
</view> </view>
</view> </view>
@ -79,30 +52,16 @@
<view v-if="activeTab === 'phone'" class="login-form"> <view v-if="activeTab === 'phone'" class="login-form">
<view class="form-item"> <view class="form-item">
<text class="label">手机号</text> <text class="label">手机号</text>
<input <input v-model="phoneForm.phone" class="input" type="number" placeholder="请输入手机号"
v-model="phoneForm.phone" placeholder-class="placeholder" />
class="input"
type="number"
placeholder="请输入手机号"
placeholder-class="placeholder"
/>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="label">验证码</text> <text class="label">验证码</text>
<view class="code-input"> <view class="code-input">
<input <input v-model="phoneForm.code" class="input" type="number" placeholder="请输入验证码"
v-model="phoneForm.code" placeholder-class="placeholder" />
class="input" <button class="send-code-btn" :disabled="phoneForm.countdown > 0" @click="handlesendPhoneCode">
type="number"
placeholder="请输入验证码"
placeholder-class="placeholder"
/>
<button
class="send-code-btn"
:disabled="phoneForm.countdown > 0"
@click="handlesendPhoneCode"
>
{{ phoneForm.countdown > 0 ? `${phoneForm.countdown}s` : '获取验证码' }} {{ phoneForm.countdown > 0 ? `${phoneForm.countdown}s` : '获取验证码' }}
</button> </button>
</view> </view>
@ -146,18 +105,36 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted } from 'vue' import {
import { onLoad, onShow } from '@dcloudio/uni-app' ref,
reactive,
onMounted
} from 'vue'
import {
onLoad,
onShow
} from '@dcloudio/uni-app'
import modal from '@/plugins/modal' import modal from '@/plugins/modal'
import { getCodeImg, login, sendPhoneCode, verifyPhoneCode } from '@/api/login' import {
import { getWxCode } from '@/utils/geek' getCodeImg,
import { wxLogin } from '@/api/oauth' login,
sendPhoneCode,
verifyPhoneCode
} from '@/api/login'
import {
getWxCode
} from '@/utils/geek'
import {
wxLogin
} from '@/api/oauth'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { setToken } from '@/utils/auth' import {
setToken
} from '@/utils/auth'
import config from '@/config.js' import config from '@/config.js'
const userStore = useUserStore() const userStore = useUserStore()
const appName = config.appName || '系统名称' const appName = config.appInfo.name || '天然气工具箱'
// //
const activeTab = ref('account') const activeTab = ref('account')
@ -215,7 +192,9 @@ const handlesendPhoneCode = async () => {
} }
try { try {
await sendPhoneCode({ phone: phoneForm.phone }, 'login') await sendPhoneCode({
phone: phoneForm.phone
}, 'login')
modal.alert('验证码已发送') modal.alert('验证码已发送')
// //
@ -266,11 +245,10 @@ const handleAccountLogin = async () => {
if (res.token) { if (res.token) {
setToken(res.token) setToken(res.token)
await userStore.getInfo() await userStore.getInfo()
modal.alert('登录成功', () => { uni.switchTab({
uni.reLaunch({
url: '/pages/index' url: '/pages/index'
}) });
})
} }
} catch (error) { } catch (error) {
// //
@ -310,11 +288,9 @@ const handlePhoneLogin = async () => {
if (res.token) { if (res.token) {
setToken(res.token) setToken(res.token)
await userStore.getInfo() await userStore.getInfo()
modal.alert('登录成功', () => { uni.switchTab({
uni.reLaunch({
url: '/pages/index' url: '/pages/index'
}) });
})
} }
} catch (error) { } catch (error) {
modal.alert(error.message || '登录失败') modal.alert(error.message || '登录失败')
@ -337,18 +313,15 @@ const handleOneClickLogin = async () => {
modal.alert('无法获取本机号码') modal.alert('无法获取本机号码')
return return
} }
// //
const res = await login(phoneNumber, '', '', '') const res = await login(phoneNumber, '', '', '')
if (res.token) { if (res.token) {
setToken(res.token) setToken(res.token)
await userStore.getInfo() await userStore.getInfo()
modal.alert('登录成功', () => { uni.switchTab({
uni.reLaunch({
url: '/pages/index' url: '/pages/index'
}) });
})
} }
} catch (error) { } catch (error) {
modal.alert(error.message || '一键登录失败') modal.alert(error.message || '一键登录失败')
@ -368,11 +341,9 @@ const handleWechatLogin = async () => {
if (res.token) { if (res.token) {
setToken(res.token) setToken(res.token)
await userStore.getInfo() await userStore.getInfo()
modal.alert('登录成功', () => { uni.switchTab({
uni.reLaunch({
url: '/pages/index' url: '/pages/index'
}) });
})
} }
} catch (error) { } catch (error) {
if (error.code === 400) { if (error.code === 400) {
@ -509,7 +480,8 @@ onLoad(() => {
color: #ccc; color: #ccc;
} }
.captcha-input, .code-input { .captcha-input,
.code-input {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 20rpx; gap: 20rpx;

View File

@ -7,14 +7,14 @@
<!-- 标况体积流量m³/s --> <!-- 标况体积流量m³/s -->
<uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况体积流量m³/s" name="dVFlowb"> <uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况体积流量m³/s" name="dVFlowb">
<a-yjly-inputunit :modelValue="meterResult.dVFlowb" :unit-type="'volumeflow'" <a-yjly-inputunit :modelValue="meterResult.dVFlowb" :unit-type="'volumeflow'"
v-model:unitOrder="meterResult.dVFlowUnit" :show-english-only="true" :decimal-places="5" v-model:unitOrder="meterResult.dVFlowUnit" :show-english-only="true" :decimal-places="6"
:width="selectWidth" :input-disable="true" /> :width="selectWidth" :input-disable="true" />
</uni-forms-item> </uni-forms-item>
<!-- 工况体积流量 --> <!-- 工况体积流量 -->
<uni-forms-item :style="{ width: selectWidth + 'px' }" label="工况体积流量" name="dVFlowf"> <uni-forms-item :style="{ width: selectWidth + 'px' }" label="工况体积流量" name="dVFlowf">
<a-yjly-inputunit :modelValue="meterResult.dVFlowf" :unit-type="'volumeflow'" <a-yjly-inputunit :modelValue="meterResult.dVFlowf" :unit-type="'volumeflow'"
v-model:unitOrder="meterResult.dVFlowWorkUnit" :show-english-only="true" :decimal-places="5" v-model:unitOrder="meterResult.dVFlowWorkUnit" :show-english-only="true" :decimal-places="6"
:input-disable="true" :width="selectWidth" /> :input-disable="true" :width="selectWidth" />
</uni-forms-item> </uni-forms-item>
@ -22,13 +22,13 @@
<uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况质量流量" name="dMFlowb"> <uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况质量流量" name="dMFlowb">
<a-yjly-inputunit :modelValue="meterResult.dMFlowb" :unit-type="'massflow'" <a-yjly-inputunit :modelValue="meterResult.dMFlowb" :unit-type="'massflow'"
v-model:unitOrder="meterResult.dMFlowUnit" :input-disable="true" :show-english-only="true" v-model:unitOrder="meterResult.dMFlowUnit" :input-disable="true" :show-english-only="true"
:decimal-places="5" :width="selectWidth" /> :decimal-places="6" :width="selectWidth" />
</uni-forms-item> </uni-forms-item>
<!-- 标况能量流量 --> <!-- 标况能量流量 -->
<uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况能量流量" name="dEFlowb"> <uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况能量流量" name="dEFlowb">
<a-yjly-inputunit :modelValue="meterResult.dEFlowb" :unit-type="'energyflow'" <a-yjly-inputunit :modelValue="meterResult.dEFlowb" :unit-type="'energyflow'"
v-model:unitOrder="meterResult.dEFlowUnit" :show-english-only="true" :decimal-places="5" v-model:unitOrder="meterResult.dEFlowUnit" :show-english-only="true" :decimal-places="6"
:width="selectWidth" :input-disable="true" /> :width="selectWidth" :input-disable="true" />
</uni-forms-item> </uni-forms-item>
<!-- 求超压缩因子 E --> <!-- 求超压缩因子 E -->

View File

@ -10,40 +10,22 @@
<view class="register-form"> <view class="register-form">
<view class="form-item"> <view class="form-item">
<text class="label">用户名</text> <text class="label">用户名</text>
<input <input v-model="registerForm.username" class="input" placeholder="请输入用户名"
v-model="registerForm.username" placeholder-class="placeholder" />
class="input"
placeholder="请输入用户名"
placeholder-class="placeholder"
/>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="label">手机号</text> <text class="label">手机号</text>
<input <input v-model="registerForm.phone" class="input" type="number" placeholder="请输入手机号"
v-model="registerForm.phone" placeholder-class="placeholder" />
class="input"
type="number"
placeholder="请输入手机号"
placeholder-class="placeholder"
/>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="label">验证码</text> <text class="label">验证码</text>
<view class="code-input"> <view class="code-input">
<input <input v-model="registerForm.code" class="input" type="number" placeholder="请输入验证码"
v-model="registerForm.code" placeholder-class="placeholder" />
class="input" <button class="send-code-btn" :disabled="countdown > 0" @click="sendCode">
type="number"
placeholder="请输入验证码"
placeholder-class="placeholder"
/>
<button
class="send-code-btn"
:disabled="countdown > 0"
@click="sendCode"
>
{{ countdown > 0 ? `${countdown}s` : '获取验证码' }} {{ countdown > 0 ? `${countdown}s` : '获取验证码' }}
</button> </button>
</view> </view>
@ -51,35 +33,20 @@
<view class="form-item"> <view class="form-item">
<text class="label">密码</text> <text class="label">密码</text>
<input <input v-model="registerForm.password" class="input" password placeholder="请输入密码"
v-model="registerForm.password" placeholder-class="placeholder" />
class="input"
password
placeholder="请输入密码"
placeholder-class="placeholder"
/>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="label">确认密码</text> <text class="label">确认密码</text>
<input <input v-model="registerForm.confirmPassword" class="input" password placeholder="请再次输入密码"
v-model="registerForm.confirmPassword" placeholder-class="placeholder" />
class="input"
password
placeholder="请再次输入密码"
placeholder-class="placeholder"
/>
</view> </view>
<view class="form-item" v-if="registerForm.showEmail"> <view class="form-item" v-if="registerForm.showEmail">
<text class="label">邮箱</text> <text class="label">邮箱</text>
<input <input v-model="registerForm.email" class="input" type="email" placeholder="请输入邮箱(选填)"
v-model="registerForm.email" placeholder-class="placeholder" />
class="input"
type="email"
placeholder="请输入邮箱(选填)"
placeholder-class="placeholder"
/>
</view> </view>
<view class="agreement"> <view class="agreement">
@ -123,14 +90,31 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive } from 'vue' import {
import { onLoad, onShow } from '@dcloudio/uni-app' ref,
reactive
} from 'vue'
import {
onLoad,
onShow
} from '@dcloudio/uni-app'
import modal from '@/plugins/modal' import modal from '@/plugins/modal'
import { getCodeImg, login, sendPhoneCode, verifyPhoneCode } from '@/api/login' import {
import { getWxCode } from '@/utils/geek' getCodeImg,
import { wxLogin } from '@/api/oauth' login,
sendPhoneCode,
verifyPhoneCode
} from '@/api/login'
import {
getWxCode
} from '@/utils/geek'
import {
wxLogin
} from '@/api/oauth'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { setToken } from '@/utils/auth' import {
setToken
} from '@/utils/auth'
import config from '@/config.js' import config from '@/config.js'
const userStore = useUserStore() const userStore = useUserStore()
@ -164,7 +148,9 @@ const sendCode = async () => {
} }
try { try {
await sendPhoneCode({ phone: registerForm.phone }, 'register') await sendPhoneCode({
phone: registerForm.phone
}, 'register')
modal.alert('验证码已发送') modal.alert('验证码已发送')
// //
@ -209,11 +195,9 @@ const handleRegister = async () => {
if (res.token) { if (res.token) {
setToken(res.token) setToken(res.token)
await userStore.getInfo() await userStore.getInfo()
modal.alert('注册成功', () => { uni.switchTab({
uni.reLaunch({ url: '/pages/login'
url: '/pages/index' });
})
})
} }
} catch (error) { } catch (error) {
modal.alert(error.message || '注册失败') modal.alert(error.message || '注册失败')
@ -318,7 +302,9 @@ const goLogin = () => {
} }
// //
import { onUnmounted } from 'vue' import {
onUnmounted
} from 'vue'
onUnmounted(() => { onUnmounted(() => {
if (countdownTimer) { if (countdownTimer) {
clearInterval(countdownTimer) clearInterval(countdownTimer)