This commit is contained in:
wangyuxin
2026-04-20 15:23:25 +08:00
17 changed files with 733 additions and 807 deletions

View File

@@ -54,7 +54,8 @@
"setting" : { "setting" : {
"urlCheck" : false "urlCheck" : false
}, },
"usingComponents" : true "usingComponents" : true,
"lazyCodeLoading": "requiredComponents"
}, },
"mp-alipay" : { "mp-alipay" : {
"usingComponents" : true "usingComponents" : true

View File

@@ -1,32 +1,14 @@
{ {
"pages": [ "pages": [
// { {
// "path": "pages/navigation/navigation", "path": "pages/navigation/navigation",
// "style": { "style": {
// "navigationBarTitleText": "引导页", "navigationBarTitleText": "引导页",
// "navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
// "enablePullDownRefresh": false, "enablePullDownRefresh": false,
// "navigationStyle": "custom" "navigationStyle": "custom"
// } }
// }, },
// {
// "path": "pages/login/pwd-login",
// "style": {
// "navigationBarTitleText": "密码登录",
// "navigationBarTextStyle": "white",
// "enablePullDownRefresh": false,
// "navigationStyle": "custom"
// }
// },
// {
// "path": "pages/login/login",
// "style": {
// "navigationBarTitleText": "验证码登录",
// "navigationBarTextStyle": "white",
// "enablePullDownRefresh": false,
// "navigationStyle": "custom"
// }
// },
{ {
"path": "pages/index/index", "path": "pages/index/index",
@@ -61,6 +43,20 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
{
"path": "pwd-login",
"style": {
"navigationBarTitleText": "账号密码登录",
"navigationStyle": "custom"
}
},
{
"path": "login",
"style": {
"navigationBarTitleText": "验证码登录",
"navigationStyle": "custom"
}
},
{ {
"path": "forget-pwd", "path": "forget-pwd",
"style": { "style": {
@@ -82,7 +78,8 @@
"pages": [{ "pages": [{
"path": "onlineRepair", "path": "onlineRepair",
"style": { "style": {
"navigationBarTitleText": "在线报修" "navigationBarTitleText": "在线报修",
"navigationStyle": "custom"
} }
}, },
{ {
@@ -128,7 +125,8 @@
"pages": [{ "pages": [{
"path": "visitor-list", "path": "visitor-list",
"style": { "style": {
"navigationBarTitleText": "访客邀请" "navigationBarTitleText": "访客邀请",
"navigationStyle": "custom"
} }
}, },
{ {
@@ -156,7 +154,8 @@
"pages": [{ "pages": [{
"path": "activityList", "path": "activityList",
"style": { "style": {
"navigationBarTitleText": "活动列表" "navigationBarTitleText": "活动列表",
"navigationStyle": "custom"
} }
}, },
{ {
@@ -180,7 +179,8 @@
"pages": [{ "pages": [{
"path": "noticeList", "path": "noticeList",
"style": { "style": {
"navigationBarTitleText": "通知公告" "navigationBarTitleText": "通知公告",
"navigationStyle": "custom"
} }
}, },
{ {

View File

@@ -1,5 +1,10 @@
<template> <template>
<view class="container"> <view class="container">
<view class="status_bar"></view>
<!-- 顶部标题栏 -->
<view class="top-bar">
<uni-nav-bar left-icon="left" title="活动列表" backgroundColor ="none" :border="false" @clickLeft="narBack" />
</view>
<!-- 顶部图片 --> <!-- 顶部图片 -->
<view class="topImg"> <view class="topImg">
<image src="/static/首页/banner.png" style="width: 100%;height:100%;"></image> <image src="/static/首页/banner.png" style="width: 100%;height:100%;"></image>
@@ -323,6 +328,15 @@
} }
}) })
// 返回
const narBack = () =>{
// uni.navigateBack({
// delta: 1
// })
uni.switchTab({
url:"/pages/index/index"
})
}
// 切换选项卡 // 切换选项卡
const switchTab = (tab) => { const switchTab = (tab) => {
activeTab.value = tab activeTab.value = tab
@@ -504,6 +518,15 @@
flex-direction: column; flex-direction: column;
padding: 20rpx; padding: 20rpx;
} }
.status_bar {
height: 32px;
width: 100%;
}
/* 顶部标题 */
.top-bar {
text-align: center;
margin-bottom: 20rpx;
}
.topImg { .topImg {
width: 100%; width: 100%;
height: 280rpx; height: 280rpx;

View File

@@ -36,11 +36,12 @@
<view class="bannarClass"> <view class="bannarClass">
<up-swiper :list="bannerList" indicator indicatorMode="dot" ></up-swiper> <up-swiper :list="bannerList" indicator indicatorMode="dot" ></up-swiper>
</view> </view>
<view class="noticeClass"> <view class="noticeClass" @click="getNoticeMore">
<image src="/static/首页/公告.png" style="width: 81rpx;height: 81rpx;position: absolute;top: 10px;left: 16px;"></image> <image src="/static/首页/公告.png" style="width: 38px;height: 38px;position: absolute;top: 21px;left: 17px;"></image>
<uni-notice-bar show-icon :text="noticeText" type="line" <uni-notice-bar show-icon :text="noticeText" type="line"
:showIcon="true" show-get-more scrollable color="#000" background-color="#fff" moreColor="#000" @getmore="getNoticeMore"/> :showIcon="false" show-get-more scrollable color="#000" background-color="#fff" moreColor="#000">
<!-- <up-notice-bar class="notice-bar" :text="noticeText" mode="link" speed="100" bgColor="#FFF" color="#000" url="pages/notice-list/noticeList"></up-notice-bar> --> </uni-notice-bar>
</view> </view>
<!-- 一键开门 --> <!-- 一键开门 -->
<view class="u-demo-block__content bg-card-open"> <view class="u-demo-block__content bg-card-open">
@@ -326,13 +327,17 @@ const moreClick = () =>{
position: relative; position: relative;
top: 110px; top: 110px;
left: 0; left: 0;
padding: 20rpx; padding: 40rpx;
} }
.noticeClass{ .noticeClass{
position: relative; position: relative;
top: 205rpx; top: 167rpx;
left: 0; left: 0;
padding: 20rpx; padding: 40rpx 36rpx;
}
// 修改通知栏样式
::v-deep .uni-noticebar__content-wrapper--scrollable{
left: 20px;
} }
.noticeClass.uni-noticebar{ .noticeClass.uni-noticebar{
padding: 10px 15px 10px 45px; padding: 10px 15px 10px 45px;
@@ -343,12 +348,12 @@ const moreClick = () =>{
} }
.bg-card-open{ .bg-card-open{
position: relative; position: relative;
top: 180rpx; top: 102rpx;
left: 0; left: 0;
padding: 20rpx; padding: 20rpx;
background-color: #fff; background-color: #fff;
border-radius: 8rpx; border-radius: 8rpx;
margin: 9px; margin: 20px 18px;
} }
.openClass{ .openClass{
display: flex; display: flex;
@@ -371,12 +376,12 @@ const moreClick = () =>{
.adCardClass{ .adCardClass{
// width: 100%; // width: 100%;
height: 200rpx; height: 200rpx;
margin: 17rpx; margin: 40rpx 30rpx;
background-color: #3E8EFF; background-color: #3E8EFF;
// margin-top: 30rpx; // margin-top: 30rpx;
border-radius: 20rpx; border-radius: 28rpx;
position: relative; position: relative;
top:99px; top:50px;
left: 0; left: 0;
.titleLeft{ .titleLeft{
text-align: left; text-align: left;
@@ -394,10 +399,13 @@ const moreClick = () =>{
} }
.activity-card{ .activity-card{
position: relative; position: relative;
top: 102px; top: 45px;
left: 0; left: 0;
bottom: 20; bottom: 20;
} }
.uni-card{
margin: 18px !important;
}
.eventListClass{ .eventListClass{
margin: 20rpx; margin: 20rpx;
display: flex; display: flex;

View File

@@ -1,260 +0,0 @@
<template>
<view class="login-page">
<view class="status_bar"></view>
<!-- 标题 -->
<view class="login-title">账号密码登录</view>
<!-- 手机号输入框 -->
<view class="input-item">
<view class="input-icon">
<!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> -->
<image src="/static/登录/手机号.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>
</view>
<!-- 密码输入框 -->
<view class="input-item">
<view class="input-icon">
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
<image src="/static/登录/密码.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="password" v-model="password"
placeholder="请输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 协议勾选 + 忘记密码 -->
<view class="agreement-wrap">
<view class="agreement-item" @click="toggleAgreement">
<uni-icons
type="checkbox-filled"
size="24"
color="#007aff"
v-if="agreeAgreement"
></uni-icons>
<uni-icons
type="checkbox"
size="24"
color="#999"
v-else
></uni-icons>
<text class="agreement-text">我已阅读并同意用户隐私政策</text>
</view>
<navigator class="forget-pwd" url="/pages/loginSub/forget-pwd">忘记密码</navigator>
</view>
<!-- 登录按钮 -->
<button
class="login-btn"
@click="handleLogin"
>
登录
</button>
<!-- 底部链接 -->
<view class="bottom-link">
<navigator class="link-item" url="/pages/login/login">验证码登录</navigator>
<navigator class="link-item" url="/pages/loginSub/register-new-user">注册新用户</navigator>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import {onLoad} from "@dcloudio/uni-app"
import {getLoginPassword} from '/pages/api/api.js'
// 响应式数据
const phoneNumber = ref('');
const password = ref('');
const agreeAgreement = ref(true); // 默认勾选
const placeholderStyle = ref('font-size:24rpx')
// 计算属性:是否可登录(帐号+密码+协议都满足)
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 toggleAgreement = () => {
agreeAgreement.value = !agreeAgreement.value;
};
// 检查表单
const checkForm = () => {};
onLoad(() =>{
});
const handleLogin = async () => {
if (!canLogin.value) return;
// 防止多次点击触发登录
canLogin.value = false;
// // 2. 空值校验
// if (!phoneNumber.value) {
// uni.showToast({ title: '请输入手机号', icon: 'none' });
// canLogin.value = true; // 解锁
// return;
// }
// if (!password.value) {
// uni.showToast({ title: '请输入密码', icon: 'none' });
// canLogin.value = true; // 解锁
// return;
// }
const params = {
username: phoneNumber.value,
password: password.value
};
try {
// 3. 调用登录接口
const res = await getLoginPassword(params);
// 登录成功逻辑
// 如果后端返回token这里保存
// uni.setStorageSync('token', res.token || '');
uni.showToast({ title: '登录成功', icon: 'success' });
// 登录成功后再跳转
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' });
}, 1500);
} catch (err) {
// 登录失败逻辑(所有错误:账号不存在/密码错/网络异常都走这里)
uni.showToast({ title: `${err || '登录失败'}`, icon: 'none' });
} finally {
// 无论成功/失败,解锁按钮
canLogin.value = true;
}
};
// 登录逻辑
// const handleLogin = () => {
// if (!canLogin.value) return
// let params = {
// username:phoneNumber.value,
// password:password.value
// }
// getLoginPassword(params).then(res =>{
// // console.log('33333',res)
// if(res.code === 200){
// // console.log('33333',res)
// //uni.setStorageSync('token', res.token); // 假设后端返回token字段
// uni.showToast({ title: '登录成功', icon: 'success' });
// uni.switchTab({ url: '/pages/index/index' });
// // uni.reLaunch({ url: '/pages/index/index' });
// }else{
// uni.showToast({ title: `${res.msg},请先注册账号`, icon: 'error' });
// }
// })
// };
</script>
<style scoped>
.login-page {
padding: 80rpx 40rpx 40rpx;
/* background-color: #f8f9fa; */
min-height: 100vh;
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF );
}
.status_bar {
height: 160px;
width: 100%;
}
.login-title {
font-size: 48rpx;
font-weight: 600;
color: #333;
text-align: center;
margin-bottom: 80rpx;
}
.input-item {
display: flex;
align-items: center;
background-color: #fff;
border-radius: 40rpx;
padding: 0 30rpx;
height: 88rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.input-icon {
margin-right: 20rpx;
width: 50rpx;
height: 50rpx;
}
.input-content {
flex: 1;
font-size: 28rpx;
color: #333;
height: 100%;
}
.agreement-wrap {
display: flex;
justify-content: space-between;
align-items: center;
margin: 40rpx 0;
padding: 0 10rpx;
}
.agreement-item {
display: flex;
align-items: center;
}
.agreement-text {
font-size: 28rpx;
color: #666;
margin-left: 10rpx;
}
.forget-pwd {
font-size: 28rpx;
color: #007aff;
text-decoration: none;
}
.login-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
background-color: #007aff;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
margin-bottom: 60rpx;
}
.login-btn:disabled {
background-color: #99c8ff;
color: #fff;
}
.bottom-link {
display: flex;
justify-content: space-between;
padding: 0 20rpx;
}
.link-item {
font-size: 28rpx;
color: #007aff;
text-decoration: none;
}
</style>

View File

@@ -77,7 +77,7 @@
<!-- 底部链接 --> <!-- 底部链接 -->
<view class="bottom-link"> <view class="bottom-link">
<navigator class="link-item" url="/pages/login/pwd-login">账号密码登录</navigator> <navigator class="link-item" url="/pages/loginSub/pwd-login">账号密码登录</navigator>
<navigator class="link-item" url="/pages/loginSub/register-new-user">注册新用户</navigator> <navigator class="link-item" url="/pages/loginSub/register-new-user">注册新用户</navigator>
</view> </view>
</view> </view>
@@ -166,16 +166,16 @@ const handleLogin = () => {
smsCode:'123456', smsCode:'123456',
scene:'login', scene:'login',
} }
getLoginBySms(params).then(res =>{ // getLoginBySms(params).then(res =>{
if(res.code === 200){ // if(res.code === 200){
//uni.setStorageSync('token', res.token); // 假设后端返回token字段 // //uni.setStorageSync('token', res.token); // 假设后端返回token字段
uni.showToast({ title: '登录成功', icon: 'success' }); // uni.showToast({ title: '登录成功', icon: 'success' });
}else{ // }else{
uni.showToast({ title:'登录失败', icon: 'error' }); // uni.showToast({ title:'登录失败', icon: 'error' });
} // }
}) // })
uni.switchTab({ url: '/pages/index/index' }); uni.switchTab({ url: '/pages/index/index' });
// 模拟登录请求 // 模拟登录请求
// uni.showLoading({ // uni.showLoading({
@@ -198,7 +198,7 @@ onUnmounted(() => {
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(to bottom, #E2F0FF, #F6FAFF );
} }
.status_bar { .status_bar {
height: 160px; height: 160px;

View File

@@ -58,7 +58,7 @@
<!-- 底部链接 --> <!-- 底部链接 -->
<view class="bottom-link"> <view class="bottom-link">
<navigator class="link-item" url="/pages/login/login">验证码登录</navigator> <navigator class="link-item" url="/pages/loginSub/login">验证码登录</navigator>
<navigator class="link-item" url="/pages/loginSub/register-new-user">注册新用户</navigator> <navigator class="link-item" url="/pages/loginSub/register-new-user">注册新用户</navigator>
</view> </view>
</view> </view>
@@ -94,72 +94,85 @@ const checkForm = () => {};
onLoad(() =>{ onLoad(() =>{
}); });
const handleLogin = async () => { // const handleLogin = async () => {
if (!canLogin.value) return; // if (!canLogin.value) return;
// 防止多次点击触发登录 // // 防止多次点击触发登录
canLogin.value = false; // // canLogin.value = false;
// // 2. 空值校验 // // // 2. 空值校验
// if (!phoneNumber.value) { // if (!phoneNumber.value) {
// uni.showToast({ title: '请输入手机号', icon: 'none' }); // uni.showToast({ title: '请输入手机号', icon: 'none' });
// canLogin.value = true; // 解锁 // // canLogin.value = true;
// return; // return;
// } // }
// if (!password.value) { // if (!password.value) {
// uni.showToast({ title: '请输入密码', icon: 'none' }); // uni.showToast({ title: '请输入密码', icon: 'none' });
// canLogin.value = true; // 解锁 // // canLogin.value = true;
// return; // return;
// } // }
const params = { // const params = {
username: phoneNumber.value, // username: phoneNumber.value,
password: password.value // password: password.value
}; // };
try { // try {
// 3. 调用登录接口 // // 3. 调用登录接口
const res = await getLoginPassword(params); // const res = await getLoginPassword(params);
// 登录成功逻辑 // // 登录成功逻辑
// 如果后端返回token这里保存 // // 如果后端返回token这里保存
// uni.setStorageSync('token', res.token || ''); // // uni.setStorageSync('token', res.token || '');
uni.showToast({ title: '登录成功', icon: 'success' }); // uni.showToast({ title: '登录成功', icon: 'success' });
// 登录成功后再跳转 // // 登录成功后再跳转
setTimeout(() => { // setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' }); // uni.switchTab({ url: '/pages/index/index' });
}, 1500); // }, 1500);
} catch (err) { // } catch (err) {
// 登录失败逻辑(所有错误:账号不存在/密码错/网络异常都走这里) // // 登录失败逻辑(所有错误:账号不存在/密码错/网络异常都走这里)
uni.showToast({ title: `${err || '登录失败'}`, icon: 'none' }); // uni.showToast({ title: `${err || '登录失败'}`, icon: 'none' });
} finally { // } finally {
// 无论成功/失败,解锁按钮 // // 无论成功/失败,解锁按钮
canLogin.value = true; // canLogin.value = true;
} // }
};
// 登录逻辑
// const handleLogin = () => {
// if (!canLogin.value) return
// let params = {
// username:phoneNumber.value,
// password:password.value
// }
// getLoginPassword(params).then(res =>{
// // console.log('33333',res)
// if(res.code === 200){
// // console.log('33333',res)
// //uni.setStorageSync('token', res.token); // 假设后端返回token字段
// uni.showToast({ title: '登录成功', icon: 'success' });
// uni.switchTab({ url: '/pages/index/index' });
// // uni.reLaunch({ url: '/pages/index/index' });
// }else{
// uni.showToast({ title: `${res.msg},请先注册账号`, icon: 'error' });
// }
// })
// }; // };
// 登录逻辑
const handleLogin = () => {
if (!canLogin.value) return
let params = {
username:phoneNumber.value,
password:password.value
}
if (!phoneNumber.value) {
uni.showToast({ title: '请输入手机号', icon: 'none' });
// canLogin.value = true;
return;
}
if (!password.value) {
uni.showToast({ title: '请输入密码', icon: 'none' });
// canLogin.value = true;
return;
}
// getLoginPassword(params).then(res =>{
// // console.log('33333',res)
// if(res.code === 200){
// // console.log('33333',res)
// //uni.setStorageSync('token', res.token); // 假设后端返回token字段
// uni.showToast({ title: '登录成功', icon: 'success' });
// uni.switchTab({ url: '/pages/index/index' });
// // uni.reLaunch({ url: '/pages/index/index' });
// }else{
// uni.showToast({ title: `${res.msg},请先注册账号`, icon: 'error' });
// }
// })
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' });
}, 1500);
};
</script> </script>
<style scoped> <style scoped>

View File

@@ -91,7 +91,7 @@
<!-- 跳转登录链接 --> <!-- 跳转登录链接 -->
<view class="login-link"> <view class="login-link">
<navigator class="link-item" url="/pages/login/pwd-login">已有账号去登录</navigator> <navigator class="link-item" url="/pages/loginSub/login">已有账号去登录</navigator>
</view> </view>
</view> </view>
</template> </template>

View File

@@ -13,7 +13,10 @@
<!-- 便捷服务 --> <!-- 便捷服务 -->
<swiper-item> <swiper-item>
<view class="guide-item"> <view class="guide-item">
<image class="guide-img" src="/static/引导1.png" ></image> <view class="guide-img">
<image class="" src="/static/引导1.png" style="width: 100%;height: 100%;"></image>
</view>
<view style="height: 200rpx;width: 100%;"></view>
<view class="guide-title">便捷服务</view> <view class="guide-title">便捷服务</view>
<view class="guide-subtitle">报修缴费预约</view> <view class="guide-subtitle">报修缴费预约</view>
</view> </view>
@@ -22,7 +25,10 @@
<!-- 高效管理 --> <!-- 高效管理 -->
<swiper-item> <swiper-item>
<view class="guide-item"> <view class="guide-item">
<image class="guide-img" src="/static/引导2.png" ></image> <view class="guide-img">
<image src="/static/引导2.png" style="width: 100%;height: 100%;"></image>
</view>
<view style="height: 200rpx;width: 100%;"></view>
<view class="guide-title">高效管理</view> <view class="guide-title">高效管理</view>
<view class="guide-subtitle">自动化流程和智能设备</view> <view class="guide-subtitle">自动化流程和智能设备</view>
</view> </view>
@@ -31,7 +37,10 @@
<!--安全保障 --> <!--安全保障 -->
<swiper-item> <swiper-item>
<view class="guide-item"> <view class="guide-item">
<image class="guide-img" src="/static/引导3.png"></image> <view class="guide-img">
<image src="/static/引导3.png" style="width: 100%;height: 100%;"></image>
</view>
<view style="height: 200rpx;width: 100%;"></view>
<view class="guide-title">安全保障</view> <view class="guide-title">安全保障</view>
<view class="guide-subtitle">智能巡检和智慧访客</view> <view class="guide-subtitle">智能巡检和智慧访客</view>
</view> </view>
@@ -83,7 +92,7 @@ const handleBtnClick = () => {
uni.setStorageSync('hasShowGuide', true); uni.setStorageSync('hasShowGuide', true);
// 2. 跳转首页 // 2. 跳转首页
uni.navigateTo({ uni.navigateTo({
url:"/pages/login/pwd-login" url:"/pages/loginSub/pwd-login"
}) })
// uni.switchTab({ // uni.switchTab({
// url: '/pages/index/index' // url: '/pages/index/index'
@@ -97,7 +106,8 @@ const handleBtnClick = () => {
.guide-page { .guide-page {
width: 100%; width: 100%;
height: 100vh; height: 100vh;
background-color: #f8f9ff; /* background-color: #f8f9ff; */
background: linear-gradient(to bottom, #E2F0FF, #F6FAFF);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
@@ -118,23 +128,23 @@ const handleBtnClick = () => {
/* 单个引导项 */ /* 单个引导项 */
.guide-item { .guide-item {
width: 360px; width: 360px;
height: 360px; height: 480px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
/* 引导插画 */
.guide-img { .guide-img {
width: 100%; width: 100%;
height: 100%; height: 50%;
margin-bottom: 80rpx; margin-bottom: 80rpx;
} }
/* 引导标题 */ /* 引导标题 */
.guide-title { .guide-title {
font-size: 48rpx; font-size: 56rpx;
font-weight: 600; font-weight: 600;
color: #333; color: #333;
margin-bottom: 20rpx; margin-bottom: 20rpx;

View File

@@ -7,6 +7,11 @@
:refresher-triggered="refreshing" :refresher-triggered="refreshing"
:style="{ height: `calc(100vh - ${statusBarHeight + navBarHeight}px)` }" :style="{ height: `calc(100vh - ${statusBarHeight + navBarHeight}px)` }"
> >
<view class="status_bar"></view>
<!-- 顶部标题栏 -->
<view class="top-bar">
<uni-nav-bar left-icon="left" title="通知公告" backgroundColor ="none" :border="false" @clickLeft="narBack" />
</view>
<!-- 下拉刷新 --> <!-- 下拉刷新 -->
<view class="refresh-container" v-if="refreshing"> <view class="refresh-container" v-if="refreshing">
<uni-icons type="spinner-cycle" size="20" color="#999" class="loading"></uni-icons> <uni-icons type="spinner-cycle" size="20" color="#999" class="loading"></uni-icons>
@@ -115,16 +120,34 @@
url:'/pages/notice-list/noticeListDetails' url:'/pages/notice-list/noticeListDetails'
}) })
} }
// 返回
const narBack = () =>{
// uni.navigateBack({
// delta: 1
// })
uni.switchTab({
url:"/pages/index/index"
})
}
</script> </script>
<style lang="scss"> <style lang="scss">
/* 通知列表容器 */ /* 通知列表容器 */
.notice-list { .notice-list {
padding: 12px 12px 20px; padding: 20px;
box-sizing: border-box; box-sizing: border-box;
background-color: #f9f9f9; background-color: #f9f9f9;
} }
.status_bar {
height: 32px;
width: 100%;
}
/* 顶部标题 */
.top-bar {
text-align: center;
margin-bottom: 20rpx;
}
/* 下拉刷新 */ /* 下拉刷新 */
.refresh-container { .refresh-container {

View File

@@ -139,6 +139,7 @@
.container { .container {
min-height: 100vh; min-height: 100vh;
background-color: #ffffff; background-color: #ffffff;
padding: 20px;
// font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; // font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
} }
@@ -155,7 +156,7 @@
// border-bottom: 1px solid #f0f0f0; // border-bottom: 1px solid #f0f0f0;
.article-title { .article-title {
font-size: 18px; font-size: 32rpx;
font-weight: bold; font-weight: bold;
color: #333333; color: #333333;
line-height: 1.4; line-height: 1.4;

View File

@@ -98,9 +98,9 @@ const openDoor = () => {
<style scoped> <style scoped>
/* 页面全局样式 */ /* 页面全局样式 */
.door-open-page { .door-open-page {
background: linear-gradient(180deg, #4a90e2, #F6FAFF); background: linear-gradient(180deg, #E2F0FF, #F6FAFF);
min-height: 100vh; min-height: 100vh;
padding: 30rpx 26rpx; padding: 30rpx 40rpx;
box-sizing: border-box; box-sizing: border-box;
} }
.status_bar { .status_bar {
@@ -191,7 +191,8 @@ const openDoor = () => {
align-items: center; align-items: center;
padding: 30rpx 20rpx; padding: 30rpx 20rpx;
border-radius: 10rpx; border-radius: 10rpx;
border: 2px solid #e5e5e5; border: 2px solid #2F77FD;
background-color: #F6F9FE;
transition: all 0.3s; transition: all 0.3s;
} }
/* 选中状态 */ /* 选中状态 */
@@ -229,8 +230,8 @@ const openDoor = () => {
width: 100%; width: 100%;
height: 88rpx; height: 88rpx;
line-height: 88rpx; line-height: 88rpx;
background-color: #ffffff; background-color: #2F77FD;
color: #2c6bc7; color: #fff;
font-size: 32rpx; font-size: 32rpx;
border-radius: 20rpx; border-radius: 20rpx;
border: none; border: none;

View File

@@ -292,7 +292,7 @@ onMounted(() => {
background-color: #f5f5f5; background-color: #f5f5f5;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
/* padding: 20rpx; */ padding: 40rpx;
} }
/* 搜索区域 */ /* 搜索区域 */
@@ -356,7 +356,7 @@ onMounted(() => {
/* 小区列表 */ /* 小区列表 */
.community-list { .community-list {
flex: 1; flex: 1;
padding: 0 30rpx; /* padding: 0 30rpx; */
margin-top: 20rpx; margin-top: 20rpx;
margin-bottom: 180rpx; margin-bottom: 180rpx;

View File

@@ -1,9 +1,14 @@
<template> <template>
<view class="repair-page"> <view class="repair-page">
<view class="status_bar"></view>
<!-- 顶部导航栏 --> <!-- 顶部导航栏 -->
<!-- <view class="nav-bar"> <view class="nav-bar">
<text class="nav-title">在线报修</text> <view class="nav-left" @tap="goBack">
</view> --> <image src="/static/首页/arr-left.png" style="width: 48rpx; height: 48rpx;"></image>
</view>
<view class="nav-title">在线报修</view>
<view class="nav-right"></view>
</view>
<!-- 报修类型Tab --> <!-- 报修类型Tab -->
<view class="repair-type-tabs"> <view class="repair-type-tabs">
@@ -11,6 +16,7 @@
class="type-tab" class="type-tab"
:class="{ active: activeType === 'public' }" :class="{ active: activeType === 'public' }"
@click="publicClick" @click="publicClick"
style="margin-right: 20rpx;"
> >
<image src="/static/在线报修/公共报修.png" style="width: 100%;height: 100%;"></image> <image src="/static/在线报修/公共报修.png" style="width: 100%;height: 100%;"></image>
<!-- <uni-icons type="staff" size="24" color="#fff"></uni-icons> --> <!-- <uni-icons type="staff" size="24" color="#fff"></uni-icons> -->
@@ -27,7 +33,7 @@
</view> </view>
</view> </view>
<view style="margin: 10px 13px;"> <view style="margin: 14px 0px;">
<text class="repair-title">报修记录</text> <text class="repair-title">报修记录</text>
</view> </view>
@@ -75,7 +81,7 @@
{{ item.content }} {{ item.content }}
</view> </view>
<!-- 图片占位可替换为图片组件 --> <!-- 图片占位 -->
<view class="item-imgs"> <view class="item-imgs">
<view class="img-placeholder" v-for="i in 3" :key="i"> <view class="img-placeholder" v-for="i in 3" :key="i">
<!-- <uni-icons type="image" size="20" color="#ccc"></uni-icons> --> <!-- <uni-icons type="image" size="20" color="#ccc"></uni-icons> -->
@@ -145,7 +151,13 @@ function personalClick(){
url:"/pages/online-repair/personalRepair" url:"/pages/online-repair/personalRepair"
}) })
} }
// 返回上一页
const goBack = () => {
// uni.navigateBack()
uni.switchTab({
url:"/pages/index/index"
})
}
// 跳转报修详情 // 跳转报修详情
const goDetail = (item) => { const goDetail = (item) => {
// const itemStr = encodeURIComponent(JSON.stringify(item)) // const itemStr = encodeURIComponent(JSON.stringify(item))
@@ -158,15 +170,55 @@ const goDetail = (item) => {
<style scoped> <style scoped>
/* 页面整体样式 */ /* 页面整体样式 */
.repair-page { .repair-page {
background-color: #f5f5f5; background: linear-gradient(to bottom left, #E2F0FF 0%, #f9f9f9 50%);
min-height: 100vh; min-height: 100vh;
padding: 0 40rpx;
}
.status_bar {
height: 32px;
width: 100%;
}
/* 顶部导航栏 */
.nav-bar {
height: 90rpx;
display: flex;
align-items: center;
/* padding: 0 30rpx; */
color: #fff;
position: sticky;
top: 44px;
z-index: 100;
margin-bottom: 20px;
/* box-shadow: 0 4rpx 12rpx rgba(0, 122, 255, 0.2); */
} }
.nav-left {
width: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.nav-title {
flex: 1;
text-align: center;
font-size: 32rpx;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 20rpx;
color: #000;
}
.nav-right {
width: 60rpx;
}
/* 报修类型Tab */ /* 报修类型Tab */
.repair-type-tabs { .repair-type-tabs {
display: flex; display: flex;
background-color: #fff; /* background-color: #fff; */
padding: 10px; /* padding: 10px; */
} }
.type-tab { .type-tab {
flex: 1; flex: 1;
@@ -178,7 +230,6 @@ const goDetail = (item) => {
border-radius: 8px; border-radius: 8px;
color: #fff; color: #fff;
font-size: 14px; font-size: 14px;
margin-right: 20rpx;
} }
.type-tab.active { .type-tab.active {
background: linear-gradient(135deg, #1E88E5 0%, #64B5F6 100%); background: linear-gradient(135deg, #1E88E5 0%, #64B5F6 100%);
@@ -199,8 +250,8 @@ const goDetail = (item) => {
.record-status-tabs { .record-status-tabs {
display: flex; display: flex;
/* background-color: #fff; */ /* background-color: #fff; */
margin-top: 10px; /* margin-top: 10px; */
padding: 0 15px; /* padding: 0 15px; */
} }
.status-tab { .status-tab {
flex: 1; flex: 1;
@@ -229,7 +280,7 @@ const goDetail = (item) => {
/* 报修列表 */ /* 报修列表 */
.repair-list { .repair-list {
padding: 10px; padding: 28rpx 0rpx;
} }
.repair-item { .repair-item {
background-color: #fff; background-color: #fff;
@@ -283,8 +334,8 @@ const goDetail = (item) => {
/* 标签 */ /* 标签 */
.item-tags { .item-tags {
display: flex; /* display: flex; */
gap: 8px; /* gap: 8px; */
margin-bottom: 10px; margin-bottom: 10px;
} }
.tag { .tag {
@@ -294,6 +345,7 @@ const goDetail = (item) => {
padding: 2px 8px; padding: 2px 8px;
border-radius: 4px; border-radius: 4px;
border: 1px solid #999999; border: 1px solid #999999;
margin-right: 8px;
} }
/* 内容 */ /* 内容 */
@@ -308,7 +360,7 @@ const goDetail = (item) => {
/* 图片占位 */ /* 图片占位 */
.item-imgs { .item-imgs {
display: flex; display: flex;
gap: 12px; /* gap: 12px; */
margin-bottom: 10px; margin-bottom: 10px;
} }
.img-placeholder { .img-placeholder {
@@ -319,6 +371,7 @@ const goDetail = (item) => {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-right: 8px;
} }
/* 底部时间和详情 */ /* 底部时间和详情 */
@@ -326,7 +379,7 @@ const goDetail = (item) => {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
font-size: 12px; font-size: 28rpx;
} }
.item-time { .item-time {
color: #999; color: #999;

View File

@@ -1,7 +1,13 @@
<template> <template>
<view class="visitor-add-page"> <view class="visitor-invite">
<!-- Tab 切换车辆来访/人员来访 --> <!-- 顶部导航 -->
<view class="tab-bar"> <!-- <view class="nav-bar">
<uni-icons type="left" size="20" color="#000" @click="navigateBack"></uni-icons>
<view class="nav-title">访客邀请</view>
</view> -->
<!-- 标签切换车辆来访/人员来访 -->
<view class="tab-wrap">
<view <view
class="tab-item" class="tab-item"
:class="{ active: activeTab === 'car' }" :class="{ active: activeTab === 'car' }"
@@ -12,485 +18,477 @@
<view <view
class="tab-item" class="tab-item"
:class="{ active: activeTab === 'person' }" :class="{ active: activeTab === 'person' }"
@click="switchTab('person')" @click="switchTab('person')"
> >
人员来访 人员来访
</view> </view>
</view> </view>
<!-- 表单区域 --> <!-- 表单区域 -->
<scroll-view class="form-scroll" scroll-y> <view class="form-wrap">
<!-- 房屋信息 -->
<view class="form-section"> <view class="form-section">
<uni-forms ref="formRef" :modelValue="formData" :rules="formRules" label-width="105px" label-align="left"> <view class="section-title">房屋信息</view>
<!-- 来访地址 --> <view class="form-item">
<uni-forms-item label="来访地址:" name="address" required> <view class="label">
<uni-data-select v-model="formData.address" :localdata="addressList" @change="changeAddress" :clear="false"></uni-data-select> <text class="required">*</text>来访地址
</uni-forms-item> </view>
<!-- 访客姓名 --> <view class="value" @click="openAddressModal">
<uni-forms-item label="访客姓名" name="name" required> {{ form.address }}
<uni-easyinput type="text" v-model="formData.name" placeholder="请输入姓名" /> <uni-icons type="right" size="16" color="#999"></uni-icons>
</uni-forms-item> </view>
<!-- 访客性别 --> </view>
<uni-forms-item label="访客性别" name="gender" required>
<uni-data-select v-model="formData.gender" :localdata="sexList" @change="changeSex" :clear="false"></uni-data-select>
</uni-forms-item>
<!-- 访客联系方式 -->
<uni-forms-item label="访客联系方式" name="phone" required>
<uni-easyinput
v-model="formData.phone"
placeholder="请输入联系方式"
type="number" />
</uni-forms-item>
<!-- 车牌号仅车辆来访显示 -->
<uni-forms-item
label="车牌号:"
name="carNumber"
required
v-if="activeTab === 'car'"
>
<view class="plate-input-wrap">
<!-- 省份简称选择框 -->
<view
class="plate-item province-item"
@click="showProvinceClick"
>
<text>{{ plateChars[0] || '选' }}</text>
</view>
<!-- 6个字符输入框省份+6=完整车牌 -->
<input
v-for="(char, index) in plateChars.slice(1)"
:key="index"
ref="el => plateInputRefs[index + 1] = el"
class="plate-item char-item"
v-model="plateChars[index + 1]"
maxlength="1"
type="text"
@input="handlePlateInput(index + 1, $event)"
placeholder=""
@keydown="handlePlateKeydown(index + 1, $event)"/>
</view>
</uni-forms-item>
<!-- 随行人数 -->
<uni-forms-item label="随行人数:" name="escortNum">
<uni-easyinput v-model="formData.escortNum" placeholder="请输入随行人数" type="number"/>
</uni-forms-item>
<!-- 来访时间 -->
<uni-forms-item label="来访时间:" name="visitTime" required>
<uni-datetime-picker type="datetime" v-model="formData.visitTime" @change="handleTimeChange" />
</uni-forms-item>
<!-- 离开时间 -->
<uni-forms-item label="离开时间:" name="leaveTime" required>
<uni-datetime-picker type="datetime" v-model="formData.leaveTime" @change="handleTimeChange" />
</uni-forms-item>
</uni-forms>
</view> </view>
<!-- 提示文字 -->
<view class="tips-text"> <!-- 访客信息 -->
预计来访时间和预计离开时间间隔不能超过24小时 <view class="form-section">
<view>车辆停留请勿超出有效期需及时驶出小区</view> <view class="section-title">访客信息</view>
<view class="form-item">
<view class="label">访客姓名</view>
<input
class="input"
placeholder="请输入访客姓名"
v-model="form.name"
/>
</view>
<view class="form-item">
<view class="label">
<text class="required">*</text>访客性别
</view>
<view class="value" @click="openGenderModal">
{{ form.gender }}
<uni-icons type="right" size="16" color="#999"></uni-icons>
</view>
</view>
<view class="form-item">
<view class="label">
<text class="required">*</text>访客联系方式
</view>
<input
class="input"
placeholder="请输入联系方式"
v-model="form.phone"
type="number"
/>
</view>
<!-- 车牌号仅车辆来访显示 -->
<view class="form-item" v-if="activeTab === 'car'">
<view class="label">
<text class="required">*</text>车牌号
</view>
<view class="car-number-wrap">
<input
class="car-input"
v-for="(item, index) in 8"
:key="index"
v-model="form.carNumber[index]"
maxlength="1"
type="text"
/>
</view>
</view>
<view class="form-item">
<view class="label">
<text class="required">*</text>随行人数
</view>
<input
class="input"
placeholder="请输入随行人数"
v-model="form.peopleNum"
type="number"
/>
</view>
</view> </view>
</scroll-view>
<!-- 有效期 -->
<view class="form-section">
<view class="section-title">有效期</view>
<view class="form-item">
<view class="label">
<text class="required">*</text>来访时间
</view>
<view class="value">
<uni-datetime-picker type="datetime" v-model="visitTime" @change="changeLog" :border="false"/>
</view>
</view>
<view class="form-item">
<view class="label">
<text class="required">*</text>离开时间
</view>
<view class="value">
<uni-datetime-picker type="datetime" v-model="leaveTime" @change="changeLog" :border="false"/>
</view>
</view>
<view class="tips">预计来访时间和预计离开时间间隔不能超过24小时</view>
<view class="tips">车辆停留请勿超出有效期需及时驶出小区</view>
</view>
</view>
<!-- 底部按钮 --> <!-- 底部按钮 -->
<view class="btn-footer"> <view class="btn-wrap">
<button <button
class="main-btn" class="submit-btn"
@click="activeTab === 'car' ? submitInvite() : goToQrcode()" @click="submitForm"
> >
{{ activeTab === 'car' ? '确认邀请' : '生成通行二维码' }} {{ activeTab === 'car' ? '确认邀请' : '生成通行二维码' }}
</button> </button>
</view> </view>
<!-- 省份选择弹窗 --> <!-- 地址选择弹窗 -->
<uni-popup v-model="showProvinceSelect" type="center" ref="popup"> <uni-popup ref="addressModalRef" type="bottom" :mask-click="false">
<view class="popup-select-wrap"> <view class="modal-wrap">
<text class="popup-title">选择省份简称</text> <view class="modal-title">选择来访地址</view>
<uni-data-select <view class="address-list">
v-model="plateChars[0]" <view
:localdata="provinceList" class="address-item"
@confirm="onProvinceConfirm" :class="{ active: item === form.address }"
@cancel="popup.close()" v-for="item in addressList"
placeholder="请选择省份简称" :key="item"
></uni-data-select> @click="selectAddress(item)"
>
{{ item }}
</view>
</view>
<uni-icons
type="closeempty"
size="20"
class="modal-close"
@click="closeAddressModal"
></uni-icons>
</view> </view>
</uni-popup> </uni-popup>
<!-- 性别选择弹窗 -->
<uni-popup ref="genderModalRef" type="bottom" :mask-click="false">
<view class="modal-wrap">
<view class="gender-list">
<view
class="gender-item"
:class="{ active: item === form.gender }"
v-for="item in genderList"
:key="item"
@click="selectGender(item)"
>
{{ item }}
</view>
</view>
</view>
</uni-popup>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref, reactive, watch, nextTick } from 'vue'; import { ref, reactive} from 'vue';
import{onLoad } from "@dcloudio/uni-app"
// 激活的Tabcar-车辆来访person-人员来访 // 标签激活状态
const activeTab = ref('car'); const activeTab = ref('car');
const popup = ref(null)
// 表单数据 // 表单数据
const formData = reactive({ const form = reactive({
address: '', // 来访地址 address: '桂花园别墅2号楼2层', // 来访地址默认值
name: '', // 访客姓名 name: '', // 访客姓名
gender: '', // 访客性别 gender: '', // 性别默认值
phone: '', // 联系方式 phone: '', // 联系方式
carNumber: '', // 车牌号(同步输入的完整车牌 carNumber: ['', '', '', '', '', '', ''], // 车牌号7位
escortNum: '', // 随行人数 peopleNum: '', // 随行人数
visitTime: '', // 来访时间 visitTime: '', // 来访时间默认值
leaveTime: '' // 离开时间 leaveTime: '' // 离开时间
}); });
// 表单Ref用于调用校验方法 // 地址列表(模拟数据
const formRef = ref(null);
// 表单校验规则
const formRules = reactive({
address: {
rules: [{ required: true, errorMessage: '请选择来访地址' }]
},
name: {
rules: [{ required: true, errorMessage: '请输入访客姓名' }]
},
gender: {
rules: [{ required: true, errorMessage: '请选择访客性别' }]
},
phone: {
rules: [
{ required: true, errorMessage: '请输入正确的手机号' },
{ pattern: /^1[3-9]\d{9}$/, errorMessage: '请输入正确的手机号' }
]
},
carNumber: {
rules: [
{
required: true,
errorMessage: "请输入车牌号",
},
{
validateFunction: (rule, value, callback) => {
// 仅车辆来访时生效
if (activeTab.value !== 'car') return callback();
// 1. 校验省份是否选择
if (!plateChars.value[0]) {
return callback('请选择省份简称');
}
// 2. 拼接完整车牌号
const fullPlate = plateChars.value.join('').trim();
// 3. 校验车牌号长度(省份+5/6位字符
if (fullPlate.length < 7) {
return callback('请输入完整车牌号(省份+5位字符');
}
if (fullPlate.length > 8) {
return callback('车牌号长度超出限制最多7位');
}
// 4. 同步到formData.carNumber供接口提交
formData.carNumber = fullPlate;
callback();
}
}
]
},
visitTime: {
rules: [{ required: true, errorMessage: '请选择来访时间' }]
},
leaveTime: {
rules: [
{ required: true, errorMessage: '请选择离开时间' },
{
validateFunction: (rule, value, callback) => {
// 1. 空值校验
if (!value) return callback('请选择离开时间');
if (!formData.visitTime) return callback('请先选择来访时间');
// 2. 校验时间格式有效性
const visitTime = new Date(formData.visitTime);
const leaveTime = new Date(value);
if (isNaN(visitTime.getTime()) || isNaN(leaveTime.getTime())) {
return callback('请选择有效的时间');
}
// 3. 校验离开时间不能早于来访时间
if (leaveTime <= visitTime) {
return callback('离开时间不能早于来访时间');
}
// 4. 校验时间间隔≤24小时
const diffHours = (leaveTime.getTime() - visitTime.getTime()) / (1000 * 60 * 60);
if (diffHours > 24) {
return callback('来访和离开时间间隔不能超过24小时');
}
callback();
}
}
]
}
});
// 地址列表
const addressList = ref([ const addressList = ref([
{ text: '桂花园别墅1号楼1层', value: '桂花园别墅1号楼1层' }, '桂花园别墅1号楼1层',
{ text: '桂花园别墅2号楼2层', value: '桂花园别墅2号楼2层' } '桂花园别墅2号楼2层'
]); ]);
// 性别列表 // 性别列表
const sexList = ref([ const genderList = ref(['男', '女']);
{ text: '男', value: '男' },
{ text: '女', value: '女' }
]);
// 省份简称列表(国标规范) // 弹窗/选择器实例
const provinceList = ref([ const addressModalRef = ref(null);
{ text: '京', value: '京' }, const genderModalRef = ref(null);
{ text: '沪', value: '沪' }, const timePickerRef = ref(null);
{ text: '粤', value: '粤' }, // 标记当前选择的是来访/离开时间
{ text: '苏', value: '' }, const currentTimeType = ref('');
{ text: '浙', value: '浙' },
{ text: '鲁', value: '鲁' },
{ text: '川', value: '川' },
{ text: '渝', value: '渝' },
{ text: '湘', value: '湘' },
{ text: '鄂', value: '鄂' }
]);
// 车牌号逐位存储索引0省份1-6字符 → 共7位兼容普通/新能源车牌) // 页面初始化
const plateChars = ref(['', '', '', '', '', '', '','']); onLoad(() => {
const showProvinceSelect = ref(false); // 省份选择弹窗 // 可在这里请求接口获取地址/默认时间等数据
const plateInputRefs = ref([]); // 输入框refs用于自动聚焦 });
// 切换tab
// 打开省份弹框
const showProvinceClick = () => {
popup.value.open()
};
// 选择省份后赋值
const onProvinceConfirm = () => {
showProvinceSelect.value = false;
popup.value.close();
// 省份选择后自动聚焦第一个字符输入框
nextTick(() => {
plateInputRefs.value[1]?.focus();
});
};
// 车牌号字符输入处理(优化过滤和自动聚焦)
const handlePlateInput = (index, e) => {
// 过滤非字母数字,转大写(车牌仅支持字母/数字)
let val = e.detail.value.replace(/[^A-Za-z0-9]/g, '').toUpperCase();
// 仅保留1个字符
val = val.slice(-1);
plateChars.value[index] = val;
// 自动聚焦下一个输入框(如果当前有值且不是最后一位)
if (val && index < 7) { // 最后一位是索引6无需再聚焦
nextTick(() => {
plateInputRefs.value[index + 1]?.focus();
});
}
// 输入完成后触发表单校验
if (activeTab.value === 'car') {
formRef.value.validateField('carNumber');
}
};
// 车牌号删除键处理(优化回退逻辑)
const handlePlateKeydown = (index, e) => {
// 监听回退键keyCode 8
if (e.keyCode === 8) {
// 当前输入框为空,聚焦上一个
if (!plateChars.value[index] && index > 1) {
nextTick(() => {
plateInputRefs.value[index - 1]?.focus();
});
} else {
// 清空当前输入框
plateChars.value[index] = '';
}
}
};
// 时间变更时重新校验离开时间
const handleTimeChange = () => {
if (formData.leaveTime) {
formRef.value.validateField('leaveTime');
}
};
// 切换Tab
const switchTab = (tab) => { const switchTab = (tab) => {
activeTab.value = tab; activeTab.value = tab;
// 切换Tab后重置表单 // 切换Tab后重置表单
if (tab === 'person') { resetForm();
resetForm();
}
// resetForm();
nextTick(() =>{ nextTick(() =>{
formRef.value.clearValidate() // 清空所有校验提示
// formRef.value.validate();
}) })
}; };
// 空方法占位 // 返回上一页
const changeAddress = () => {}; const navigateBack = () => {
const changeSex = (e) => {}; uni.navigateBack();
};
// 提交前表单校验 // 打开地址弹窗
const submitForm = async () => { const openAddressModal = () => {
try { addressModalRef.value.open();
// 调用uni-forms内置校验 };
await formRef.value.validate();
return true; // 关闭地址弹窗
} catch (err) { const closeAddressModal = () => {
return false; addressModalRef.value.close();
};
// 选择地址
const selectAddress = (item) => {
form.address = item;
closeAddressModal();
};
// 打开性别弹窗
const openGenderModal = () => {
genderModalRef.value.open();
};
// 选择性别
const selectGender = (item) => {
form.gender = item;
genderModalRef.value.close();
};
// 打开时间选择器
// const openTimePicker = (type) => {
// currentTimeType.value = type;
// timePickerRef.value.open();
// };
// 校验来访/离开时间间隔
const checkTimeInterval = () => {
if (!form.visitTime || !form.leaveTime) return;
const visitTime = new Date(form.visitTime).getTime();
const leaveTime = new Date(form.leaveTime).getTime();
const diffHours = (leaveTime - visitTime) / (1000 * 60 * 60);
if (diffHours > 24) {
uni.showToast({
title: '时间间隔不能超过24小时',
icon: 'none'
});
form.leaveTime = '';
} }
}; };
// 车辆来访:提交确认邀请 // 表单提交
const submitInvite = async () => { const submitForm = () => {
const isValid = await submitForm(); // 必填项校验
if (!isValid) return; if (!form.phone) {
uni.showToast({ title: '请输入访客联系方式', icon: 'none' });
// 模拟接口提交 return;
uni.showToast({ }
title: '邀请成功', if (!/^1[3-9]\d{9}$/.test(form.phone)) {
icon: 'success', uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
duration: 2000 return;
}); }
if (activeTab === 'car' && form.carNumber.join('').length < 8) {
uni.showToast({ title: '请填写完整车牌号', icon: 'none' });
return;
}
if (!form.peopleNum || form.peopleNum < 0) {
uni.showToast({ title: '请输入正确的随行人数', icon: 'none' });
return;
}
if (!form.leaveTime) {
uni.showToast({ title: '请选择离开时间', icon: 'none' });
return;
}
checkTimeInterval();
if (!form.leaveTime) return; // 时间校验失败则终止提交
// 提交逻辑(替换为实际接口请求)
uni.showLoading({ title: '提交中...' });
setTimeout(() => { setTimeout(() => {
resetForm(); uni.hideLoading();
}, 2000); uni.showToast({
}; title: activeTab === 'car' ? '邀请成功' : '二维码生成成功',
icon: 'success'
// 跳转到二维码页面(人员来访) });
const goToQrcode = async () => { }, 1000);
const isValid = await submitForm();
if (!isValid) return;
const formStr = encodeURIComponent(JSON.stringify(formData));
uni.navigateTo({
url: `/pages/visitor/qrcode-page?form=${formStr}`
});
};
// 重置表单
const resetForm = () => {
formData.address = '';
formData.name = '';
formData.gender = '';
formData.phone = '';
formData.carNumber = '';
formData.escortNum = '';
formData.visitTime = '';
formData.leaveTime = '';
plateChars.value = ['', '', '', '', '', '', '']; // 重置车牌号输入
}; };
// 重置表单
const resetForm = () => {
form.address = '';
form.name = '';
form.gender = '';
form.phone = '';
form.carNumber = '';
form.escortNum = '';
form.visitTime = '';
form.leaveTime = '';
form.carNumber = ['', '', '', '', '', '', '']; // 重置车牌号输入
};
</script> </script>
<style scoped> <style scoped>
.visitor-add-page { .visitor-invite {
background-color: #f8f8f8; background-color: #f5f5f5;
min-height: 100vh; min-height: 100vh;
} }
/* Tab 切换样式 */ /* 导航栏 */
.tab-bar { .nav-bar {
display: flex; display: flex;
background: #fff; align-items: center;
padding: 20rpx;
background-color: #fff;
}
.nav-title {
font-size: 36rpx;
font-weight: 500;
margin-left: 20rpx;
}
/* 标签切换 */
.tab-wrap {
display: flex;
background-color: #fff;
border-bottom: 1rpx solid #eee;
} }
.tab-item { .tab-item {
flex: 1; flex: 1;
text-align: center; text-align: center;
padding: 20rpx 0; padding: 20rpx 0;
font-size: 32rpx; font-size: 32rpx;
color: #666; color: #333;
border-bottom: 4rpx solid transparent;
} }
.tab-item.active { .tab-item.active {
color: #007aff; color: #007aff;
border-bottom-color: #007aff; border-bottom: 4rpx solid #007aff;
} }
/* 表单样式 */ /* 表单区域 */
.form-scroll { .form-wrap {
height: calc(100vh - 220rpx); padding: 10rpx;
} }
.form-section { .form-section {
background: #fff; background-color: #fff;
margin-top: 20rpx; margin-bottom: 10rpx;
padding: 20rpx; padding: 20rpx 40rpx;
} }
.section-title {
/* 车牌号逐位输入样式 */ font-size: 32rpx;
.plate-input-wrap { font-weight: 500;
flex: 1; margin-bottom: 20rpx;
}
.form-item {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4rpx; padding: 20rpx 0;
border-bottom: 1rpx solid #f0f0f0;
} }
.plate-item { .form-item:last-child {
width: 52rpx; border-bottom: none;
height: 60rpx; }
line-height: 60rpx; .label {
text-align: center; width: 200rpx;
border: 1rpx solid #ddd; font-size: 30rpx;
border-radius: 4rpx;
font-size: 28rpx;
color: #333; color: #333;
} }
.province-item { .required {
background-color: #f8f8f8; color: red;
margin-right: 4rpx;
} }
.char-item { .value {
border: 1px solid #666; flex: 1;
outline: none; font-size: 30rpx;
padding: 0; color: #666;
margin: 0 3rpx; display: flex;
justify-content: flex-end;
align-items: center;
} }
.char-item:focus { .input {
border-color: #007aff; flex: 1;
box-shadow: 0 0 4rpx rgba(0, 122, 255, 0.5); font-size: 30rpx;
color: #666;
text-align: right;
} }
/* 省份选择弹窗样式 */ /* 车牌号输入 */
.popup-select-wrap { .car-number-wrap {
background: #fff; flex: 1;
border-radius: 12rpx; display: flex;
padding: 30rpx; justify-content: space-between;
width: 600rpx;
margin: 0 auto;
} }
.popup-title { .car-input {
font-size: 32rpx; width: 52rpx;
font-weight: 600; height: 60rpx;
color: #333; border: 1rpx solid #eee;
margin-bottom: 20rpx;
display: block;
text-align: center; text-align: center;
font-size: 30rpx;
} }
/* 提示文字 */ /* 提示文字 */
.tips-text { .tips {
margin: 20rpx;
font-size: 24rpx; font-size: 24rpx;
color: #999; color: #999;
line-height: 1.6; margin-top: 10rpx;
text-align: center;
} }
/* 底部按钮 */ /* 底部按钮 */
.btn-footer { .btn-wrap {
padding: 20rpx; padding: 20rpx;
background: #fff;
} }
.main-btn { .submit-btn {
background-color: #007aff; background-color: #007aff;
color: #fff; color: #fff;
border-radius: 8rpx;
height: 88rpx;
font-size: 32rpx; font-size: 32rpx;
height: 80rpx;
line-height: 80rpx;
border-radius: 8rpx;
}
/* 弹窗样式 */
.modal-wrap {
background-color: #fff;
padding: 30rpx;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
position: relative;
}
.modal-title {
font-size: 32rpx;
text-align: center;
margin-bottom: 30rpx;
}
.modal-close {
position: absolute;
top: 20rpx;
right: 20rpx;
color: #999;
}
.address-list, .gender-list {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.address-item, .gender-item {
padding: 20rpx;
background-color: #f5f5f5;
border-radius: 8rpx;
text-align: center;
font-size: 30rpx;
}
.address-item.active, .gender-item.active {
background-color: #007aff;
color: #fff;
} }
</style> </style>

View File

@@ -1,5 +1,14 @@
<template> <template>
<view class="visitor-page"> <view class="visitor-page">
<view class="status_bar"></view>
<!-- 顶部导航栏 -->
<view class="nav-bar">
<view class="nav-left" @tap="goBack">
<image src="/static/首页/arr-left.png" style="width: 48rpx; height: 48rpx;"></image>
</view>
<view class="nav-title">访客邀请</view>
<view class="nav-right"></view>
</view>
<!-- 标签切换栏 --> <!-- 标签切换栏 -->
<view class="tab-bar"> <view class="tab-bar">
@@ -112,7 +121,13 @@ const visitorList = ref([
const filterdList = computed(() => { const filterdList = computed(() => {
return visitorList.value.filter(item => item.status === activeTab.value) return visitorList.value.filter(item => item.status === activeTab.value)
}) })
// 返回上一页
const goBack = () => {
// uni.navigateBack()
uni.switchTab({
url:"/pages/index/index"
})
}
// 查看详情 // 查看详情
const viewDetail = (item) => { const viewDetail = (item) => {
@@ -134,19 +149,57 @@ const addInvitation = () => {
<style scoped> <style scoped>
/* 页面整体样式 */ /* 页面整体样式 */
.visitor-page { .visitor-page {
background-color: #f5f5f5; background: linear-gradient(to bottom left, #E2F0FF 0%, #f9f9f9 50%);
min-height: 100vh; min-height: 100vh;
padding: 0 40rpx;
}
.status_bar {
height: 32px;
width: 100%;
}
/* 顶部导航栏 */
.nav-bar {
height: 90rpx;
display: flex;
align-items: center;
/* padding: 0 30rpx; */
color: #fff;
position: sticky;
top: 44px;
z-index: 100;
margin-bottom: 20px;
}
.nav-left {
width: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.nav-title {
flex: 1;
text-align: center;
font-size: 32rpx;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 20rpx;
color: #000;
}
.nav-right {
width: 60rpx;
} }
/* 标签切换栏 */ /* 标签切换栏 */
.tab-bar { .tab-bar {
display: flex; display: flex;
background-color: #fff;
border-bottom: 2px solid #f5f5f5;
} }
.tab-item { .tab-item {
flex: 1; flex: 1;
text-align: center; text-align: left;
padding: 12px 0; padding: 12px 0;
font-size: 16px; font-size: 16px;
color: #666; color: #666;
@@ -161,11 +214,13 @@ const addInvitation = () => {
content: ''; content: '';
position: absolute; position: absolute;
bottom: -2px; bottom: -2px;
left: 50%; left: 18%;
transform: translateX(-50%); transform: translateX(-50%);
width: 40px; width: 64px;
height: 2px; height: 4px;
background-color: #007aff; border-radius: 6rpx;
background-color: #2F77FD;
/* background-color: linear-gradient(to bottom, #2F77FD, #CEDFFF); */
} }
/* 列表容器 */ /* 列表容器 */
@@ -176,7 +231,7 @@ const addInvitation = () => {
/* 访客列表项 */ /* 访客列表项 */
.visitor-item { .visitor-item {
background-color: #fff; background-color: #fff;
margin: 10px 15px; margin: 10px 0px;
padding: 15px; padding: 15px;
border-radius: 8px; border-radius: 8px;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B