对接访客邀请接口
This commit is contained in:
@@ -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>
|
|
||||||
@@ -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 = () => {
|
||||||
|
|||||||
@@ -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'; // 生产环境
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,28 +13,26 @@
|
|||||||
<!-- 手机号输入框 -->
|
<!-- 手机号输入框 -->
|
||||||
<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=""
|
||||||
|
style="height: 100%;width: 100%;"></image>
|
||||||
</view>
|
</view>
|
||||||
<uni-easyinput class="input-content" type="number" v-model="phoneNumber"
|
<uni-easyinput class="input-content" type="number" v-model="phoneNumber" placeholder="请输入手机号"
|
||||||
placeholder="请输入手机号" :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
|
:inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
|
||||||
</uni-easyinput>
|
</uni-easyinput>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 验证码输入 + 获取验证码按钮 -->
|
<!-- 验证码输入 + 获取验证码按钮 -->
|
||||||
<view class="input-item verify-item">
|
<view class="input-item verify-item">
|
||||||
<view class="input-icon">
|
<view class="input-icon">
|
||||||
<image src="http://47.104.199.163:9090/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
|
<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> -->
|
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
|
||||||
</view>
|
</view>
|
||||||
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode"
|
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" placeholder="请输入验证码"
|
||||||
placeholder="请输入验证码" :inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
|
:inputBorder="false" maxlength="6" :placeholderStyle="placeholderStyle">
|
||||||
</uni-easyinput>
|
</uni-easyinput>
|
||||||
|
|
||||||
<button
|
<button class="get-verify-btn" :disabled="!canGetVerify || countDown > 0" @click="getVerifyCode">
|
||||||
class="get-verify-btn"
|
|
||||||
:disabled="!canGetVerify || countDown > 0"
|
|
||||||
@click="getVerifyCode"
|
|
||||||
>
|
|
||||||
{{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
|
{{ countDown > 0 ? `${countDown}s后重新获取` : '获取验证码' }}
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -42,11 +40,12 @@
|
|||||||
<!-- 账号输入框 -->
|
<!-- 账号输入框 -->
|
||||||
<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/account.png" mode="" style="height: 100%;width: 100%;"></image>
|
<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> -->
|
<!-- <uni-icons type="person" size="24" color="#999"></uni-icons> -->
|
||||||
</view>
|
</view>
|
||||||
<uni-easyinput class="input-content" type="text" v-model="account"
|
<uni-easyinput class="input-content" type="text" v-model="account" placeholder="请输入账号" :inputBorder="false"
|
||||||
placeholder="请输入账号" :inputBorder="false" :placeholderStyle="placeholderStyle">
|
:placeholderStyle="placeholderStyle">
|
||||||
</uni-easyinput>
|
</uni-easyinput>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
@@ -54,40 +53,28 @@
|
|||||||
<!-- 密码输入框 -->
|
<!-- 密码输入框 -->
|
||||||
<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/password.png" mode="" style="height: 100%;width: 100%;"></image>
|
<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> -->
|
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
|
||||||
</view>
|
</view>
|
||||||
<uni-easyinput class="input-content" type="password" v-model="password"
|
<uni-easyinput class="input-content" type="password" v-model="password" placeholder="请输入密码"
|
||||||
placeholder="请输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle" >
|
:inputBorder="false" :placeholderStyle="placeholderStyle">
|
||||||
</uni-easyinput>
|
</uni-easyinput>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<!-- 协议勾选 -->
|
<!-- 协议勾选 -->
|
||||||
<view class="agreement-item">
|
<view class="agreement-item">
|
||||||
<view @click="toggleAgreement">
|
<view @click="toggleAgreement">
|
||||||
<uni-icons
|
<uni-icons type="checkbox-filled" size="24" color="#007aff" v-if="agreeAgreement"></uni-icons>
|
||||||
type="checkbox-filled"
|
<uni-icons type="checkbox" size="24" color="#999" v-else></uni-icons>
|
||||||
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>
|
<text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意<text
|
||||||
|
class="agreePrivacy">《用户隐私政策》</text></text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<!-- 立即注册按钮 -->
|
<!-- 立即注册按钮 -->
|
||||||
<button
|
<button class="register-btn" :disabled="!canRegister" @click="handleRegister">
|
||||||
class="register-btn"
|
|
||||||
:disabled="!canRegister"
|
|
||||||
@click="handleRegister"
|
|
||||||
>
|
|
||||||
立即注册
|
立即注册
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -99,8 +86,15 @@
|
|||||||
</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'
|
||||||
|
|
||||||
// ========== 响应式数据 ==========
|
// ========== 响应式数据 ==========
|
||||||
// 表单数据
|
// 表单数据
|
||||||
@@ -129,11 +123,11 @@ const canRegister = computed(() => {
|
|||||||
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;
|
||||||
});
|
});
|
||||||
|
|
||||||
// ========== 方法 ==========
|
// ========== 方法 ==========
|
||||||
@@ -198,7 +192,10 @@ const getVerifyCode = () => {
|
|||||||
// 处理注册逻辑
|
// 处理注册逻辑
|
||||||
const handleRegister = () => {
|
const handleRegister = () => {
|
||||||
if (!canRegister.value) return;
|
if (!canRegister.value) return;
|
||||||
uni.showLoading({ title: '注册中...', mask: true });
|
uni.showLoading({
|
||||||
|
title: '注册中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
let params = {
|
let params = {
|
||||||
phone: phoneNumber.value,
|
phone: phoneNumber.value,
|
||||||
smsCode: verifyCode.value,
|
smsCode: verifyCode.value,
|
||||||
@@ -213,7 +210,9 @@ const handleRegister = () => {
|
|||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' });
|
uni.redirectTo({
|
||||||
|
url: '/pageSubPack/loginSub/pwd-login'
|
||||||
|
});
|
||||||
}, 1500);
|
}, 1500);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -255,6 +254,7 @@ onUnmounted(() => {
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF);
|
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
.status_bar {
|
.status_bar {
|
||||||
height: 46px;
|
height: 46px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -344,6 +344,7 @@ onUnmounted(() => {
|
|||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.get-verify-btn::after {
|
.get-verify-btn::after {
|
||||||
border-radius: 50px;
|
border-radius: 50px;
|
||||||
}
|
}
|
||||||
@@ -361,6 +362,7 @@ onUnmounted(() => {
|
|||||||
color: #666;
|
color: #666;
|
||||||
margin-left: 10rpx;
|
margin-left: 10rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agreePrivacy {
|
.agreePrivacy {
|
||||||
color: #2F77FD;
|
color: #2F77FD;
|
||||||
}
|
}
|
||||||
@@ -376,9 +378,11 @@ onUnmounted(() => {
|
|||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
margin-bottom: 40rpx;
|
margin-bottom: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:after {
|
button:after {
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.register-btn:disabled {
|
.register-btn:disabled {
|
||||||
background-color: #99c8ff;
|
background-color: #99c8ff;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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) : [];
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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}`
|
||||||
})
|
})
|
||||||
|
|
||||||
// 返回上一页
|
// 返回上一页
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -2,18 +2,10 @@
|
|||||||
<view class="visitor-invite">
|
<view class="visitor-invite">
|
||||||
<!-- 标签切换:车辆来访/人员来访 -->
|
<!-- 标签切换:车辆来访/人员来访 -->
|
||||||
<view class="tab-wrap">
|
<view class="tab-wrap">
|
||||||
<view
|
<view class="tab-item" :class="{ active: activeTab === 'car' }" @click="switchTab('car')">
|
||||||
class="tab-item"
|
|
||||||
:class="{ active: activeTab === 'car' }"
|
|
||||||
@click="switchTab('car')"
|
|
||||||
>
|
|
||||||
车辆来访
|
车辆来访
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view class="tab-item" :class="{ active: activeTab === 'person' }" @click="switchTab('person')">
|
||||||
class="tab-item"
|
|
||||||
:class="{ active: activeTab === 'person' }"
|
|
||||||
@click="switchTab('person')"
|
|
||||||
>
|
|
||||||
人员来访
|
人员来访
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -40,11 +32,7 @@
|
|||||||
|
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<view class="label">访客姓名</view>
|
<view class="label">访客姓名</view>
|
||||||
<input
|
<input class="input" placeholder="请输入访客姓名" v-model="form.name" />
|
||||||
class="input"
|
|
||||||
placeholder="请输入访客姓名"
|
|
||||||
v-model="form.name"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<view class="label">
|
<view class="label">
|
||||||
@@ -59,12 +47,7 @@
|
|||||||
<view class="label">
|
<view class="label">
|
||||||
<text class="required">*</text>访客联系方式
|
<text class="required">*</text>访客联系方式
|
||||||
</view>
|
</view>
|
||||||
<input
|
<input class="input" placeholder="请输入联系方式" v-model="form.phone" type="number" />
|
||||||
class="input"
|
|
||||||
placeholder="请输入联系方式"
|
|
||||||
v-model="form.phone"
|
|
||||||
type="number"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 车牌号:仅车辆来访显示 -->
|
<!-- 车牌号:仅车辆来访显示 -->
|
||||||
@@ -73,14 +56,9 @@
|
|||||||
<text class="required">*</text>车牌号
|
<text class="required">*</text>车牌号
|
||||||
</view>
|
</view>
|
||||||
<view class="car-number-wrap">
|
<view class="car-number-wrap">
|
||||||
<input
|
<input class="car-input" v-for="(item, index) in 8" :key="index"
|
||||||
class="car-input"
|
:value="form.carNumber[index]" @input="(e) => onCarInput(index, e)"
|
||||||
v-for="(item, index) in 8"
|
type="text" />
|
||||||
:key="index"
|
|
||||||
v-model="form.carNumber[index]"
|
|
||||||
maxlength="1"
|
|
||||||
type="text"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -88,12 +66,7 @@
|
|||||||
<view class="label">
|
<view class="label">
|
||||||
<text class="required">*</text>随行人数
|
<text class="required">*</text>随行人数
|
||||||
</view>
|
</view>
|
||||||
<input
|
<input class="input" placeholder="请输入随行人数" v-model="form.peopleNum" type="number" />
|
||||||
class="input"
|
|
||||||
placeholder="请输入随行人数"
|
|
||||||
v-model="form.peopleNum"
|
|
||||||
type="number"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -106,7 +79,8 @@
|
|||||||
<text class="required">*</text>来访时间
|
<text class="required">*</text>来访时间
|
||||||
</view>
|
</view>
|
||||||
<view class="value">
|
<view class="value">
|
||||||
<uni-datetime-picker type="datetime" v-model="form.visitTime" @change="handleTimeChange" :border="false"/>
|
<uni-datetime-picker type="datetime" v-model="form.visitTime" @change="handleTimeChange"
|
||||||
|
:border="false" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
@@ -114,7 +88,8 @@
|
|||||||
<text class="required">*</text>离开时间
|
<text class="required">*</text>离开时间
|
||||||
</view>
|
</view>
|
||||||
<view class="value">
|
<view class="value">
|
||||||
<uni-datetime-picker type="datetime" v-model="form.leaveTime" @change="handleTimeChange" :border="false"/>
|
<uni-datetime-picker type="datetime" v-model="form.leaveTime" @change="handleTimeChange"
|
||||||
|
:border="false" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="tips">预计来访时间和预计离开时间间隔不能超过24小时</view>
|
<view class="tips">预计来访时间和预计离开时间间隔不能超过24小时</view>
|
||||||
@@ -124,10 +99,7 @@
|
|||||||
|
|
||||||
<!-- 底部按钮 -->
|
<!-- 底部按钮 -->
|
||||||
<view class="btn-wrap">
|
<view class="btn-wrap">
|
||||||
<button
|
<button class="submit-btn" @click="submitForm">
|
||||||
class="submit-btn"
|
|
||||||
@click="submitForm"
|
|
||||||
>
|
|
||||||
{{ activeTab === 'car' ? '确认邀请' : '生成通行二维码' }}
|
{{ activeTab === 'car' ? '确认邀请' : '生成通行二维码' }}
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
@@ -137,22 +109,12 @@
|
|||||||
<view class="modal-wrap">
|
<view class="modal-wrap">
|
||||||
<view class="modal-title">选择来访地址</view>
|
<view class="modal-title">选择来访地址</view>
|
||||||
<view class="address-list">
|
<view class="address-list">
|
||||||
<view
|
<view class="address-item" :class="{ active: item.label === form.address }" v-for="item in addressList"
|
||||||
class="address-item"
|
:key="item.id" @click="selectAddress(item)">
|
||||||
:class="{ active: item === form.address }"
|
{{ item.label }}
|
||||||
v-for="item in addressList"
|
|
||||||
:key="item"
|
|
||||||
@click="selectAddress(item)"
|
|
||||||
>
|
|
||||||
{{ item }}
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<uni-icons
|
<uni-icons type="closeempty" size="20" class="modal-close" @click="closeAddressModal"></uni-icons>
|
||||||
type="closeempty"
|
|
||||||
size="20"
|
|
||||||
class="modal-close"
|
|
||||||
@click="closeAddressModal"
|
|
||||||
></uni-icons>
|
|
||||||
</view>
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
|
|
||||||
@@ -160,13 +122,8 @@
|
|||||||
<uni-popup ref="genderModalRef" type="bottom" :mask-click="false">
|
<uni-popup ref="genderModalRef" type="bottom" :mask-click="false">
|
||||||
<view class="modal-wrap">
|
<view class="modal-wrap">
|
||||||
<view class="gender-list">
|
<view class="gender-list">
|
||||||
<view
|
<view class="gender-item" :class="{ active: item === form.gender }" v-for="item in genderList"
|
||||||
class="gender-item"
|
:key="item" @click="selectGender(item)">
|
||||||
:class="{ active: item === form.gender }"
|
|
||||||
v-for="item in genderList"
|
|
||||||
:key="item"
|
|
||||||
@click="selectGender(item)"
|
|
||||||
>
|
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -176,9 +133,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive} from 'vue';
|
import {
|
||||||
import{onLoad } from "@dcloudio/uni-app"
|
ref,
|
||||||
|
reactive
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
onLoad
|
||||||
|
} from "@dcloudio/uni-app"
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import{getHouseList,addVisitorData} from '../api/api.js'
|
||||||
|
|
||||||
// 标签激活状态
|
// 标签激活状态
|
||||||
const activeTab = ref('car');
|
const activeTab = ref('car');
|
||||||
@@ -186,20 +149,19 @@ const activeTab = ref('car');
|
|||||||
// 表单数据
|
// 表单数据
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
address: '',
|
address: '',
|
||||||
|
villageId: '',
|
||||||
|
houseId: '',
|
||||||
name: '',
|
name: '',
|
||||||
gender: '',
|
gender: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
carNumber: ['', '', '', '', '', '', '', ''], // 修复:8位车牌
|
carNumber:['', '', '', '', '', '', '', ''],
|
||||||
peopleNum: '',
|
peopleNum: '',
|
||||||
visitTime: '',
|
visitTime: '',
|
||||||
leaveTime: ''
|
leaveTime: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// 地址列表
|
// 地址列表
|
||||||
const addressList = ref([
|
const addressList = ref([]);
|
||||||
'桂花园(别墅)1号楼1层',
|
|
||||||
'桂花园(别墅)2号楼2层'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 性别列表
|
// 性别列表
|
||||||
const genderList = ref(['男', '女']);
|
const genderList = ref(['男', '女']);
|
||||||
@@ -208,8 +170,24 @@ const genderList = ref(['男', '女']);
|
|||||||
const addressModalRef = ref(null);
|
const addressModalRef = ref(null);
|
||||||
const genderModalRef = ref(null);
|
const genderModalRef = ref(null);
|
||||||
|
|
||||||
onLoad(() => {
|
// =========方法===========
|
||||||
|
// 获取房屋列表
|
||||||
|
const fetchHouseList = async () => {
|
||||||
|
try {
|
||||||
|
const res = await getHouseList({ pageNum: 1, pageSize: 10 })
|
||||||
|
if (res.code === 200) {
|
||||||
|
addressList.value = (res.rows || []).map(item => ({
|
||||||
|
...item,
|
||||||
|
label: `${item.buildingName || ''}${item.unitNo}-${item.floorNo || ''}-${item.houseNo || ''}`.trim()
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('获取房屋列表失败', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
fetchHouseList()
|
||||||
});
|
});
|
||||||
|
|
||||||
// 切换tab
|
// 切换tab
|
||||||
@@ -230,7 +208,9 @@ const closeAddressModal = () => {
|
|||||||
|
|
||||||
// 选择地址
|
// 选择地址
|
||||||
const selectAddress = (item) => {
|
const selectAddress = (item) => {
|
||||||
form.address = item;
|
form.address = item.label;
|
||||||
|
form.villageId = item.villageId || '';
|
||||||
|
form.houseId = item.id || '';
|
||||||
closeAddressModal();
|
closeAddressModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -245,6 +225,12 @@ const selectGender = (item) => {
|
|||||||
genderModalRef.value.close();
|
genderModalRef.value.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 车牌号单格输入
|
||||||
|
const onCarInput = (index, e) => {
|
||||||
|
const val = (e.detail && e.detail.value !== undefined) ? e.detail.value : (e.target ? e.target.value : '');
|
||||||
|
form.carNumber[index] = (val || '').toUpperCase().slice(0, 1);
|
||||||
|
};
|
||||||
|
|
||||||
// 时间校验
|
// 时间校验
|
||||||
const handleTimeChange = () => {
|
const handleTimeChange = () => {
|
||||||
if (!form.visitTime || !form.leaveTime) return true;
|
if (!form.visitTime || !form.leaveTime) return true;
|
||||||
@@ -276,68 +262,118 @@ const handleTimeChange = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 提交表单
|
// 提交表单
|
||||||
const submitForm = () => {
|
const submitForm = async () => {
|
||||||
// 1. 必填项校验
|
// 1. 必填项校验
|
||||||
if (!form.address) {
|
if (!form.address) {
|
||||||
uni.showToast({ title: '请选择来访地址', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请选择来访地址',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!form.name) {
|
if (!form.name) {
|
||||||
uni.showToast({ title: '请输入访客姓名', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请输入访客姓名',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!form.gender) {
|
if (!form.gender) {
|
||||||
uni.showToast({ title: '请选择性别', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请选择性别',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!form.phone) {
|
if (!form.phone) {
|
||||||
uni.showToast({ title: '请输入访客联系方式', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请输入访客联系方式',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!/^1[3-9]\d{9}$/.test(form.phone)) {
|
if (!/^1[3-9]\d{9}$/.test(form.phone)) {
|
||||||
uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请输入正确的手机号',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (activeTab === 'car' && form.carNumber.join('').length < 7) {
|
if (activeTab.value === 'car' && form.carNumber.filter(Boolean).join('').length < 7) {
|
||||||
uni.showToast({ title: '请填写完整车牌号', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请填写完整车牌号',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!form.peopleNum || form.peopleNum <= 0) {
|
if (!form.peopleNum || form.peopleNum <= 0) {
|
||||||
uni.showToast({ title: '请输入正确的随行人数', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请输入正确的随行人数',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!form.visitTime) {
|
if (!form.visitTime) {
|
||||||
uni.showToast({ title: '请选择来访时间', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请选择来访时间',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!form.leaveTime) {
|
if (!form.leaveTime) {
|
||||||
uni.showToast({ title: '请选择离开时间', icon: 'none' });
|
uni.showToast({
|
||||||
|
title: '请选择离开时间',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 时间规则校验
|
// 2. 时间规则校验
|
||||||
if (!handleTimeChange()) return;
|
if (!handleTimeChange()) return;
|
||||||
|
|
||||||
// 3. 提交成功
|
// 3. 构造参数并提交
|
||||||
|
const villageId = uni.getStorageSync('currentVillageId')
|
||||||
|
const carNumStr = form.carNumber.filter(Boolean).join('')
|
||||||
|
const params = {
|
||||||
|
villageId: villageId,
|
||||||
|
houseId: form.houseId,
|
||||||
|
visitorName: form.name,
|
||||||
|
visitorGender: form.gender === '男' ? '0' : (form.gender === '女' ? '1' : ''),
|
||||||
|
visitorPhone: form.phone,
|
||||||
|
carNum: activeTab.value === 'car' ? carNumStr : '',
|
||||||
|
visitorNum: String(form.peopleNum),
|
||||||
|
startTime: form.visitTime,
|
||||||
|
endTime: form.leaveTime,
|
||||||
|
type: activeTab.value === 'car' ? '0' : '1',
|
||||||
|
status: '0'
|
||||||
|
}
|
||||||
|
|
||||||
uni.showLoading({ title: '提交中...' });
|
uni.showLoading({ title: '提交中...' });
|
||||||
setTimeout(() => {
|
try {
|
||||||
|
const res = await addVisitorData(params)
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
if (res.code === 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: activeTab === 'car' ? '邀请成功' : '二维码生成成功',
|
title: activeTab.value === 'car' ? '邀请成功' : '二维码生成成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
});
|
||||||
}, 1000);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({ url: `/pageSubPack/visitor/qrcode-page?qrcodeUrl=${encodeURIComponent(res.data.url)}&villageName=${res.data.villageName}` })
|
||||||
url:"/pageSubPack/visitor/qrcode-page"
|
}, 1500);
|
||||||
})
|
} else {
|
||||||
},1500)
|
uni.showToast({ title: res.msg || '提交失败', icon: 'none' });
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({ title: '网络异常,请重试', icon: 'none' });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置表单
|
// 重置表单
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
form.address = '';
|
form.address = '';
|
||||||
|
form.villageId = '';
|
||||||
|
form.houseId = '';
|
||||||
form.name = '';
|
form.name = '';
|
||||||
form.gender = '';
|
form.gender = '';
|
||||||
form.phone = '';
|
form.phone = '';
|
||||||
@@ -362,6 +398,7 @@ const resetForm = () => {
|
|||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-title {
|
.nav-title {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -374,6 +411,7 @@ const resetForm = () => {
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-bottom: 1rpx solid #eee;
|
border-bottom: 1rpx solid #eee;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-item {
|
.tab-item {
|
||||||
/* flex: 1; */
|
/* flex: 1; */
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -382,6 +420,7 @@ const resetForm = () => {
|
|||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-item.active {
|
.tab-item.active {
|
||||||
color: #007aff;
|
color: #007aff;
|
||||||
/* border-bottom: 4rpx solid #007aff; */
|
/* border-bottom: 4rpx solid #007aff; */
|
||||||
@@ -391,35 +430,42 @@ const resetForm = () => {
|
|||||||
.form-wrap {
|
.form-wrap {
|
||||||
padding: 10rpx;
|
padding: 10rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-section {
|
.form-section {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
margin-bottom: 10rpx;
|
margin-bottom: 10rpx;
|
||||||
padding: 20rpx 40rpx;
|
padding: 20rpx 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section-title {
|
.section-title {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
/* margin-bottom: 20rpx; */
|
/* margin-bottom: 20rpx; */
|
||||||
margin: 30rpx 40rpx 10rpx;
|
margin: 30rpx 40rpx 10rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-item {
|
.form-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 30rpx 0;
|
padding: 30rpx 0;
|
||||||
border-bottom: 1rpx solid #f0f0f0;
|
border-bottom: 1rpx solid #f0f0f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-item:last-child {
|
.form-item:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
width: 205rpx;
|
width: 205rpx;
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
.required {
|
.required {
|
||||||
color: red;
|
color: red;
|
||||||
margin-right: 4rpx;
|
margin-right: 4rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.value {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
@@ -428,6 +474,7 @@ const resetForm = () => {
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.input {
|
.input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
@@ -441,6 +488,7 @@ const resetForm = () => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.car-input {
|
.car-input {
|
||||||
width: 52rpx;
|
width: 52rpx;
|
||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
@@ -456,6 +504,7 @@ const resetForm = () => {
|
|||||||
margin-top: 44rpx;
|
margin-top: 44rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tips-2 {
|
.tips-2 {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
@@ -467,6 +516,7 @@ const resetForm = () => {
|
|||||||
.btn-wrap {
|
.btn-wrap {
|
||||||
padding: 20rpx 40rpx 50rpx;
|
padding: 20rpx 40rpx 50rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.submit-btn {
|
.submit-btn {
|
||||||
background-color: #007aff;
|
background-color: #007aff;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@@ -484,30 +534,38 @@ const resetForm = () => {
|
|||||||
border-top-right-radius: 20rpx;
|
border-top-right-radius: 20rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-title {
|
.modal-title {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 30rpx;
|
margin-bottom: 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-close {
|
.modal-close {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 20rpx;
|
top: 20rpx;
|
||||||
right: 20rpx;
|
right: 20rpx;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
.address-list, .gender-list {
|
|
||||||
|
.address-list,
|
||||||
|
.gender-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20rpx;
|
gap: 20rpx;
|
||||||
}
|
}
|
||||||
.address-item, .gender-item {
|
|
||||||
|
.address-item,
|
||||||
|
.gender-item {
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
}
|
}
|
||||||
.address-item.active, .gender-item.active {
|
|
||||||
|
.address-item.active,
|
||||||
|
.gender-item.active {
|
||||||
background-color: #007aff;
|
background-color: #007aff;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 || ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取访客详情
|
||||||
|
const fetchVisitorDetail = async (id) => {
|
||||||
|
try {
|
||||||
|
const res = await getVisitorDetail(id)
|
||||||
|
if (res && res.data) {
|
||||||
|
visitorInfo.value = mapDetail(res.data)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('获取访客详情失败:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onLoad((option) => {
|
onLoad((option) => {
|
||||||
const infoStr = decodeURIComponent(JSON.stringify(option))
|
if (option && option.id) {
|
||||||
// console.log('infoStr',infoStr)
|
fetchVisitorDetail(option.id)
|
||||||
visitorInfo.value = infoStr.item
|
}
|
||||||
})
|
})
|
||||||
// 跳转到二维码页面
|
// 跳转到二维码页面
|
||||||
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 {
|
||||||
|
|||||||
@@ -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,13 +97,14 @@ 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,
|
||||||
@@ -121,8 +122,8 @@ 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user