修复校验

This commit is contained in:
Zy
2026-07-20 14:50:16 +08:00
parent d7c201d357
commit a5a883a652
8 changed files with 672 additions and 640 deletions

View File

@@ -3,12 +3,12 @@
* @Author: Zy * @Author: Zy
* @Date: 2026-05-18 15:36:10 * @Date: 2026-05-18 15:36:10
* @LastEditor: Zy * @LastEditor: Zy
* @LastEditTime: 2026-07-08 17:26:41 * @LastEditTime: 2026-07-20 14:29:10
*/ */
let baseUrl = '' let baseUrl = ''
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.1.222:8080' // 开发环境 baseUrl = 'http://192.168.1.6:8080' // 开发环境
} else { } else {
baseUrl = 'https://wuyeapi.ckdzkj.com' // 生产环境 baseUrl = 'https://wuyeapi.ckdzkj.com' // 生产环境
// baseUrl = 'https://wuyeapi.bugtc.com' // 生产环境 // baseUrl = 'https://wuyeapi.bugtc.com' // 生产环境

View File

@@ -54,11 +54,9 @@
"NSBluetoothPeripheralUsageDescription": "需要蓝牙权限连接小区智能门禁,实现蓝牙一键开门通行,仅用于小区门禁解锁业务,不采集蓝牙设备信息。", "NSBluetoothPeripheralUsageDescription": "需要蓝牙权限连接小区智能门禁,实现蓝牙一键开门通行,仅用于小区门禁解锁业务,不采集蓝牙设备信息。",
"NSBluetoothAlwaysUsageDescription": "本应用需要蓝牙权限,用于扫描、连接小区蓝牙门禁设备实现一键开门,仅和本小区门禁硬件建立通信,不会扫描、连接无关蓝牙设备。" "NSBluetoothAlwaysUsageDescription": "本应用需要蓝牙权限,用于扫描、连接小区蓝牙门禁设备实现一键开门,仅和本小区门禁硬件建立通信,不会扫描、连接无关蓝牙设备。"
}, },
"urltypes" : [ "urltypes": [{
{
"urlschemes": ["unionpaycashier"] "urlschemes": ["unionpaycashier"]
} }],
],
"idfa": false "idfa": false
}, },
"sdkConfigs": { "sdkConfigs": {
@@ -150,5 +148,10 @@
} }
} }
} }
},
"h5": {
"devServer": {
"port": 5588
}
} }
} }

View File

