继续修改登录,已完成账户密码登录
This commit is contained in:
parent
0f9a78b64c
commit
92d05778b9
@ -8,7 +8,7 @@ const config = {
|
||||
// 应用信息
|
||||
appInfo: {
|
||||
// 应用名称
|
||||
name: "ruoyi-app-vue3",
|
||||
name: "天然气工具箱",
|
||||
// 应用版本
|
||||
version: "1.1.0",
|
||||
// 应用logo
|
||||
@ -26,6 +26,6 @@ const config = {
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default config
|
||||
export default config
|
||||
11
pages.json
11
pages.json
@ -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"
|
||||
|
||||
360
pages/login.vue
360
pages/login.vue
@ -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,52 +105,70 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
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 useUserStore from '@/store/modules/user'
|
||||
import { setToken } from '@/utils/auth'
|
||||
import config from '@/config.js'
|
||||
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 useUserStore from '@/store/modules/user'
|
||||
import {
|
||||
setToken
|
||||
} from '@/utils/auth'
|
||||
import config from '@/config.js'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const appName = config.appName || '系统名称'
|
||||
const userStore = useUserStore()
|
||||
const appName = config.appInfo.name || '天然气工具箱'
|
||||
|
||||
// 响应式数据
|
||||
const activeTab = ref('account')
|
||||
const accountLogining = ref(false)
|
||||
const phoneLogining = ref(false)
|
||||
// 响应式数据
|
||||
const activeTab = ref('account')
|
||||
const accountLogining = ref(false)
|
||||
const phoneLogining = ref(false)
|
||||
|
||||
// 账号登录表单
|
||||
const accountForm = reactive({
|
||||
// 账号登录表单
|
||||
const accountForm = reactive({
|
||||
username: '',
|
||||
password: '',
|
||||
code: '',
|
||||
captchaImg: '',
|
||||
uuid: '',
|
||||
showCaptcha: false
|
||||
})
|
||||
})
|
||||
|
||||
// 手机登录表单
|
||||
const phoneForm = reactive({
|
||||
// 手机登录表单
|
||||
const phoneForm = reactive({
|
||||
phone: '',
|
||||
code: '',
|
||||
countdown: 0,
|
||||
timer: null
|
||||
})
|
||||
})
|
||||
|
||||
// 切换登录方式
|
||||
const switchTab = (tab) => {
|
||||
// 切换登录方式
|
||||
const switchTab = (tab) => {
|
||||
activeTab.value = tab
|
||||
if (tab === 'account' && !accountForm.captchaImg) {
|
||||
getCaptcha()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取验证码
|
||||
const getCaptcha = async () => {
|
||||
// 获取验证码
|
||||
const getCaptcha = async () => {
|
||||
try {
|
||||
const res = await getCodeImg()
|
||||
accountForm.captchaImg = 'data:image/gif;base64,' + res.img
|
||||
@ -200,10 +177,10 @@ const getCaptcha = async () => {
|
||||
} catch (error) {
|
||||
modal.alert('验证码获取失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发送手机验证码
|
||||
const handlesendPhoneCode = async () => {
|
||||
// 发送手机验证码
|
||||
const handlesendPhoneCode = async () => {
|
||||
if (!phoneForm.phone) {
|
||||
modal.alert('请输入手机号')
|
||||
return
|
||||
@ -215,7 +192,9 @@ const handlesendPhoneCode = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
await sendPhoneCode({ phone: phoneForm.phone }, 'login')
|
||||
await sendPhoneCode({
|
||||
phone: phoneForm.phone
|
||||
}, 'login')
|
||||
modal.alert('验证码已发送')
|
||||
|
||||
// 开始倒计时
|
||||
@ -229,10 +208,10 @@ const handlesendPhoneCode = async () => {
|
||||
} catch (error) {
|
||||
modal.alert(error.message || '验证码发送失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 账号密码登录
|
||||
const handleAccountLogin = async () => {
|
||||
// 账号密码登录
|
||||
const handleAccountLogin = async () => {
|
||||
if (!accountForm.username) {
|
||||
modal.alert('请输入账号')
|
||||
return
|
||||
@ -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) {
|
||||
// 如果需要验证码,重新获取
|
||||
@ -281,10 +259,10 @@ const handleAccountLogin = async () => {
|
||||
} finally {
|
||||
accountLogining.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 手机验证码登录
|
||||
const handlePhoneLogin = async () => {
|
||||
// 手机验证码登录
|
||||
const handlePhoneLogin = async () => {
|
||||
if (!phoneForm.phone) {
|
||||
modal.alert('请输入手机号')
|
||||
return
|
||||
@ -310,21 +288,19 @@ 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 || '登录失败')
|
||||
} finally {
|
||||
phoneLogining.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 本机一键登录
|
||||
const handleOneClickLogin = async () => {
|
||||
// 本机一键登录
|
||||
const handleOneClickLogin = async () => {
|
||||
try {
|
||||
// 这里需要调用uni的一键登录API
|
||||
// 由于不同平台实现不同,这里使用模拟实现
|
||||
@ -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 || '一键登录失败')
|
||||
@ -357,10 +330,10 @@ const handleOneClickLogin = async () => {
|
||||
} catch (error) {
|
||||
modal.alert('一键登录功能暂不可用')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 微信登录
|
||||
const handleWechatLogin = async () => {
|
||||
// 微信登录
|
||||
const handleWechatLogin = async () => {
|
||||
try {
|
||||
const code = await getWxCode()
|
||||
const res = await wxLogin('miniapp', code)
|
||||
@ -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) {
|
||||
@ -386,28 +357,28 @@ const handleWechatLogin = async () => {
|
||||
modal.alert(error.message || '微信登录失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转注册页面
|
||||
const goRegister = () => {
|
||||
// 跳转注册页面
|
||||
const goRegister = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages_system/pages/register/index'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转忘记密码页面
|
||||
const goForgetPwd = () => {
|
||||
// 跳转忘记密码页面
|
||||
const goForgetPwd = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages_system/pages/forget/index'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
getCaptcha()
|
||||
})
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
onLoad(() => {
|
||||
// 检查是否有token,如果有则直接跳转
|
||||
const token = uni.getStorageSync('token')
|
||||
if (token) {
|
||||
@ -415,64 +386,64 @@ onLoad(() => {
|
||||
url: '/pages/index'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.login-container {
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 60rpx 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.login-header {
|
||||
.login-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 80rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.logo {
|
||||
.logo {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.app-name {
|
||||
.app-name {
|
||||
font-size: 36rpx;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.login-content {
|
||||
.login-content {
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.login-tabs {
|
||||
.login-tabs {
|
||||
display: flex;
|
||||
margin-bottom: 40rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 20rpx;
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
.tab-item.active {
|
||||
color: #007aff;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.tab-item.active::after {
|
||||
.tab-item.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -2rpx;
|
||||
@ -482,20 +453,20 @@ onLoad(() => {
|
||||
height: 4rpx;
|
||||
background: #007aff;
|
||||
border-radius: 2rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.form-item {
|
||||
.form-item {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
.label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.input {
|
||||
.input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
@ -503,26 +474,27 @@ onLoad(() => {
|
||||
padding: 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
.placeholder {
|
||||
color: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.captcha-input, .code-input {
|
||||
.captcha-input,
|
||||
.code-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.captcha-img {
|
||||
.captcha-img {
|
||||
width: 200rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 10rpx;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
}
|
||||
}
|
||||
|
||||
.send-code-btn {
|
||||
.send-code-btn {
|
||||
width: 200rpx;
|
||||
height: 80rpx;
|
||||
background: #007aff;
|
||||
@ -531,24 +503,24 @@ onLoad(() => {
|
||||
border-radius: 10rpx;
|
||||
font-size: 24rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.send-code-btn[disabled] {
|
||||
.send-code-btn[disabled] {
|
||||
background: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.form-options {
|
||||
.form-options {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.forget-pwd {
|
||||
.forget-pwd {
|
||||
color: #007aff;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
background: #007aff;
|
||||
@ -557,23 +529,23 @@ onLoad(() => {
|
||||
border-radius: 44rpx;
|
||||
font-size: 32rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.login-btn[disabled] {
|
||||
.login-btn[disabled] {
|
||||
background: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.quick-login {
|
||||
.quick-login {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.divider {
|
||||
.divider {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
margin: 40rpx 0;
|
||||
}
|
||||
}
|
||||
|
||||
.divider::before {
|
||||
.divider::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
@ -581,28 +553,28 @@ onLoad(() => {
|
||||
right: 0;
|
||||
height: 1rpx;
|
||||
background: #e0e0e0;
|
||||
}
|
||||
}
|
||||
|
||||
.divider-text {
|
||||
.divider-text {
|
||||
background: #fff;
|
||||
padding: 0 20rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.login-methods {
|
||||
.login-methods {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 80rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.method-item {
|
||||
.method-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.method-icon {
|
||||
.method-icon {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 50%;
|
||||
@ -611,30 +583,30 @@ onLoad(() => {
|
||||
justify-content: center;
|
||||
margin-bottom: 10rpx;
|
||||
font-size: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.method-icon.one-click {
|
||||
.method-icon.one-click {
|
||||
background: #ff9500;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.method-icon.wechat {
|
||||
.method-icon.wechat {
|
||||
background: #07c160;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.method-text {
|
||||
.method-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.register-link {
|
||||
.register-link {
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.link {
|
||||
.link {
|
||||
color: #007aff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -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 -->
|
||||
|
||||
@ -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,25 +90,42 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
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 useUserStore from '@/store/modules/user'
|
||||
import { setToken } from '@/utils/auth'
|
||||
import config from '@/config.js'
|
||||
const userStore = useUserStore()
|
||||
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 useUserStore from '@/store/modules/user'
|
||||
import {
|
||||
setToken
|
||||
} from '@/utils/auth'
|
||||
import config from '@/config.js'
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 响应式数据
|
||||
const registering = ref(false)
|
||||
const agreed = ref(false)
|
||||
const countdown = ref(0)
|
||||
let countdownTimer = null
|
||||
// 响应式数据
|
||||
const registering = ref(false)
|
||||
const agreed = ref(false)
|
||||
const countdown = ref(0)
|
||||
let countdownTimer = null
|
||||
|
||||
// 注册表单
|
||||
const registerForm = reactive({
|
||||
// 注册表单
|
||||
const registerForm = reactive({
|
||||
username: '',
|
||||
phone: '',
|
||||
code: '',
|
||||
@ -149,10 +133,10 @@ const registerForm = reactive({
|
||||
confirmPassword: '',
|
||||
email: '',
|
||||
showEmail: false
|
||||
})
|
||||
})
|
||||
|
||||
// 发送验证码
|
||||
const sendCode = async () => {
|
||||
// 发送验证码
|
||||
const sendCode = async () => {
|
||||
if (!registerForm.phone) {
|
||||
modal.alert('请输入手机号')
|
||||
return
|
||||
@ -164,7 +148,9 @@ const sendCode = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
await sendPhoneCode({ phone: registerForm.phone }, 'register')
|
||||
await sendPhoneCode({
|
||||
phone: registerForm.phone
|
||||
}, 'register')
|
||||
modal.alert('验证码已发送')
|
||||
|
||||
// 开始倒计时
|
||||
@ -178,10 +164,10 @@ const sendCode = async () => {
|
||||
} catch (error) {
|
||||
modal.alert(error.message || '验证码发送失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理注册
|
||||
const handleRegister = async () => {
|
||||
// 处理注册
|
||||
const handleRegister = async () => {
|
||||
if (!validateForm()) return
|
||||
|
||||
registering.value = true
|
||||
@ -209,21 +195,19 @@ 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 || '注册失败')
|
||||
} finally {
|
||||
registering.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表单验证
|
||||
const validateForm = () => {
|
||||
// 表单验证
|
||||
const validateForm = () => {
|
||||
if (!registerForm.username) {
|
||||
modal.alert('请输入用户名')
|
||||
return false
|
||||
@ -265,10 +249,10 @@ const validateForm = () => {
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// 微信注册
|
||||
const handleWechatRegister = async () => {
|
||||
// 微信注册
|
||||
const handleWechatRegister = async () => {
|
||||
try {
|
||||
const code = await getWxCode()
|
||||
const res = await wxRegister('miniapp', code)
|
||||
@ -285,105 +269,107 @@ const handleWechatRegister = async () => {
|
||||
} catch (error) {
|
||||
modal.alert(error.message || '微信注册失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 切换协议同意状态
|
||||
const toggleAgreement = (e) => {
|
||||
// 切换协议同意状态
|
||||
const toggleAgreement = (e) => {
|
||||
agreed.value = e.detail.value.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
// 显示用户协议
|
||||
const showAgreement = () => {
|
||||
// 显示用户协议
|
||||
const showAgreement = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages_system/pages/login/agreement?type=user'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 显示隐私政策
|
||||
const showPrivacy = () => {
|
||||
// 显示隐私政策
|
||||
const showPrivacy = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages_system/pages/login/agreement?type=privacy'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 返回登录页面
|
||||
const goBack = () => {
|
||||
// 返回登录页面
|
||||
const goBack = () => {
|
||||
uni.navigateBack()
|
||||
}
|
||||
}
|
||||
|
||||
const goLogin = () => {
|
||||
const goLogin = () => {
|
||||
uni.redirectTo({
|
||||
url: '/pages/login'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 清理计时器
|
||||
import { onUnmounted } from 'vue'
|
||||
onUnmounted(() => {
|
||||
// 清理计时器
|
||||
import {
|
||||
onUnmounted
|
||||
} from 'vue'
|
||||
onUnmounted(() => {
|
||||
if (countdownTimer) {
|
||||
clearInterval(countdownTimer)
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.register-container {
|
||||
.register-container {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
}
|
||||
|
||||
.register-header {
|
||||
.register-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 40rpx 30rpx;
|
||||
background: #fff;
|
||||
border-bottom: 1rpx solid #e0e0e0;
|
||||
}
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
.back-btn {
|
||||
font-size: 50rpx;
|
||||
color: #333;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
.placeholder {
|
||||
width: 60rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.register-content {
|
||||
.register-content {
|
||||
padding: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.register-form {
|
||||
.register-form {
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
margin-bottom: 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
.form-item {
|
||||
.form-item {
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.label {
|
||||
.label {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.input {
|
||||
.input {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
@ -391,15 +377,15 @@ onUnmounted(() => {
|
||||
padding: 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
.code-input {
|
||||
.code-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.send-code-btn {
|
||||
.send-code-btn {
|
||||
width: 200rpx;
|
||||
height: 80rpx;
|
||||
background: #007aff;
|
||||
@ -408,37 +394,37 @@ onUnmounted(() => {
|
||||
border-radius: 10rpx;
|
||||
font-size: 24rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.send-code-btn[disabled] {
|
||||
.send-code-btn[disabled] {
|
||||
background: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.agreement {
|
||||
.agreement {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin: 40rpx 0;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
.checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.agreement-text {
|
||||
.agreement-text {
|
||||
margin-left: 10rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
.agreement-link {
|
||||
color: #007aff;
|
||||
margin: 0 5rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.register-btn {
|
||||
.register-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
background: #007aff;
|
||||
@ -447,36 +433,36 @@ onUnmounted(() => {
|
||||
border-radius: 44rpx;
|
||||
font-size: 32rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.register-btn[disabled] {
|
||||
.register-btn[disabled] {
|
||||
background: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.login-link {
|
||||
.login-link {
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
.link {
|
||||
.link {
|
||||
color: #007aff;
|
||||
}
|
||||
}
|
||||
|
||||
.third-register {
|
||||
.third-register {
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
.divider {
|
||||
.divider {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.divider::before {
|
||||
.divider::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
@ -484,27 +470,27 @@ onUnmounted(() => {
|
||||
right: 0;
|
||||
height: 1rpx;
|
||||
background: #e0e0e0;
|
||||
}
|
||||
}
|
||||
|
||||
.divider-text {
|
||||
.divider-text {
|
||||
background: #fff;
|
||||
padding: 0 20rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.register-methods {
|
||||
.register-methods {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.method-item {
|
||||
.method-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.method-icon {
|
||||
.method-icon {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 50%;
|
||||
@ -515,10 +501,10 @@ onUnmounted(() => {
|
||||
font-size: 40rpx;
|
||||
background: #07c160;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.method-text {
|
||||
.method-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user