"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = SSXX;
var _react = _interopRequireWildcard(require("react"));
require("./index.less");
var _olMap = require("@vtx/ol-map");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function SSXX(_ref) {
  var info = _ref.info,
    sxzczzCount = _ref.sxzczzCount;
  var _a, _b;
  var mapRef = (0, _react.useRef)(null);
  var _ref2 = info || {},
    _ref2$geoLocation = _ref2.geoLocation,
    geoLocation = _ref2$geoLocation === void 0 ? {} : _ref2$geoLocation;
  var values = [{
    name: '今日行驶',
    key: 'mileage',
    num: (_a = info === null || info === void 0 ? void 0 : info.mileage) !== null && _a !== void 0 ? _a : 0,
    unit: 'km'
  }, {
    name: '当前速度',
    key: 'gpsSpeed',
    num: (_b = info === null || info === void 0 ? void 0 : info.gpsSpeed) !== null && _b !== void 0 ? _b : 0,
    unit: 'km/h'
  }, {
    name: '生效中处置证',
    key: 'czz',
    num: sxzczzCount !== null && sxzczzCount !== void 0 ? sxzczzCount : 0,
    unit: '张'
  }];
  var mapCenter = (geoLocation === null || geoLocation === void 0 ? void 0 : geoLocation.lngLats) ? geoLocation.lngLats.split(',') : [];
  var mapPoints = [{
    name: info.carCode,
    geometryInfo: {
      type: 'point',
      lngLats: mapCenter,
      coordType: 'wgs84'
    }
  }];
  (0, _react.useEffect)(function () {
    if (mapCenter.length) {
      mapRef.current && mapRef.current.fitView(mapPoints);
    }
  }, [JSON.stringify(geoLocation)]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card-title"
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "jzlj-card-title-text"
  }, "\u5B9E\u65F6\u4FE1\u606F")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card-content"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "ssxx-top"
  }, values.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: item.key,
      style: {
        textAlign: 'center'
      }
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "num"
    }, /*#__PURE__*/_react["default"].createElement("span", null, item.num), /*#__PURE__*/_react["default"].createElement("span", {
      className: "unit"
    }, item.unit)), /*#__PURE__*/_react["default"].createElement("div", {
      className: "name"
    }, item.name));
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "ssxx-map"
  }, /*#__PURE__*/_react["default"].createElement(_olMap.Map, {
    tk: "1adbb6e47668cb33757cd799548bf1f4",
    createdMap: function createdMap(map) {
      mapRef.current = map;
    }
  }, /*#__PURE__*/_react["default"].createElement(_olMap.FeatureLayer, {
    data: mapPoints,
    style: {
      type: 'Marker',
      style: {
        icon: 'CAR',
        color: '#119FFB'
      }
    }
  })))));
}
//# sourceMappingURL=SSXX.js.map
