<template>
  <div class="AppGoodDeeds">
    <template v-if="datas.length > 0">
      <AiCard v-for="(item, i) in datas" :key="i" @click.native="toAdd(item, 1)">
        <template #custom>
          <div class="titles">{{ item.createUserName }}</div>

          <div class="contents">生活中有多少点点滴滴？人生的每一天会有几滴？生活中有那么多点点滴滴，你会记得多少？最难忘的事情是什么？我记得有一…生活中有多少点点滴滴？人生的每一天会有几滴？生活中有那么多点点滴滴，你会记得多少？最难忘的事情是什么？我记得有</div>

          <div class="imgs">
            <img src="./yan.jpg" alt="" v-for="(items, i) in 4" :key="i" />
            <!-- <img :src="items.url" alt="" v-for="(items, i) in item.images" :key="i" @click.stop="previewImage(item.images, items.url)" /> -->
          </div>

          <div class="imgBottom">
            <div>2021_12_17_13_23</div>
            <div class="right">
              <div class="right-left">
                <u-icon name="eye"></u-icon>
                <span class="hint">24</span>
              </div>

              <div class="right-right" @click.stop="toChange">
                <u-icon name="thumb-up" color="red"></u-icon>
                <span class="hint">4</span>
              </div>
            </div>
          </div>
        </template>

        <template #menu>
          <div class="menu" @tap.stop="toAdd(item, 2)">编辑</div>
          <div class="menu" @tap.stop="toDetele(item)">删除</div>
        </template>
      </AiCard>

      <u-loadmore :status="loadmore" color="#999" font-size="24" margin-top="32" margin-bottom="80" />
    </template>

    <AiEmpty description="暂无数据" v-else></AiEmpty>

    <AiFixedBtn :y="740">
      <div class="addBtn iconfont iconfont-iconfangda" @tap.stop="toAdd()" />
    </AiFixedBtn>

    <u-modal v-model="deletShow" content="您确认要结束议题公示？" :show-cancel-button="true" :mask-close-able="true" :show-title="false" @confirm="delet"></u-modal>
  </div>
</template>

<script>
export default {
  name: 'AppGoodDeeds',
  appName: '好人好事',
  components: {},
  props: {},
  data() {
    return {
      datas: [],
      currentTabs: 0,
      current: 1,
      current: 1,
      size: 10,
      pages: 0,
      deletShow: false,
      deletId: '',
    }
  },
  computed: {
    loadmore() {
      return this.pages <= this.current ? 'loading ' : 'nomore'
    },
  },
  watch: {},
  onLoad() {
    this.getList()
  },
  mounted() {},
  methods: {
    getList() {
      this.$http
        .post('/app/appvisitvondolence/list', null, {
          params: {
            size: 6,
            current: this.current,
            areaId: this.areaId,
            title: this.keyword,
          },
        })
        .then((res) => {
          if (res.code == 0) {
            this.datas = this.current > 1 ? [...this.datas, ...res.data.records] : res.data.records
            this.pages = res.data.pages
          }
        })
    },

    toAdd(item, type) {
      if (type == '1') {
        console.log('详情')
        uni.navigateTo({ url: `./Detail?id=${item.id}` })
      }
      if (type == '2') {
        console.log('编辑')
        uni.navigateTo({ url: `./Add?id=${item.id}` })
      }
      if (type == null) {
        console.log('添加')
        uni.navigateTo({ url: `./Add` })
      }
    },

    toDetele(item) {
      this.deletShow = true
      this.deletId = item.id
    },

    delet() {
      this.$http.post(`/app/appvisitvondolence/delete?ids=${this.deletId}`).then((res) => {
        if (res.code == 0) {
          this.$u.toast('删除成功！')
          this.getList()
        }
      })
    },

    toChange() {
      console.log('点赞')
    },
  },
  onReachBottom() {
    this.current = this.current + 1
    this.getList()
  },
}
</script>

<style scoped lang="scss">
uni-page-body {
  height: 100%;
}
.AppGoodDeeds {
  height: 100%;

  ::v-deep .AiCard {
    background: #f3f6f9;
    .start {
      background: #fff;
      padding: 32px;
      border-radius: 16px;
      .titles {
        font-size: 32px;
        font-weight: 500;
        color: #333333;
        margin-bottom: 16px;
      }
      .contents {
        line-height: 1.4;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
      }
      .imgs {
        margin-top: 24px;
        img {
          width: 200px;
          height: 200px;
          margin-right: 8px;
        }
        img:nth-child(3n) {
          margin-right: 0;
        }
      }
      .imgBottom {
        display: flex;
        justify-content: space-between;
        margin-top: 24px;
        .right {
          display: flex;
          justify-content: space-between;

          .right-right,
          .right-left {
            margin-left: 48px;
            .hint {
              margin-left: 8px;
            }
          }
        }
      }
    }
    .mask {
      .moreMenu {
        transform: translate(-175px, 30px);
        .menu {
          text-align: center;
          line-height: 80px;
          width: 192px;
          height: 80px;
          font-size: 28px;
          font-weight: 400;
          color: #333333;
        }
      }
    }
  }

  .AiFixedBtn {
    .movableArea {
      .addBtn {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 96px;
        height: 96px;
        flex-shrink: 0;
        background: $uni-color-primary;
        box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
        font-size: 60px;
        color: #1365dd;
        background: #fff;
        border-radius: 50%;
      }
    }
  }
}
</style>
