diff --git a/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.js b/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.js index cf76b34..5855d97 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.js +++ b/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.js @@ -52,193 +52,408 @@ Page({ getData() { let _this = this let id = _this.data.rId + + // 显示加载中提示 + wx.showLoading({ + title: '加载中...', + mask: true + }); + // 获取预约信息 selectReservationByIdRq({ id: id }).then(res => { console.log('预约信息:', res) - let staffIdArr = [] - let staff = res.waiters - for (let key in staff) { - staffIdArr.push(staff[key].userId) + // 初始化数组 + let musicStaffArr = [] // 音控组人员ID + let serviceStaffArr = [] // 会务服务组人员ID + let staff = res.waiters || [] + + // 清晰记录每个waiter的类型和ID,便于调试 + console.log('服务器返回的会务人员:', staff.map(item => ({id: item.userId, type: item.type}))); + + // 分别存储音控组和会务服务组的人员ID + for (let i = 0; i < staff.length; i++) { + // 类型1为音控组 + if (staff[i].type === '1' || staff[i].type === 1) { + musicStaffArr.push(staff[i].userId) + } + // 类型3为会务服务组 + else if (staff[i].type === '3' || staff[i].type === 3) { + serviceStaffArr.push(staff[i].userId) + } } + getStaff().then(resStaff => { - console.log('会务人员:', resStaff) + wx.hideLoading(); + console.log('会务人员列表:', resStaff) let musicList = [] let serveList = [] - let hasMusicStaff = false - let hasServiceStaff = false - for (let key in resStaff.voiceWaiter) { - let eachObj = resStaff.voiceWaiter[key] - let isSel = false - if (staffIdArr.includes(eachObj.id)) { - isSel = true - hasMusicStaff = true + // 检查服务器返回的已选择人员 + let hasMusicStaff = musicStaffArr.length > 0 + let hasServiceStaff = serviceStaffArr.length > 0 + + // 处理音控组数据 + if (resStaff.voiceWaiter && resStaff.voiceWaiter.length > 0) { + for (let i = 0; i < resStaff.voiceWaiter.length; i++) { + let eachObj = resStaff.voiceWaiter[i] + // 判断该人员是否已被选择 + let isSel = musicStaffArr.includes(eachObj.id) + musicList.push({ + id: eachObj.id, + name: eachObj.username, + isSelect: isSel + }) } - musicList.push({ - id: eachObj.id, - name: eachObj.username, - isSelect: isSel - }) } - for (let key in resStaff.serveWaiter) { - let eachObj = resStaff.serveWaiter[key] - let isSel = false - if (staffIdArr.includes(eachObj.id)) { - isSel = true - hasServiceStaff = true + + // 处理会务服务组数据 + if (resStaff.serveWaiter && resStaff.serveWaiter.length > 0) { + for (let i = 0; i < resStaff.serveWaiter.length; i++) { + let eachObj = resStaff.serveWaiter[i] + // 判断该人员是否已被选择 + let isSel = serviceStaffArr.includes(eachObj.id) + serveList.push({ + id: eachObj.id, + name: eachObj.username, + isSelect: isSel + }) } - serveList.push({ - id: eachObj.id, - name: eachObj.username, - isSelect: isSel - }) } + // 重新检查选择状态,以确保准确性 + hasMusicStaff = musicList.some(item => item.isSelect); + hasServiceStaff = serveList.some(item => item.isSelect); + + // 计算全选状态 + const musicCheckAll = musicList.length > 0 && musicList.every(item => item.isSelect); + const serviceCheckAll = serveList.length > 0 && serveList.every(item => item.isSelect); + + console.log('音控组选择状态:', hasMusicStaff, '音控组IDs:', musicStaffArr); + console.log('会务服务组选择状态:', hasServiceStaff, '会务服务组IDs:', serviceStaffArr); + // 保存初始状态到本地存储 wx.setStorageSync('staffStatus_' + _this.data.rId, { hasMusicStaff, - hasServiceStaff + hasServiceStaff, + musicIds: musicStaffArr, + serviceIds: serviceStaffArr, + timestamp: new Date().getTime() }); _this.setData({ staffServeList: serveList, - staffMusicList: musicList + staffMusicList: musicList, + musicCheckAll: musicCheckAll, + serviceCheckAll: serviceCheckAll }) - }) - }) - // ajax获取当前预约的人员以及会务人员列表 + }).catch(err => { + wx.hideLoading(); + console.error('获取会务人员列表失败:', err); + Notify({ + type: 'danger', + message: '获取会务人员列表失败' + }); + }); + }).catch(err => { + wx.hideLoading(); + console.error('获取预约信息失败:', err); + Notify({ + type: 'danger', + message: '获取预约信息失败' + }); + }); }, - // 服务选择 + // 音控组全选 + checkMusicAll() { + let _this = this + let checkStatus = !_this.data.musicCheckAll // 直接取反更可靠 + + // 更新所有音控组成员的选择状态 + let staffMusicList = _this.data.staffMusicList.map(item => { + item.isSelect = checkStatus + return item + }) + + _this.setData({ + staffMusicList, + musicCheckAll: checkStatus + }) + + // 更新本地存储状态 + let hasServiceStaff = _this.data.staffServeList.some(item => item.isSelect); + wx.setStorageSync('staffStatus_' + _this.data.rId, { + hasMusicStaff: checkStatus, + hasServiceStaff + }); + + console.log('音控组全选状态更新为:', checkStatus); + }, + + // 会务服务组全选 + checkServiceAll() { + let _this = this + let checkStatus = !_this.data.serviceCheckAll // 直接取反更可靠 + + // 更新所有会务服务组成员的选择状态 + let staffServeList = _this.data.staffServeList.map(item => { + item.isSelect = checkStatus + return item + }) + + _this.setData({ + staffServeList, + serviceCheckAll: checkStatus + }) + + // 更新本地存储状态 + let hasMusicStaff = _this.data.staffMusicList.some(item => item.isSelect); + wx.setStorageSync('staffStatus_' + _this.data.rId, { + hasMusicStaff, + hasServiceStaff: checkStatus + }); + + console.log('会务服务组全选状态更新为:', checkStatus); + }, + + // 单个选择框点击 checkBoxClick(e) { let _this = this console.log('checkBoxClick', e) // get param let id = e.target.dataset.id let type = e.target.dataset.type + if (type === 'music') { + // 音控组成员选择 let staffMusicList = _this.data.staffMusicList.map(item => { if (item.id == id) { item.isSelect = !item.isSelect } return item }) + + // 检查是否需要更新全选状态 + const allSelected = staffMusicList.length > 0 && staffMusicList.every(item => item.isSelect); + const noneSelected = staffMusicList.every(item => !item.isSelect); + _this.setData({ - staffMusicList + staffMusicList, + musicCheckAll: allSelected }) - } else { + + // 检查音控组选择状态 + let hasMusicStaff = staffMusicList.some(item => item.isSelect); + + // 获取会务服务组选择状态 + let hasServiceStaff = _this.data.staffServeList.some(item => item.isSelect); + + // 更新本地存储 + wx.setStorageSync('staffStatus_' + _this.data.rId, { + hasMusicStaff, + hasServiceStaff + }); + + console.log('音控组选择状态:', hasMusicStaff, '全选状态:', allSelected); + + } else if (type === 'serve' || type === 'service') { + // 会务服务组成员选择 (支持两种数据类型值) let staffServeList = _this.data.staffServeList.map(item => { if (item.id == id) { item.isSelect = !item.isSelect } return item }) + + // 检查是否需要更新全选状态 + const allSelected = staffServeList.length > 0 && staffServeList.every(item => item.isSelect); + const noneSelected = staffServeList.every(item => !item.isSelect); + _this.setData({ - staffServeList + staffServeList, + serviceCheckAll: allSelected }) + + // 检查会务服务组选择状态 + let hasServiceStaff = staffServeList.some(item => item.isSelect); + + // 获取音控组选择状态 + let hasMusicStaff = _this.data.staffMusicList.some(item => item.isSelect); + + // 更新本地存储 + wx.setStorageSync('staffStatus_' + _this.data.rId, { + hasMusicStaff, + hasServiceStaff + }); + + console.log('会务服务组选择状态:', hasServiceStaff, '全选状态:', allSelected); } }, // 确定 submit() { let _this = this; - // 提交 - console.log(_this.data.staffMusicList) - console.log(_this.data.staffServeList) - let staffMusicList = _this.data.staffMusicList - let staffServeList = _this.data.staffServeList - let musicId = '' - // 检查音控组是否有选择 - let hasMusicStaff = false - for (let key in staffMusicList) { - if (staffMusicList[key].isSelect) { - hasMusicStaff = true - musicId += staffMusicList[key].id + ',' - } - } - if (musicId != '') { - // 去掉最后一个, - musicId = musicId.substring(0, musicId.length - 1) - } - let serveId = '' - // 检查会务服务组是否有选择 - let hasServiceStaff = false - for (let key in staffServeList) { - if (staffServeList[key].isSelect) { - hasServiceStaff = true - serveId += staffServeList[key].id + ',' - } - } - if (serveId != '') { - // 去掉最后一个, - serveId = serveId.substring(0, serveId.length - 1) - } - // 保存选择状态到本地存储 - wx.setStorageSync('staffStatus_' + _this.data.rId, { - hasMusicStaff, - hasServiceStaff + console.log('提交全选状态:', { + musicCheckAll: _this.data.musicCheckAll, + serviceCheckAll: _this.data.serviceCheckAll }); + // 收集音控组选择的ID + let staffMusicList = _this.data.staffMusicList; + let musicIds = []; + let hasMusicStaff = false; + + // 获取所有选中的音控组成员ID + staffMusicList.forEach(item => { + if (item.isSelect) { + hasMusicStaff = true; + musicIds.push(item.id); + } + }); + + // 收集会务服务组选择的ID + let staffServeList = _this.data.staffServeList; + let serveIds = []; + let hasServiceStaff = false; + + // 获取所有选中的会务服务组成员ID + staffServeList.forEach(item => { + if (item.isSelect) { + hasServiceStaff = true; + serveIds.push(item.id); + } + }); + + // 将数组转换为以逗号分隔的字符串 + let musicId = musicIds.join(','); + let serveId = serveIds.join(','); + + console.log('提交选择状态:', { + hasMusicStaff, + hasServiceStaff, + 音控组IDs: musicIds, + 会务服务组IDs: serveIds + }); + + // 保存选择状态到本地存储,添加更多信息和时间戳 + wx.setStorageSync('staffStatus_' + _this.data.rId, { + hasMusicStaff, + hasServiceStaff, + musicIds: musicIds, + serviceIds: serveIds, + timestamp: new Date().getTime() + }); + + // 显示加载中 + wx.showLoading({ + title: '保存中...', + mask: true + }); + + // 调用接口保存到服务器 addStaff({ id: _this.data.rId, - voiceWaiter: musicId, - serveWaiter: serveId + voiceWaiter: musicId, // 音控组 type=1 + serveWaiter: serveId // 会务服务组 type=3 }).then(res => { + wx.hideLoading(); + + if (res.code == 0) { + Notify({ + type: 'success', + message: '分配成功!' + }); + + // 再次确认状态已正确保存 + console.log('会务人员设置成功,最终状态:', { + 音控组: hasMusicStaff, + 会务服务组: hasServiceStaff, + 音控组人员: musicIds, + 会务服务组人员: serveIds + }); + + // 获取页面栈 + let pages = getCurrentPages(); + // 获取上一页实例 + let prevPage = pages[pages.length - 2]; + + // 判断上一页是否是approve页面 + if (prevPage && prevPage.route && prevPage.route.includes('approve')) { + // 设置上一页的dataChange为true,触发刷新 + prevPage.setData({ + dataChange: true + }); + + // 尝试直接更新上一页的记录数据 + try { + // 查找对应的预约记录并更新其状态 + const reservationList = prevPage.data.reservationDataList || []; + const currentRecord = reservationList.find(item => item.id === _this.data.rId); + + if (currentRecord) { + // 构造一个模拟的waiters数组 + const waiters = []; + + // 添加音控组人员 + musicIds.forEach(id => { + waiters.push({ + userId: id, + type: '1' + }); + }); + + // 添加会务服务组人员 + serveIds.forEach(id => { + waiters.push({ + userId: id, + type: '3' + }); + }); + + // 更新记录的waiters属性 + currentRecord.waiters = waiters; + + // 重新处理会务负责人状态 + if (typeof prevPage.processStaffStatus === 'function') { + prevPage.processStaffStatus(currentRecord); + + // 通知页面更新 + prevPage.setData({ + reservationDataList: reservationList + }); + + console.log('直接更新上一页预约记录状态成功'); + } + } + } catch (err) { + console.error('更新上一页数据失败:', err); + } + } + + // 返回上一页 + setTimeout(() => { + wx.navigateBack(); + }, 500); + } else { + // 提交失败 + Notify({ + type: 'danger', + message: res.msg || '分配失败,请重试' + }); + } + }).catch(err => { + wx.hideLoading(); + console.error('分配会务人员失败:', err); Notify({ - type: 'success', - message: '分配成功!' - }) - - // 获取页面栈 - let pages = getCurrentPages() - // 获取上一页实例 - let prevPage = pages[pages.length - 2] - // 设置上一页的dataChange为true,触发刷新 - prevPage.setData({ - dataChange: true - }) - - // 返回上一页 - wx.navigateBack() - }) + type: 'danger', + message: '网络错误,请重试' + }); + }); + }, - // let pages = getCurrentPages(); //获取page - // let prevPage = pages[pages.length - 2]; //上一个页面(父页面) - // prevPage.setData({ - // serviceList: _this.data.serviceList - // }) - // console.log(_this.data.serviceList) - // wx.navigateBack() - }, - checkMusicAll() { - let _this = this - let checkStatus = _this.data.musicCheckAll - checkStatus = checkStatus ? false : true - let staffMusicList = _this.data.staffMusicList.map(item => { - item.isSelect = checkStatus - return item - }) - _this.setData({ - staffMusicList, - musicCheckAll: checkStatus - }) - }, - checkServiceAll() { - let _this = this - let checkStatus = _this.data.serviceCheckAll - checkStatus = checkStatus ? false : true - let staffServeList = _this.data.staffServeList.map(item => { - item.isSelect = checkStatus - return item - }) - _this.setData({ - staffServeList, - serviceCheckAll: checkStatus - }) - }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxml b/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxml index 444fa01..cf587f8 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxml +++ b/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxml @@ -15,12 +15,12 @@ - 会务服务组 + 会务服务组 - - {{item.name}} + + {{item.name}} diff --git a/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxss b/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxss index 77e6f5b..39ac6e3 100644 --- a/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxss +++ b/miniprogram/pages/meeting/meetingRoom/meetingStaff/meetingStaff.wxss @@ -1,10 +1,11 @@ - .serviceView { margin-top: 80rpx; } .serviceView .leftLineTitle { margin-left: 20rpx; + padding: 10rpx 0; + font-weight: bold; } .serviceView .serviceItemView { @@ -18,13 +19,19 @@ align-items: center; word-break: break-all; padding: 20rpx 20rpx; + transition: background-color 0.2s; +} + +.serviceView .serviceItemView .serviceItem:active { + background-color: #f2f2f2; } .serviceView .serviceItemView .serviceItem:first-of-type { border-top: 1px solid rgb(126, 126, 126, 0.2); } -.leftLineTitle { -font-size: 42rpx; + +.leftLineTitle { + font-size: 42rpx; } .serviceView .serviceItem .name { @@ -33,6 +40,7 @@ font-size: 42rpx; margin-right: 20rpx; padding-left: 10rpx; font-size: 34rpx; + padding: 15rpx 0; } .serviceView .serviceItem .content { @@ -47,3 +55,24 @@ font-size: 42rpx; text-indent: 48rpx; color: gray; } + +.submitBtn { + position: fixed; + bottom: 40rpx; + left: 50%; + transform: translateX(-50%); + width: 90%; + height: 88rpx; + line-height: 88rpx; + text-align: center; + background-color: #1989fa; + color: #fff; + border-radius: 44rpx; + font-size: 32rpx; + font-weight: bold; + box-shadow: 0 6rpx 10rpx rgba(25, 137, 250, 0.3); +} + +.submitBtn:active { + background-color: #0b70d5; +} diff --git a/miniprogram/pages/meeting/reservationRecord/approve/approve.js b/miniprogram/pages/meeting/reservationRecord/approve/approve.js index f591ae6..938de38 100644 --- a/miniprogram/pages/meeting/reservationRecord/approve/approve.js +++ b/miniprogram/pages/meeting/reservationRecord/approve/approve.js @@ -15,7 +15,9 @@ import { selectVisitorInvitationRecordRq, cancelOrderRq, approveOrderRq, - approveOrderDel + approveOrderDel, + selectReservationByIdRq, + getStaff } from "../../../../api/meeting/meetingRoom.js" Page({ @@ -292,6 +294,11 @@ Page({ let currentUserData = wx.getStorageSync('user'); let currentRole = currentUserData ? currentUserData.roomRole : _this.data.userData.roomRole; + wx.showLoading({ + title: '加载中...', + mask: true + }); + // 查询数据 selectReservationListByUserIdRq({ role: currentRole, // 使用最新的角色 @@ -302,29 +309,51 @@ Page({ status: _this.data.search.status.value === '' ? null : _this.data.search.status.value, sort: _this.data.search.sort.value, // 排序 }).then(res => { - console.log('selectReservationListByUserIdRq', res); + wx.hideLoading(); + console.log('获取预约列表数据:', res); + // 判断数据是否全部查询 - let queryDataList = res.rows; + let queryDataList = res.rows || []; + + // 检查是否还有更多数据可加载 if (_this.data.reservationDataList.length < res.total) { + // 格式化新获取的数据 + let formattedData = _this.formartData(queryDataList); + // 更新参数 - let reservationDataList = _this.data.reservationDataList.concat(_this.formartData(queryDataList)); + let reservationDataList = _this.data.reservationDataList.concat(formattedData); let reservationPageNum = _this.data.reservationPageNum + 1; + _this.setData({ reservationPageNum, reservationDataList, - }) + }); + // 超过总大小,则加载完成 if (_this.data.reservationDataList.length >= res.total) { _this.setData({ reservationIsDataAll: true - }) + }); + console.log('所有预约数据加载完成,共', res.total, '条记录'); + } else { + console.log('已加载', _this.data.reservationDataList.length, '条记录,总共', res.total, '条'); } } else { _this.setData({ reservationIsDataAll: true - }) + }); + console.log('所有预约数据已加载完成'); } - }) + }).catch(err => { + wx.hideLoading(); + console.error('获取预约列表失败:', err); + + // 显示错误提示 + Notify({ + type: 'danger', + message: '获取数据失败,请重试' + }); + }); }, // 获取参与数据,此处不需要 @@ -378,7 +407,10 @@ Page({ let secondDateStr = selfFormatTimeYMD(secondDate); let thirdDateStr = selfFormatTimeYMD(thirdDate); - return queryDataList.map(item => { + console.log('格式化数据,记录数量:', queryDataList.length); + + // 首先进行基本格式化 + let formattedData = queryDataList.map(item => { // 会议开始日期 let meetingDateStr = selfFormatTimeYMD(item.start); @@ -446,45 +478,8 @@ Page({ showStaff = true // 根据会务负责人选择状态设置按钮颜色和提示 - try { - // 从本地存储获取会务负责人选择状态 - let staffStatus = wx.getStorageSync('staffStatus_' + item.id); - if (staffStatus) { - // 判断音控组和会务服务组选择状态 - const hasMusicStaff = staffStatus.hasMusicStaff; - const hasServiceStaff = staffStatus.hasServiceStaff; - - if (hasMusicStaff && hasServiceStaff) { - // 音控组和会务服务组都有选择 - item.staffBtnType = ''; - item.staffTip = ''; - // 绿色样式标记 - item.isStaffComplete = true; - } else if (!hasMusicStaff && !hasServiceStaff) { - // 音控组和会务服务组都没有选择 - item.staffBtnType = 'danger'; - item.staffTip = '请选择音控组和会务服务组'; - item.isStaffComplete = false; - } else if (hasMusicStaff && !hasServiceStaff) { - // 只选择了音控组 - item.staffBtnType = 'warning'; - item.staffTip = '请选择会务服务组'; - item.isStaffComplete = false; - } else if (!hasMusicStaff && hasServiceStaff) { - // 只选择了会务服务组 - item.staffBtnType = 'warning'; - item.staffTip = '请选择音控组'; - item.isStaffComplete = false; - } - } else { - // 默认状态:黄色按钮(与取消预约按钮一致),提示选择两个组 - item.staffBtnType = 'warning'; - item.staffTip = '请选择音控组和会务服务组'; - item.isStaffComplete = false; - } - } catch (error) { - console.error('获取会务负责人状态失败', error); - } + // 预先进行一次状态判断,稍后将异步获取详细信息 + this.processStaffStatus(item); } } if (statusValue == 9) { @@ -520,7 +515,147 @@ Page({ } } return item - }) + }); + + // 异步加载所有"待开始"状态的预约记录的会务人员信息 + this.loadStaffInfoForItems(formattedData); + + return formattedData; + }, + + // 为所有待开始状态的预约记录加载会务人员信息 + loadStaffInfoForItems(items) { + if (!items || items.length === 0) return; + + // 过滤出所有"待开始"状态的记录 + const pendingItems = items.filter(item => item.status == 7); + console.log('需要获取会务人员信息的记录数:', pendingItems.length); + + if (pendingItems.length === 0) return; + + // 为每个待开始的预约记录异步获取会务人员信息 + pendingItems.forEach(item => { + selectReservationByIdRq({ + id: item.id + }).then(res => { + console.log('获取预约详情(ID:' + item.id + '):', res); + + // 更新waiters数据 + if (res && res.waiters) { + item.waiters = res.waiters; + + // 重新处理会务负责人状态 + this.processStaffStatus(item); + + // 触发视图更新 + this.setData({ + reservationDataList: this.data.reservationDataList + }); + } + }).catch(err => { + console.error('获取预约详情失败(ID:' + item.id + '):', err); + }); + }); + }, + + // 处理会务负责人状态 - 抽取为独立方法以便重用 + processStaffStatus(item) { + try { + // 从服务器数据中判断是否有选择(优先使用) + let hasMusicStaffFromServer = false; + let hasServiceStaffFromServer = false; + let musicIdsFromServer = []; + let serviceIdsFromServer = []; + + if (item.waiters && item.waiters.length > 0) { + // 分别检查服务器返回的数据中是否有音控组和会务服务组的人员 + for (let i = 0; i < item.waiters.length; i++) { + // 音控组 + if (item.waiters[i].type === '1' || item.waiters[i].type === 1) { + hasMusicStaffFromServer = true; + musicIdsFromServer.push(item.waiters[i].userId); + } + // 会务服务组 + else if (item.waiters[i].type === '3' || item.waiters[i].type === 3) { + hasServiceStaffFromServer = true; + serviceIdsFromServer.push(item.waiters[i].userId); + } + } + } + + console.log('服务器返回的会务负责人状态(ID:' + item.id + '):', { + 音控组: hasMusicStaffFromServer, + 会务服务组: hasServiceStaffFromServer, + 音控组IDs: musicIdsFromServer, + 会务服务组IDs: serviceIdsFromServer + }); + + // 从本地存储获取会务负责人选择状态(作为备用) + let staffStatus = wx.getStorageSync('staffStatus_' + item.id); + + // 如果本地存储有详细信息,使用这些信息 + if (staffStatus) { + console.log('本地存储的会务负责人状态(ID:' + item.id + '):', { + 音控组: staffStatus.hasMusicStaff, + 会务服务组: staffStatus.hasServiceStaff, + 音控组IDs: staffStatus.musicIds || [], + 会务服务组IDs: staffStatus.serviceIds || [], + 时间戳: staffStatus.timestamp ? new Date(staffStatus.timestamp).toLocaleString() : '未知' + }); + } else { + console.log('本地存储中没有找到会务负责人状态(ID:' + item.id + ')'); + } + + // 优先使用服务器数据,如果服务器数据为空则使用本地存储 + // 如果本地存储时间戳比较新(10分钟内),则优先使用本地存储 + const useLocalFirst = staffStatus && staffStatus.timestamp && + (new Date().getTime() - staffStatus.timestamp < 10 * 60 * 1000); + + let hasMusicStaff, hasServiceStaff; + + if (useLocalFirst) { + // 优先使用本地存储(因为时间戳较新) + hasMusicStaff = staffStatus.hasMusicStaff; + hasServiceStaff = staffStatus.hasServiceStaff; + console.log('使用本地存储的状态(更新时间较新)'); + } else { + // 否则优先使用服务器数据 + hasMusicStaff = hasMusicStaffFromServer || (staffStatus && staffStatus.hasMusicStaff); + hasServiceStaff = hasServiceStaffFromServer || (staffStatus && staffStatus.hasServiceStaff); + console.log('优先使用服务器状态,并结合本地存储'); + } + + console.log('最终判断的会务负责人状态(ID:' + item.id + '):', {hasMusicStaff, hasServiceStaff}); + + if (hasMusicStaff && hasServiceStaff) { + // 音控组和会务服务组都有选择 + item.staffBtnType = ''; // 绿色(无类型) + item.staffTip = ''; + // 绿色样式标记 + item.isStaffComplete = true; + } else if (!hasMusicStaff && !hasServiceStaff) { + // 音控组和会务服务组都没有选择 + item.staffBtnType = 'danger'; // 红色 + item.staffTip = '请选择音控组和会务服务组'; + item.isStaffComplete = false; + } else if (hasMusicStaff && !hasServiceStaff) { + // 只选择了音控组 + item.staffBtnType = 'warning'; // 灰色 + item.staffTip = '请选择会务服务组'; + item.isStaffComplete = false; + } else if (!hasMusicStaff && hasServiceStaff) { + // 只选择了会务服务组 + item.staffBtnType = 'warning'; // 灰色 + item.staffTip = '请选择音控组'; + item.isStaffComplete = false; + } + } catch (error) { + console.error('处理会务负责人状态失败', error); + // 出错时默认为未选择 + item.staffBtnType = 'danger'; + item.staffTip = '请选择音控组和会务服务组'; + item.isStaffComplete = false; + } }, // 跳转-预约详情 @@ -889,6 +1024,26 @@ Page({ */ onPullDownRefresh() { console.log('onPullDownRefresh', '页面相关事件处理函数--监听用户下拉动作'); + let _this = this; + + // 重置数据 + _this.setData({ + reservationPageNum: 1, + reservationDataList: [], + reservationIsDataAll: false, + }); + + // 重新获取数据 + _this.getDataList(); + + // 停止下拉刷新动画 + wx.stopPullDownRefresh(); + + // 提示用户 + Notify({ + type: 'success', + message: '刷新成功' + }); }, /** @@ -897,8 +1052,28 @@ Page({ onReachBottom() { console.log('onReachBottom', '页面上拉触底事件的处理函数'); let _this = this; - // 获取数据 - _this.getDataList() + + // 如果数据已全部加载完成,则不再请求 + if (_this.data.reservationIsDataAll) { + Notify({ + type: 'primary', + message: '已加载全部数据' + }); + return; + } + + // 显示加载中提示 + wx.showLoading({ + title: '加载更多...', + mask: true + }); + + // 延迟一下再加载,避免频繁请求 + setTimeout(() => { + // 获取数据 + _this.getDataList(); + wx.hideLoading(); + }, 300); }, /** diff --git a/miniprogram/pages/meeting/reservationRecord/approve/approve.json b/miniprogram/pages/meeting/reservationRecord/approve/approve.json index 3399b1a..33a2662 100644 --- a/miniprogram/pages/meeting/reservationRecord/approve/approve.json +++ b/miniprogram/pages/meeting/reservationRecord/approve/approve.json @@ -14,5 +14,7 @@ "van-action-sheet": "@vant/weapp/action-sheet/index" }, "navigationBarTitleText": "会议审核", - "onReachBottomDistance": 100 + "onReachBottomDistance": 100, + "enablePullDownRefresh": true, + "backgroundTextStyle": "dark" } \ No newline at end of file