对接接口

This commit is contained in:
wangxiaowei
2025-12-18 15:28:00 +08:00
parent 63d8e04465
commit ee681133b8
15 changed files with 715 additions and 585 deletions

View File

@ -12,7 +12,7 @@
</view>
<view class="mt-50rpx mx-40rpx">
<view class="">
<view>
<view class="font-bold text-36rpx leading-50rpx text-[#303133]">大门</view>
<view class="relative mt-30rpx">
<wd-img width="670rpx" height="202rpx" :src="`${OSS}images/store/store/image1.png`" mode="aspectFill" />
@ -23,35 +23,43 @@
</view>
<view class="relative h-64rpx">
<wd-img width="224rpx" height="64rpx" :src="`${OSS}images/reserve_room/reserve_room_image5.png`"/>
<view class="text-[#4C9F44] font-bold text-32rpx leading-44rpx absolute top-[50%] transform translate-y-[-50%] left-74rpx">点击开锁</view>
<!-- TODO 如果没有大门锁的话 -->
<!-- <view class="text-[#4C9F44] font-bold text-32rpx leading-44rpx absolute top-[50%] transform translate-y-[-50%] left-74rpx">暂无门锁</view> -->
<view
class="text-[#4C9F44] font-bold text-32rpx leading-44rpx absolute top-[50%] transform translate-y-[-50%] left-74rpx"
v-if="device.is_lock == 1" @click="Device.handleOpenLock('door')">
点击开锁
</view>
<view
class="text-[#4C9F44] font-bold text-32rpx leading-44rpx absolute top-[50%] transform translate-y-[-50%] left-74rpx"
v-if="device.is_lock == 0">
暂无门锁
</view>
</view>
</view>
</view>
</view>
<view class="mt-30rpx">
<view class="mb-40rpx" v-for="(item, index) in 5" :key="index">
<view class="font-bold text-36rpx leading-50rpx text-[#303133] mb-30rpx">大楼开门码</view>
<view class="mb-40rpx" v-for="(item, index) in device.roomDevice" :key="index">
<view class="font-bold text-36rpx leading-50rpx text-[#303133] mb-30rpx">{{ item.title }}</view>
<view class="flex items-center justify-between">
<view class="w-240rpx h-280rpx bg-white rounded-32rpx flex flex-col items-center justify-center">
<view class="">
<wd-img width="90rpx" height="90rpx" :src="`${OSS}images/store/store/image2.png`" mode="aspectFill" />
</view>
<view class="font-bold text-34rpx text-[#303133] leading-48rpx">门锁</view>
<view class="bg-[#4C9F44] rounded-20rpx w-168rpx h-60rpx text-center leading-60rpx text-[#fff] mt-10rpx" @cliclk="Device.handleOpenLock">
<view class="bg-[#4C9F44] rounded-20rpx w-168rpx h-60rpx text-center leading-60rpx text-[#fff] mt-10rpx"
@click="Device.handleOpenLock('room', item)">
开锁
</view>
</view>
<view class="w-410rpx h-280rpx bg-white rounded-16rpx pl-60rpx pr-34rpx">
<view class="flex items-top justify-between px-20rpx py-4rpx pt-40rpx">
<wd-img width="90rpx" height="90rpx" :src="`${OSS}images/store/store/image3.png`" mode="aspectFill" />
<view class="text-28rpx leading-40rpx text-[#303133] mt-12rpx">ON</view>
<view class="text-28rpx leading-40rpx text-[#303133] mt-12rpx">{{ item.is_open ? 'OFF' : 'ON' }}</view>
</view>
<view class="font-bold text-28rpx text-[#303133] leading-40rpx mt-34rpx flex items-center justify-between">
<view class="font-bold text-34rpx leading-48rpx text-[#303133]">插座空开</view>
<wd-switch v-model="item.checked" size="48rpx" active-color="#4C9F44"/>
<wd-switch v-model="item.is_open" size="48rpx" active-color="#4C9F44" @change="Device.handleToggleSocket($event, item)"/>
</view>
</view>
</view>
@ -64,39 +72,31 @@
<script lang="ts" setup>
import { OrderSource, OrderStatus, TeaRoomOrderStatusText, TeaRoomOrderStatusValue } from '@/utils/order'
import ComboCard from '@/components/order/ComboCard.vue'
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { getTeaRoomOrderList } from '@/api/tea-room'
import { getDeviceList, openLock, openPower } from '@/api/store'
import { router } from '@/utils/tools'
import { useStoreStore } from '@/store'
import { toast } from '@/utils/toast'
const OSS = inject('OSS')
const useStore = useStoreStore()
const checked = ref<boolean>(false)
// mescroll
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
const downOption = {
auto: true
}
const upOption = {
auto: true,
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const orderStatus = ref<string>('')
const list = ref<Array<any>>([]) // 茶室列表
const keywords = ref<string>('') // 搜索关键词
// tab
const tab = ref<string>('list')
const tabList = ref<Array<{title: string, num: number, name: string}>>([
{ title: '已上架', num: 10, name: 'list'},
{ title: '已下架', num: 11, name: 'delist' },
// { title: '草稿箱', num: 0, name: 'draft' }
])
// 设备
const device = ref({
store_id: useStore.defaultStore.id,
is_lock: 0, //是否存在大门门锁 0:不存在 1:存在
lock_no: '', // 门锁编号
roomDevice: [
{
room_id: 0, // 包间ID
title: '', // 包间名称
lock_no: '', // 门锁编号
is_open: false, //空开状态:后端返回的是 0关闭 1打开前端转换为数字
}
]
})
onLoad((args) => {
Device.handleGetDeviceList()
})
onUnload(() => {
@ -104,12 +104,78 @@
const Device = {
/**
* 开锁
* 初始化设备列表
*/
handleOpenLock: () => {
handleGetDeviceList: async () => {
const res = await getDeviceList(useStore.defaultStore.id)
device.value = res
device.value.roomDevice.map((item) => {
item.is_open = Boolean(item.is_open)
})
},
/**
* 开门锁
* @params type 类型 door:大门门锁 room:包间门锁
* @params item 设备项
*/
handleOpenLock: async (type: string, item: any = null) => {
let params = {
type: 0,
lock_no: '',
store_id: device.value.store_id,
room_id: 0
}
if (type === 'door') {
params.type = 1
params.lock_no = device.value.lock_no
} else if (type === 'room') {
params.type = 2
params.lock_no = item.lock_no
params.room_id = item.room_id
}
uni.showLoading({
title: '开锁中...',
mask: true,
})
try {
uni.hideLoading
// await openLock(params)
Device.handleGetDeviceList()
toast.success('开锁成功')
} catch(e) {
uni.hideLoading
toast.info('开锁失败,请稍后重试')
}
},
/**
* 插座空开
* @params event 事件参数
* @params item 设备项
*/
handleToggleSocket: (event: {value: boolean}, item: any) => {
let params = {
device_id: item.device_id,
state: Number(event.value),
room_id: item.room_id
}
uni.showLoading({
title: '操作中...',
mask: true,
})
try {
uni.hideLoading
// await openPower(params)
Device.handleGetDeviceList()
toast.success('操作成功')
} catch(e) {
uni.hideLoading
toast.info('操作失败,请稍后重试')
}
}
}
</script>

View File

@ -5,261 +5,6 @@
}
}</route>
<script lang="ts" setup>
import { toast } from '@/utils/toast'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
// tab
const tab = ref<number>(0)
// 上传文件
const action = 'https://www.mocky.io/v2/5cc8019d300000980a055e76' // 仅做测试使用,实际请换成真实上传接口
// 表单
const form = reactive({
roomName: '',
tags: [] as string[],
video: null as any,
images: [] as string[],
hourlyPrice: '',
minBookingTime: '',
inventory: '',
packageIntro: '',
otherNotes: '',
userCount: '',
refundPolicy: '',
})
// 标签相关
const showTagSelectPopup = ref(false)
const showCreateTagPopup = ref(false)
const newTagName = ref('')
const isTagManageMode = ref(false) // 是否处于管理模式
const selectedTags = ref<string[]>([]) // 临时选中的标签,点击确认后才回填到表单
// Mock 已有标签列表
const availableTags = ref([
'全息投影',
'环境优雅',
'幽静雅致',
'禅意悠然',
'雅室禅意浓',
'古朴韵悠长',
])
const StoreManage = {
/**
* 切换tab
*/
handleChangeTab: (e: any) => {
tab.value = e.name
},
/**
* 添加标签 - 显示选择标签弹窗
*/
handleAddTag: () => {
// 初始化临时选中的标签为当前表单中的标签
selectedTags.value = [...form.tags]
showTagSelectPopup.value = true
},
/**
* 关闭选择标签弹窗
*/
handleCloseTagSelect: () => {
showTagSelectPopup.value = false
isTagManageMode.value = false // 关闭时重置管理模式
selectedTags.value = [] // 清空临时选中的标签
},
/**
* 选择标签(临时选择,不直接修改表单)
*/
handleSelectTag: (tag: string) => {
if (isTagManageMode.value) {
// 管理模式时,点击标签不进行选择操作
return
}
if (selectedTags.value.includes(tag)) {
// 如果已选择,则取消选择
const index = selectedTags.value.indexOf(tag)
selectedTags.value.splice(index, 1)
}
else {
// 如果未选择,则添加
if (selectedTags.value.length >= 2) {
toast.info('最多只能选择2个标签')
return
}
selectedTags.value.push(tag)
}
},
/**
* 从选择列表删除标签
*/
handleRemoveTagFromList: (tag: string, event: any) => {
event.stopPropagation()
const index = availableTags.value.indexOf(tag)
if (index > -1) {
availableTags.value.splice(index, 1)
}
// 如果该标签已被选中,也从临时选中列表中移除
const selectedIndex = selectedTags.value.indexOf(tag)
if (selectedIndex > -1) {
selectedTags.value.splice(selectedIndex, 1)
}
// 如果该标签在表单中,也从表单中移除
const formIndex = form.tags.indexOf(tag)
if (formIndex > -1) {
form.tags.splice(formIndex, 1)
}
},
/**
* 确认选择标签
*/
handleConfirmTags: () => {
form.tags = [...selectedTags.value]
showTagSelectPopup.value = false
isTagManageMode.value = false
selectedTags.value = []
},
/**
* 进入管理模式
*/
handleEnterManagement: () => {
isTagManageMode.value = true
},
/**
* 退出管理模式
*/
handleExitManagement: () => {
isTagManageMode.value = false
},
/**
* 显示新建标签弹窗
*/
handleShowCreateTag: () => {
showTagSelectPopup.value = false
showCreateTagPopup.value = true
},
/**
* 关闭新建标签弹窗
*/
handleCloseCreateTag: () => {
showCreateTagPopup.value = false
newTagName.value = ''
},
/**
* 完成新建标签
*/
handleCompleteCreateTag: () => {
const tagName = newTagName.value.trim()
if (!tagName) {
toast.info('请输入标签名称')
return
}
if (tagName.length > 5) {
toast.info('标签不能超过5个字')
return
}
if (availableTags.value.includes(tagName)) {
toast.info('该标签已存在')
return
}
// 添加到可用标签列表
availableTags.value.push(tagName)
// 如果当前临时选中的标签少于2个自动选中新创建的标签
if (selectedTags.value.length < 2) {
selectedTags.value.push(tagName)
}
// 关闭弹窗,重新打开选择标签弹窗
showCreateTagPopup.value = false
newTagName.value = ''
showTagSelectPopup.value = true
toast.info('标签创建成功')
},
/**
* 删除标签
*/
handleRemoveTag: (index: number) => {
form.tags.splice(index, 1)
},
/**
* 上传视频
*/
handleUploadVideo: (event: any) => {
if (event.fileList && event.fileList.length > 0) {
form.video = event.fileList[0]
}
},
/**
* 删除视频
*/
handleRemoveVideo: () => {
form.video = null
},
/**
* 上传图片
*/
handleUploadImage: (event: any) => {
if (event.fileList && event.fileList.length > 0) {
const newImages = event.fileList.map((file: any) => file.url || file.tempFilePath)
form.images.push(...newImages)
// 限制最多9张
if (form.images.length > 9) {
form.images = form.images.slice(0, 9)
toast.info('最多只能上传9张图片')
}
}
},
/**
* 删除图片
*/
handleRemoveImage: (index: number) => {
form.images.splice(index, 1)
},
/**
* 保存
*/
handleSave: () => {
// TODO: 实现保存功能
console.log('保存表单:', form)
toast.info('保存成功')
},
/**
* 点击更多选项
*/
handleMore: () => {
// TODO: 实现更多选项功能
console.log('更多选项')
},
/**
* 点击目标图标
*/
handleTarget: () => {
// TODO: 实现目标功能
console.log('目标功能')
},
}
</script>
<template>
<view class="pb-180rpx">
<view>
@ -287,7 +32,7 @@ const StoreManage = {
</view>
<!-- 包间名称 -->
<view class="mt-28rpx">
<view class="mt-28rpx add-textarea">
<view class="mb-20rpx flex items-center">
<view class="mr-10rpx text-32rpx text-[#303133] font-bold leading-44rpx">
包间名称
@ -621,7 +366,7 @@ const StoreManage = {
<!-- 确认按钮 -->
<view
class="mt-40rpx h-90rpx rounded-8rpx bg-[#4C9F44] text-center text-30rpx text-[#fff] leading-90rpx"
:class="{ 'opacity-0 pointer-events-none': isTagManageMode }"
:class="isTagManageMode ? 'opacity-0 pointer-events-none' : ''"
@click="StoreManage.handleConfirmTags">
确认
</view>
@ -661,6 +406,263 @@ const StoreManage = {
</view>
</template>
<script lang="ts" setup>
import { toast } from '@/utils/toast'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
// tab
const tab = ref<number>(0)
// 上传文件
const action = 'https://www.mocky.io/v2/5cc8019d300000980a055e76' // 仅做测试使用,实际请换成真实上传接口
// 表单
const form = reactive({
roomName: '',
tags: [] as string[],
video: null as any,
images: [] as string[],
hourlyPrice: '',
minBookingTime: '',
inventory: '',
packageIntro: '',
otherNotes: '',
userCount: '',
refundPolicy: '',
})
// 标签相关
const showTagSelectPopup = ref(false)
const showCreateTagPopup = ref(false)
const newTagName = ref('')
const isTagManageMode = ref(false) // 是否处于管理模式
const selectedTags = ref<string[]>([]) // 临时选中的标签,点击确认后才回填到表单
// Mock 已有标签列表
const availableTags = ref([
'全息投影',
'环境优雅',
'幽静雅致',
'禅意悠然',
'雅室禅意浓',
'古朴韵悠长',
])
const StoreManage = {
/**
* 切换tab
*/
handleChangeTab: (e: any) => {
tab.value = e.name
},
/**
* 添加标签 - 显示选择标签弹窗
*/
handleAddTag: () => {
// 初始化临时选中的标签为当前表单中的标签
selectedTags.value = [...form.tags]
showTagSelectPopup.value = true
},
/**
* 关闭选择标签弹窗
*/
handleCloseTagSelect: () => {
showTagSelectPopup.value = false
isTagManageMode.value = false // 关闭时重置管理模式
selectedTags.value = [] // 清空临时选中的标签
},
/**
* 选择标签(临时选择,不直接修改表单)
*/
handleSelectTag: (tag: string) => {
if (isTagManageMode.value) {
// 管理模式时,点击标签不进行选择操作
return
}
if (selectedTags.value.includes(tag)) {
// 如果已选择,则取消选择
const index = selectedTags.value.indexOf(tag)
selectedTags.value.splice(index, 1)
}
else {
// 如果未选择,则添加
if (selectedTags.value.length >= 2) {
toast.info('最多只能选择2个标签')
return
}
selectedTags.value.push(tag)
}
},
/**
* 从选择列表删除标签
*/
handleRemoveTagFromList: (tag: string, event: any) => {
event.stopPropagation()
const index = availableTags.value.indexOf(tag)
if (index > -1) {
availableTags.value.splice(index, 1)
}
// 如果该标签已被选中,也从临时选中列表中移除
const selectedIndex = selectedTags.value.indexOf(tag)
if (selectedIndex > -1) {
selectedTags.value.splice(selectedIndex, 1)
}
// 如果该标签在表单中,也从表单中移除
const formIndex = form.tags.indexOf(tag)
if (formIndex > -1) {
form.tags.splice(formIndex, 1)
}
},
/**
* 确认选择标签
*/
handleConfirmTags: () => {
form.tags = [...selectedTags.value]
showTagSelectPopup.value = false
isTagManageMode.value = false
selectedTags.value = []
},
/**
* 进入管理模式
*/
handleEnterManagement: () => {
isTagManageMode.value = true
},
/**
* 退出管理模式
*/
handleExitManagement: () => {
isTagManageMode.value = false
},
/**
* 显示新建标签弹窗
*/
handleShowCreateTag: () => {
showTagSelectPopup.value = false
showCreateTagPopup.value = true
},
/**
* 关闭新建标签弹窗
*/
handleCloseCreateTag: () => {
showCreateTagPopup.value = false
newTagName.value = ''
},
/**
* 完成新建标签
*/
handleCompleteCreateTag: () => {
const tagName = newTagName.value.trim()
if (!tagName) {
toast.info('请输入标签名称')
return
}
if (tagName.length > 5) {
toast.info('标签不能超过5个字')
return
}
if (availableTags.value.includes(tagName)) {
toast.info('该标签已存在')
return
}
// 添加到可用标签列表
availableTags.value.push(tagName)
// 如果当前临时选中的标签少于2个自动选中新创建的标签
if (selectedTags.value.length < 2) {
selectedTags.value.push(tagName)
}
// 关闭弹窗,重新打开选择标签弹窗
showCreateTagPopup.value = false
newTagName.value = ''
showTagSelectPopup.value = true
toast.info('标签创建成功')
},
/**
* 删除标签
*/
handleRemoveTag: (index: number) => {
form.tags.splice(index, 1)
},
/**
* 上传视频
*/
handleUploadVideo: (event: any) => {
if (event.fileList && event.fileList.length > 0) {
form.video = event.fileList[0]
}
},
/**
* 删除视频
*/
handleRemoveVideo: () => {
form.video = null
},
/**
* 上传图片
*/
handleUploadImage: (event: any) => {
if (event.fileList && event.fileList.length > 0) {
const newImages = event.fileList.map((file: any) => file.url || file.tempFilePath)
form.images.push(...newImages)
// 限制最多9张
if (form.images.length > 9) {
form.images = form.images.slice(0, 9)
toast.info('最多只能上传9张图片')
}
}
},
/**
* 删除图片
*/
handleRemoveImage: (index: number) => {
form.images.splice(index, 1)
},
/**
* 保存
*/
handleSave: () => {
// TODO: 实现保存功能
console.log('保存表单:', form)
toast.info('保存成功')
},
/**
* 点击更多选项
*/
handleMore: () => {
// TODO: 实现更多选项功能
console.log('更多选项')
},
/**
* 点击目标图标
*/
handleTarget: () => {
// TODO: 实现目标功能
console.log('目标功能')
},
}
</script>
<style lang="scss">
page {
background: #f6f7f8;
@ -676,9 +678,8 @@ page {
.add-textarea {
:deep() {
.wd-textarea__value,
.wd-textarea__count {
.wd-input__value,
.wd-input__count {
background: transparent !important;
}
}

View File

@ -17,7 +17,7 @@
<mescroll-body ref="mescrollItem0" @init="mescrollInit" @down="downCallback" @up="RoomManage.upCallback" :down="downOption" :up="upOption">
<view class="grid grid-cols-2 gap-24rpx">
<view v-for="room in list" :key="room.id"
<view v-for="(room, index) in list" :key="room.id"
class="flex flex-col overflow-hidden rounded-16rpx bg-white"
@click="RoomManage.handleClickRoom(room)">
<!-- 房间图片 -->
@ -35,22 +35,22 @@
<view class="flex flex-col p-24rpx">
<!-- 房间名称 -->
<view class="mb-0rpx text-center text-28rpx text-[#303133] leading-40rpx">
{{ room.title }} ({{ room.type }})
{{ room.title }}
</view>
<!-- 状态指示器 -->
<view class="flex items-baseline justify-center align-middle">
<view class="flex items-baseline justify-center align-middle" @click.stop="RoomManage.handleEditRoomStatus(room, index)">
<!-- 状态点 -->
<view class="mr-8rpx h-12rpx w-12rpx flex-shrink-0 rounded-full"
:style="{ backgroundColor: getStatusConfig(room.status).color }" />
:style="{ backgroundColor: RoomManage.handleGetStatusConfig(room.status).color }" />
<!-- 状态文字 -->
<view class="text-24rpx text-[#303133] leading-34rpx"
:style="{ color: getStatusConfig(room.status).color }">
{{ getStatusConfig(room.status).text }}
:style="{ color: RoomManage.handleGetStatusConfig(room.status).color }">
{{ RoomManage.handleGetStatusConfig(room.status).text }}
</view>
<!-- 右箭头 -->
<view class="ml-8rpx">
<wd-icon name="arrow-right" size="12px" :color="getStatusConfig(room.status).color" />
<wd-icon name="arrow-right" size="12px" :color="RoomManage.handleGetStatusConfig(room.status).color" />
</view>
</view>
</view>
@ -58,84 +58,84 @@
</view>
</mescroll-body>
</view>
<!-- 状态修改弹窗 -->
<wd-action-sheet v-model="showActionMenu" :actions="actions" @select="RoomManage.handleSelectAction" />
</view>
</template>
<script lang="ts" setup>
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { getRoomList } from '@/api/store'
import { getRoomList, editRoom } from '@/api/store'
import { router } from '@/utils/tools'
import { toast } from '@/utils/toast'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
// 房间状态枚举
enum RoomStatus {
AVAILABLE = 'available', // 空闲中 - 绿
CLEANING = 'cleaning', // 待打扫 - 蓝色/橙
MAINTENANCE = 'maintenance', // 维护中 - 红色
IN_USE = 'in_use', // 使用中 -
WAIT_CLEANING = 1, // 待打扫 -
AVAILABLE = 2, // 空闲中 - 绿
MAINTENANCE = 3, // 维护中 - 红色
CLEANING = 4, // 打扫中 -
IN_USE = 5, // 使用中 - 蓝色
}
// 房间状态配置
const statusConfig = {
[RoomStatus.WAIT_CLEANING]: {
text: '待打扫',
color: '#818CA9', // 灰色
},
[RoomStatus.AVAILABLE]: {
text: '空闲中',
color: '#4C9F44', // 绿色
},
[RoomStatus.CLEANING]: {
text: '待打扫',
color: '#F29747', // 蓝色
},
[RoomStatus.MAINTENANCE]: {
text: '维护中',
color: '#F65353', // 红色
},
[RoomStatus.CLEANING]: {
text: '打扫中',
color: '#F29747', // 橙色
},
[RoomStatus.IN_USE]: {
text: '使用中',
color: '#1890FF', // 蓝色
},
}
// Mock 房间数据
const roomList = ref([
// 房间数据
const showActionMenu = ref<boolean>(false)
const actions = ref([
{
id: 1,
name: '对月',
type: '榻榻米',
image: `${OSS}images/room1.jpg`, // Mock图片实际需要替换
status: RoomStatus.AVAILABLE,
name: '待打扫',
value: RoomStatus.WAIT_CLEANING
},
{
id: 2,
name: '听雨',
type: '榻榻米',
image: `${OSS}images/room2.jpg`,
status: RoomStatus.CLEANING,
name: '空闲中',
value: RoomStatus.AVAILABLE
},
{
id: 3,
name: '观星',
type: '榻榻米',
image: `${OSS}images/room3.jpg`,
status: RoomStatus.MAINTENANCE,
name: '维护中',
value: RoomStatus.MAINTENANCE
},
{
id: 4,
name: '品茶',
type: '榻榻米',
image: `${OSS}images/room4.jpg`,
status: RoomStatus.CLEANING,
name: '打扫中',
value: RoomStatus.CLEANING
},
{
id: 5,
name: '静心',
type: '榻榻米',
image: `${OSS}images/room5.jpg`,
status: RoomStatus.IN_USE,
},
name: '使用中',
value: RoomStatus.IN_USE
}
])
const selectRoom = ref<{
id: number,
index: number
}>({
id: 0,
index: -1
})
// mescroll
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
@ -163,7 +163,6 @@
}
getRoomList(filter).then((res) => {
console.log("🚀 ~ res:", res)
const curPageData = res.list || [] // 当前页数据
if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
list.value = list.value.concat(curPageData) //追加新数据
@ -205,13 +204,46 @@
// TODO: 实现目标功能
console.log('目标功能')
},
}
/**
* 获取状态配置
*/
function getStatusConfig(status: RoomStatus) {
return statusConfig[status] || statusConfig[RoomStatus.AVAILABLE]
/**
* 点击编辑房间状态
*/
handleEditRoomStatus: (item: any, index: number) => {
selectRoom.value.id = item.id
selectRoom.value.index = index
showActionMenu.value = true
},
/**
* 获取房间状态
*/
handleGetStatusConfig: (status: RoomStatus) => {
return statusConfig[status] || statusConfig[RoomStatus.AVAILABLE]
},
/**
* 修改房间选择状态
*/
handleSelectAction: async (action: any) => {
uni.showLoading({
title: '修改中...'
})
try {
const status = action.item.value
await editRoom({
id: selectRoom.value.id,
status
})
uni.hideLoading()
toast.success('修改状态成功')
list.value[selectRoom.value.index].status = status
} catch (error) {
uni.hideLoading()
toast.info('修改状态失败')
}
}
}
</script>