'use strict'
!(function(require, directRequire) {
  const a = require('react'),
    b = require('./3b5f8e2469c474c8d433c1c6926d8999.js'),
    c = require('./NavigationBar.js'),
    d = require('./4389a88e405d1d37f36c16fc0ec96540.js')
  class e extends a.Component {
    constructor(a) {
      super(a)
    }
    componentWillReceiveProps() {}
    formatTime(a) {
      let b = new Date(1e3 * a)
      return `${b.getFullYear()}.${b.getMonth() + 1}.${b.getDate()}`
    }
    batchAddCard() {
      let a = this.props,
        b = a.args,
        c = b.cardList || [],
        d = []
      for (let a, b = 0; b < c.length; b++)
        (a = c[b]),
          d.push({ card_id: a.card_id, card_ext: a.card_ext, is_succ: 1 })
      this.props.batchAddCard({
        callbackID: a.callbackID,
        runtimeID: this.props.runtimeID,
        list: d
      })
    }
    cancel() {
      this.props.hideCardView({
        callbackID: this.props.callbackID,
        runtimeID: this.props.runtimeID,
        res: { errMsg: `addCard:cancel` }
      })
    }
    render() {
      let e = this.props,
        f = e.show ? {} : b.displayNone
      ;(f.width = e.width),
        (f.height = e.height),
        (f.backgroundColor = '#63B35A'),
        (f.transform = `scale(${e.deviceScale})`),
        (f.marginLeft = -e.width / 2),
        (f.transformOrigin = '50% 0')
      let g = e.cardInfo || [],
        h = '',
        i = g.map((b, c) => {
          if (b.errmsg)
            return a.createElement(
              'div',
              { className: 'ui-flex', key: c },
              a.createElement(
                'div',
                { className: 'coupons-card-logo' },
                a.createElement('img', { src: i })
              ),
              a.createElement(
                'div',
                { className: 'ui-flex-item' },
                a.createElement(
                  'p',
                  { className: 'coupons-card-biz' },
                  '\u9519\u8BEF\u7684\u5361\u5238'
                ),
                a.createElement(
                  'p',
                  { className: 'coupons-card-name' },
                  'cardId: ',
                  b.card_id
                ),
                a.createElement(
                  'p',
                  { className: 'coupons-valid' },
                  'errmsg: ',
                  b.errmsg
                )
              )
            )
          let d = b.card_tp_info,
            e = d.brand_name,
            g = d.title,
            i = d.logo_url,
            j = b.card_data_info,
            k = this.formatTime(d.begin_time),
            l = this.formatTime(d.end_time)
          return (
            0 == j.limit_num && (h = d.limit_wording),
            (f.backgroundColor = d.color),
            a.createElement(
              'div',
              { className: 'ui-flex', key: c },
              a.createElement(
                'div',
                { className: 'coupons-card-logo' },
                a.createElement('img', { src: i })
              ),
              a.createElement(
                'div',
                { className: 'ui-flex-item' },
                a.createElement('p', { className: 'coupons-card-biz' }, e),
                a.createElement(
                  'p',
                  { className: 'coupons-card-name' },
                  g,
                  ' ',
                  a.createElement(
                    'span',
                    { className: 'coupons-card-counter' },
                    'x',
                    b.amount
                  )
                ),
                a.createElement(
                  'p',
                  { className: 'coupons-valid' },
                  k,
                  ' - ',
                  l
                )
              )
            )
          )
        })
      return a.createElement(
        'div',
        { className: 'simulator', style: f },
        a.createElement(d, { backgroundColor: f.backgroundColor }),
        a.createElement(c, {
          height: e.navigationbarHeight,
          title: '\u6DFB\u52A0\u5361\u5377',
          backgroundColor: f.backgroundColor,
          frontColor: '#ffffff',
          showLeftBtn: !0,
          onLeftBtnClick: this.cancel.bind(this)
        }),
        a.createElement(
          'div',
          { className: 'webview' },
          a.createElement(
            'div',
            { className: 'coupons' },
            a.createElement(
              'div',
              {
                className: 'coupons-chooser',
                style: { backgroundColor: f.backgroundColor }
              },
              a.createElement(
                'div',
                { className: 'coupons-card' },
                a.createElement('div', { className: 'coupons-card-bd' }, i),
                h
                  ? a.createElement(
                      'div',
                      { className: 'coupons-card-ft' },
                      a.createElement(
                        'button',
                        {
                          className: 'coupons-card-button disabled',
                          style: { backgroundColor: f.backgroundColor }
                        },
                        h
                      )
                    )
                  : a.createElement(
                      'div',
                      {
                        className: 'coupons-card-ft',
                        onClick: this.batchAddCard.bind(this)
                      },
                      a.createElement(
                        'button',
                        {
                          className: 'coupons-card-button',
                          style: { backgroundColor: f.backgroundColor }
                        },
                        '\u9886\u53D6\u5230\u5361\u5305'
                      )
                    )
              )
            )
          )
        )
      )
    }
  }
  module.exports = e
})(require('lazyload'), require)
