import { computed, onUnmounted, ref, watch } from 'vue'; import { onShow } from "@dcloudio/uni-app"; import dayjs from 'dayjs'; import { getChatOrder, orderStatus } from "@/utils/order.js"; export default function useChatOrder(orderId) { const currentOrder = ref(null);// 当前聊天室的最新咨询订单 const countdown = ref(''); // 倒计时 const chatRoomStatus = computed(() => { const order = currentOrder.value || {}; const isWaiting = order.orderStatus === orderStatus.PAID; const isPending = order.orderStatus === orderStatus.CONSULTING; return { isWaiting, isPending }; }) async function getCurrentOrder() { if (orderId.value) { currentOrder.value = await getChatOrder(orderId.value) } else { currentOrder.value = null } } watch(orderId, n=>{ getCurrentOrder() }) return { currentOrder, chatRoomStatus, countdown, getCurrentOrder } }