var g = Object.defineProperty
var o = Object.getOwnPropertySymbols
var r = Object.prototype.hasOwnProperty,
  u = Object.prototype.propertyIsEnumerable
var d = (t, s, e) =>
    s in t
      ? g(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e })
      : (t[s] = e),
  p = (t, s) => {
    for (var e in s || (s = {})) r.call(s, e) && d(t, e, s[e])
    if (o) for (var e of o(s)) u.call(s, e) && d(t, e, s[e])
    return t
  }
var c = (t, s) => {
  var e = {}
  for (var a in t) r.call(t, a) && s.indexOf(a) < 0 && (e[a] = t[a])
  if (t != null && o)
    for (var a of o(t)) s.indexOf(a) < 0 && u.call(t, a) && (e[a] = t[a])
  return e
}
import { s as f, C as L, r as j } from './index.9e4b607f.js'
import {
  d as m,
  a as i,
  M as y,
  x,
  F as C,
  v as A,
  w as n
} from './vendor.3506a68e.js'
/* empty css               */ /* empty css              */ /* empty css               */ import {
  s as h,
  I as E
} from './item.c80360f7.js'
import { a as b } from './hooks.6a14d51f.js'
/* empty css               */ function I(t) {
  return (
    typeof t == 'function' ||
    (Object.prototype.toString.call(t) === '[object Object]' && !x(t))
  )
}
var l = m({
    name: 'coupon-list',
    props: { useState: { type: String, default: 'USABLE' } },
    data() {
      return {
        list: [],
        listState: { dataShow: !0, loading: !1, finished: !1 },
        params: { useState: this.useState, page: 1, rows: 20 }
      }
    },
    mounted() {
      this.getList()
    },
    methods: {
      async getList() {
        try {
          const t = await b(
              `${f.platformApi}/couponInfo/page`,
              p({ params: this.params, list: this.list }, this.listState)
            ),
            { params: e, list: a } = t,
            S = c(t, ['params', 'list'])
          ;(this.params = e), (this.list = a), (this.listState = S)
        } catch {}
      }
    },
    render() {
      let t
      return i(C, null, [
        this.listState.dataShow
          ? i(
              y,
              {
                loading: this.listState.loading,
                'onUpdate:loading': s => (this.listState.loading = s),
                finished: this.listState.finished,
                finishedText: ' ',
                class: [this.list.length > 0 && h.list],
                onLoad: this.getList,
                immediateCheck: !1
              },
              I((t = this.list.map(s => i(E, { item: s }, null))))
                ? t
                : { default: () => [t] }
            )
          : i(
              L,
              {
                btnStatus: !1,
                classImgSize: 'SMALL',
                tips: '\u6682\u65E0\u4F18\u60E0\u5238'
              },
              null
            )
      ])
    }
  }),
  F = m({
    name: 'coupon-container',
    data() {
      return { couponCount: { total: 0, useState: 'USABLE' } }
    },
    async mounted() {
      try {
        const t =
            f.platformType === 'STUDENT' ? '/api-student' : '/api-teacher',
          e = (await j.get(`${t}/couponInfo/statInfo`)).data || []
        ;(this.couponCount = e.find(a => a.useState === 'USABLE')),
          console.log(e.find(a => a.useState === 'USABLE'))
      } catch {}
    },
    render() {
      return i('div', { class: h.coupons }, [
        i(
          A,
          { color: '#01C1B5', lineWidth: 44, sticky: !0 },
          {
            default: () => [
              i(
                n,
                {
                  title: `\u53EF\u4F7F\u7528${
                    this.couponCount.total > 0
                      ? '(' + this.couponCount.total + '\u5F20)'
                      : ''
                  }`
                },
                { default: () => [i(l, null, null)] }
              ),
              i(
                n,
                { title: '\u5DF2\u4F7F\u7528' },
                { default: () => [i(l, { useState: 'USED' }, null)] }
              ),
              i(
                n,
                { title: '\u5DF2\u5931\u6548' },
                { default: () => [i(l, { useState: 'EXPIRED' }, null)] }
              )
            ]
          }
        )
      ])
    }
  })
export { F as default }
