对接访客邀请接口

This commit is contained in:
zhouyanli
2026-05-06 17:48:39 +08:00
parent e030bb7cb9
commit 231de9cde8
13 changed files with 1028 additions and 1037 deletions

View File

@@ -1,113 +0,0 @@
<template>
<canvas v-if="value" :type="type" :style="{width: size + 'px', height: size + 'px'}" :canvas-id="canvasId"
ref="qrcodeCanvas"></canvas>
</template>
<script setup>
import {
ref,
onMounted,
watch
} from 'vue';
import {
uqrcode
} from 'uqrcodejs'
const props = defineProps({
// 二维码内容(必填,如链接/文本)
value: {
type: String,
default: ''
},
// 尺寸默认300px
size: {
type: [Number, String],
default: 300
},
// 二维码颜色
color: {
type: String,
default: '#000000'
},
// 背景色
backgroundColor: {
type: String,
default: '#ffffff'
},
// logo图片地址
logo: {
type: String,
default: ''
},
// logo大小占二维码比例
logoSize: {
type: Number,
default: 0.2
},
// canvas 类型(小程序需指定)
type: {
type: String,
default: '2d'
},
// canvas ID避免重复
canvasId: {
type: String,
default: 'uqrcode'
}
});
const emit = defineEmits(['success', 'fail']);
const qrcodeCanvas = ref(null);
// 生成二维码核心方法
const createQRCode = async () => {
if (!props.value) return;
try {
// 引入uQRCode核心库
const uQRCode = require('uqrcodejs');
// 获取canvas上下文
const query = uni.createSelectorQuery().in(getCurrentInstance());
const res = await query.select(`#${props.canvasId}`).fields({
node: true,
size: true
}).exec();
const canvas = res[0].node;
const ctx = canvas.getContext('2d');
// 设置canvas尺寸
const dpr = uni.getSystemInfoSync().pixelRatio;
canvas.width = props.size * dpr;
canvas.height = props.size * dpr;
ctx.scale(dpr, dpr);
// 生成二维码
await uQRCode.default.draw({
canvas: canvas,
componentInstance: getCurrentInstance(),
text: props.value,
width: props.size,
color: props.color,
background: props.backgroundColor,
logo: props.logo,
logoSize: props.logoSize
});
// 生成临时图片(可选,用于分享/保存)
uni.canvasToTempFilePath({
canvasId: props.canvasId,
success: (res) => emit('success', res.tempFilePath),
fail: (err) => emit('fail', err)
}, getCurrentInstance());
} catch (err) {
emit('fail', err);
}
};
// 监听value变化重新生成
watch(() => props.value, () => createQRCode(), {
immediate: true
});
onMounted(() => createQRCode());
</script>

View File

