修改访客邀请、一键开门bug
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user