修改访客邀请、一键开门bug

This commit is contained in:
zhouyanli
2026-05-07 11:57:57 +08:00
parent 231de9cde8
commit 0fb361ad64
6 changed files with 82 additions and 114 deletions

View File

@@ -40,7 +40,7 @@
<!-- 预约时间 -->
<view class="form-item time-item" @click="openTimePopup">
<text class="label">预约时间</text>
<text class="value time-value">{{ showTimeText }}</text>
<text class="value time-value">{{ showTimeText || '请选择预约时间' }}</text>
</view>
<!-- <view class="form-item">
<text class="label">预约时间</text>
@@ -78,7 +78,7 @@
<text class="popup-title">预约时间({{ tempTime.format('YYYY-MM-DD HH:mm') }})</text>
<text class="confirm-btn" @click="confirmTime">确认</text>
</view>
<!-- 时间选择列日期 | 小时 | 分钟 -->
<view class="time-selector">
<!-- 日期列 -->
@@ -142,7 +142,6 @@
</uni-popup>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { onLoad, onUnload } from '@dcloudio/uni-app'
@@ -153,7 +152,7 @@ import moment from 'moment/moment'
const houseName = ref('')
const houseId = ref('')
const projectName = ref('')
const projectId = ref('') // ✅ 修复新增项目ID
const projectId = ref('')
// 表单数据
const form = ref({
@@ -166,10 +165,10 @@ const form = ref({
// ========== 基础数据 ==========
const timePopupRef = ref(null)
const selectedTime = ref(moment().hour(9).minute(30).second(0))
const selectedTime = ref('')
const tempTime = ref(moment().hour(9).minute(30).second(0))
// ========== 时间选择列数据 ✅ 修复:固定小时/分钟,不跟随当前时间 ==========
// ========== 时间选择列数据 ==========
const dateList = ref([
{ label: '(今天)', value: moment().format('YYYY-MM-DD') },
{ label: '(明天)', value: moment().add(1, 'day').format('YYYY-MM-DD') },
@@ -195,11 +194,12 @@ const selectedMinute = ref('')
// ========== 滚动配置 ==========
const itemHeight = 80
const dateScrollTop = ref(0)
const hourScrollTop = ref(1)
const minuteScrollTop = ref(1)
const hourScrollTop = ref(0)
const minuteScrollTop = ref(0)
// ========== 显示文本 ==========
const showTimeText = computed(() => {
if(!selectedTime.value) return ''
return selectedTime.value.format('YYYY-MM-DD HH:mm')
})
@@ -228,7 +228,7 @@ const confirmTime = () => {
})
}
// ========== 滚动/选择逻辑 ==========
// ========== 核心修复:只允许点击,滚动失效! ==========
const syncScrollPosition = () => {
const dateIdx = dateList.value.findIndex(i => i.value === selectedDate.value)
const hourIdx = hourList.value.findIndex(i => i.time === selectedHour.value)
@@ -239,47 +239,32 @@ const syncScrollPosition = () => {
minuteScrollTop.value = minIdx * itemHeight
}
// 点击选择日期
const selectDate = (index) => {
selectedDate.value = dateList.value[index].value
dateScrollTop.value = index * itemHeight
updateTempTime()
}
const selectHour = (index) => {
selectedHour.value = hourList.value[index].time
hourScrollTop.value = index * itemHeight
updateTempTime()
}
const selectMinute = (index) => {
selectedMinute.value = minuteList.value[index].minute
minuteScrollTop.value = index * itemHeight
syncScrollPosition()
updateTempTime()
}
const onDateScroll = (e) => {
const idx = Math.round(e.detail.scrollTop / itemHeight)
if (idx >= 0 && idx < dateList.value.length) {
selectedDate.value = dateList.value[idx].value
dateScrollTop.value = idx * itemHeight
updateTempTime()
}
// 点击选择小时
const selectHour = (index) => {
selectedHour.value = hourList.value[index].time
syncScrollPosition() // 选中后立刻复位滚动
updateTempTime()
}
const onHourScroll = (e) => {
const idx = Math.round(e.detail.scrollTop / itemHeight)
if (idx >= 0 && idx < hourList.value.length) {
selectedHour.value = hourList.value[idx].time
hourScrollTop.value = idx * itemHeight
updateTempTime()
}
}
const onMinuteScroll = (e) => {
const idx = Math.round(e.detail.scrollTop / itemHeight)
if (idx >= 0 && idx < minuteList.value.length) {
selectedMinute.value = minuteList.value[idx].minute
minuteScrollTop.value = idx * itemHeight
updateTempTime()
}
// 点击选择分钟
const selectMinute = (index) => {
selectedMinute.value = minuteList.value[index].minute
syncScrollPosition() // 选中后立刻复位滚动
updateTempTime()
}
// 完全禁用滚动监听(去掉滚动干扰)
const onDateScroll = () => {}
const onHourScroll = () => {}
const onMinuteScroll = () => {}
const updateTempTime = () => {
tempTime.value = moment(`${selectedDate.value} ${selectedHour.value}:${selectedMinute.value}`, 'YYYY-MM-DD HH:mm')
}
@@ -296,7 +281,7 @@ onLoad(() => {
})
uni.$on('selectProject', (data) => {
projectName.value = data.name
projectId.value = data.id // 接收项目ID
projectId.value = data.id
})
})
@@ -369,7 +354,6 @@ const submitForm = async () => {
try {
const imageUrls = await uploadImages()
// 参数
const params = {
villageId,
houseId: houseId.value,
@@ -388,8 +372,6 @@ const submitForm = async () => {
if (res.code === 200) {
uni.showToast({ title: '提交成功', icon: 'success' })
// const tempProjectId = projectId.value
// 清空表单
form.value = { title: '', desc: '', phone: '', datetime: '', images: [] }
houseName.value = ''
houseId.value = ''
@@ -397,22 +379,21 @@ const submitForm = async () => {
projectId.value = ''
setTimeout(() => {
uni.navigateTo({
url:'/pageSubPack/online-repair/onlineRepair'
})
// uni.navigateTo({ url: `/pageSubPack/online-repair/onlineRepair?maintenanceProjectId=${tempProjectId}` })
uni.navigateTo({
url:'/pageSubPack/online-repair/onlineRepair'
})
}, 1500)
} else {
uni.showToast({ title: res.msg || '提交失败', icon: 'none' })
}
} catch (e) {
// console.error('提交异常:', e)
uni.showToast({ title: '提交失败,请检查网络或重试', icon: 'none' })
} finally {
uni.hideLoading()
}
}
</script>
<style scoped>
.form-container {
padding: 15px;
@@ -462,20 +443,7 @@ const submitForm = async () => {
/* border-bottom: 1px solid #eee; */
padding-bottom: 10px;
}
/* .label {
font-size: 14px;
color: #333;
margin-bottom: 8px;
display: block;
}
.value {
font-size: 14px;
color: #666;
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0;
} */
.switch {
font-size: 12px;
color: #007aff;
@@ -589,25 +557,14 @@ textarea {
height: 80rpx;
line-height: 80rpx;
font-size: 28rpx;
color: #666;
color: #BBBCBE;
position: relative;
}
/* 选中项样式(高亮) */
.time-item.active {
color: #007aff;
color: #1D2129;
font-weight: 600;
background-color: #d0d0d0;
}
.time-item.active::after {
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
/* width: 80%; */
/* height: 1px; */
background-color: #d0d0d0;
background-color: #F7F7F7;
}
</style>

View File

@@ -13,9 +13,9 @@
</up-steps>
</uni-col>
<uni-col :span="12">
<view class="step-time">2026-03-26 09:30:38</view>
<view class="step-time">2026-03-26 09:30:38</view>
<view class="step-time-3">2026-03-28 09:30:38</view>
<view class="step-time" v-if="currentStep >= 0">{{timeData.createTime}}</view>
<view class="step-time" v-if="currentStep >= 1">{{timeData.dispatchTime}}</view>
<view class="step-time-3" v-if="currentStep >= 2">{{timeData.finishTime}}</view>
</uni-col>
</uni-row>
</view>
@@ -61,9 +61,9 @@
</view>
<!-- 联系物业按钮 -->
<view class="btn-container">
<!-- <view class="btn-container">
<button class="contact-btn" @click="contactProperty">联系物业</button>
</view>
</view> -->
</view>
</template>
@@ -87,6 +87,13 @@ const repairInfo = ref({
// 步骤状态
const currentStep = ref(0)
// 三个步骤对应的时间
const timeData = ref({
createTime: '', // 待处理/提交时间
dispatchTime: '', // 已派单时间
finishTime: '' // 已完成时间
})
const setStep = (status) => {
if (status === '0' || status === 0) currentStep.value = 0
@@ -108,6 +115,10 @@ const mapData = (data) => {
images
}
setStep(data.problemStatus)
// 三个步骤时间赋值
timeData.value.createTime = data.updateTime || ''
timeData.value.dispatchTime = data.updateTime || ''
timeData.value.finishTime = data.updateTime || ''
}
// 获取详情接口
@@ -145,11 +156,11 @@ const previewImage = (url) => {
}
// 联系物业按钮点击事件
const contactProperty = () => {
uni.makePhoneCall({
phoneNumber: '物业电话' // 换成真实电话
})
}
// const contactProperty = () => {
// uni.makePhoneCall({
// phoneNumber: '物业电话' // 换成真实电话
// })
// }
</script>
<style scoped>