// 获取路由参数
export function getRouteParams() {
  const pages = getCurrentPages()
  const currentPage = pages[pages.length - 1]
  return currentPage.options || {}
}

// 获取工单ID
export function getWorkOrderId(): string {
  return getRouteParams().id || ''
}

// 获取延时审核ID
export function getDelayId(): string {
  return getRouteParams().delayId || ''
}

// 获取任务ID
export function getTaskId(): string {
  return getRouteParams().taskId || ''
}

// 获取按钮权限
export function getButton(): string {
  return getRouteParams().button || ''
}

// 复制文本到剪贴板
export function copyToClipboard(text: string): void {
  uni.setClipboardData({
    data: text,
    success: () => {
      uni.showToast({
        title: '复制成功',
        icon: 'success'
      })
    }
  })
}

// 显示确认弹窗
export function showConfirmModal(
  title: string,
  content: string,
  confirmCallback: () => void,
  cancelCallback?: () => void
): void {
  uni.showModal({
    title: title,
    content: content,
    success: (res) => {
      if (res.confirm) {
        confirmCallback()
      } else if (res.cancel && cancelCallback) {
        cancelCallback()
      }
    }
  })
}
