function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useEffect, useState } from 'react';
import apis from '../../constants/api';
import request from '../../utils/ajax';
import './index.less';
import banner from './imgs/banner.png';
import img1 from './imgs/img-1.png';
import img2 from './imgs/img-2.png';
import img3 from './imgs/img-3.png';
import img4 from './imgs/img-4.png';
import img5 from './imgs/img-5.png';
import img6 from './imgs/img-6.png';
import img7 from './imgs/img-7.png';
import img8 from './imgs/img-8.png';
import img9 from './imgs/img-9.png';
import img10 from './imgs/img-10.png';
import img11 from './imgs/img-11.png';
import img12 from './imgs/img-12.png';
var DataOpen = function DataOpen() {
  var classPrefix = 'open-data';
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    list = _useState2[0],
    setList = _useState2[1];
  var imgList = [img1, img2, img3, img4, img5, img6, img7, img8, img9, img10, img11, img12];
  var getList = function getList() {
    request(apis.getOpenDataList, {
      method: 'get'
    }).then(function (res) {
      if (!res) throw new Error();
      setList(res.data);
    }).catch(function (err) {
      console.error('失败', err);
    });
  };
  useEffect(function () {
    getList();
  }, []);
  var clickHandle = function clickHandle(url) {
    url && window.open(url);
  };
  var _useState3 = useState(''),
    _useState4 = _slicedToArray(_useState3, 2),
    tooltip = _useState4[0],
    setTooltip = _useState4[1];
  return /*#__PURE__*/React.createElement("div", {
    className: classPrefix
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-banner")
  }, /*#__PURE__*/React.createElement("img", {
    src: banner
  }), /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-banner-desc")
  }, /*#__PURE__*/React.createElement("p", null, "\u8BF8\u845B\u667A\u80FD\u5F00\u653E\u5E73\u53F0"), /*#__PURE__*/React.createElement("p", null, "\u8BF8\u845B\u667A\u80FD\u5F00\u653E\u5E73\u53F0\u63D0\u4F9B\u4E86\u5927\u91CF\u7684\u5F00\u653EAPI\u4F9B\u60A8\u5E94\u7528\uFF0C\u6211\u4EEC\u5728\u8BBE\u8BA1\u7684\u6BCF\u4E00\u6B65\u90FD\u5F3A\u8C03\u4E86\u7075\u6D3B\u6027\u548C\u6807\u51C6\u9075\u4ECE\u6027\uFF0C\u4F7F\u7528\u7B80\u5355\u4E14\u573A\u666F\u4E30\u5BCC\u3002"), /*#__PURE__*/React.createElement("p", null, "\u540C\u65F6\uFF0C\u4E3A\u4E86\u83B7\u5F97\u6700\u5927\u5B89\u5168\u6027\uFF0C\u4E0D\u652F\u6301\u4F7F\u7528\u975E\u52A0\u5BC6HTTP\u4E0A\u7684API\u3002"), /*#__PURE__*/React.createElement("p", null, "\u5728\u4F7F\u7528API\u524D\uFF0C\u60A8\u9700\u8981\u5148\u6210\u4E3A\u8BF8\u845B\u667A\u80FD\u7684\u4EA7\u54C1\u7528\u6237\uFF0C\u7528\u4F5C\u8EAB\u4EFD\u7684\u9A8C\u8BC1\u3002"))), /*#__PURE__*/React.createElement("div", {
    className: "".concat(classPrefix, "-content clearfix")
  }, list.map(function (item, index) {
    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(classPrefix, "-content-item"),
      onClick: function onClick() {
        return clickHandle(item.url);
      },
      onMouseOver: function onMouseOver() {
        return setTooltip(item.name);
      },
      onMouseLeave: function onMouseLeave() {
        return setTooltip('');
      }
    }, /*#__PURE__*/React.createElement("img", {
      src: imgList[index]
    }), /*#__PURE__*/React.createElement("p", {
      className: "dest-title"
    }, item.name), /*#__PURE__*/React.createElement("p", {
      className: "description"
    }, item.description), tooltip === item.name && /*#__PURE__*/React.createElement("p", {
      className: "tooltip-plus ".concat(item.url === '' ? 'empty-tips' : '')
    }, item.description));
  })));
};
export default DataOpen;