// modal
export const modal = async (title:string, content:string, options = {}) => {
  let res = await uni.showModal({
    title,
    content,
    showCancel: true,
    cancelColor: '#999999',
    confirmColor: '#4EB331',
    ...options
  })
  if (res.errMsg === 'showModal:ok') return res.confirm
  else return false
}

// errToast
export const errToast = async (title:string | Record<string,string>, options = {}) => {
  let msg = typeof title === 'string' ? title : ''
  if (typeof title !== 'string' && Object.prototype.toString.call(title).indexOf('Error') > -1) msg = title.message
  return uni.showToast({
    title: msg,
    icon: 'none',
    duration: 3000,
    ...options
  })
}