<template>
  <tabbar :titles='["全部","未使用","已使用"]' :indicator-color='"#D95554"' @change='args => {}' />
  <scroll-view :scroll-y='true' class='content'>
    <coupon-item v-for='item in coupons' :item='item' />
  </scroll-view>
</template>

<script lang='ts' setup>

import CouponItem from './components/coupon-item.vue';
import { getCouponList } from '@/api/user';
import { useUserStore } from '@/store';

const store = useUserStore();
const { userInfo } = storeToRefs(store);

const coupons = ref([{
  id: 1,
  title: '优惠券',
  desc: '满100减10',
  price: 100,
  threshold: 10,
  priceDesc: '满100减10',
  useTime: '2021-12-31',
  status: 1,
  useStatus: '未使用'
}, {
  id: 1,
  title: '优惠券',
  desc: '满100减10',
  price: 200,
  threshold: 80,
  priceDesc: '满100减10',
  useTime: '2021-01-01',
  status: 1,
  useStatus: '未使用'
}, {
  id: 1,
  title: '优惠券',
  desc: '满100减10',
  price: 300,
  threshold: 60,
  priceDesc: '满100减10',
  useTime: '2023-12-31',
  status: '0',
  useStatus: '未使用'
}, {
  id: 1,
  title: '优惠券',
  desc: '满100减10',
  price: 50,
  threshold: 50,
  priceDesc: '满100减10',
  useTime: '2021-10-31',
  status: 0,
  useStatus: '未使用'
}, {
  id: 1,
  title: '优惠券',
  desc: '满1000减30',
  price: 200,
  threshold: 30,
  priceDesc: '满100减10',
  useTime: '2024-12-31',
  status: 0,
  useStatus: '未使用'
}]);

onLoad(async () => {
  const { data } = await getCouponList({
    obj: {
      memberId: userInfo.value?.id, status: 0
    }, pageNum: 1, pageSize: 1000
  });
  coupons.value = data.list;
});
</script>

<style lang='scss' scoped>

</style>
