// 如果url是tab的页面，使用switchTab，否则使用navigateTo
export function goto(url: string) {
  uni.navigateTo({ url, fail: () => uni.switchTab({ url }) })
}
export function showToastBack(label?: string, delta = 1, back = true, backFun?: Function) {
  uni.showToast({
    title: label || '提交成功！',
    duration: 1000,
    icon: 'none',
    success() {
      if (back) {
        setTimeout(() => {
          uni.navigateBack({ delta })
        }, 1000)
      } else {
        setTimeout(() => {
          return backFun?.()
        }, 1000)
      }
    }
  })
}

export function showToast(label?: string, fun?: (res: boolean) => void) {
  uni.showToast({
    title: label || '提交成功！',
    duration: 1000,
    icon: 'none',
    success() {
      setTimeout(() => {
        return fun?.(true)
      }, 1000)
    }
  })
}
