first commit
This commit is contained in:
117
property-uniapp-project/pages/visitor/qrcode-page.vue
Normal file
117
property-uniapp-project/pages/visitor/qrcode-page.vue
Normal file
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<view class="qrcode-page">
|
||||
|
||||
<view class="qrcode-wrap">
|
||||
<view class="qrcode-box">
|
||||
<!-- 调用uqrcode组件 -->
|
||||
<uqrcode
|
||||
:value="qrcodeValue"
|
||||
:size="400"
|
||||
:logo="'/static/logo.png'"
|
||||
:logoSize="0.2"
|
||||
canvasId="visitor-qrcode"
|
||||
@success="onQrcodeSuccess"
|
||||
></uqrcode>
|
||||
<!-- 二维码边框装饰 -->
|
||||
<view class="qrcode-border border-top"></view>
|
||||
<view class="qrcode-border border-right"></view>
|
||||
<view class="qrcode-border border-bottom"></view>
|
||||
<view class="qrcode-border border-left"></view>
|
||||
</view>
|
||||
|
||||
<text class="qrcode-desc">桂花园(别墅)东门通行二维码</text>
|
||||
<text class="qrcode-tips">分享此二维码给访客,可扫码开门,单次有效</text>
|
||||
</view>
|
||||
|
||||
<view class="btn-wrap">
|
||||
<button class="send-btn" @click="sendToFriend">发送给好友</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
// import { navigateBack, showToast, share } from '@dcloudio/uni-app';
|
||||
// 引入本地uqrcode组件
|
||||
import uqrcode from '@/components/uqrcode/uqrcode.vue';
|
||||
|
||||
// 二维码内容(替换为实际的通行链接)
|
||||
const qrcodeValue = ref('https://your-domain.com/visitor/123456');
|
||||
// 生成的二维码临时图片地址
|
||||
const qrcodeImage = ref('');
|
||||
|
||||
// 二维码生成成功回调
|
||||
const onQrcodeSuccess = (tempFilePath) => {
|
||||
qrcodeImage.value = tempFilePath;
|
||||
uni.showToast({ title: '二维码生成成功', icon: 'success' });
|
||||
};
|
||||
|
||||
// 分享给好友
|
||||
const sendToFriend = () => {
|
||||
if (!qrcodeImage.value) {
|
||||
uni.showToast({ title: '二维码生成中...', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
uni.share({
|
||||
provider: 'weixin',
|
||||
type: 0,
|
||||
title: '访客通行二维码',
|
||||
imageUrl: qrcodeImage.value,
|
||||
success: () => uni.showToast({ title: '分享成功' }),
|
||||
fail: () => uni.showToast({ title: '分享失败', icon: 'none' })
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.qrcode-page {
|
||||
/* background-color: #f8f8f8; */
|
||||
min-height: 100vh;
|
||||
}
|
||||
.qrcode-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
.qrcode-box {
|
||||
position: relative;
|
||||
width: 400rpx;
|
||||
height: 400rpx;
|
||||
}
|
||||
/* 二维码边框样式 */
|
||||
.qrcode-border {
|
||||
position: absolute;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border: 4rpx solid #007aff;
|
||||
}
|
||||
.border-top { top: 0; left: 0; border-right: none; border-bottom: none; }
|
||||
.border-right { top: 0; right: 0; border-left: none; border-bottom: none; }
|
||||
.border-bottom { bottom: 0; right: 0; border-left: none; border-top: none; }
|
||||
.border-left { bottom: 0; left: 0; border-right: none; border-top: none; }
|
||||
/* 文字样式 */
|
||||
.qrcode-desc {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
margin-top: 30rpx;
|
||||
color: #333;
|
||||
}
|
||||
.qrcode-tips {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
/* 按钮样式 */
|
||||
.btn-wrap {
|
||||
margin: 80rpx 20rpx 20rpx;
|
||||
}
|
||||
.send-btn {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 8rpx;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
</style>
|
||||
496
property-uniapp-project/pages/visitor/visitor-add.vue
Normal file
496
property-uniapp-project/pages/visitor/visitor-add.vue
Normal file
@@ -0,0 +1,496 @@
|
||||
<template>
|
||||
<view class="visitor-add-page">
|
||||
<!-- Tab 切换:车辆来访/人员来访 -->
|
||||
<view class="tab-bar">
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'car' }"
|
||||
@click="switchTab('car')"
|
||||
>
|
||||
车辆来访
|
||||
</view>
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'person' }"
|
||||
@click="switchTab('person')"
|
||||
>
|
||||
人员来访
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 表单区域 -->
|
||||
<scroll-view class="form-scroll" scroll-y>
|
||||
<view class="form-section">
|
||||
<uni-forms ref="formRef" :modelValue="formData" :rules="formRules" label-width="105px" label-align="left">
|
||||
<!-- 来访地址 -->
|
||||
<uni-forms-item label="来访地址:" name="address" required>
|
||||
<uni-data-select v-model="formData.address" :localdata="addressList" @change="changeAddress" :clear="false"></uni-data-select>
|
||||
</uni-forms-item>
|
||||
<!-- 访客姓名 -->
|
||||
<uni-forms-item label="访客姓名" name="name" required>
|
||||
<uni-easyinput type="text" v-model="formData.name" placeholder="请输入姓名" />
|
||||
</uni-forms-item>
|
||||
<!-- 访客性别 -->
|
||||
<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 class="tips-text">
|
||||
预计来访时间和预计离开时间间隔不能超过24小时
|
||||
<view>车辆停留请勿超出有效期,需及时驶出小区</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="btn-footer">
|
||||
<button
|
||||
class="main-btn"
|
||||
@click="activeTab === 'car' ? submitInvite() : goToQrcode()"
|
||||
>
|
||||
{{ activeTab === 'car' ? '确认邀请' : '生成通行二维码' }}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<!-- 省份选择弹窗 -->
|
||||
<uni-popup v-model="showProvinceSelect" type="center" ref="popup">
|
||||
<view class="popup-select-wrap">
|
||||
<text class="popup-title">选择省份简称</text>
|
||||
<uni-data-select
|
||||
v-model="plateChars[0]"
|
||||
:localdata="provinceList"
|
||||
@confirm="onProvinceConfirm"
|
||||
@cancel="popup.close()"
|
||||
placeholder="请选择省份简称"
|
||||
></uni-data-select>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, watch, nextTick } from 'vue';
|
||||
|
||||
// 激活的Tab:car-车辆来访,person-人员来访
|
||||
const activeTab = ref('car');
|
||||
const popup = ref(null)
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
address: '', // 来访地址
|
||||
name: '', // 访客姓名
|
||||
gender: '', // 访客性别
|
||||
phone: '', // 联系方式
|
||||
carNumber: '', // 车牌号(同步输入的完整车牌)
|
||||
escortNum: '', // 随行人数
|
||||
visitTime: '', // 来访时间
|
||||
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([
|
||||
{ text: '桂花园(别墅)1号楼1层', value: '桂花园(别墅)1号楼1层' },
|
||||
{ text: '桂花园(别墅)2号楼2层', value: '桂花园(别墅)2号楼2层' }
|
||||
]);
|
||||
|
||||
// 性别列表
|
||||
const sexList = ref([
|
||||
{ text: '男', value: '男' },
|
||||
{ text: '女', value: '女' }
|
||||
]);
|
||||
|
||||
// 省份简称列表(国标规范)
|
||||
const provinceList = ref([
|
||||
{ text: '京', value: '京' },
|
||||
{ text: '沪', value: '沪' },
|
||||
{ text: '粤', value: '粤' },
|
||||
{ text: '苏', value: '苏' },
|
||||
{ text: '浙', value: '浙' },
|
||||
{ text: '鲁', value: '鲁' },
|
||||
{ text: '川', value: '川' },
|
||||
{ text: '渝', value: '渝' },
|
||||
{ text: '湘', value: '湘' },
|
||||
{ text: '鄂', value: '鄂' }
|
||||
]);
|
||||
|
||||
// 车牌号逐位存储(索引0:省份,1-6:字符 → 共7位,兼容普通/新能源车牌)
|
||||
const plateChars = ref(['', '', '', '', '', '', '','']);
|
||||
const showProvinceSelect = ref(false); // 省份选择弹窗
|
||||
const plateInputRefs = ref([]); // 输入框refs,用于自动聚焦
|
||||
|
||||
// 打开省份弹框
|
||||
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) => {
|
||||
activeTab.value = tab;
|
||||
// 切换Tab后重置表单
|
||||
if (tab === 'person') {
|
||||
resetForm();
|
||||
}
|
||||
// resetForm();
|
||||
nextTick(() =>{
|
||||
formRef.value.clearValidate() // 清空所有校验提示
|
||||
// formRef.value.validate();
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
// 空方法占位
|
||||
const changeAddress = () => {};
|
||||
const changeSex = (e) => {};
|
||||
|
||||
// 提交前表单校验
|
||||
const submitForm = async () => {
|
||||
try {
|
||||
// 调用uni-forms内置校验
|
||||
await formRef.value.validate();
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// 车辆来访:提交确认邀请
|
||||
const submitInvite = async () => {
|
||||
const isValid = await submitForm();
|
||||
if (!isValid) return;
|
||||
|
||||
// 模拟接口提交
|
||||
uni.showToast({
|
||||
title: '邀请成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
resetForm();
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
// 跳转到二维码页面(人员来访)
|
||||
const goToQrcode = async () => {
|
||||
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 = ['', '', '', '', '', '', '']; // 重置车牌号输入
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.visitor-add-page {
|
||||
background-color: #f8f8f8;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Tab 切换样式 */
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
background: #fff;
|
||||
}
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 20rpx 0;
|
||||
font-size: 32rpx;
|
||||
color: #666;
|
||||
border-bottom: 4rpx solid transparent;
|
||||
}
|
||||
.tab-item.active {
|
||||
color: #007aff;
|
||||
border-bottom-color: #007aff;
|
||||
}
|
||||
|
||||
/* 表单样式 */
|
||||
.form-scroll {
|
||||
height: calc(100vh - 220rpx);
|
||||
}
|
||||
.form-section {
|
||||
background: #fff;
|
||||
margin-top: 20rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
/* 车牌号逐位输入样式 */
|
||||
.plate-input-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
}
|
||||
.plate-item {
|
||||
width: 52rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
text-align: center;
|
||||
border: 1rpx solid #ddd;
|
||||
border-radius: 4rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
.province-item {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
.char-item {
|
||||
border: 1px solid #666;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
margin: 0 3rpx;
|
||||
}
|
||||
.char-item:focus {
|
||||
border-color: #007aff;
|
||||
box-shadow: 0 0 4rpx rgba(0, 122, 255, 0.5);
|
||||
}
|
||||
|
||||
/* 省份选择弹窗样式 */
|
||||
.popup-select-wrap {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 30rpx;
|
||||
width: 600rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 提示文字 */
|
||||
.tips-text {
|
||||
margin: 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
.btn-footer {
|
||||
padding: 20rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.main-btn {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 8rpx;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
</style>
|
||||
172
property-uniapp-project/pages/visitor/visitor-detail.vue
Normal file
172
property-uniapp-project/pages/visitor/visitor-detail.vue
Normal file
@@ -0,0 +1,172 @@
|
||||
<template>
|
||||
<view class="visitor-detail-page">
|
||||
<!-- 访客信息卡片 -->
|
||||
<view class="info-card">
|
||||
<view class="info-header">
|
||||
<text class="title">来访者:{{ visitorInfo.name }}</text>
|
||||
<text class="status {{ visitorInfo.status === 'visited' ? 'visited' : 'waiting' }}">
|
||||
{{ visitorInfo.status === 'visited' ? '已到访' : '等待来访' }}
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<uni-divider margin="10rpx 0"></uni-divider>
|
||||
|
||||
<view class="info-list">
|
||||
<view class="info-item">
|
||||
<text class="label">来访地址:</text>
|
||||
<text class="value">{{ visitorInfo.address }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">联系方式:</text>
|
||||
<text class="value">{{ visitorInfo.phone }}</text>
|
||||
</view>
|
||||
<!-- 车牌号可选显示 -->
|
||||
<view class="info-item" v-if="visitorInfo.carNumber">
|
||||
<text class="label">车牌号:</text>
|
||||
<text class="value">{{ visitorInfo.carNumber }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">随行人数:</text>
|
||||
<text class="value">{{ visitorInfo.escortNum }}人</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">有效期:</text>
|
||||
<text class="value">{{ visitorInfo.validTime }}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<text class="label">邀请时间:</text>
|
||||
<text class="value">{{ visitorInfo.inviteTime }}</text>
|
||||
</view>
|
||||
<!-- 已到访状态显示到访时间 -->
|
||||
<view class="info-item" v-if="visitorInfo.status === 'visited'">
|
||||
<text class="label">到访时间:</text>
|
||||
<text class="value">{{ visitorInfo.visitTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 提示文字 -->
|
||||
<view class="tips-text">
|
||||
<view>预计来访时间盒预计离开时间间隔不能超过24小时</view>
|
||||
车辆停留请勿超出有效期,需及时驶出小区
|
||||
</view>
|
||||
|
||||
<!-- 分享二维码按钮(仅等待来访状态显示) -->
|
||||
<view class="btn-wrap" v-if="visitorInfo.status === 'waiting'">
|
||||
<button class="share-btn" @click="goToQrcode">分享通行二维码</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import {onLoad} from '@dcloudio/uni-app'
|
||||
|
||||
// 访客信息(实际项目中从接口获取)
|
||||
// const visitorInfo = ref({})
|
||||
const visitorInfo = ref({
|
||||
name: '张三',
|
||||
status: 'waiting', // waiting:等待来访,visited:已到访
|
||||
address: '桂花园(别墅)2号楼2层',
|
||||
phone: '13866666666',
|
||||
carNumber: '京A88888', // 可传空隐藏
|
||||
escortNum: 0,
|
||||
validTime: '2023.06.30 10:00至2023.06.30 23:00',
|
||||
inviteTime: '2023年06月30日 09:35',
|
||||
visitTime: '2023年06月30日 14:32' // 已到访时显示
|
||||
});
|
||||
|
||||
|
||||
onLoad((option) =>{
|
||||
const infoStr = decodeURIComponent(JSON.stringify(option))
|
||||
// console.log('infoStr',infoStr)
|
||||
visitorInfo.value = infoStr.item
|
||||
})
|
||||
// 跳转到二维码页面
|
||||
const goToQrcode = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/visitor/qrcode-page'
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.visitor-detail-page {
|
||||
background-color: #f8f8f8;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
background: #fff;
|
||||
margin: 20rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.info-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 28rpx;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
.waiting {
|
||||
color: #007aff;
|
||||
background: #e8f4ff;
|
||||
}
|
||||
|
||||
.visited {
|
||||
color: #34c759;
|
||||
background: #e6fffa;
|
||||
}
|
||||
|
||||
.info-list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
margin-bottom: 16rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
color: #666;
|
||||
width: 160rpx;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.tips-text {
|
||||
margin: 0 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.btn-wrap {
|
||||
margin: 40rpx 20rpx;
|
||||
}
|
||||
|
||||
.share-btn {
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 8rpx;
|
||||
height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
</style>
|
||||
273
property-uniapp-project/pages/visitor/visitor-list.vue
Normal file
273
property-uniapp-project/pages/visitor/visitor-list.vue
Normal file
@@ -0,0 +1,273 @@
|
||||
<template>
|
||||
<view class="visitor-page">
|
||||
|
||||
<!-- 标签切换栏 -->
|
||||
<view class="tab-bar">
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'waiting' }"
|
||||
@click="activeTab = 'waiting'"
|
||||
>
|
||||
等待来访
|
||||
</view>
|
||||
<view
|
||||
class="tab-item"
|
||||
:class="{ active: activeTab === 'visited' }"
|
||||
@click="activeTab = 'visited'"
|
||||
>
|
||||
已到访
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 访客列表 -->
|
||||
<scroll-view class="list-container" scroll-y>
|
||||
<!-- 列表项:根据标签切换显示对应数据 -->
|
||||
<view
|
||||
class="visitor-item"
|
||||
v-for="(item, index) in filterdList"
|
||||
:key="index"
|
||||
>
|
||||
<!-- 访客基本信息 -->
|
||||
<view class="item-header">
|
||||
<text class="visitor-name" :class="item.status">来访者:{{ item.name }}</text>
|
||||
<text class="status-tag" :class="item.status">{{ item.statusText }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 有效期/到访时间 -->
|
||||
<view class="item-row">
|
||||
<text class="label" :class="item.status">{{ item.status === 'waiting' ? '有效期' : '到访时间' }}:</text>
|
||||
<text class="value" :class="item.status">{{ item.timeRange }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 联系方式 -->
|
||||
<view class="item-row">
|
||||
<text class="label" :class="item.status">联系方式:</text>
|
||||
<text class="value" :class="item.status">{{ item.phone }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 车牌号 -->
|
||||
<view class="item-row" v-if="item.carNumber">
|
||||
<text class="label" :class="item.status">车牌号:</text>
|
||||
<text class="value" :class="item.status">{{ item.carNumber }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 时间+查看详情 -->
|
||||
<view class="item-footer">
|
||||
<text class="time-text">时间:{{ item.createTime }}</text>
|
||||
<view class="detail-btn" @click="viewDetail(item)">
|
||||
<text>查看详情</text>
|
||||
<uni-icons type="arrowright" size="14"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 新增邀请按钮 -->
|
||||
<view class="add-btn" @click="addInvitation">
|
||||
<uni-icons type="plus" size="18" color="#fff"></uni-icons>
|
||||
<text class="add-text">新增邀请</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
// import { uniNavigateTo, uniShowToast } from '@dcloudio/uni-app'
|
||||
|
||||
// 激活的标签(waiting=等待来访,visited=已到访)
|
||||
const activeTab = ref('waiting')
|
||||
|
||||
// 模拟访客数据(可替换为接口请求数据)
|
||||
const visitorList = ref([
|
||||
{
|
||||
name: '张三',
|
||||
status: 'waiting', // waiting/visited
|
||||
statusText: '等待来访',
|
||||
timeRange: '2023.06.30 10:00至2023.06.30 23:00',
|
||||
phone: '13866666666',
|
||||
carNumber: '京A88888',
|
||||
createTime: '2023年06月30日 09:35'
|
||||
},
|
||||
{
|
||||
name: '张三',
|
||||
status: 'visited',
|
||||
statusText: '已到访',
|
||||
timeRange: '2023.06.30 16:32:28',
|
||||
phone: '13866666666',
|
||||
carNumber: '京A88888',
|
||||
createTime: '2023年06月30日 09:35'
|
||||
},
|
||||
{
|
||||
name: '张三',
|
||||
status: 'waiting',
|
||||
statusText: '等待来访',
|
||||
timeRange: '2023.06.30 10:00至2023.06.30 23:00',
|
||||
phone: '13866666666',
|
||||
carNumber: '',
|
||||
createTime: '2023年06月30日 09:35'
|
||||
}
|
||||
])
|
||||
|
||||
// 根据标签筛选列表
|
||||
const filterdList = computed(() => {
|
||||
return visitorList.value.filter(item => item.status === activeTab.value)
|
||||
})
|
||||
|
||||
|
||||
// 查看详情
|
||||
const viewDetail = (item) => {
|
||||
const itemStr = encodeURIComponent(JSON.stringify(item))
|
||||
console.log('eeeee',itemStr)
|
||||
uni.navigateTo({
|
||||
url: `/pages/visitor/visitor-detail?item=${itemStr}` // 传参到详情页
|
||||
})
|
||||
}
|
||||
|
||||
// 新增邀请
|
||||
const addInvitation = () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/visitor/visitor-add'
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 页面整体样式 */
|
||||
.visitor-page {
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* 标签切换栏 */
|
||||
.tab-bar {
|
||||
display: flex;
|
||||
background-color: #fff;
|
||||
border-bottom: 2px solid #f5f5f5;
|
||||
}
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
padding: 12px 0;
|
||||
font-size: 16px;
|
||||
color: #666;
|
||||
position: relative;
|
||||
}
|
||||
.tab-item.active {
|
||||
color: #007aff;
|
||||
font-weight: 500;
|
||||
}
|
||||
/* 激活标签下划线 */
|
||||
.tab-item.active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -2px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 40px;
|
||||
height: 2px;
|
||||
background-color: #007aff;
|
||||
}
|
||||
|
||||
/* 列表容器 */
|
||||
.list-container {
|
||||
height: calc(100vh - 150px); /* 预留导航、标签、按钮高度 */
|
||||
}
|
||||
|
||||
/* 访客列表项 */
|
||||
.visitor-item {
|
||||
background-color: #fff;
|
||||
margin: 10px 15px;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
/* 列表项头部(姓名+状态) */
|
||||
.item-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.visitor-name {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
.visitor-name.visited{
|
||||
color: #999;
|
||||
}
|
||||
.status-tag {
|
||||
font-size: 14px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.status-tag.waiting {
|
||||
color: #2F77FD;
|
||||
/* background-color: #fff8e6; */
|
||||
}
|
||||
.status-tag.visited {
|
||||
color: #999999;
|
||||
/* background-color: #e6fffa; */
|
||||
}
|
||||
|
||||
/* 列表项行数据 */
|
||||
.item-row {
|
||||
display: flex;
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.label {
|
||||
color: #222;
|
||||
min-width: 80px;
|
||||
}
|
||||
.value {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
.label.visited{
|
||||
color: #999;
|
||||
}
|
||||
.value.visited{
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 列表项底部(时间+查看详情) */
|
||||
.item-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid #f5f5f5;
|
||||
}
|
||||
.time-text {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
.detail-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/* 新增邀请按钮 */
|
||||
.add-btn {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
left: 15px;
|
||||
right: 15px;
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.add-text {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user