<!--
  信息列表的预览页面， 比如 通知消息的前几条等。
  通用信息
  @author terrfly
  @site https://www.jeequan.com
  @date 2022/11/15 06:18
-->
<template>
  <view class="notice-wrapper">
    <view class="notice-title" v-if="props.tableTitle">
      <view class="notice-news">{{ props.tableTitle }}</view>
      <view class="notice-more flex-center" v-if="props.isShowMoreBtn" @tap="listviewClickFunc(true, null)">
        更多<image src="/static/iconImg/icon-arrow-black.svg" mode="scaleToFill" /></view>
    </view>
    <block v-for="(v, i) in props.dataList" :key="i">
      <view class="notice-main" hover-class="touch-hover" hover-stay-time="150" @tap="listviewClickFunc(false, v)">
        <view class="notice-content single-text-beyond">{{ v[props.fields.title] }}</view>
        <view class="notice-time">{{ v[props.fields.subtitle] }}</view>
      </view>
    </block>
  </view>
</template>

<script setup>
const props = defineProps({
	
  //列表标题 传则展示 不传则移除
  tableTitle: { type: String },
  
  // 数据列表， 默认是按照： { title, subtitle }
  dataList: { type: Array, default: () => [] },
  
  // 约定的字段 
  fields: { type: Object, default: {title: 'title', subtitle: 'subtitle'} },
  
  // 是否显示更多按钮 
  isShowMoreBtn: { type: Boolean, default: true },
  
})
// touchDown 列表点击回调 touchMore点击更多回调
const emits = defineEmits(["click"])


function listviewClickFunc (isClickMore, record) {
  emits('click', isClickMore, record)
}

</script>

<style lang="scss" scoped>
.notice-wrapper {
  width: 680rpx;
  margin: 0 auto;
  background-color: $J-bg-ff;
  border-radius: $J-b-r32;
  .notice-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30rpx;
    height: 102rpx;
    border-bottom: 1rpx solid #ededed;
    .notice-news {
      font-size: 32rpx;
      font-weight: 500;
    }
    .notice-more {
      font-size: 32rpx;
      color: $J-color-t80;
      image {
        width: 42rpx;
        height: 42rpx;
        transform: rotate(90deg);
        margin-left: 5rpx;
      }
    }
  }
  .notice-main {
    padding: 30rpx;
    height: 90rpx;
    .notice-content {
      margin-bottom: 16rpx;
      font-size: 30rpx;
    }
    .notice-time {
      font-size: 26rpx;
      color: $J-color-ta6;
    }
  }
}
</style>
