import { Apis } from '@/gen/Apis'
import useModel from './model'
import { useWeAppAuthStore } from '@/common'
import { getApiLoading } from '@/common/libraries/apiLoading'
import userLoginStatus from '@/common/libraries/userUserLogin'
import { showToastBack, showToast } from '@/common/libraries/naviHelper'
const auth = useWeAppAuthStore()
export default {
  getShow(id: number) {
    getApiLoading(Apis.Activity.ActivityEnrolls.Show, {
      id
    }).then(res => {
      useModel.showData.value = { ...res.data?.activity, activity_id: res?.data?.id }
      console.log(res)
    })
  },
  handleCancelSignUp() {
    uni.showModal({
      title: '提示',
      content: `您将取消 [${useModel?.showData?.value?.title}]，取消后释放名额?`,
      success(res) {
        if (res.confirm) {
          getApiLoading(Apis.Activity.ActivityEnrolls.Cancelled, {
            id: useModel?.formData?.value?.activity_id
          }).then(res => {
            showToastBack('取消报名成功', 1, true)
            console.log(res)
          })
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  }
}
