/*
 * @Description:
 * @Author: jiass
 * @Date: 2022-01-25 13:29:21
 * @LastEditTime: 2022-04-08 16:17:39
 * @LastEditors: lanzhisheng
 */
import React, { FC } from "react";
import { View, Text } from "@tarojs/components";

interface propsType {
  data: any;
  onClick: any;
}

const SharesView: FC<propsType> = (props) => {
  const { data, onClick } = props;

  const handleGo = (item) => {
    onClick(item);
  };

  const getMarketColor = (val: any) => {
    switch (val) {
      case 0:
        return "#66b3ff";
        break;
      case 1:
        return "#ec5562";
        break;
      case 2:
        return "#ec5562";
        break;
      case 3:
        return "#ca68dd";
        break;
      case 4:
        return "#e58247";
        break;
      case 5:
        return "#ca68dd";
        break;
      case 6:
        return "#1d8feb";
        break;
      case 7:
        return "#e58247";
        break;
      case 8:
        return "#ec5562";
        break;
      case 9:
        return "#ec5562";
        break;
      default:
        "";
        break;
    }
  };

  //推荐股票类型
  const getMarketType = (val) => {
    switch (val) {
      case 0:
        return "";
        break;
      case 1:
        return "SH";
        break;
      case 2:
        return "SZ";
        break;
      case 3:
        return "HK";
        break;
      case 4:
        return "科";
        break;
      case 5:
        return "债";
        break;
      case 6:
        return "申万";
        break;
      case 7:
        return "基金";
        break;
      case 9:
        return "京";
        break;
      default:
        "";
        break;
    }
  };

  return (
    <View
      className="tbodyContent"
      onClick={() => {
        handleGo(data);
      }}
    >
      <View className="Stock_title">
        <View className="Stock_name">{data?.secuAbbr}</View>
        <View className="Stock_tips">
          <Text style={{ background: getMarketColor(data?.marketType) }}>
            {getMarketType(data?.marketType)}
          </Text>
          {data?.secuCode}
        </View>
      </View>
    </View>
  );
};
export default SharesView;
