'use strict'
!(function(require, directRequire) {
  const a = require('react'),
    b = require('./3b5f8e2469c474c8d433c1c6926d8999.js'),
    c = require('./df6d0ff021a69fb541c733de4dbba0fe.js'),
    d = require('./NavigationBar.js'),
    e = require('./4389a88e405d1d37f36c16fc0ec96540.js')
  class f extends a.Component {
    constructor(a) {
      super(a), (this.state = { showDetails: !1, cardIndex: -1 })
    }
    componentWillReceiveProps() {}
    formatTime(a) {
      let b = new Date(1e3 * a)
      return `${b.getFullYear()}.${b.getMonth() + 1}.${b.getDate()}`
    }
    onDetailClick() {
      this.props.cardInfo && 1 < this.props.cardInfo.length
        ? this.setState({ showDetails: !1, cardIndex: -1 })
        : this.props.hideCardView({})
    }
    cancel() {
      this.props.hideCardView({})
    }
    cardDetail(a) {
      let b = a.currentTarget,
        c = b.dataset,
        d = c.index
      this.setState({ showDetails: !0, cardIndex: d })
    }
    render() {
      let c = this.props,
        f = c.show ? {} : b.displayNone
      ;(f.width = c.width),
        (f.height = c.height),
        (f.transform = `scale(${c.deviceScale})`),
        (f.marginLeft = -c.width / 2),
        (f.transformOrigin = '50% 0')
      let g = null,
        h = null,
        i = c.cardInfo,
        j = c.errData,
        k = !!j.length,
        l = this.state.showDetails
      if (-1 != this.state.cardIndex) {
        let b,
          e = i[this.state.cardIndex],
          f = e.card_data_info,
          j = e.card_tp_info,
          k = this.formatTime(f.begin_time),
          l = this.formatTime(f.end_time),
          m = j.brand_name,
          n = j.title,
          o = j.logo_url,
          p = {}
        ;(p.backgroundColor = j.color),
          (b =
            0 === j.limit_num
              ? a.createElement(
                  'div',
                  { className: 'coupons-profile-action' },
                  a.createElement(
                    'button',
                    {
                      className: 'coupons-profile-button',
                      style: { borderColor: '#63B35A', color: '#63B35A' }
                    },
                    j.limit_wording
                  )
                )
              : a.createElement(
                  'div',
                  { className: 'coupons-profile-action' },
                  a.createElement(
                    'button',
                    {
                      className: 'coupons-profile-button',
                      style: { borderColor: '#63B35A', color: '#63B35A' }
                    },
                    (f.operate_field && f.operate_field.title) ||
                      '\u67E5\u770B\u8BE6\u60C5'
                  )
                )),
          (h = a.createElement(d, {
            height: c.navigationbarHeight,
            title: '\u5361\u5238\u5217\u8868',
            backgroundColor: '#000000',
            frontColor: '#ffffff',
            showLeftBtn: !0,
            onLeftBtnClick: this.onDetailClick.bind(this)
          })),
          (g = a.createElement(
            'div',
            { className: 'coupons-detail' },
            a.createElement(
              'div',
              { className: 'coupons-profile-wrapper' },
              a.createElement(
                'div',
                { className: 'coupons-profile', style: p },
                a.createElement(
                  'div',
                  { className: 'coupons-profile-bd' },
                  a.createElement(
                    'div',
                    { className: 'ui-flex' },
                    a.createElement(
                      'div',
                      { className: 'coupons-profile-logo' },
                      a.createElement('img', { src: o })
                    ),
                    a.createElement(
                      'div',
                      { className: 'ui-flex-item' },
                      a.createElement(
                        'p',
                        { className: 'coupons-profile-biz' },
                        m
                      ),
                      a.createElement(
                        'p',
                        { className: 'coupons-profile-name' },
                        n
                      )
                    )
                  )
                ),
                a.createElement(
                  'div',
                  { className: 'coupons-profile-ft' },
                  a.createElement(
                    'p',
                    { className: 'coupons-profile-serial' },
                    '\u6709\u6548\u671F: ',
                    k,
                    '-',
                    l
                  )
                )
              ),
              b
            )
          ))
      } else {
        let b = i.map((b, c) => {
            let d = b.card_tp_info
            return a.createElement(
              'div',
              {
                className: 'coupons-item ui-flex',
                key: c,
                'data-index': c,
                onClick: this.cardDetail.bind(this)
              },
              a.createElement(
                'div',
                { className: 'coupons-item-logo' },
                a.createElement('img', { src: d.logo_url })
              ),
              a.createElement(
                'div',
                { className: 'ui-flex-item' },
                a.createElement(
                  'p',
                  { className: 'coupons-item-biz' },
                  d.brand_name
                ),
                a.createElement(
                  'p',
                  { className: 'coupons-item-name' },
                  d.title
                )
              )
            )
          }),
          e = j.map((b, c) => {
            return a.createElement(
              'div',
              { key: c, className: 'webview-card-choose-item' },
              a.createElement(
                'div',
                { className: 'webview-card-choose_mErr' },
                a.createElement(
                  'div',
                  { className: 'webview-card-choose_details' },
                  a.createElement(
                    'div',
                    { className: 'webview-card-choose-item_error' },
                    '\u9519\u8BEF\u5361\u5238'
                  ),
                  a.createElement(
                    'div',
                    { className: 'webview-card-choose-item_error' },
                    'cardId: ',
                    b.card_id
                  ),
                  a.createElement(
                    'div',
                    { className: 'webview-card-choose-item_error' },
                    'code: ',
                    b.code
                  )
                )
              )
            )
          })
        ;(h = a.createElement(d, {
          height: c.navigationbarHeight,
          title: '\u5361\u5238\u5217\u8868',
          backgroundColor: '#000000',
          frontColor: '#ffffff',
          showLeftBtn: !0,
          onLeftBtnClick: this.cancel.bind(this)
        })),
          (g = a.createElement('div', { className: 'coupons-list' }, b, e))
      }
      return a.createElement(
        'div',
        { className: 'simulator', style: f },
        a.createElement(e, null),
        h,
        a.createElement(
          'div',
          { className: 'webview' },
          a.createElement('div', { className: 'coupons' }, g)
        )
      )
    }
  }
  module.exports = f
})(require('lazyload'), require)
