恢复接口

This commit is contained in:
zhouyanli
2026-04-28 16:52:51 +08:00
parent fdc53b09bb
commit e3e74a1be0
15 changed files with 187 additions and 242 deletions

View File

@@ -2,11 +2,9 @@
export default { export default {
onLaunch: function() { onLaunch: function() {
// console.log('App Launch') // console.log('App Launch')
uni.removeStorageSync('token');
}, },
onShow: function() { onShow: function() {
// console.log('App Show') // console.log('App Show')
uni.removeStorageSync('token');
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')

View File

@@ -125,7 +125,7 @@
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { onLoad, onUnload, onShow } from '@dcloudio/uni-app' import { onLoad, onUnload, onShow } from '@dcloudio/uni-app'
import moment from 'moment'; import moment from 'moment';
// import { getActivityList } from '../api/api.js' import { getActivityList } from '../api/api.js'
// ===================== 响应式数据 ===================== // ===================== 响应式数据 =====================
const activeTab = ref('list') // 'list' 或 'my' const activeTab = ref('list') // 'list' 或 'my'
@@ -298,12 +298,6 @@ onLoad(() => {
uni.$on('refreshActivityList', (data) => { uni.$on('refreshActivityList', (data) => {
console.log('收到活动列表刷新通知:', data) console.log('收到活动列表刷新通知:', data)
getActivityListData(1) getActivityListData(1)
// 方式2局部更新性能更好可选启用
// const index = displayedActivities.value.findIndex(item => item.id === data.activityId)
// if (index > -1) {
// displayedActivities.value[index].applied = data.isSigned
// }
}) })
}) })

View File

@@ -212,7 +212,7 @@
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import {onLoad,onUnload} from '@dcloudio/uni-app' import {onLoad,onUnload} from '@dcloudio/uni-app'
import moment from 'moment' import moment from 'moment'
// import {getActivityDetails,confirmResident,cancelActivity,getActivityLive} from '../api/api.js' import {getActivityDetails,confirmResident,cancelActivity,getActivityLive} from '../api/api.js'
// 响应式数据 // 响应式数据
const activeTab = ref('detail') // 'detail' 或 'status' const activeTab = ref('detail') // 'detail' 或 'status'
@@ -249,7 +249,6 @@ const liveRecords = ref([
// 时间格式化函数 // 时间格式化函数
const formatTime = (timeStr) => { const formatTime = (timeStr) => {
if (!timeStr) return '' if (!timeStr) return ''
// 格式化YYYY-MM-DD HH:mm:ss → 简化为 YYYY-MM-DD HH:mm
return moment(timeStr).format('YYYY-MM-DD HH:mm') return moment(timeStr).format('YYYY-MM-DD HH:mm')
} }
@@ -409,10 +408,10 @@ const getLiveActivityList = async () =>{
liveRecords.value = res.rows || [] liveRecords.value = res.rows || []
}else{ }else{
liveRecords.value = [] liveRecords.value = []
// uni.showToast({ uni.showToast({
// title: res.msg ||"实况列表获取失败", title: res.msg ||"实况列表获取失败",
// icon:"error" icon:"error"
// }) })
} }
}catch(err){ }catch(err){
uni.showToast({ uni.showToast({

View File

@@ -1,7 +1,7 @@
let baseUrl = ''; let baseUrl = '';
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.0.224:8080'; // 开发环境 baseUrl = 'http://192.168.1.215:8080'; // 开发环境
} else { } else {
baseUrl = 'http://192.168.1.224:8080'; // 生产环境 baseUrl = 'http://192.168.1.224:8080'; // 生产环境
} }
@@ -16,7 +16,7 @@ export default function request(url, data = {}, method = "GET") {
data: data, data: data,
method: method, method: method,
header: { header: {
// "Authorization": "Bearer " + (uni.getStorageSync("token") || ''), "Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
"clientid": "resident", "clientid": "resident",
'content-type': 'application/json' 'content-type': 'application/json'
}, },

View File

@@ -64,7 +64,7 @@
v-else v-else
></uni-icons> ></uni-icons>
</view> </view>
<text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意<text class="agreePrivacy" :class="{active:isClicked}">用户隐私政策</text></text> <text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意<text class="agreePrivacy">用户隐私政策</text></text>
</view> </view>
<!-- 登录按钮 --> <!-- 登录按钮 -->
@@ -86,7 +86,7 @@
<script setup> <script setup>
import { ref, computed, onUnmounted } from 'vue'; import { ref, computed, onUnmounted } from 'vue';
// import {getLoginBySms,getSendCode} from '../api/api.js' import {getLoginBySms,getSendCode} from '../api/api.js'
// ========== 响应式数据 ========== // ========== 响应式数据 ==========
// 手机号 // 手机号
@@ -101,7 +101,7 @@ const countDown = ref(0);
// 定时器 // 定时器
let timer = null; let timer = null;
// 控制点击变色 // 控制点击变色
const isClicked = ref(false) // const isClicked = ref(false)
// ========== 计算属性 ========== // ========== 计算属性 ==========
// 是否可以获取验证码(手机号格式正确) // 是否可以获取验证码(手机号格式正确)
@@ -131,7 +131,7 @@ const toggleAgreement = () => {
// 跳转隐私协议 // 跳转隐私协议
const goToPrivacy = () => { const goToPrivacy = () => {
// 点击变色 // 点击变色
isClicked.value = true // isClicked.value = true
uni.navigateTo({ uni.navigateTo({
url:'/pageSubPack/loginSub/privacy', url:'/pageSubPack/loginSub/privacy',
}) })
@@ -179,55 +179,55 @@ const getVerifyCode = () => {
// 登录处理 // 登录处理
const handleLogin = () => { const handleLogin = () => {
if (!canLogin.value) return; if (!canLogin.value) return;
// uni.showLoading({ title: '登录中...', mask: true }); uni.showLoading({ title: '登录中...', mask: true });
let params = { let params = {
phone:phoneNumber.value, phone:phoneNumber.value,
smsCode:'123456', smsCode:'123456',
scene:'login', scene:'login',
} }
// getLoginBySms(params).then(res =>{ getLoginBySms(params).then(res =>{
// if(res.code === 200){ if(res.code === 200){
// if(res.data){ if(res.data){
// uni.setStorageSync('token', res.data.token); uni.setStorageSync('token', res.data.token);
// // 存用户ID // 存用户ID
// if(res.data.userId) { if(res.data.userId) {
// uni.setStorageSync('userId', res.data.userId); uni.setStorageSync('userId', res.data.userId);
// } }
// // 存当前绑定的小区ID0 表示未绑定 // 存当前绑定的小区ID0 表示未绑定
// const currentVillageId = res.data.currentVillageId || 0; const currentVillageId = res.data.currentVillageId || 0;
// uni.setStorageSync('currentVillageId', currentVillageId); uni.setStorageSync('currentVillageId', currentVillageId);
// uni.hideLoading(); uni.hideLoading();
// uni.showToast({ title: '登录成功', icon: 'success' }); uni.showToast({ title: '登录成功', icon: 'success' });
// setTimeout(() =>{ setTimeout(() =>{
// uni.switchTab({ url: '/pages/index/index' }); uni.switchTab({ url: '/pages/index/index' });
// },1500) },1500)
// }else{ }else{
// uni.showToast({ title: '登录失败', icon: 'error' }); uni.showToast({ title: '登录失败', icon: 'error' });
// } }
// }else{ }else{
// uni.showToast({ title:'登录失败', icon: 'error' }); uni.showToast({ title:'登录失败', icon: 'error' });
// } }
// }).catch(err => { }).catch(err => {
// uni.showToast({ uni.showToast({
// title: '网络异常,请重试', title: '网络异常,请重试',
// icon: 'error' icon: 'error'
// }); });
// }) })
// 模拟登录请求 // 模拟登录请求
uni.showLoading({ // uni.showLoading({
title: '登录中...' // title: '登录中...'
}); // });
uni.showToast({ // uni.showToast({
title:"登录成功", // title:"登录成功",
icon:'success' // icon:'success'
}) // })
setTimeout(() =>{ // setTimeout(() =>{
uni.switchTab({ url: '/pages/index/index' }); // uni.switchTab({ url: '/pages/index/index' });
},1500) // },1500)
uni.hideLoading() uni.hideLoading()
}; };
@@ -340,11 +340,11 @@ onUnmounted(() => {
margin-left: 10rpx; margin-left: 10rpx;
} }
.agreePrivacy{ .agreePrivacy{
color: #666;
}
.agreePrivacy.active{
color: #2F77FD; color: #2F77FD;
} }
/* .agreePrivacy.active{
color: #2F77FD;
} */
/* 登录按钮 */ /* 登录按钮 */
.login-btn { .login-btn {
width: 100%; width: 100%;

View File

@@ -1,13 +1,5 @@
<template> <template>
<view class="privacy-page"> <view class="privacy-page">
<!-- 导航栏 -->
<!-- <view class="nav-bar">
<view class="nav-back" @click="goToBack">
<uni-icons type="left" size="20" color="#333"></uni-icons>
<text class="back-text">返回</text>
</view>
<view class="nav-title">隐私协议</view>
</view> -->
<!-- 协议内容 --> <!-- 协议内容 -->
<scroll-view class="privacy-content" scroll-y> <scroll-view class="privacy-content" scroll-y>
@@ -32,15 +24,6 @@
</view> </view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<!-- 底部同意按钮新增 --> <!-- 底部同意按钮新增 -->
@@ -54,25 +37,25 @@
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
// 返回上一页 // 返回上一页
const navigateBack = () => { // const navigateBack = () => {
uni.navigateBack({ // uni.navigateBack({
delta: 1 // delta: 1
}); // });
}; // };
// 页面加载 // 页面加载
onLoad((options) => { // onLoad((options) => {
// 判断是否需要同意 // // 判断是否需要同意
if (options.needAgree === '1') { // if (options.needAgree === '1') {
needAgree.value = true; // needAgree.value = true;
} // }
}); // });
// 返回上一页 // 返回上一页
const goToBack = () => { // const goToBack = () => {
uni.navigateBack({ // uni.navigateBack({
delta: 1 // delta: 1
}); // });
}; // };
// 同意隐私政策(新增) // 同意隐私政策(新增)
// const agreePrivacy = () => { // const agreePrivacy = () => {

View File

@@ -46,7 +46,7 @@
</view> </view>
<text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意 <text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意
<text class="agreePrivacy" :class="{ active:isClicked }">用户隐私政策</text> <text class="agreePrivacy" >用户隐私政策</text>
</text> </text>
</view> </view>
<navigator class="forget-pwd" url="/pageSubPack/loginSub/forget-pwd">忘记密码</navigator> <navigator class="forget-pwd" url="/pageSubPack/loginSub/forget-pwd">忘记密码</navigator>
@@ -72,7 +72,7 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import {onLoad} from "@dcloudio/uni-app" import {onLoad} from "@dcloudio/uni-app"
// import {getLoginPassword} from '../api/api.js' import {getLoginPassword} from '../api/api.js'
// 响应式数据 // 响应式数据
const phoneNumber = ref(''); const phoneNumber = ref('');
@@ -80,7 +80,7 @@ const password = ref('');
const agreeAgreement = ref(false); // 默认勾选 const agreeAgreement = ref(false); // 默认勾选
const placeholderStyle = ref('font-size:24rpx') const placeholderStyle = ref('font-size:24rpx')
// 控制点击变色 // 控制点击变色
const isClicked = ref(false) // const isClicked = ref(false)
// 计算属性:是否可登录(帐号+密码+协议都满足) // 计算属性:是否可登录(帐号+密码+协议都满足)
const canLogin = computed(() => { const canLogin = computed(() => {
@@ -97,7 +97,7 @@ const toggleAgreement = () => {
// 跳转隐私协议 // 跳转隐私协议
const goToPrivacy = () => { const goToPrivacy = () => {
// 点击变色 // 点击变色
isClicked.value = true // isClicked.value = true
uni.navigateTo({ uni.navigateTo({
url:'/pageSubPack/loginSub/privacy', url:'/pageSubPack/loginSub/privacy',
}) })
@@ -134,43 +134,43 @@ const handleLogin = () => {
username:phoneNumber.value, username:phoneNumber.value,
password:password.value password:password.value
} }
// getLoginPassword(params).then(res =>{ getLoginPassword(params).then(res =>{
// // console.log('33333',res) // console.log('33333',res)
// if(res.code === 200){ if(res.code === 200){
// uni.setStorageSync('token', res.data.token); uni.setStorageSync('token', res.data.token);
// // 存用户ID // 存用户ID
// if(res.data) { if(res.data) {
// // 存当前绑定的小区ID0 表示未绑定 // 存当前绑定的小区ID0 表示未绑定
// const currentVillageId = res.data.currentVillageId || 0; const currentVillageId = res.data.currentVillageId || 0;
// uni.setStorageSync('currentVillageId', currentVillageId); uni.setStorageSync('currentVillageId', currentVillageId);
// } }
// uni.hideLoading(); uni.hideLoading();
// uni.showToast({ title: '登录成功', icon: 'success' }); uni.showToast({ title: '登录成功', icon: 'success' });
// setTimeout(() =>{ setTimeout(() =>{
// uni.switchTab({ uni.switchTab({
// url: '/pages/index/index' url: '/pages/index/index'
// },1000); },1000);
// }) })
// }else{ }else{
// uni.showToast({ title: res.msg, icon: 'error' }); uni.showToast({ title: res.msg, icon: 'error' });
// } }
// }).catch(err => { }).catch(err => {
// uni.showToast({ uni.showToast({
// title: '网络异常', title: '网络异常',
// icon: 'error' icon: 'error'
// }); });
// }) })
// 测试 // 测试
uni.showLoading({ // uni.showLoading({
title: '登录中...', // title: '登录中...',
mask:true // mask:true
}); // });
setTimeout(() => { // setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' }); // uni.switchTab({ url: '/pages/index/index' });
}, 1500); // }, 1500);
uni.hideLoading() // uni.hideLoading()
}; };
</script> </script>
@@ -237,11 +237,11 @@ const handleLogin = () => {
margin-left: 10rpx; margin-left: 10rpx;
} }
.agreePrivacy{ .agreePrivacy{
color: #666;
}
.agreePrivacy.active{
color: #2F77FD; color: #2F77FD;
} }
/* .agreePrivacy.active{
color: #2F77FD;
} */
.forget-pwd { .forget-pwd {
font-size: 28rpx; font-size: 28rpx;

View File

@@ -56,7 +56,7 @@
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'
import { onLoad ,onShow,onUnload} from '@dcloudio/uni-app' import { onLoad ,onShow,onUnload} from '@dcloudio/uni-app'
// import { getNoticeList } from '../api/api.js' import { getNoticeList } from '../api/api.js'
const noticeList = ref([]) const noticeList = ref([])
const refreshing = ref(false) const refreshing = ref(false)

View File

@@ -73,7 +73,7 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad, onShow } from '@dcloudio/uni-app'
// import {getNoticeDetails} from '../api/api.js' import {getNoticeDetails} from '../api/api.js'
const isLoading = ref(false) const isLoading = ref(false)
const noticeDetail = ref({}) const noticeDetail = ref({})

View File

@@ -55,7 +55,7 @@
<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 {getAccessDevices,getAccessOpen} from '../api/api.js' import {getAccessDevices,getAccessOpen} from '../api/api.js'
// 响应式数据:选中的门索引、开门成功提示 // 响应式数据:选中的门索引、开门成功提示
const selectedDoor = ref(-1) // -1表示未选中 const selectedDoor = ref(-1) // -1表示未选中

View File

@@ -93,7 +93,7 @@
<script setup> <script setup>
import { ref, computed, onMounted, watch } from 'vue' import { ref, computed, onMounted, watch } from 'vue'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
// import { getVillageList, getVillageSwitch } from "../api/api.js" import { getVillageList, getVillageSwitch } from "../api/api.js"
// 响应式数据 // 响应式数据
const searchText = ref('') const searchText = ref('')

View File

@@ -178,9 +178,9 @@ const goBack = () => {
} }
// 跳转报修详情 // 跳转报修详情
const goDetail = (item) => { const goDetail = (item) => {
// const itemStr = encodeURIComponent(JSON.stringify(item)) const itemStr = encodeURIComponent(JSON.stringify(item))
uni.navigateTo({ uni.navigateTo({
url: `/pageSubPack/online-repair/repairDetail?item = ${encodeURIComponent(JSON.stringify(item))}` url: `/pageSubPack/online-repair/repairDetail?item = ${itemStr}`
}); });
}; };
</script> </script>

View File

@@ -3,7 +3,6 @@
<!-- 维修流程模块 --> <!-- 维修流程模块 -->
<view class="info-section"> <view class="info-section">
<!-- <uni-section title="维修流程" type="line" style="margin-bottom: 20rpx;"> -->
<view class="section-title">维修流程</view> <view class="section-title">维修流程</view>
<uni-row class="demo-uni-row" :width="nvueWidth"> <uni-row class="demo-uni-row" :width="nvueWidth">
<uni-col :span="12"> <uni-col :span="12">
@@ -19,13 +18,10 @@
<view class="step-time-3">2026-03-28 09:30:38</view> <view class="step-time-3">2026-03-28 09:30:38</view>
</uni-col> </uni-col>
</uni-row> </uni-row>
<!-- </uni-section> -->
</view> </view>
<!-- 报修信息模块 --> <!-- 报修信息模块 -->
<view class="info-section"> <view class="info-section">
<!-- <uni-section title="报修信息" type="line" style="margin-bottom: 20rpx;"> -->
<view class="section-title">报修信息</view> <view class="section-title">报修信息</view>
<view class="info-item"> <view class="info-item">
<view class="info-label">报修房屋</view> <view class="info-label">报修房屋</view>
@@ -59,7 +55,6 @@
</view> </view>
</view> </view>
</view> </view>
<!-- </uni-section> -->
</view> </view>
<!-- 联系物业按钮 --> <!-- 联系物业按钮 -->
@@ -70,15 +65,9 @@
</template> </template>
<script setup> <script setup>
import { import { ref, computed } from 'vue'
ref import { onLoad } from '@dcloudio/uni-app'
} from 'vue'
import {
onLoad
} from '@dcloudio/uni-app'
// 步骤条当前激活的步骤0=待处理1=已派单2=已完成)
const currentStep = ref(2)
const nvueWidth = ref('300') const nvueWidth = ref('300')
// 报修信息数据 // 报修信息数据
@@ -91,21 +80,25 @@
time: '2023-08-01 15:30' time: '2023-08-01 15:30'
}) })
// 步骤状态
const currentStep = ref(1)
onLoad((option) => { onLoad((option) => {
const decodeStr = decodeURIComponent(JSON.stringify(option)) const optionstr = decodeURIComponent(JSON.stringify(option))
// let item = JSON.parse(decodeStr) // console.log('接收参数:', optionstr)
// repairInfo.value = optionStr
console.log('item', decodeStr) // ✅ 正确解析参数
const status = decodeStr.statusClass const status = optionstr.statusClass
// console.log('status',status)
// ✅ 正确赋值
switch (status) { switch (status) {
case 'pending': //待处理 case 'pending': //待处理
currentStep.value = 0 currentStep.value = 0
break break
case 'assignde': case 'assignde': //已派单
currentStep.value = 1 currentStep.value = 1
break break
case 'completed': case 'completed': //已完成
currentStep.value = 2 currentStep.value = 2
break break
default: default:
@@ -135,7 +128,6 @@
border-radius: 8px; border-radius: 8px;
padding: 13px; padding: 13px;
margin-bottom: 16px; margin-bottom: 16px;
/* margin-top: 20rpx; */
} }
.repair-steps-container { .repair-steps-container {
@@ -153,21 +145,16 @@
.step-time { .step-time {
height: 54px; height: 54px;
line-height: 54px; line-height: 54px;
font-size: 12px; font-size: 24rpx;
color: #999; color: #999;
/* font-size: 22rpx;
color: #999;
text-align: right;
margin-top: 5rpx; */
} }
.step-time-3{ .step-time-3{
height: 38px; height: 38px;
line-height: 38px; line-height: 38px;
font-size: 12px; font-size: 24rpx;
color: #999; color: #999;
} }
/* -------- */
.section-title { .section-title {
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
@@ -184,32 +171,18 @@
.slot-desc { .slot-desc {
font-size: 10px; font-size: 10px;
} }
/* .step-time {
position: absolute;
right: 0;
top: 0;
font-size: 14px;
color: #999;
white-space: nowrap;
} */
.info-item { .info-item {
display: flex; display: flex;
padding: 12px 0; padding: 12px 0;
/* border-bottom: 1px solid #f0f0f0; */
} }
.info-item-desc { .info-item-desc {
/* display: flex; */
padding: 12px 0; padding: 12px 0;
/* border-bottom: 1px solid #f0f0f0; */
} }
.info-section.active { .info-section.active {
color: #007AFF; color: #007AFF;
/* font-weight: 500; */
} }
.info-item:last-child { .info-item:last-child {
@@ -270,4 +243,14 @@
.contact-btn::after { .contact-btn::after {
border: none; border: none;
} }
/* ========== 颜色的代码 ========== */
/* u-text__value u-text__value--main */
/* 激活的步骤标题 + 描述 强制蓝色 */
::v-deep .u-text__value .u-text__value--main {
color: #007aff !important;
}
::v-deep .up-steps-item--active .up-steps-item__desc {
color: #007aff !important;
}
</style> </style>

View File

@@ -106,7 +106,7 @@
<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('visit')" :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 +114,7 @@
<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('leave')" :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>
@@ -183,19 +183,19 @@ import moment from 'moment';
// 标签激活状态 // 标签激活状态
const activeTab = ref('car'); const activeTab = ref('car');
// 表单数据(完全保留原有默认值) // 表单数据
const form = reactive({ const form = reactive({
address: '', address: '',
name: '', name: '',
gender: '', gender: '',
phone: '', phone: '',
carNumber: ['', '', '', '', '', '', ''], carNumber: ['', '', '', '', '', '', '', ''], // 修复8位车牌
peopleNum: '', peopleNum: '',
visitTime: '', visitTime: '',
leaveTime: '' leaveTime: ''
}); });
// 地址列表(原数据不变) // 地址列表
const addressList = ref([ const addressList = ref([
'桂花园别墅1号楼1层', '桂花园别墅1号楼1层',
'桂花园别墅2号楼2层' '桂花园别墅2号楼2层'
@@ -208,13 +208,8 @@ const genderList = ref(['男', '女']);
const addressModalRef = ref(null); const addressModalRef = ref(null);
const genderModalRef = ref(null); const genderModalRef = ref(null);
// 页面初始化
onLoad(() => { onLoad(() => {
// 用moment设置默认时间格式与原逻辑一致
// const now = moment();
// form.visitTime = now.format('YYYY-MM-DD HH:mm');
// 默认离开时间为1小时后
// form.leaveTime = now.clone().add(1, 'hours').format('YYYY-MM-DD HH:mm');
}); });
// 切换tab // 切换tab
@@ -250,24 +245,24 @@ const selectGender = (item) => {
genderModalRef.value.close(); genderModalRef.value.close();
}; };
// 用moment处理时间 // 时间校验
const handleTimeChange = (type) => { const handleTimeChange = () => {
if (!form.visitTime || !form.leaveTime) return; if (!form.visitTime || !form.leaveTime) return true;
const visitMoment = moment(form.visitTime); const visitMoment = moment(form.visitTime);
const leaveMoment = moment(form.leaveTime); const leaveMoment = moment(form.leaveTime);
// 校验1离开时间不能早于来访时间 // 离开时间不能早于来访时间
if (leaveMoment.isBefore(visitMoment)) { if (leaveMoment.isBefore(visitMoment)) {
uni.showToast({ uni.showToast({
title: '离开时间不能早于来访时间', title: '离开时间不能早于来访时间',
icon: 'none' icon: 'none'
}); });
form.leaveTime = visitMoment.clone().add(1, 'hours').format('YYYY-MM-DD HH:mm'); form.leaveTime = visitMoment.clone().add(1, 'hours').format('YYYY-MM-DD HH:mm');
return; return false;
} }
// 校验2间隔不超过24小时 // 不超过24小时
const diffHours = leaveMoment.diff(visitMoment, 'hours', true); const diffHours = leaveMoment.diff(visitMoment, 'hours', true);
if (diffHours > 24) { if (diffHours > 24) {
uni.showToast({ uni.showToast({
@@ -275,44 +270,26 @@ const handleTimeChange = (type) => {
icon: 'none' icon: 'none'
}); });
form.leaveTime = visitMoment.clone().add(24, 'hours').format('YYYY-MM-DD HH:mm'); form.leaveTime = visitMoment.clone().add(24, 'hours').format('YYYY-MM-DD HH:mm');
}
};
// 提交前时间校验
const checkTimeInterval = () => {
if (!form.visitTime) {
uni.showToast({ title: '请选择来访时间', icon: 'none' });
return false; return false;
} }
if (!form.leaveTime) {
uni.showToast({ title: '请选择离开时间', icon: 'none' });
return false;
}
const visitMoment = moment(form.visitTime);
const leaveMoment = moment(form.leaveTime);
if (!visitMoment.isValid() || !leaveMoment.isValid()) {
uni.showToast({ title: '时间格式错误,请重新选择', icon: 'none' });
return false;
}
if (leaveMoment.isBefore(visitMoment)) {
uni.showToast({ title: '离开时间不能早于来访时间', icon: 'none' });
return false;
}
const diffHours = leaveMoment.diff(visitMoment, 'hours', true);
if (diffHours > 24) {
uni.showToast({ title: '时间间隔不能超过24小时', icon: 'none' });
return false;
}
return true; return true;
}; };
// 表单提交(仅替换时间校验逻辑,其余完全不变) // 提交表单
const submitForm = () => { const submitForm = () => {
// 1. 必填项校验
if (!form.address) {
uni.showToast({ title: '请选择来访地址', icon: 'none' });
return;
}
if (!form.name) {
uni.showToast({ title: '请输入访客姓名', icon: 'none' });
return;
}
if (!form.gender) {
uni.showToast({ title: '请选择性别', icon: 'none' });
return;
}
if (!form.phone) { if (!form.phone) {
uni.showToast({ title: '请输入访客联系方式', icon: 'none' }); uni.showToast({ title: '请输入访客联系方式', icon: 'none' });
return; return;
@@ -325,18 +302,23 @@ const submitForm = () => {
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) {
uni.showToast({ title: '请选择来访时间', icon: 'none' });
return;
}
if (!form.leaveTime) { if (!form.leaveTime) {
uni.showToast({ title: '请选择离开时间', icon: 'none' }); uni.showToast({ title: '请选择离开时间', icon: 'none' });
return; return;
} }
// 时间校验 // 2. 时间规则校验
if (!checkTimeInterval()) return; if (!handleTimeChange()) return;
// 3. 提交成功
uni.showLoading({ title: '提交中...' }); uni.showLoading({ title: '提交中...' });
setTimeout(() => { setTimeout(() => {
uni.hideLoading(); uni.hideLoading();
@@ -345,6 +327,12 @@ const submitForm = () => {
icon: 'success' icon: 'success'
}); });
}, 1000); }, 1000);
setTimeout(() =>{
uni.navigateTo({
url:"/pageSubPack/visitor/qrcode-page"
})
},1500)
}; };
// 重置表单 // 重置表单
@@ -353,7 +341,7 @@ const resetForm = () => {
form.name = ''; form.name = '';
form.gender = ''; form.gender = '';
form.phone = ''; form.phone = '';
form.carNumber = ['', '', '', '', '', '', '']; form.carNumber = ['', '', '', '', '', '', '', ''];
form.peopleNum = ''; form.peopleNum = '';
form.visitTime = ''; form.visitTime = '';
form.leaveTime = ''; form.leaveTime = '';

View File

@@ -60,7 +60,7 @@
<view class="iconClass"> <view class="iconClass">
<image src="http://47.104.199.163:9090/images/home/lifePay.png" class="iconClass-img"></image> <image src="http://47.104.199.163:9090/images/home/lifePay.png" class="iconClass-img"></image>
</view> </view>
<view class="title-dome-calss">物业</view> <view class="title-dome-calss">生活缴</view>
</view> </view>
</up-col> </up-col>
<up-col span="3"> <up-col span="3">