<template>
  <view class="content">
    <view class="header">
      <image src="/static/attract/u2043.png" alt="" class="header-image" />
    </view>
    <view class="attracts">
      <view class="activity-theme">活动主题</view>

      <view
        class="notice-content-box"
        v-for="(item, index) in attractList"
        :key="index"
        style="justify-content: start"
        @click="goAttractDeatil(item.id, item.time_type)">
	    <view class="maskModal" v-if="item.time_type == 0">
			<text>敬请期待</text>
		</view>
        <image
          :src="item.pic_url"
          mode="aspectFill"
          style="
            width: 112rpx;
            height: 112rpx;
            margin-right: 20rpx;
            border-radius: 10rpx;
          "
        ></image>
        <view
          class="notice-content"
          style="
            width: 75%;
          "
        >
          <view class="notice-content-font">{{ item.title }}</view>
          <view class="attract-content">{{ item.desc }}</view>
          <view
            class="notice-content-time"
            style="margin-top: 20rpx"
            v-if="item.time_type == 1"
            >时间：{{ item.time | globalTime }}</view
          >
          <view class="notice-content-time" style="margin-top: 20rpx" v-else
            >时间：待定</view
          >
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import md5 from "@/common/md5.js";
export default {
  data() {
    return {
      attractList: [
        // {
        //   url: "/static/attract/1.png",
        //   title: "工业互联网",
        //   subtitle: "工业互联网是全球工业系统与高级计算、分析、...",
        //   time: "2021-09-05",
        // },
        // {
        //   url: "/static/attract/2.png",
        //   title: "生产性服务业",
        //   subtitle: "生产性服务业是指为保持工业生产过程的连续性...",
        //   time: "2021-09-05",
        // },
      ],
    };
  },
  onLoad() {
    this.getAttract();
  },
  methods: {
    goAttractDeatil(id, type) {
      if (type == 0) return;
      uni.navigateTo({
        url: "/pages/attract/attract_deatil?id=" + id,
      });
    },
    getAttract() {
      let md5Sign = md5(
        "method=" +
          "common" +
          "&timestamp=" +
          getApp().globalData.globalTimestamp +
          "&secret=" +
          getApp().globalData.secret
      );
      let url =
        getApp().globalData.shareUrl +
        "api/api.php" +
        "?method=common&source=business&action=list&timestamp=" +
        getApp().globalData.globalTimestamp +
        "&sign=" +
        md5Sign;
      let postData = {
        // page: 1,
        // page_size: 5,
      };
      uni.request({
        url: url,
        method: "POST",
        header: {
          "content-type": "application/x-www-form-urlencoded",
        },
        data: postData,
        success: (res) => {
          if (res.data.code === 200) {
            console.log(res.data.data.list);
            res.data.data.list.forEach((item) => {
              item.pic_url = getApp().globalData.shareUrl + item.pic_url;
            });
			this.attractList = res.data.data.list.filter(
			  (item) => item.show != 0
			);
          }
        },
        fail: () => {
          console.log("连接失败");
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.unclick {
  background-color: #bfbfbf !important;
}
.content {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  .header {
    .header-image {
      width: 100%;
      height: 350rpx;
    }
  }
  .attracts {
    display: flex;
    box-sizing: border-box;
    // justify-content: center;
    padding: 80rpx;
    padding-top: 30rpx;
    align-items: center;
    flex-direction: column;
    .activity-theme {
      font-size: 28rpx;
      font-weight: 600;
      border-left: 10rpx solid #02a7f0;
      padding-left: 20rpx;
      width: 100%;
      justify-items: start;
      margin-bottom: 10rpx;
    }
    .notice-content-box {
      width: 100%;
	  position: relative;
      display: flex;
      padding: 30rpx;
      background-color: #ffffff;
      box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
      border-radius: 32rpx;
      margin-top: 20rpx;
      justify-content: space-between;
	  .maskModal {
		width: 100%;
		position: absolute;
		background-color: rgba(0, 0, 0, 0.4);
		border-radius: 32rpx;
		height: 100%;
		top: 0;
		right: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		font-size: 28rpx;
		font-weight: bold;
	  }
      .notice-content-font {
        font-size: 26rpx;
        color: #0d1937;
        font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .attract-content {
        color: #697594;
        font-weight: 600;
        font-size: 20rpx;
        margin-top: 8rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .notice-content-time {
        font-size: 20rpx;
        letter-spacing: 0.02em;
        color: #cfcfcf;
        margin-right: 14rpx;
      }
    }
  }
}
</style>