@@ -122,6 +122,14 @@ export const getRepairDetail = (data) =>{
export const getVisitorList = (data) =>{ export const getVisitorList = (data) =>{
return get('/api/visitor/list',data) return get('/api/visitor/list',data)
} }
// 获取详情信息
export const getVisitorDetail = (id) =>{
return get(`/api/visitor/${id}`)
}
// 新增访客
export const addVisitorData = (data) =>{
return post("/api/visitor", data)
}
// 通用文件上传 // 通用文件上传
export const uploadImage = () => { export const uploadImage = () => {

View File

@@ -2,7 +2,7 @@ let baseUrl = '';
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// http://192.168.1.215 // http://192.168.1.215
// http://192.168.0.224 // http://192.168.0.224
baseUrl = 'http://192.168.1.215:8080'; // 开发环境 baseUrl = 'http://192.168.0.239:8080'; // 开发环境
} else { } else {
baseUrl = 'http://192.168.0.224:8080'; // 生产环境 baseUrl = 'http://192.168.0.224:8080'; // 生产环境
} }

View File

@@ -1,397 +1,401 @@
<template> <template>
<view class="register-page"> <view class="register-page">
<view class="status_bar"></view> <view class="status_bar"></view>
<!-- 顶部导航 --> <!-- 顶部导航 -->
<view class="nav-bar"> <view class="nav-bar">
<uni-icons type="left" size="28" color="#333" @click="goBack"></uni-icons> <uni-icons type="left" size="28" color="#333" @click="goBack"></uni-icons>
<view class="nav-title">注册</view> <view class="nav-title">注册</view>
</view> </view>
<!-- 注册标题 --> <!-- 注册标题 -->
<view class="register-title">注册用户</view> <view class="register-title">注册用户</view>
<!-- 手机号输入框 --> <!-- 手机号输入框 -->
<view class="input-item"> <view class="input-item">
<view class="input-icon"> <view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image> <image src="http://47.104.199.163:9090/images/login/phone.png" mode=""
</view> style="height: 100%;width: 100%;"></image>
<uni-easyinput class="input-content" type="number" v-model="phoneNumber"
placeholder="请输入手机号" :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 验证码输入 + 获取验证码按钮 -->
<view class="input-item verify-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode"
placeholder="请输入验证码" :inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
</uni-easyinput>
<button
class="get-verify-btn"
:disabled="!canGetVerify || countDown > 0"
@click="getVerifyCode"
>
{{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
</button>
</view>
<!-- 账号输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/account.png" mode="" style="height: 100%;width: 100%;"></image>
<!-- <uni-icons type="person" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content" type="text" v-model="account"
placeholder="请输入账号" :inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 密码输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/password.png" mode="" style="height: 100%;width: 100%;"></image>
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content" type="password" v-model="password"
placeholder="请输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle" >
</uni-easyinput>
</view>
<!-- 协议勾选 -->
<view class="agreement-item" >
<view @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>
</view> </view>
<text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意<text class="agreePrivacy">用户隐私政策</text></text> <uni-easyinput class="input-content" type="number" v-model="phoneNumber" placeholder="请输入手机号"
</view> :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 立即注册按钮 --> <!-- 验证码输入 + 获取验证码按钮 -->
<button <view class="input-item verify-item">
class="register-btn" <view class="input-icon">
:disabled="!canRegister" <image src="http://47.104.199.163:9090/images/login/code.png" mode="" style="height: 100%;width: 100%;">
@click="handleRegister" </image>
> <!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
立即注册 </view>
</button> <uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" placeholder="请输入验证码"
:inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
</uni-easyinput>
<!-- 跳转登录链接 --> <button class="get-verify-btn" :disabled="!canGetVerify || countDown > 0" @click="getVerifyCode">
<view class="login-link"> {{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
<navigator class="link-item" url="/pageSubPack/loginSub/login">已有账号去登录</navigator> </button>
</view> </view>
</view>
<!-- 账号输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/account.png" mode=""
style="height: 100%;width: 100%;"></image>
<!-- <uni-icons type="person" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content" type="text" v-model="account" placeholder="请输入账号" :inputBorder="false"
:placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 密码输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/password.png" mode=""
style="height: 100%;width: 100%;"></image>
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content" type="password" v-model="password" placeholder="请输入密码"
:inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 协议勾选 -->
<view class="agreement-item">
<view @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>
</view>
<text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意<text
class="agreePrivacy">用户隐私政策</text></text>
</view>
<!-- 立即注册按钮 -->
<button class="register-btn" :disabled="!canRegister" @click="handleRegister">
立即注册
</button>
<!-- 跳转登录链接 -->
<view class="login-link">
<navigator class="link-item" url="/pageSubPack/loginSub/login">已有账号去登录</navigator>
</view>
</view>
</template> </template>
<script setup> <script setup>
import { ref, computed, onUnmounted } from 'vue'; import {
import {getRegisterUser,getSendCode} from '../api/api.js' ref,
computed,
onUnmounted
} from 'vue';
import {
getRegisterUser,
getSendCode
} from '../api/api.js'
// ========== 响应式数据 ========== // ========== 响应式数据 ==========
// 表单数据 // 表单数据
const phoneNumber = ref(''); const phoneNumber = ref('');
const verifyCode = ref(''); const verifyCode = ref('');
const account = ref(''); const account = ref('');
const password = ref(''); const password = ref('');
const placeholderStyle = ref('font-size:24rpx') const placeholderStyle = ref('font-size:24rpx')
// 协议勾选 // 协议勾选
const agreeAgreement = ref(false); const agreeAgreement = ref(false);
// 验证码倒计时 // 验证码倒计时
const countDown = ref(0); const countDown = ref(0);
let timer = null; let timer = null;
// ========== 计算属性 ========== // ========== 计算属性 ==========
// 是否可获取验证码(手机号格式正确) // 是否可获取验证码(手机号格式正确)
const canGetVerify = computed(() => { const canGetVerify = computed(() => {
const phoneReg = /^1[3-9]\d{9}$/; const phoneReg = /^1[3-9]\d{9}$/;
return phoneReg.test(phoneNumber.value); return phoneReg.test(phoneNumber.value);
}); });
// 是否可注册(所有表单项+协议都满足) // 是否可注册(所有表单项+协议都满足)
const canRegister = computed(() => { const canRegister = computed(() => {
const phoneReg = /^1[3-9]\d{9}$/; // 手机号11位 const phoneReg = /^1[3-9]\d{9}$/; // 手机号11位
const verifyReg = /^\d{6}$/; // 验证码6位 const verifyReg = /^\d{6}$/; // 验证码6位
const accountReg = /^.{4,20}$/; // 账号4-20位 const accountReg = /^.{4,20}$/; // 账号4-20位
const pwdReg = /^.{6,16}$/; // 密码6-16位 const pwdReg = /^.{6,16}$/; // 密码6-16位
return phoneReg.test(phoneNumber.value) return phoneReg.test(phoneNumber.value) &&
&& verifyReg.test(verifyCode.value) verifyReg.test(verifyCode.value) &&
&& accountReg.test(account.value) accountReg.test(account.value) &&
&& pwdReg.test(password.value) pwdReg.test(password.value) &&
&& agreeAgreement.value; agreeAgreement.value;
}); });
// ========== 方法 ========== // ========== 方法 ==========
// 返回上一页 // 返回上一页
const goBack = () => { const goBack = () => {
uni.navigateBack(); uni.navigateBack();
}; };
// 切换协议勾选状态 // 切换协议勾选状态
const toggleAgreement = () => { const toggleAgreement = () => {
agreeAgreement.value = !agreeAgreement.value; agreeAgreement.value = !agreeAgreement.value;
}; };
// 跳转隐私协议 // 跳转隐私协议
const goToPrivacy = () => { const goToPrivacy = () => {
uni.navigateTo({ uni.navigateTo({
url:'/pageSubPack/loginSub/privacy', url: '/pageSubPack/loginSub/privacy',
}) })
} }
// 检查表单状态(实时更新按钮状态) // 检查表单状态(实时更新按钮状态)
const checkForm = () => {}; const checkForm = () => {};
// 获取验证码 // 获取验证码
const getVerifyCode = () => { const getVerifyCode = () => {
if (!canGetVerify.value) return; if (!canGetVerify.value) return;
let params = { let params = {
phone:phoneNumber.value, phone: phoneNumber.value,
scene:'register' scene: 'register'
} }
getSendCode(params).then(res =>{ getSendCode(params).then(res => {
if(res.code === 200){ if (res.code === 200) {
uni.showToast({ uni.showToast({
title: '验证码已发送', title: '验证码已发送',
icon: 'success' icon: 'success'
}); });
// 开始60秒倒计时 // 开始60秒倒计时
countDown.value = 60; countDown.value = 60;
timer = setInterval(() => { timer = setInterval(() => {
countDown.value--; countDown.value--;
if (countDown.value <= 0) { if (countDown.value <= 0) {
clearInterval(timer); clearInterval(timer);
timer = null; timer = null;
} }
}, 1000); }, 1000);
}else{
uni.showToast({
title: '验证码发送失败',
icon: 'error'
});
}
}).catch(err =>{
uni.showToast({
title: '网路异常',
icon: 'error'
});
})
} else {
}; uni.showToast({
title: '验证码发送失败',
icon: 'error'
});
}
}).catch(err => {
uni.showToast({
title: '网路异常',
icon: 'error'
});
})
// 处理注册逻辑
const handleRegister = () => {
if (!canRegister.value) return;
uni.showLoading({ title: '注册中...', mask: true });
let params = {
phone:phoneNumber.value,
smsCode:verifyCode.value,
username:account.value,
password:password.value
}
getRegisterUser(params).then(res =>{
if(res.code === 200){
uni.hideLoading();
uni.showToast({
title: '注册成功',
icon: 'success'
});
setTimeout(() => {
uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' });
}, 1500);
}else{
uni.showToast({
title: '注册失败',
icon: 'error'
});
}
}).catch((err) =>{
uni.showToast({
title: '网络异常',
icon: 'error'
});
})
// 注册成功后跳转到登录页
// uni.redirectTo({
// url: '/pages/login/pwd-login'
// });
// setTimeout(() => {
// }, 1500);
};
// ========== 生命周期 ========== };
// 页面卸载时清除定时器
onUnmounted(() => { // 处理注册逻辑
if (timer) { const handleRegister = () => {
clearInterval(timer); if (!canRegister.value) return;
} uni.showLoading({
}); title: '注册中...',
mask: true
});
let params = {
phone: phoneNumber.value,
smsCode: verifyCode.value,
username: account.value,
password: password.value
}
getRegisterUser(params).then(res => {
if (res.code === 200) {
uni.hideLoading();
uni.showToast({
title: '注册成功',
icon: 'success'
});
setTimeout(() => {
uni.redirectTo({
url: '/pageSubPack/loginSub/pwd-login'
});
}, 1500);
} else {
uni.showToast({
title: '注册失败',
icon: 'error'
});
}
}).catch((err) => {
uni.showToast({
title: '网络异常',
icon: 'error'
});
})
// 注册成功后跳转到登录页
// uni.redirectTo({
// url: '/pages/login/pwd-login'
// });
// setTimeout(() => {
// }, 1500);
};
// ========== 生命周期 ==========
// 页面卸载时清除定时器
onUnmounted(() => {
if (timer) {
clearInterval(timer);
}
});
</script> </script>
<style scoped> <style scoped>
/* 页面容器 */ /* 页面容器 */
.register-page { .register-page {
padding: 20rpx 40rpx 40rpx; padding: 20rpx 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 {
height: 46px;
width: 100%;
} }
/* 顶部导航栏 */ .status_bar {
.nav-bar { height: 46px;
display: flex; width: 100%;
align-items: center; }
/* height: 88rpx; */
margin-bottom: 70rpx;
}
.nav-title { /* 顶部导航栏 */
flex: 1; .nav-bar {
text-align: center; display: flex;
font-size: 36rpx; align-items: center;
font-weight: 500; /* height: 88rpx; */
color: #333; margin-bottom: 70rpx;
margin-right: 100rpx; }
}
/* 注册标题 */ .nav-title {
.register-title { flex: 1;
font-size: 40rpx; text-align: center;
font-weight: 600; font-size: 36rpx;
color: #333; font-weight: 500;
margin-bottom: 60rpx; color: #333;
} margin-right: 100rpx;
}
/* 输入框通用样式 */ /* 注册标题 */
.input-item { .register-title {
display: flex; font-size: 40rpx;
align-items: center; font-weight: 600;
background-color: #fff; color: #333;
border-radius: 40rpx; margin-bottom: 60rpx;
padding: 0 30rpx; }
height: 88rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
/* 验证码输入项特殊布局 */ /* 输入框通用样式 */
.verify-item { .input-item {
position: relative; display: flex;
padding-right: 220rpx; 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 { .verify-item {
margin-right: 20rpx; position: relative;
color: #999; padding-right: 220rpx;
width: 50rpx; }
height: 50rpx;
}
/* 输入框内容 */ /* 输入框图标 */
.input-content { .input-icon {
flex: 1; margin-right: 20rpx;
font-size: 32rpx; color: #999;
color: #333; width: 50rpx;
height: 100%; height: 50rpx;
} }
.verify-input { /* 输入框内容 */
padding-right: 20rpx; .input-content {
} flex: 1;
font-size: 32rpx;
color: #333;
height: 100%;
}
/* 获取验证码按钮 */ .verify-input {
.get-verify-btn { padding-right: 20rpx;
position: absolute; }
right: 10rpx;
top: 50%;
transform: translateY(-50%);
width: 200rpx;
height: 70rpx;
line-height: 70rpx;
background-color: #007aff;
color: #fff;
border-radius: 35rpx;
font-size: 26rpx;
padding: 0;
margin: 0;
}
.get-verify-btn:disabled { /* 获取验证码按钮 */
background-color: #ccc; .get-verify-btn {
color: #fff; position: absolute;
} right: 10rpx;
.get-verify-btn::after{ top: 50%;
border-radius: 50px; transform: translateY(-50%);
} width: 200rpx;
height: 70rpx;
line-height: 70rpx;
background-color: #007aff;
color: #fff;
border-radius: 35rpx;
font-size: 26rpx;
padding: 0;
margin: 0;
}
/* 协议勾选项 */ .get-verify-btn:disabled {
.agreement-item { background-color: #ccc;
display: flex; color: #fff;
align-items: center; }
margin: 70rpx 0 28rpx 0;
padding-left: 10rpx;
}
.agreement-text { .get-verify-btn::after {
font-size: 24rpx; border-radius: 50px;
color: #666; }
margin-left: 10rpx;
}
.agreePrivacy{
color: #2F77FD;
}
/* 立即注册按钮 */ /* 协议勾选项 */
.register-btn { .agreement-item {
width: 100%; display: flex;
height: 88rpx; align-items: center;
line-height: 88rpx; margin: 70rpx 0 28rpx 0;
background-color: #007aff; padding-left: 10rpx;
color: #fff; }
border-radius: 8rpx;
font-size: 28rpx;
margin-bottom: 40rpx;
}
button:after{
border-radius: 8px;
}
.register-btn:disabled {
background-color: #99c8ff;
color: #fff;
}
/* 跳转登录链接 */ .agreement-text {
.login-link { font-size: 24rpx;
text-align: center; color: #666;
} margin-left: 10rpx;
}
.link-item { .agreePrivacy {
font-size: 28rpx; color: #2F77FD;
color: #007aff; }
text-decoration: none;
} /* 立即注册按钮 */
.register-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
background-color: #007aff;
color: #fff;
border-radius: 8rpx;
font-size: 28rpx;
margin-bottom: 40rpx;
}
button:after {
border-radius: 8px;
}
.register-btn:disabled {
background-color: #99c8ff;
color: #fff;
}
/* 跳转登录链接 */
.login-link {
text-align: center;
}
.link-item {
font-size: 28rpx;
color: #007aff;
text-decoration: none;
}
</style> </style>

View File

@@ -128,7 +128,7 @@ const getCommunityList = async (pageNum = 1, keyword = '') => {
const res = await getVillageList(params) const res = await getVillageList(params)
if (res.code === 200) { if (res.code === 200) {
const listData = res.data?.rows || res.data?.list || res.data || [] const listData = res.data || []
const total = res.data?.total || listData.length const total = res.data?.total || listData.length
if (pageNum === 1) { if (pageNum === 1) {

View File

@@ -155,7 +155,7 @@ const fetchRepairList = async () => {
const res = await getQueryRepair(params); const res = await getQueryRepair(params);
// console.log('接口返回:', res); // console.log('接口返回:', res);
if (res.code === 200) { if (res.code === 200) {
const list = res.data || []; const list = res.rows || [];
repairList.value = list.map(item => { repairList.value = list.map(item => {
const statusInfo = getStatusInfo(item.problemStatus); const statusInfo = getStatusInfo(item.problemStatus);
const images = item.problemImageUrl ? item.problemImageUrl.split(',').filter(Boolean) : []; const images = item.problemImageUrl ? item.problemImageUrl.split(',').filter(Boolean) : [];

View File

@@ -349,7 +349,7 @@ const uploadImages = async () => {
return urls return urls
} }
// ========== 表单提交 ✅ 修复:所有错误都解决 ========== // ========== 表单提交 ==========
const submitForm = async () => { const submitForm = async () => {
if (!houseName.value) return uni.showToast({ title: '请选择报修房屋', icon: 'none' }) if (!houseName.value) return uni.showToast({ title: '请选择报修房屋', icon: 'none' })
if (!projectName.value) return uni.showToast({ title: '请选择维修项目', icon: 'none' }) if (!projectName.value) return uni.showToast({ title: '请选择维修项目', icon: 'none' })
@@ -406,7 +406,7 @@ const submitForm = async () => {
uni.showToast({ title: res.msg || '提交失败', icon: 'none' }) uni.showToast({ title: res.msg || '提交失败', icon: 'none' })
} }
} catch (e) { } catch (e) {
console.error('提交异常:', e) // 看控制台真实错误 // console.error('提交异常:', e)
uni.showToast({ title: '提交失败,请检查网络或重试', icon: 'none' }) uni.showToast({ title: '提交失败,请检查网络或重试', icon: 'none' })
} finally { } finally {
uni.hideLoading() uni.hideLoading()

View File

@@ -108,11 +108,12 @@ const selectProject = (item) => {
padding: 10px; padding: 10px;
height: 100vh; height: 100vh;
box-sizing: border-box; box-sizing: border-box;
background-color: #f9f9f9;
} }
.search-bar { .search-bar {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 8px 10px; padding: 15px 10px;
background: #f5f5f5; background: #f5f5f5;
border-radius: 6px; border-radius: 6px;
margin-bottom: 10px; margin-bottom: 10px;
@@ -128,8 +129,10 @@ const selectProject = (item) => {
.category-left { .category-left {
width: 120px; width: 120px;
height: 100%; height: 100%;
background: #f8f8f8; background: #fff;
border-radius: 6px 0 0 6px; border-radius: 6px 0 0 6px;
margin-right: 20rpx;
color: #666;
} }
.category-item { .category-item {
padding: 15px 10px; padding: 15px 10px;
@@ -138,8 +141,8 @@ const selectProject = (item) => {
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
} }
.category-item.active { .category-item.active {
background: #fff; background: #f9f9f9;
color: #007aff; color: #222;
font-weight: bold; font-weight: bold;
} }
.category-right { .category-right {
@@ -148,6 +151,7 @@ const selectProject = (item) => {
background: #fff; background: #fff;
border-radius: 0 6px 6px 0; border-radius: 0 6px 6px 0;
padding: 10px; padding: 10px;
text-align: center;
} }
.project-item { .project-item {
padding: 12px 10px; padding: 12px 10px;

View File

@@ -12,7 +12,7 @@
<image src="http://47.104.199.163:9090/images/repair/house.png" style="width: 48rpx;height: 48rpx;"></image> <image src="http://47.104.199.163:9090/images/repair/house.png" style="width: 48rpx;height: 48rpx;"></image>
<view class="house-name"> <view class="house-name">
{{ item.villageName }} {{ item.villageName }}
<view class="house-detail">{{ item.houseType }}</view> <view class="house-detail">{{item.unitNo}}-{{item.floorNo}}-{{item.houseNo}}</view>
</view> </view>
<uni-icons type="checkbox-filled" size="20" color="#007aff" v-if="selectedHouse.id === item.id"></uni-icons> <uni-icons type="checkbox-filled" size="20" color="#007aff" v-if="selectedHouse.id === item.id"></uni-icons>
@@ -93,7 +93,7 @@ const confirmSelect = () => {
// 把选中的房屋信息传给表单页通过uni.$emit // 把选中的房屋信息传给表单页通过uni.$emit
uni.$emit('selectHouse', { uni.$emit('selectHouse', {
id: selectedHouse.value.id, id: selectedHouse.value.id,
name: `${selectedHouse.value.villageName} ${selectedHouse.value.houseType}` name: `${selectedHouse.value.villageName} ${selectedHouse.value.unitNo}-${selectedHouse.value.floorNo}-${selectedHouse.value.houseNo}`
}) })
// 返回上一页 // 返回上一页

View File

@@ -1,72 +1,66 @@
<template> <template>
<view class="qrcode-page"> <view class="qrcode-page">
<view class="qrcode-wrap"> <view class="qrcode-wrap">
<!-- 显示后台返回的二维码图片 -->
<view class="qrcode-box"> <view class="qrcode-box">
<!-- 调用uqrcode组件 --> <image :src="qrcodeUrl" mode="widthFix" class="qrcode-img" />
<uqrcode
:value="qrcodeValue" <!-- 四角装饰边框保留 -->
:size="400"
:logo="'http://47.104.199.163:9090/images/logo.png'"
:logoSize="0.2"
canvasId="visitor-qrcode"
@success="onQrcodeSuccess"
></uqrcode>
<!-- 二维码边框装饰 -->
<view class="qrcode-border border-top"></view> <view class="qrcode-border border-top"></view>
<view class="qrcode-border border-right"></view> <view class="qrcode-border border-right"></view>
<view class="qrcode-border border-bottom"></view> <view class="qrcode-border border-bottom"></view>
<view class="qrcode-border border-left"></view> <view class="qrcode-border border-left"></view>
</view> </view>
<text class="qrcode-desc">桂花园别墅东门通行二维码</text> <text class="qrcode-desc">{{houseName}}通行二维码</text>
<text class="qrcode-tips">分享此二维码给访客可扫码开门单次有效</text> <text class="qrcode-tips">分享此二维码给访客可扫码开门单次有效</text>
</view> </view>
<view class="btn-wrap"> <view class="btn-wrap">
<button class="send-btn" @click="sendToFriend">发送给好友</button> <button class="send-btn" open-type="share" :image-url="qrcodeUrl">发送给好友</button>
</view> </view>
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
// import { navigateBack, showToast, share } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
// 引入本地uqrcode组件
import uqrcode from '@/components/uqrcode/uqrcode.vue';
// 二维码内容(替换为实际的通行链接) // 直接接收图片URL
const qrcodeValue = ref('https://your-domain.com/visitor/123456'); const qrcodeUrl = ref('');
// 生成的二维码临时图片地址
const qrcodeImage = ref(''); const qrcodeImage = ref('');
const houseName = ref('')
// 二维码生成成功回调 onLoad((option) => {
const onQrcodeSuccess = (tempFilePath) => { if (option.qrcodeUrl) {
qrcodeImage.value = tempFilePath; // 接收后台返回的二维码图片链接
uni.showToast({ title: '二维码生成成功', icon: 'success' }); qrcodeUrl.value = decodeURIComponent(option.qrcodeUrl);
}; qrcodeImage.value = qrcodeUrl.value;
houseName.value = option.villageName
console.log('最终二维码图片:', qrcodeUrl.value);
}
});
// 分享给好友 // 分享给好友
const sendToFriend = () => { // const sendToFriend = () => {
if (!qrcodeImage.value) { // if (!qrcodeImage.value) {
uni.showToast({ title: '二维码生成中...', icon: 'none' }); // uni.showToast({ title: '二维码生成中...', icon: 'none' });
return; // return;
} // }
uni.share({ // uni.share({
provider: 'weixin', // provider: 'weixin',
type: 0, // type: 0,
title: '访客通行二维码', // title: '访客通行二维码',
imageUrl: qrcodeImage.value, // imageUrl: qrcodeImage.value,
success: () => uni.showToast({ title: '分享成功' }), // success: () => uni.showToast({ title: '分享成功' }),
fail: () => uni.showToast({ title: '分享失败', icon: 'none' }) // fail: () => uni.showToast({ title: '分享失败', icon: 'none' })
}); // });
}; // };
</script> </script>
<style scoped> <style scoped>
.qrcode-page { .qrcode-page {
/* background-color: #f8f8f8; */
min-height: 100vh; min-height: 100vh;
} }
.qrcode-wrap { .qrcode-wrap {
@@ -80,7 +74,12 @@ const sendToFriend = () => {
width: 400rpx; width: 400rpx;
height: 400rpx; height: 400rpx;
} }
/* 二维码边框样式 */ /* 图片铺满 */
.qrcode-img {
width: 100%;
height: 100%;
}
/* 边框装饰 */
.qrcode-border { .qrcode-border {
position: absolute; position: absolute;
width: 40rpx; width: 40rpx;
@@ -91,7 +90,7 @@ const sendToFriend = () => {
.border-right { top: 0; right: 0; border-left: 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-bottom { bottom: 0; right: 0; border-left: none; border-top: none; }
.border-left { bottom: 0; left: 0; border-right: none; border-top: none; } .border-left { bottom: 0; left: 0; border-right: none; border-top: none; }
/* 文字样式 */
.qrcode-desc { .qrcode-desc {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
@@ -103,9 +102,8 @@ const sendToFriend = () => {
color: #999; color: #999;
margin-top: 10rpx; margin-top: 10rpx;
} }
/* 按钮样式 */
.btn-wrap { .btn-wrap {
margin: 80rpx 20rpx 20rpx; margin: 80rpx 40rpx 20rpx;
} }
.send-btn { .send-btn {
background-color: #007aff; background-color: #007aff;
@@ -114,6 +112,5 @@ const sendToFriend = () => {
height: 88rpx; height: 88rpx;
font-size: 28rpx; font-size: 28rpx;
line-height: 88rpx; line-height: 88rpx;
} }
</style> </style>

File diff suppressed because it is too large Load Diff

View File

@@ -20,8 +20,7 @@
<text class="label">联系方式</text> <text class="label">联系方式</text>
<text class="value">{{ visitorInfo.phone }}</text> <text class="value">{{ visitorInfo.phone }}</text>
</view> </view>
<!-- 车牌号可选显示 --> <view class="info-item">
<view class="info-item" v-if="visitorInfo.carNumber">
<text class="label">车牌号</text> <text class="label">车牌号</text>
<text class="value">{{ visitorInfo.carNumber }}</text> <text class="value">{{ visitorInfo.carNumber }}</text>
</view> </view>
@@ -52,35 +51,68 @@
</view> </view>
<!-- 分享二维码按钮仅等待来访状态显示 --> <!-- 分享二维码按钮仅等待来访状态显示 -->
<view class="btn-wrap" v-if="visitorInfo.status === 'waiting'"> <!-- <view class="btn-wrap" v-if="visitorInfo.status === 'waiting'">
<button class="share-btn" @click="goToQrcode">分享通行二维码</button> <button class="share-btn" @click="goToQrcode">分享通行二维码</button>
</view> </view> -->
</view> </view>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import {onLoad} from '@dcloudio/uni-app' import {onLoad} from '@dcloudio/uni-app'
import {getVisitorDetail} from '../api/api.js'
// 访客信息(实际项目中从接口获取) // 访客信息(实际项目中从接口获取)
// const visitorInfo = ref({})
const visitorInfo = ref({ const visitorInfo = ref({
name: '张三', name: '',
status: 'waiting', // waiting:等待来访visited:已到访 status: 'waiting', // waiting:等待来访visited:已到访
address: '桂花园别墅2号楼2层', address: '',
phone: '13866666666', phone: '',
carNumber: '京A88888', // 可传空隐藏 carNumber: '',
escortNum: 0, escortNum: 0,
validTime: '2023.06.30 10:00至2023.06.30 23:00', validTime: '',
inviteTime: '2023年06月30日 09:35', inviteTime: '',
visitTime: '2023年06月30日 14:32' // 已到访时显示 visitTime: ''
}); })
// 把后端返回的字段映射成详情页
const mapDetail = (item) => {
const addressParts = [
item.villageName,
item.floorNo ? item.floorNo + '栋' : '',
item.unitNo ? item.unitNo + '单元' : '',
item.houseNo
].filter(Boolean)
const status = item.status === 1 || item.status === '1' ? 'visited' : 'waiting'
return {
name: item.visitorName || '',
status,
address: addressParts.join(''),
phone: item.visitorPhone || '',
carNumber: item.carNum || '',
escortNum: item.visitorNum || 0,
validTime: item.startTime && item.endTime ? `${item.startTime}${item.endTime}` : '',
inviteTime: item.createTime || '',
visitTime: item.visitTime || ''
}
}
onLoad((option) =>{ // 获取访客详情
const infoStr = decodeURIComponent(JSON.stringify(option)) const fetchVisitorDetail = async (id) => {
// console.log('infoStr',infoStr) try {
visitorInfo.value = infoStr.item const res = await getVisitorDetail(id)
if (res && res.data) {
visitorInfo.value = mapDetail(res.data)
}
} catch (e) {
console.error('获取访客详情失败:', e)
}
}
onLoad((option) => {
if (option && option.id) {
fetchVisitorDetail(option.id)
}
}) })
// 跳转到二维码页面 // 跳转到二维码页面
const goToQrcode = () => { const goToQrcode = () => {
@@ -92,7 +124,7 @@ const goToQrcode = () => {
<style scoped> <style scoped>
.visitor-detail-page { .visitor-detail-page {
background-color: #f8f8f8; background-color: #fff;
min-height: 100vh; min-height: 100vh;
} }
@@ -111,8 +143,7 @@ const goToQrcode = () => {
} }
.title { .title {
font-size: 32rpx; font-size: 28rpx;
font-weight: 600;
} }
.status { .status {
@@ -123,7 +154,6 @@ const goToQrcode = () => {
.waiting { .waiting {
color: #007aff; color: #007aff;
background: #e8f4ff;
} }
.visited { .visited {
@@ -142,20 +172,22 @@ const goToQrcode = () => {
} }
.label { .label {
color: #666; color: #222;
width: 160rpx; width: 160rpx;
} }
.value { .value {
color: #333; color: #222;
flex: 1; flex: 1;
} }
.tips-text { .tips-text {
margin: 0 20rpx; margin: 0 20rpx;
font-size: 24rpx; font-size: 24rpx;
color: #999; color: #666;
line-height: 1.6; line-height: 1.6;
text-align: center;
margin-top: 98rpx;
} }
.btn-wrap { .btn-wrap {

View File

@@ -55,14 +55,14 @@
</view> </view>
<!-- 车牌号 --> <!-- 车牌号 -->
<view class="item-row" v-if="item.carNumber"> <view class="item-row">
<text class="label" :class="item.status">车牌号</text> <text class="label" :class="item.status">车牌号</text>
<text class="value" :class="item.status">{{ item.carNumber }}</text> <text class="value" :class="item.status">{{ item.carNumber }}</text>
</view> </view>
<!-- 时间+查看详情 --> <!-- 时间+查看详情 -->
<view class="item-footer"> <view class="item-footer">
<text class="time-text">时间{{ item.createTime }}</text> <text class="time-text" :class="item.status">时间{{ item.createTime }}</text>
<view class="detail-btn" @click="viewDetail(item)"> <view class="detail-btn" @click="viewDetail(item)">
<text>查看详情</text> <text>查看详情</text>
<uni-icons type="arrowright" size="14"></uni-icons> <uni-icons type="arrowright" size="14"></uni-icons>
@@ -97,17 +97,18 @@ const activeTab = ref('waiting')
// 访客列表数据 // 访客列表数据
const visitorList = ref([]) const visitorList = ref([])
// 后端数据映射到前端结构(根据实际字段名调整) // 后端数据映射到前端
const mapData = (list) => { const mapData = (list) => {
if (!Array.isArray(list)) return [] if (!Array.isArray(list)) return []
return list.map(item => { return list.map(item => {
const status = item.status === 1 || item.status === '1' ? 'visited' : 'waiting' const status = item.status === 1 || item.status === '1' ? 'visited' : 'waiting'
return { return {
name: item.visitorName, ...item,
visitorName: item.visitorName,
status, status,
statusText: status === 'visited' ? '已到访' : '等待来访', statusText: status === 'visited' ? '已到访' : '等待来访',
startTime: item.startTime, startTime: item.startTime,
endTime:item.endTime, endTime: item.endTime,
phone: item.visitorPhone, phone: item.visitorPhone,
carNumber: item.carNum, carNumber: item.carNum,
createTime: item.createTime || '' createTime: item.createTime || ''
@@ -121,9 +122,9 @@ const fetchVisitorList = async () => {
let params = {userId:userId} let params = {userId:userId}
try { try {
const res = await getVisitorList(params) const res = await getVisitorList(params)
// visitorList.value = mapData(res.data|| []) visitorList.value = mapData(res.data || [])
visitorList.value = res.data || [] // console.log('222222',visitorList.value)
} catch (e) { } catch (e) {
console.error('获取访客列表失败:', e) console.error('获取访客列表失败:', e)
} }
@@ -154,10 +155,8 @@ const goBack = () => {
// 查看详情 // 查看详情
const viewDetail = (item) => { const viewDetail = (item) => {
const itemStr = encodeURIComponent(JSON.stringify(item))
console.log('eeeee',itemStr)
uni.navigateTo({ uni.navigateTo({
url: `/pageSubPack/visitor/visitor-detail?item=${itemStr}` // 传到详情页 url: `/pageSubPack/visitor/visitor-detail?id=${item.id}` // 传 id 到详情页
}) })
} }
@@ -249,7 +248,7 @@ const addInvitation = () => {
/* 列表容器 */ /* 列表容器 */
.list-container { .list-container {
height: calc(100vh - 150px); /* 预留导航、标签、按钮高度 */ height: calc(100vh - 220px); /* 预留导航、标签、按钮高度 */
} }
/* 访客列表项 */ /* 访客列表项 */
@@ -308,7 +307,9 @@ const addInvitation = () => {
.value.visited{ .value.visited{
color: #999; color: #999;
} }
.time-text.visited{
color: #999;
}
/* 列表项底部(时间+查看详情) */ /* 列表项底部(时间+查看详情) */
.item-footer { .item-footer {
display: flex; display: flex;
@@ -316,11 +317,11 @@ const addInvitation = () => {
align-items: center; align-items: center;
margin-top: 10px; margin-top: 10px;
padding-top: 10px; padding-top: 10px;
border-top: 1px solid #f5f5f5; /* border-top: 1px solid #f5f5f5; */
} }
.time-text { .time-text {
font-size: 12px; font-size: 28rpx;
color: #666; /* color: #666; */
} }
.detail-btn { .detail-btn {
display: flex; display: flex;