import { Block, View, Image, Text, CoverView } from "@tarojs/components";
import "./FR200.less";

interface Props {
  // isShowNurse: boolean;
  currentWorkModeType: number; // 当前工作模式  1：基础脸部等，只有结束按钮 2.促渗，可以开始暂停和结束 3.水分测试
  isStopNurse: boolean;
  isRuningTest: any; // 是否在运行测试  1是启动，2进行中，3重新检测，4检测完成
  onEmitStartNurse: Function; // 每次点击item，回调事件和数据给父组件
  onEmitSwitchChange: Function;
  onEmitEndPlan: Function;
  onsuccess: Function;
}
function Index({
  currentWorkModeType,
  isStopNurse,
  isRuningTest,
  onEmitStartNurse,
  onEmitSwitchChange,
  onEmitEndPlan,
  onsuccess,
}: Props) {
  const onStartNurse = () => {
    onEmitStartNurse();
  };

  const onSwitchChange = () => {
    onEmitSwitchChange();
  };

  const onEndPlan = () => {
    onEmitEndPlan();
  };
  const onSuccessNurse = () => {
    onsuccess();
  };

  return (
    <Block>
      <View className="iot-footer">
        {currentWorkModeType === 3 && (
          <Block>
            {isRuningTest === 1 ? (
              <View className="btn" onClick={onStartNurse}>
                启动检测
              </View>
            ) : isRuningTest === 2 ? (
              <View className="btn">检测中...</View>
            ) : isRuningTest === 3 ? (
              <View className="btn" onClick={onStartNurse}>
                重新检测
              </View>
            ) : (
              <View className="btn" onClick={onSuccessNurse}>
                检测完成
              </View>
            )}
          </Block>
        )}

        {currentWorkModeType === 2 && (
          <View className="switch-btn-box">
            <View className="btn-item border-right" onClick={onSwitchChange}>
              {isStopNurse ? (
                <Block>
                  <Image
                    className="btn-icon"
                    src={require("@/img/iot/start_nurse.png")}
                    mode="aspectFill"
                  />
                  <Text className="btn-text">启动光照</Text>
                </Block>
              ) : (
                <Block>
                  <Image
                    className="btn-icon"
                    src={require("@/img/iot/pause_nurse.png")}
                    mode="aspectFill"
                  />
                  <Text className="btn-text">暂停光照</Text>
                </Block>
              )}
            </View>

            <View className="btn-item" onClick={onEndPlan}>
              <Image
                className="btn-icon"
                src={require("@/img/iot/over_nurse.png")}
                mode="aspectFill"
              />
              <Text className="btn-text">结束护理</Text>
            </View>
          </View>
        )}

        {currentWorkModeType === 1 && (
          <View className="switch-btn-box">
            <View className="btn-item" onClick={onEndPlan}>
              <Image
                className="btn-icon"
                src={require("@/img/iot/over_nurse.png")}
                mode="aspectFill"
              />
              <Text className="btn-text">结束护理</Text>
            </View>
          </View>
        )}
      </View>
    </Block>
  );
}

export default Index;