@@ -71,7 +71,8 @@
>我已阅读并同意 >我已阅读并同意
<text class="agreePrivacy">《用户隐私政策》</text> <text class="agreePrivacy">《用户隐私政策》</text>
</text> --> </text> -->
<text class="agreement-text" >我已阅读并同意 <text class="agreement-text"
>我已阅读并同意
<text class="agreePrivacy" @click.stop="goToUserAgreement">《用户协议》</text>和 <text class="agreePrivacy" @click.stop="goToUserAgreement">《用户协议》</text>和
<text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text> <text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text>
</text> </text>
@@ -87,7 +88,11 @@
</view> </view>
<!-- 隐私协议弹窗 --> <!-- 隐私协议弹窗 -->
<privacy-popup v-model:show="showPrivacyPopup" @agree="agreePrivacy" @disagree="disagreePrivacy" /> <privacy-popup
v-model:show="showPrivacyPopup"
@agree="agreePrivacy"
@disagree="disagreePrivacy"
/>
</view> </view>
</template> </template>
@@ -159,7 +164,6 @@ const toggleAgreement = () => {
// #endif // #endif
} }
// 不同意隐私协议 // 不同意隐私协议
const disagreePrivacy = () => { const disagreePrivacy = () => {
agreeAgreement.value = false agreeAgreement.value = false
@@ -247,6 +251,7 @@ const handleLogin = () => {
if (res.code === 200) { if (res.code === 200) {
if (res.data) { if (res.data) {
uni.setStorageSync('token', res.data.token) uni.setStorageSync('token', res.data.token)
uni.setStorageSync('userPermission', res.data.user.permissions)
// 存用户ID // 存用户ID
if (res.data.user.userId) { if (res.data.user.userId) {
uni.setStorageSync('userId', res.data.user.userId) uni.setStorageSync('userId', res.data.user.userId)

View File

@@ -8,11 +8,20 @@
<view class="input-item"> <view class="input-item">
<view class="input-icon"> <view class="input-icon">
<!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> --> <!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> -->
<image src="https://wuyeadmin.bugtc.com/images/login/phone.png" mode="" <image
style="height: 100%;width: 100%;"></image> src="https://wuyeadmin.bugtc.com/images/login/phone.png"
mode=""
style="height: 100%; width: 100%"
></image>
</view> </view>
<uni-easyinput class="input-content" type="text" v-model="phoneNumber" placeholder="请输入帐号" <uni-easyinput
:inputBorder="false" :placeholderStyle="placeholderStyle"> class="input-content"
type="text"
v-model="phoneNumber"
placeholder="请输入帐号"
:inputBorder="false"
:placeholderStyle="placeholderStyle"
>
</uni-easyinput> </uni-easyinput>
</view> </view>
@@ -20,17 +29,25 @@
<view class="input-item"> <view class="input-item">
<view class="input-icon"> <view class="input-icon">
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> --> <!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
<image src="https://wuyeadmin.bugtc.com/images/login/password.png" mode="" <image
style="height: 100%;width: 100%;"></image> src="https://wuyeadmin.bugtc.com/images/login/password.png"
mode=""
style="height: 100%; width: 100%"
></image>
</view> </view>
<uni-easyinput class="input-content" type="password" v-model="password" placeholder="请输入6-16位密码" <uni-easyinput
:inputBorder="false" :placeholderStyle="placeholderStyle"> class="input-content"
type="password"
v-model="password"
placeholder="请输入6-16位密码"
:inputBorder="false"
:placeholderStyle="placeholderStyle"
>
</uni-easyinput> </uni-easyinput>
</view> </view>
<!-- 记住密码 --> <!-- 记住密码 -->
<view class="remember-wrap" style="display: none;"> <view class="remember-wrap" style="display: none">
<view class="remember-item" @click="toggleRemember"> <view class="remember-item" @click="toggleRemember">
<uni-icons type="checkbox-filled" size="18" color="#4D5DFA" v-if="rememberPwd"></uni-icons> <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> <uni-icons type="checkbox" size="18" color="#999" v-else></uni-icons>
@@ -42,10 +59,16 @@
<view class="agreement-wrap"> <view class="agreement-wrap">
<view class="agreement-item"> <view class="agreement-item">
<view @click="toggleAgreement"> <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> <uni-icons type="checkbox" size="24" color="#999" v-else></uni-icons>
</view> </view>
<text class="agreement-text" >我已阅读并同意 <text class="agreement-text"
>我已阅读并同意
<text class="agreePrivacy" @click.stop="goToUserAgreement">《用户协议》</text>和 <text class="agreePrivacy" @click.stop="goToUserAgreement">《用户协议》</text>和
<text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text> <text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text>
</text> </text>
@@ -54,9 +77,7 @@
</view> </view>
<!-- 登录按钮 --> <!-- 登录按钮 -->
<button class="login-btn" @click="handleLogin"> <button class="login-btn" @click="handleLogin">登录</button>
登录
</button>
<!-- 底部链接 --> <!-- 底部链接 -->
<view class="bottom-link"> <view class="bottom-link">
@@ -65,45 +86,43 @@
</view> </view>
</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> </template>
<script setup> <script setup>
import { import { ref, computed } from 'vue'
ref, import { onLoad } from '@dcloudio/uni-app'
computed import { getLoginPassword } from '../../api/api.js'
} from 'vue';
import {
onLoad
} from "@dcloudio/uni-app"
import {
getLoginPassword
} from '../../api/api.js'
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue' import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
// 响应式数据 // 响应式数据
const phoneNumber = ref(''); const phoneNumber = ref('')
const password = ref(''); const password = ref('')
const agreeAgreement = ref(false); // 默认勾选 const agreeAgreement = ref(false) // 默认勾选
const rememberPwd = ref(false); const rememberPwd = ref(false)
const placeholderStyle = ref('font-size:24rpx') const placeholderStyle = ref('font-size:24rpx')
const showPrivacyPopup = ref(false) const showPrivacyPopup = ref(false)
// 计算属性:是否可登录(帐号+密码+协议都满足) // 计算属性:是否可登录(帐号+密码+协议都满足)
const canLogin = computed(() => { const canLogin = computed(() => {
const phoneReg = /^[a-zA-Z0-9_-]{4,16}$/; // 4-16位 const phoneReg = /^[a-zA-Z0-9_-]{4,16}$/ // 4-16位
const pwdReg = /^.{6,16}$/; // 密码6-16位 const pwdReg = /^.{6,16}$/ // 密码6-16位
return phoneReg.test(phoneNumber.value) && pwdReg.test(password.value) && agreeAgreement.value; return phoneReg.test(phoneNumber.value) && pwdReg.test(password.value) && agreeAgreement.value
}); })
// 切换协议勾选 // 切换协议勾选
const toggleAgreement = () => { const toggleAgreement = () => {
agreeAgreement.value = !agreeAgreement.value; agreeAgreement.value = !agreeAgreement.value
}; }
// 切换记住密码 // 切换记住密码
const toggleRemember = () => { const toggleRemember = () => {
rememberPwd.value = !rememberPwd.value; rememberPwd.value = !rememberPwd.value
}; }
// 打开用户协议 // 打开用户协议
const goToUserAgreement = () => { const goToUserAgreement = () => {
@@ -130,7 +149,6 @@
// showPrivacyPopup.value = true // showPrivacyPopup.value = true
// } // }
// 不同意隐私协议 // 不同意隐私协议
const disagreePrivacy = () => { const disagreePrivacy = () => {
agreeAgreement.value = false agreeAgreement.value = false
@@ -138,45 +156,44 @@
} }
// 检查表单 // 检查表单
const checkForm = () => {}; const checkForm = () => {}
onLoad(() => { onLoad(() => {
const savedPhone = uni.getStorageSync('rememberPhone'); const savedPhone = uni.getStorageSync('rememberPhone')
const savedPwd = uni.getStorageSync('rememberPassword'); const savedPwd = uni.getStorageSync('rememberPassword')
const savedRemember = uni.getStorageSync('rememberPwd'); const savedRemember = uni.getStorageSync('rememberPwd')
if (savedPhone) phoneNumber.value = savedPhone; if (savedPhone) phoneNumber.value = savedPhone
if (savedPwd) password.value = savedPwd; if (savedPwd) password.value = savedPwd
if (savedRemember) rememberPwd.value = savedRemember; if (savedRemember) rememberPwd.value = savedRemember
}); })
// 登录逻辑 // 登录逻辑
const handleLogin = () => { const handleLogin = () => {
if (!phoneNumber.value) { if (!phoneNumber.value) {
uni.showToast({ title: '请输入账号', icon: 'none' }); uni.showToast({ title: '请输入账号', icon: 'none' })
return; return
} }
if (phoneNumber.value.length < 4 || phoneNumber.value.length > 16) { if (phoneNumber.value.length < 4 || phoneNumber.value.length > 16) {
uni.showToast({ title: '账号长度需为 4-16 位', icon: 'none' }); uni.showToast({ title: '账号长度需为 4-16 位', icon: 'none' })
return; return
} }
if (!password.value) { if (!password.value) {
uni.showToast({ title: '请输入密码', icon: 'none' }); uni.showToast({ title: '请输入密码', icon: 'none' })
return; return
} }
if (password.value.length < 6) { if (password.value.length < 6) {
uni.showToast({ title: '密码至少输入 6 位', icon: 'none' }); uni.showToast({ title: '密码至少输入 6 位', icon: 'none' })
return; return
} }
if (password.value.length > 16) { if (password.value.length > 16) {
uni.showToast({ title: '密码不能超过 16 位', icon: 'none' }); uni.showToast({ title: '密码不能超过 16 位', icon: 'none' })
return; return
} }
if (!agreeAgreement.value) { if (!agreeAgreement.value) {
showPrivacyPopup.value = true; showPrivacyPopup.value = true
return; return
} }
uni.showLoading({ title: '登录中...', mask: true }); uni.showLoading({ title: '登录中...', mask: true })
const push_cid = uni.getStorageSync('push_cid') const push_cid = uni.getStorageSync('push_cid')
// console.log('登录cid',push_cid) // console.log('登录cid',push_cid)
let params = { let params = {
@@ -184,47 +201,50 @@
password: password.value, password: password.value,
cid: push_cid cid: push_cid
} }
getLoginPassword(params).then(res =>{ getLoginPassword(params)
.then(res => {
// console.log('33333',res) // console.log('33333',res)
if (res.code === 200) { if (res.code === 200) {
uni.setStorageSync('token', res.data.token); uni.setStorageSync('token', res.data.token)
// 清掉上次账号的小区缓存,防止新账号显示旧小区 // 清掉上次账号的小区缓存,防止新账号显示旧小区
uni.removeStorageSync('currentVillage'); uni.removeStorageSync('currentVillage')
// 存用户ID // 存用户ID
// if(res.data) { // if(res.data) {
// // 存当前绑定的小区ID,0 表示未绑定 // // 存当前绑定的小区ID,0 表示未绑定
// // const currentVillageId = res.data.currentVillageId || 0; // // const currentVillageId = res.data.currentVillageId || 0;
// // uni.setStorageSync('currentVillageId', currentVillageId); // // uni.setStorageSync('currentVillageId', currentVillageId);
// } // }
uni.hideLoading(); uni.setStorageSync('userPermission', res.data.user.permissions)
uni.hideLoading()
if (rememberPwd.value) { if (rememberPwd.value) {
uni.setStorageSync('rememberPhone', phoneNumber.value); uni.setStorageSync('rememberPhone', phoneNumber.value)
uni.setStorageSync('rememberPassword', password.value); uni.setStorageSync('rememberPassword', password.value)
uni.setStorageSync('rememberPwd', true); uni.setStorageSync('rememberPwd', true)
} else { } else {
uni.removeStorageSync('rememberPhone'); uni.removeStorageSync('rememberPhone')
uni.removeStorageSync('rememberPassword'); uni.removeStorageSync('rememberPassword')
uni.removeStorageSync('rememberPwd'); uni.removeStorageSync('rememberPwd')
} }
uni.showToast({ title: '登录成功', icon: 'success' }); uni.showToast({ title: '登录成功', icon: 'success' })
setTimeout(() => { setTimeout(() => {
uni.switchTab({ uni.switchTab(
{
url: '/pages/index/index' url: '/pages/index/index'
},1000); },
1000
)
}) })
} else { } else {
uni.showToast({ title: res.msg, icon: 'error' }); uni.showToast({ title: res.msg, icon: 'error' })
} }
})
}).catch(err => { .catch(err => {
uni.showToast({ uni.showToast({
title: err.msg, title: err.msg,
icon: 'error' icon: 'error'
});
}) })
})
}
};
// 同意隐私协议(弹窗中点击同意 → 直接登录) // 同意隐私协议(弹窗中点击同意 → 直接登录)
const agreePrivacy = () => { const agreePrivacy = () => {
@@ -239,7 +259,7 @@
padding: 80rpx 40rpx 40rpx; padding: 80rpx 40rpx 40rpx;
/* background-color: #f8f9fa; */ /* background-color: #f8f9fa; */
min-height: 100vh; min-height: 100vh;
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF); background: repeating-linear-gradient(180deg, #e2f0ff, #f6faff);
} }
.status_bar { .status_bar {
@@ -337,7 +357,7 @@
line-height: 1.5; line-height: 1.5;
} }
.agreePrivacy { .agreePrivacy {
color: #4D5DFA; color: #4d5dfa;
} }
/* .agreePrivacy.active{ /* .agreePrivacy.active{
color: #4D5DFA; color: #4D5DFA;
@@ -356,7 +376,7 @@
width: 100%; width: 100%;
height: 88rpx; height: 88rpx;
line-height: 88rpx; line-height: 88rpx;
background-color: #4D5DFA; background-color: #4d5dfa;
color: #fff; color: #fff;
border-radius: 8rpx; border-radius: 8rpx;
font-size: 28rpx; font-size: 28rpx;
@@ -367,7 +387,6 @@
background-color: #99c8ff; background-color: #99c8ff;
color: #fff; color: #fff;
/* border-radius: 50px; */ /* border-radius: 50px; */
} }
/* 禁用按钮边框 */ /* 禁用按钮边框 */
@@ -383,7 +402,7 @@
.link-item { .link-item {
font-size: 28rpx; font-size: 28rpx;
color: #4D5DFA; color: #4d5dfa;
text-decoration: none; text-decoration: none;
} }
</style> </style>

View File

@@ -35,9 +35,7 @@
<!-- 退出登录按钮 --> <!-- 退出登录按钮 -->
<view class="logout-btn-wrap"> <view class="logout-btn-wrap">
<button class="logout-btn" @tap="handleLogout"> <button class="logout-btn" @tap="handleLogout">退出登录</button>
退出登录
</button>
</view> </view>
</view> </view>
</template> </template>
@@ -46,6 +44,7 @@
import { ref } from 'vue' import { ref } from 'vue'
import { onShow } from '@dcloudio/uni-app' import { onShow } from '@dcloudio/uni-app'
import { logout, getSettingInfo } from '../../api/api.js' import { logout, getSettingInfo } from '../../api/api.js'
import { clearPermList } from '../../utils/permissions.js'
// 响应式数据 // 响应式数据
const phoneNumber = ref('') // 绑定手机号 const phoneNumber = ref('') // 绑定手机号
@@ -116,17 +115,21 @@ const handleLogout = () => {
const confirmLogout = () => { const confirmLogout = () => {
uni.showLoading({ title: '退出中...' }) uni.showLoading({ title: '退出中...' })
logout().then(res => { logout()
.then(res => {
if (res.code === 200) { if (res.code === 200) {
clearPermList()
uni.clearStorageSync() uni.clearStorageSync()
uni.showToast({ title: '退出登录成功', icon: 'success' }) uni.showToast({ title: '退出登录成功', icon: 'success' })
uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' }) uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' })
} else { } else {
uni.showToast({ title: res.msg || '退出失败', icon: 'none' }) uni.showToast({ title: res.msg || '退出失败', icon: 'none' })
} }
}).catch(() => { })
.catch(() => {
uni.showToast({ title: '退出失败,请重试', icon: 'none' }) uni.showToast({ title: '退出失败,请重试', icon: 'none' })
}).finally(() => { })
.finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
} }

View File

@@ -163,7 +163,7 @@
<view <view
class="function-item" class="function-item"
@tap="goToReplacement_record" @tap="goToReplacement_record"
v-if="hasPermi('butler:,meter:replace')" v-if="hasPermi('butler:meter:replace')"
> >
<image <image
class="item-icon" class="item-icon"
@@ -198,6 +198,7 @@ const pendingCount = ref(0) //待巡检
const InspectedCount = ref(0) //已巡检 const InspectedCount = ref(0) //已巡检
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0) const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
console.log(hasPermi('butler:meter:replace'))
// =======方法======= // =======方法=======
// 跳转小区 // 跳转小区
const navigateToPage = () => { const navigateToPage = () => {

View File

@@ -10,7 +10,7 @@ export function getPermList() {
* 权限校验函数 * 权限校验函数
* @param perm 单个权限字符串 / 多个权限数组 * @param perm 单个权限字符串 / 多个权限数组
* @param mode or满足任一 / and全部满足,默认or * @param mode or满足任一 / and全部满足,默认or
* @returns 是否拥有权限 * @returns 是否拥有权限 false 没有权限 true 有权限
*/ */
export function hasPermi(perm, mode = 'or') { export function hasPermi(perm, mode = 'or') {
const permList = getPermList() const permList = getPermList()
@@ -23,6 +23,7 @@ export function hasPermi(perm, mode = 'or') {
// 所有权限都要有 // 所有权限都要有
return checkArr.every(item => permList.includes(item)) return checkArr.every(item => permList.includes(item))
} else { } else {
console.log(permList, checkArr)
// 有一个即可 // 有一个即可
return checkArr.some(item => permList.includes(item)) return checkArr.some(item => permList.includes(item))
} }