<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="font-size: 14px;margin-top: 5px;">
            <view class="u-line-1" style="flex: 1;margin-right: 20px;color: #333"> {{ item.templateCode || '无' }}</view>
            <view style="color: #000">{{ timeFormat(item.createTime, 'yyyy-mm-dd hh:MM:ss') }}</view>
          </view>
          <view class="u-line-1 ">
            {{ item.templateContent || '无' }}
          </view>


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

<script setup lang="ts">
import { computed,ref } from 'vue'
import { useUserStore } from '@/pinia/user'
import {  onShow } from '@dcloudio/uni-app'
import { getMsg } from '@/api/user'
// 初始化Pinia仓库
const userStore = useUserStore()
import { timeFormat } from '@/uni_modules/uview-plus';
// 计算属性获取用户信息（响应式）
const userInfo = computed(() => userStore.userInfo.user || {})

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 () => {
//   const  res = await getMsg()
// })
</script>



<style lang="scss" scoped>

</style>