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

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: {
// 应用名称
name: "ruoyi-app-vue3",
name: "天然气工具箱",
// 应用版本
version: "1.1.0",
// 应用logo

View File

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

View File

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

View File

@ -7,14 +7,14 @@
<!-- 标况体积流量m³/s -->
<uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况体积流量m³/s" name="dVFlowb">
<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" />
</uni-forms-item>
<!-- 工况体积流量 -->
<uni-forms-item :style="{ width: selectWidth + 'px' }" label="工况体积流量" name="dVFlowf">
<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" />
</uni-forms-item>
@ -22,13 +22,13 @@
<uni-forms-item :style="{ width: selectWidth + 'px' }" label="标况质量流量" name="dMFlowb">
<a-yjly-inputunit :modelValue="meterResult.dMFlowb" :unit-type="'massflow'"
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 :style="{ width: selectWidth + 'px' }" label="标况能量流量" name="dEFlowb">
<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" />
</uni-forms-item>
<!-- 求超压缩因子 E -->

View File

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