'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _fdx = require('@whalecloud/fdx');

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

var GoodsTags = function (_React$Component) {
    (0, _inherits3['default'])(GoodsTags, _React$Component);

    function GoodsTags() {
        (0, _classCallCheck3['default'])(this, GoodsTags);

        var _this = (0, _possibleConstructorReturn3['default'])(this, (GoodsTags.__proto__ || Object.getPrototypeOf(GoodsTags)).apply(this, arguments));

        _this.zyIcon = require('../imgs/store.svg');
        _this.msIcon = require('../imgs/second.svg');
        _this.shipIcon = require('../imgs/free.svg');
        _this.couponIcon = require('../imgs/coupon.svg');
        return _this;
    }

    (0, _createClass3['default'])(GoodsTags, [{
        key: 'render',
        value: function render() {
            var data = this.props.data;

            var iconType = {
                '自营': this.zyIcon,
                '免邮': this.shipIcon,
                '秒杀': this.msIcon,
                '优惠券': this.couponIcon
            };
            return _react2['default'].createElement(
                'div',
                { className: 'goods-tags-wrap' },
                _react2['default'].createElement(
                    _fdx.Row,
                    { type: 'flex', align: 'middle' },
                    data && data.map(function (tag, index) {
                        return _react2['default'].createElement(
                            _fdx.Popover,
                            { key: tag.id + index, content: tag && tag.description, title: '', trigger: 'hover', placement: 'bottom' },
                            tag.url ? _react2['default'].createElement('img', { className: 'ml6', src: tag.url, alt: tag.name }) : iconType[tag.name] ? _react2['default'].createElement('img', { className: 'ml6', src: iconType[tag.name], alt: tag.name }) : _react2['default'].createElement(
                                _fdx.Tag,
                                { className: 'goods-tag', color: tag && tag.color },
                                tag.name
                            )
                        );
                    })
                )
            );
        }
    }]);
    return GoodsTags;
}(_react2['default'].Component);

exports['default'] = GoodsTags;
module.exports = exports['default'];