<template>
  <view class="user-center-page">
    <z-paging
        ref="paging"
        v-model="dataList"
        @query="queryList"
        :auto-show-system-loading="true"

    >
      <template #empty>
        <empty-view/>
      </template>
    <up-card
        :border="false"
        :foot-border-top="false"
        v-for="(item,index) in dataList"
        :key="`${item.orderNo}_${index}`"
        :show-head="false"
    >

      <template #body>
        <view class="card-body">
          <view class="u-flex common-item-center common-justify-between" style="margin-top: 5px;">
            <view class="u-line-1" style="flex: 1;margin-right: 20px;color: #333;font-size: 14px;"> {{ item.templateCode || '无' }}</view>
            <view style="color: #030303;font-size: 12px;" >{{ timeFormat(item.createTime, 'yyyy-mm-dd') }}</view>
          </view>
          <view class="u-line-1 "  style="font-size: 13px;color: #848484">
            {{ item.templateContent || '无' }}
          </view>


        </view>
      </template>
    </up-card>
    </z-paging>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import {  onShow } from '@dcloudio/uni-app'
import { getMsg } from '@/api/user'
import { timeFormat } from '@/uni_modules/uview-plus';

const paging = ref(null);
const dataList = ref([]);
// 分页查询列表
const queryList = async (pageNo, pageSize) => {
  try {
    const apiParams = {
      readStatus: false,
      pageNo,
      pageSize,
    };
    const  res = await getMsg(apiParams)
    // 适配z-paging分页
    paging.value.complete(res.list, res.total);
  } catch (error) {
    console.error('加载工单失败：', error);
    paging.value?.complete(false);
    uni.showToast({title:  res.msg||'加载失败，请重试', icon: 'none'});
  }
};

// // 页面显示时检查登录状态
onShow( async () => {
  // 初始化分页数据
  paging.value?.reload()
})
</script>



<style lang="scss" scoped>

</style>
<script setup lang="ts">
</script>