"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = pageTitle;

var _react = _interopRequireDefault(require("react"));

var _IconBase = require("../../../../assets/IconBase64");

var _androidUtil = require("../../../../utils/androidUtil");

var _commonUtil = require("../../../../utils/commonUtil");

require("./index.less");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function pageTitle(props) {
  var _props$data = props.data,
      data = _props$data === void 0 ? {} : _props$data;

  var onShare = function onShare() {
    if ((0, _androidUtil.browserVersion)().isApp && (0, _androidUtil.browserVersion)().ios) {
      (0, _androidUtil.sendToIos)({
        type: 'SHARE'
      });
      return;
    }

    window.MParams && window.MParams.api && window.MParams.api.showShareModal();
  };

  var onBack = function onBack() {
    if ((0, _androidUtil.browserVersion)().isApp && (0, _androidUtil.browserVersion)().android) {
      (0, _androidUtil.sendToAndroid)({
        type: 'onBack',
        params: {}
      });
      return;
    }

    if ((0, _androidUtil.browserVersion)().isApp && (0, _androidUtil.browserVersion)().ios) {
      (0, _androidUtil.sendToIos)({
        type: 'BACK'
      });
      return;
    }

    (0, _commonUtil.navigateTo)('/main/home');
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "page-title-wrap"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "header-inner",
    style: _objectSpread({
      backgroundColor: '#FFF'
    }, props.style)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "header-back",
    onClick: onBack
  }, /*#__PURE__*/_react["default"].createElement("img", {
    className: "back",
    alt: "back",
    src: _IconBase.backIcon
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "title"
  }, data.icon && /*#__PURE__*/_react["default"].createElement("img", {
    alt: "",
    src: data.icon
  }), /*#__PURE__*/_react["default"].createElement("span", null, data.pageName)), /*#__PURE__*/_react["default"].createElement("img", {
    className: "share",
    alt: "share",
    src: _IconBase.shareIcon,
    onClick: onShare
  })));
}