import React, { Component } from "react";
import Taro from "@tarojs/taro";
import { View, Text, Image, Button } from "@tarojs/components";
import Skeleton from "taro-skeleton";
import { getClockState } from "../../utils/tools";
import ListBottomStart from "../../components/common/listBottomStart";
import RevokeWhite from "../../image/revokeWhite.png";
import "./index.less";

class MyList extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <View className="indexPage">
        <View className="elist">
          {
            this.props.list.length === 0 && this.props.listState === "LOADING" &&
            this.props.typelist?.map((v) => (
              <Skeleton key={v} title row={3} avatarShape="square" loading />
            ))
          }
          {this.props.list.length > 0 && this.props.list?.map((v, k) => (
            <View
              key={k}
              className="eitem"
            >
              <View className="einfor">
                <View className="etitle">
                  <View className="ename">
                    {v.nickname}
                  </View>
                  <View className="ecode">
                    <Text onClick={() => {
                      Taro.setClipboardData({
                        data: v.orgCode,
                        success: function (res) {
                          Taro.showToast({
                            title: '复制成功',
                          });
                        }
                      })
                    }}>{v.orgCode}{v.orgCode && " [复制]"}</Text>
                  </View>
                </View>
                <View className="etime"
                  style={{ color: ["red", "green"][v.signBills] }}
                >{["未签单", "已签单"][v.signBills]}
                  {v.signBills == 1 && v.signTime && ("（" + v.signTime + "）")}
                </View>
                <View className="euserName">
                  <View className="euNtext">
                    营销员：{v.adminName}
                  </View>
                </View>
                {
                  !v.latestFollow &&
                  <View className="emore"
                    onClick={e => {
                      e.stopPropagation()
                      this.props.getMore(v)
                    }}>查看更多 ▼</View>
                }
                {
                  !!v.latestFollow &&
                  <View>
                    <View className="euserName">
                      <View className="euNtext">
                        累计公出次数：{v.count}
                      </View>
                    </View>
                    <View className="euserName">
                      <View className="euNtext">
                        首次面谈时间：{!v.minPublicRelease.id ? "无" : (v.minPublicRelease.releaseStart + "【" + v.minPublicRelease.aname + "】")}
                      </View>
                    </View>
                    <View className="euserName">
                      <View className="euNtext">
                        最新公出时间：{!v.maxPublicRelease.id ? "无" : (v.maxPublicRelease.releaseStart + "【" + v.maxPublicRelease.aname + "】")}
                      </View>
                    </View>
                    <View className="euserName">
                      <View className="euNtext">
                        最新跟进时间：{!v.latestFollow.id ? "无" : (v.latestFollow.followTime + "【" + v.latestFollow.followName + "】")}
                      </View>
                    </View>
                  </View>
                }
                {
                  !!v.latestFollow &&
                  <View className="emore"
                    onClick={e => {
                      e.stopPropagation()
                      this.props.onHide(v)
                    }}>收起 ▲</View>
                }
                {
                  <View
                    className="ereject"
                    onClick={e => {
                      e.stopPropagation();
                      Taro.navigateTo({
                        url: "/pages/situation/index?id=" + v.id,
                      });
                    }}
                  >
                    公出情况
                  </View>
                }
                {
                  <View
                    className="eselect"
                    onClick={e => {
                      e.stopPropagation();
                      Taro.navigateTo({
                        url: "/pages/customerProfile/index?id=" + v.id,
                      });
                    }}
                  >
                    客户档案
                  </View>
                }
              </View>
            </View>
          ))}
          <ListBottomStart
            state={this.props.listState}
            reload={() => {
              this.props.onRefresh;
            }}
          />
        </View>
      </View>
    );
  }
}

export default MyList;