/*
 * @Description:
 * @Author: lanzhisheng
 * @Date: 2022-04-08 11:19:36
 * @LastEditTime: 2022-04-08 16:17:24
 * @LastEditors: lanzhisheng
 */
// 外部活动列表项
import React from "react";
import { View, Image } from "@tarojs/components";
interface Props {
  data: any;
  onClick?: any;
}
const OuterActivityItem = ({ data, onClick }: Props) => {
  const {
    title,
    orgName,
    analyst,
    startTime = "",
    isEnd,
    resourceUrl,
    resourceUrlSmall,
  } = data;

  // console.log("datat====", data);
  //isEnd  0未结束 1结束 -1 已取消（1.3.4） 2预告 3 回放 4进行中
  const judgeAnalyst = () => {
    if (analyst && analyst.length) {
      let str = analyst
        .map((item) => {
          return item.name;
        })
        .join();
      if (str) return " | " + str;
    } else return "";
  };
  const judgeIsend = () => {
    if (isEnd === 0) return { text: "未结束", color: "#666666" };
    if (isEnd === 1) return { text: "结束", color: "#666666" };
    if (isEnd === 2) return { text: "预告", color: "#FF9500" };
    if (isEnd === 3) return { text: "回放", color: "#41A3FF" };
    if (isEnd === 4) return { text: "直播", color: "#E73A3A" };
    return { text: "", color: "" };
  };

  return (
    <View className="outerActivityItem" onClick={() => onClick(data)}>
      <View className="leftContent">
        <Image
          lazyLoad
          src={resourceUrl || resourceUrlSmall}
          className="defaultImg"
        />
        <View
          className="meetingStatus"
          style={{ backgroundColor: judgeIsend().color }}
        >
          {judgeIsend().text}
        </View>
      </View>
      <View className="rightContent">
        <View className="twoLine">{title}</View>
        <View className="text">{orgName + judgeAnalyst()}</View>
        <View className="text">{startTime}</View>
      </View>
    </View>
  );
};
OuterActivityItem.defaultProps = {
  data: { title: "", orgName: "", analyst: [], startTime: "" },
};
export default OuterActivityItem;
