subscribe.vue 1.71 KB
<!--
 * @Author: hookehuyr hookehuyr@gmail.com
 * @Date: 2022-04-28 11:37:47
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-06-09 16:13:47
 * @FilePath: /tswj/src/views/me/subscribe.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="book-list">
    <template v-for="(item, key) in items" :key="key">
      <book-card type="C" :item="item" @on-click="go('/client/bookDetail', { id: item.id })"></book-card>
    </template>
  </div>
  <van-empty v-if="emptyStatus"
    class="custom-image"
    :image="no_image"
    description="暂无订阅"
  />
</template>

<script setup>
import no_image from '@images/que-shuju@2x.png'
import BookCard from '@/components/BookCard/index.vue'
import { ref } from 'vue'
import axios from '@/utils/axios';
import { useGo } from '@/hooks/useGo'

const go = useGo()
// 因为不能让空图标提前出来的写法
const emptyStatus = ref(false);

const items = ref([]);
axios.get('/srv/?a=my_subscribe')
  .then(res => {
    if (res.data.code === 1) {
      items.value = res.data.data;
      if (!res.data.data.length) {
        emptyStatus.value = true;
      } else {
        emptyStatus.value = false;
      }
    } else {
      console.warn(res);
      if (!res.data.show) return false;
      Toast({
        icon: 'close',
        message: res.data.msg
      });
    }
  })
  .catch(err => {
    console.error(err);
  });
</script>

<script>
import mixin from 'common/mixin';

export default {
  mixins: [mixin.init],
  data() {
    return {

    }
  },
  mounted() {

  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
</style>