修复校验
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
* @Author: Zy
|
||||
* @Date: 2026-05-18 15:36:10
|
||||
* @LastEditor: Zy
|
||||
* @LastEditTime: 2026-07-08 17:26:41
|
||||
* @LastEditTime: 2026-07-20 14:29:10
|
||||
*/
|
||||
let baseUrl = ''
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
baseUrl = 'http://192.168.1.222:8080' // 开发环境
|
||||
baseUrl = 'http://192.168.1.6:8080' // 开发环境
|
||||
} else {
|
||||
baseUrl = 'https://wuyeapi.ckdzkj.com' // 生产环境
|
||||
// baseUrl = 'https://wuyeapi.bugtc.com' // 生产环境
|
||||
|
||||
@@ -54,11 +54,9 @@
|
||||
"NSBluetoothPeripheralUsageDescription": "需要蓝牙权限连接小区智能门禁,实现蓝牙一键开门通行,仅用于小区门禁解锁业务,不采集蓝牙设备信息。",
|
||||
"NSBluetoothAlwaysUsageDescription": "本应用需要蓝牙权限,用于扫描、连接小区蓝牙门禁设备实现一键开门,仅和本小区门禁硬件建立通信,不会扫描、连接无关蓝牙设备。"
|
||||
},
|
||||
"urltypes" : [
|
||||
{
|
||||
"urltypes": [{
|
||||
"urlschemes": ["unionpaycashier"]
|
||||
}
|
||||
],
|
||||
}],
|
||||
"idfa": false
|
||||
},
|
||||
"sdkConfigs": {
|
||||
@@ -150,5 +148,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"h5": {
|
||||
"devServer": {
|
||||
"port": 5588
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@
|
||||
>我已阅读并同意
|
||||
<text class="agreePrivacy">《用户隐私政策》</text>
|
||||
</text> -->
|
||||
<text class="agreement-text" >我已阅读并同意
|
||||
<text class="agreement-text"
|
||||
>我已阅读并同意
|
||||
<text class="agreePrivacy" @click.stop="goToUserAgreement">《用户协议》</text>和
|
||||
<text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text>
|
||||
</text>
|
||||
@@ -87,7 +88,11 @@
|
||||
</view>
|
||||
|
||||
<!-- 隐私协议弹窗 -->
|
||||
<privacy-popup v-model:show="showPrivacyPopup" @agree="agreePrivacy" @disagree="disagreePrivacy" />
|
||||
<privacy-popup
|
||||
v-model:show="showPrivacyPopup"
|
||||
@agree="agreePrivacy"
|
||||
@disagree="disagreePrivacy"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -159,7 +164,6 @@ const toggleAgreement = () => {
|
||||
// #endif
|
||||
}
|
||||
|
||||
|
||||
// 不同意隐私协议
|
||||
const disagreePrivacy = () => {
|
||||
agreeAgreement.value = false
|
||||
@@ -247,6 +251,7 @@ const handleLogin = () => {
|
||||
if (res.code === 200) {
|
||||
if (res.data) {
|
||||
uni.setStorageSync('token', res.data.token)
|
||||
uni.setStorageSync('userPermission', res.data.user.permissions)
|
||||
// 存用户ID
|
||||
if (res.data.user.userId) {
|
||||
uni.setStorageSync('userId', res.data.user.userId)
|
||||
|
||||
@@ -8,11 +8,20 @@
|
||||
<view class="input-item">
|
||||
<view class="input-icon">
|
||||
<!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> -->
|
||||
<image src="https://wuyeadmin.bugtc.com/images/login/phone.png" mode=""
|
||||
style="height: 100%;width: 100%;"></image>
|
||||
<image
|
||||
src="https://wuyeadmin.bugtc.com/images/login/phone.png"
|
||||
mode=""
|
||||
style="height: 100%; width: 100%"
|
||||
></image>
|
||||
</view>
|
||||
<uni-easyinput class="input-content" type="text" v-model="phoneNumber" placeholder="请输入帐号"
|
||||
:inputBorder="false" :placeholderStyle="placeholderStyle">
|
||||
<uni-easyinput
|
||||
class="input-content"
|
||||
type="text"
|
||||
v-model="phoneNumber"
|
||||
placeholder="请输入帐号"
|
||||
:inputBorder="false"
|
||||
:placeholderStyle="placeholderStyle"
|
||||
>
|
||||
</uni-easyinput>
|
||||
</view>
|
||||
|
||||
@@ -20,17 +29,25 @@
|
||||
<view class="input-item">
|
||||
<view class="input-icon">
|
||||
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
|
||||
<image src="https://wuyeadmin.bugtc.com/images/login/password.png" mode=""
|
||||
style="height: 100%;width: 100%;"></image>
|
||||
<image
|
||||
src="https://wuyeadmin.bugtc.com/images/login/password.png"
|
||||
mode=""
|
||||
style="height: 100%; width: 100%"
|
||||
></image>
|
||||
</view>
|
||||
<uni-easyinput class="input-content" type="password" v-model="password" placeholder="请输入6-16位密码"
|
||||
:inputBorder="false" :placeholderStyle="placeholderStyle">
|
||||
<uni-easyinput
|
||||
class="input-content"
|
||||
type="password"
|
||||
v-model="password"
|
||||
placeholder="请输入6-16位密码"
|
||||
:inputBorder="false"
|
||||
:placeholderStyle="placeholderStyle"
|
||||
>
|
||||
</uni-easyinput>
|
||||
|
||||
</view>
|
||||
|
||||
<!-- 记住密码 -->
|
||||
<view class="remember-wrap" style="display: none;">
|
||||
<view class="remember-wrap" style="display: none">
|
||||
<view class="remember-item" @click="toggleRemember">
|
||||
<uni-icons type="checkbox-filled" size="18" color="#4D5DFA" v-if="rememberPwd"></uni-icons>
|
||||
<uni-icons type="checkbox" size="18" color="#999" v-else></uni-icons>
|
||||
@@ -42,10 +59,16 @@
|
||||
<view class="agreement-wrap">
|
||||
<view class="agreement-item">
|
||||
<view @click="toggleAgreement">
|
||||
<uni-icons type="checkbox-filled" size="24" color="#4D5DFA" v-if="agreeAgreement"></uni-icons>
|
||||
<uni-icons
|
||||
type="checkbox-filled"
|
||||
size="24"
|
||||
color="#4D5DFA"
|
||||
v-if="agreeAgreement"
|
||||
></uni-icons>
|
||||
<uni-icons type="checkbox" size="24" color="#999" v-else></uni-icons>
|
||||
</view>
|
||||
<text class="agreement-text" >我已阅读并同意
|
||||
<text class="agreement-text"
|
||||
>我已阅读并同意
|
||||
<text class="agreePrivacy" @click.stop="goToUserAgreement">《用户协议》</text>和
|
||||
<text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text>
|
||||
</text>
|
||||
@@ -54,9 +77,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
登录
|
||||
</button>
|
||||
<button class="login-btn" @click="handleLogin">登录</button>
|
||||
|
||||
<!-- 底部链接 -->
|
||||
<view class="bottom-link">
|
||||
@@ -65,45 +86,43 @@
|
||||
</view>
|
||||
</view>
|
||||
<!-- 隐私协议弹窗 -->
|
||||
<privacy-popup v-model:show="showPrivacyPopup" @agree="agreePrivacy" @disagree="disagreePrivacy" @close="showPrivacyPopup = false" />
|
||||
<privacy-popup
|
||||
v-model:show="showPrivacyPopup"
|
||||
@agree="agreePrivacy"
|
||||
@disagree="disagreePrivacy"
|
||||
@close="showPrivacyPopup = false"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
computed
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad
|
||||
} from "@dcloudio/uni-app"
|
||||
import {
|
||||
getLoginPassword
|
||||
} from '../../api/api.js'
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getLoginPassword } from '../../api/api.js'
|
||||
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
|
||||
|
||||
// 响应式数据
|
||||
const phoneNumber = ref('');
|
||||
const password = ref('');
|
||||
const agreeAgreement = ref(false); // 默认勾选
|
||||
const rememberPwd = ref(false);
|
||||
const phoneNumber = ref('')
|
||||
const password = ref('')
|
||||
const agreeAgreement = ref(false) // 默认勾选
|
||||
const rememberPwd = ref(false)
|
||||
const placeholderStyle = ref('font-size:24rpx')
|
||||
const showPrivacyPopup = ref(false)
|
||||
|
||||
// 计算属性:是否可登录(帐号+密码+协议都满足)
|
||||
const canLogin = computed(() => {
|
||||
const phoneReg = /^[a-zA-Z0-9_-]{4,16}$/; // 4-16位
|
||||
const pwdReg = /^.{6,16}$/; // 密码6-16位
|
||||
return phoneReg.test(phoneNumber.value) && pwdReg.test(password.value) && agreeAgreement.value;
|
||||
});
|
||||
const phoneReg = /^[a-zA-Z0-9_-]{4,16}$/ // 4-16位
|
||||
const pwdReg = /^.{6,16}$/ // 密码6-16位
|
||||
return phoneReg.test(phoneNumber.value) && pwdReg.test(password.value) && agreeAgreement.value
|
||||
})
|
||||
|
||||
// 切换协议勾选
|
||||
const toggleAgreement = () => {
|
||||
agreeAgreement.value = !agreeAgreement.value;
|
||||
};
|
||||
agreeAgreement.value = !agreeAgreement.value
|
||||
}
|
||||
// 切换记住密码
|
||||
const toggleRemember = () => {
|
||||
rememberPwd.value = !rememberPwd.value;
|
||||
};
|
||||
rememberPwd.value = !rememberPwd.value
|
||||
}
|
||||
|
||||
// 打开用户协议
|
||||
const goToUserAgreement = () => {
|
||||
@@ -130,7 +149,6 @@
|
||||
// showPrivacyPopup.value = true
|
||||
// }
|
||||
|
||||
|
||||
// 不同意隐私协议
|
||||
const disagreePrivacy = () => {
|
||||
agreeAgreement.value = false
|
||||
@@ -138,45 +156,44 @@
|
||||
}
|
||||
|
||||
// 检查表单
|
||||
const checkForm = () => {};
|
||||
|
||||
const checkForm = () => {}
|
||||
|
||||
onLoad(() => {
|
||||
const savedPhone = uni.getStorageSync('rememberPhone');
|
||||
const savedPwd = uni.getStorageSync('rememberPassword');
|
||||
const savedRemember = uni.getStorageSync('rememberPwd');
|
||||
if (savedPhone) phoneNumber.value = savedPhone;
|
||||
if (savedPwd) password.value = savedPwd;
|
||||
if (savedRemember) rememberPwd.value = savedRemember;
|
||||
});
|
||||
const savedPhone = uni.getStorageSync('rememberPhone')
|
||||
const savedPwd = uni.getStorageSync('rememberPassword')
|
||||
const savedRemember = uni.getStorageSync('rememberPwd')
|
||||
if (savedPhone) phoneNumber.value = savedPhone
|
||||
if (savedPwd) password.value = savedPwd
|
||||
if (savedRemember) rememberPwd.value = savedRemember
|
||||
})
|
||||
|
||||
// 登录逻辑
|
||||
const handleLogin = () => {
|
||||
if (!phoneNumber.value) {
|
||||
uni.showToast({ title: '请输入账号', icon: 'none' });
|
||||
return;
|
||||
uni.showToast({ title: '请输入账号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (phoneNumber.value.length < 4 || phoneNumber.value.length > 16) {
|
||||
uni.showToast({ title: '账号长度需为 4-16 位', icon: 'none' });
|
||||
return;
|
||||
uni.showToast({ title: '账号长度需为 4-16 位', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!password.value) {
|
||||
uni.showToast({ title: '请输入密码', icon: 'none' });
|
||||
return;
|
||||
uni.showToast({ title: '请输入密码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (password.value.length < 6) {
|
||||
uni.showToast({ title: '密码至少输入 6 位', icon: 'none' });
|
||||
return;
|
||||
uni.showToast({ title: '密码至少输入 6 位', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (password.value.length > 16) {
|
||||
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' });
|
||||
return;
|
||||
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!agreeAgreement.value) {
|
||||
showPrivacyPopup.value = true;
|
||||
return;
|
||||
showPrivacyPopup.value = true
|
||||
return
|
||||
}
|
||||
uni.showLoading({ title: '登录中...', mask: true });
|
||||
uni.showLoading({ title: '登录中...', mask: true })
|
||||
const push_cid = uni.getStorageSync('push_cid')
|
||||
// console.log('登录cid',push_cid)
|
||||
let params = {
|
||||
@@ -184,47 +201,50 @@
|
||||
password: password.value,
|
||||
cid: push_cid
|
||||
}
|
||||
getLoginPassword(params).then(res =>{
|
||||
getLoginPassword(params)
|
||||
.then(res => {
|
||||
// console.log('33333',res)
|
||||
if (res.code === 200) {
|
||||
uni.setStorageSync('token', res.data.token);
|
||||
uni.setStorageSync('token', res.data.token)
|
||||
// 清掉上次账号的小区缓存,防止新账号显示旧小区
|
||||
uni.removeStorageSync('currentVillage');
|
||||
uni.removeStorageSync('currentVillage')
|
||||
// 存用户ID
|
||||
// if(res.data) {
|
||||
// // 存当前绑定的小区ID,0 表示未绑定
|
||||
// // const currentVillageId = res.data.currentVillageId || 0;
|
||||
// // uni.setStorageSync('currentVillageId', currentVillageId);
|
||||
// }
|
||||
uni.hideLoading();
|
||||
uni.setStorageSync('userPermission', res.data.user.permissions)
|
||||
uni.hideLoading()
|
||||
if (rememberPwd.value) {
|
||||
uni.setStorageSync('rememberPhone', phoneNumber.value);
|
||||
uni.setStorageSync('rememberPassword', password.value);
|
||||
uni.setStorageSync('rememberPwd', true);
|
||||
uni.setStorageSync('rememberPhone', phoneNumber.value)
|
||||
uni.setStorageSync('rememberPassword', password.value)
|
||||
uni.setStorageSync('rememberPwd', true)
|
||||
} else {
|
||||
uni.removeStorageSync('rememberPhone');
|
||||
uni.removeStorageSync('rememberPassword');
|
||||
uni.removeStorageSync('rememberPwd');
|
||||
uni.removeStorageSync('rememberPhone')
|
||||
uni.removeStorageSync('rememberPassword')
|
||||
uni.removeStorageSync('rememberPwd')
|
||||
}
|
||||
uni.showToast({ title: '登录成功', icon: 'success' });
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
uni.switchTab(
|
||||
{
|
||||
url: '/pages/index/index'
|
||||
},1000);
|
||||
},
|
||||
1000
|
||||
)
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: res.msg, icon: 'error' });
|
||||
uni.showToast({ title: res.msg, icon: 'error' })
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
})
|
||||
.catch(err => {
|
||||
uni.showToast({
|
||||
title: err.msg,
|
||||
icon: 'error'
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
// 同意隐私协议(弹窗中点击同意 → 直接登录)
|
||||
const agreePrivacy = () => {
|
||||
@@ -239,7 +259,7 @@
|
||||
padding: 80rpx 40rpx 40rpx;
|
||||
/* background-color: #f8f9fa; */
|
||||
min-height: 100vh;
|
||||
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF);
|
||||
background: repeating-linear-gradient(180deg, #e2f0ff, #f6faff);
|
||||
}
|
||||
|
||||
.status_bar {
|
||||
@@ -337,7 +357,7 @@
|
||||
line-height: 1.5;
|
||||
}
|
||||
.agreePrivacy {
|
||||
color: #4D5DFA;
|
||||
color: #4d5dfa;
|
||||
}
|
||||
/* .agreePrivacy.active{
|
||||
color: #4D5DFA;
|
||||
@@ -356,7 +376,7 @@
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
background-color: #4D5DFA;
|
||||
background-color: #4d5dfa;
|
||||
color: #fff;
|
||||
border-radius: 8rpx;
|
||||
font-size: 28rpx;
|
||||
@@ -367,7 +387,6 @@
|
||||
background-color: #99c8ff;
|
||||
color: #fff;
|
||||
/* border-radius: 50px; */
|
||||
|
||||
}
|
||||
|
||||
/* 禁用按钮边框 */
|
||||
@@ -383,7 +402,7 @@
|
||||
|
||||
.link-item {
|
||||
font-size: 28rpx;
|
||||
color: #4D5DFA;
|
||||
color: #4d5dfa;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -35,9 +35,7 @@
|
||||
|
||||
<!-- 退出登录按钮 -->
|
||||
<view class="logout-btn-wrap">
|
||||
<button class="logout-btn" @tap="handleLogout">
|
||||
退出登录
|
||||
</button>
|
||||
<button class="logout-btn" @tap="handleLogout">退出登录</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -46,6 +44,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { logout, getSettingInfo } from '../../api/api.js'
|
||||
import { clearPermList } from '../../utils/permissions.js'
|
||||
|
||||
// 响应式数据
|
||||
const phoneNumber = ref('') // 绑定手机号
|
||||
@@ -116,17 +115,21 @@ const handleLogout = () => {
|
||||
const confirmLogout = () => {
|
||||
uni.showLoading({ title: '退出中...' })
|
||||
|
||||
logout().then(res => {
|
||||
logout()
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
clearPermList()
|
||||
uni.clearStorageSync()
|
||||
uni.showToast({ title: '退出登录成功', icon: 'success' })
|
||||
uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' })
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '退出失败', icon: 'none' })
|
||||
}
|
||||
}).catch(() => {
|
||||
})
|
||||
.catch(() => {
|
||||
uni.showToast({ title: '退出失败,请重试', icon: 'none' })
|
||||
}).finally(() => {
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
<view
|
||||
class="function-item"
|
||||
@tap="goToReplacement_record"
|
||||
v-if="hasPermi('butler:,meter:replace')"
|
||||
v-if="hasPermi('butler:meter:replace')"
|
||||
>
|
||||
<image
|
||||
class="item-icon"
|
||||
@@ -198,6 +198,7 @@ const pendingCount = ref(0) //待巡检
|
||||
const InspectedCount = ref(0) //已巡检
|
||||
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
|
||||
|
||||
console.log(hasPermi('butler:meter:replace'))
|
||||
// =======方法=======
|
||||
// 跳转小区
|
||||
const navigateToPage = () => {
|
||||
|
||||
@@ -10,7 +10,7 @@ export function getPermList() {
|
||||
* 权限校验函数
|
||||
* @param perm 单个权限字符串 / 多个权限数组
|
||||
* @param mode or满足任一 / and全部满足,默认or
|
||||
* @returns 是否拥有权限
|
||||
* @returns 是否拥有权限 false 没有权限 true 有权限
|
||||
*/
|
||||
export function hasPermi(perm, mode = 'or') {
|
||||
const permList = getPermList()
|
||||
@@ -23,6 +23,7 @@ export function hasPermi(perm, mode = 'or') {
|
||||
// 所有权限都要有
|
||||
return checkArr.every(item => permList.includes(item))
|
||||
} else {
|
||||
console.log(permList, checkArr)
|
||||
// 有一个即可
|
||||
return checkArr.some(item => permList.includes(item))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user