<!--pages/score/index.wxml-->

<view wx:if="{{ pageLoaded }}" class="page-view" style="{{ pageStyle }}">
  <mx-page-navigation
    title="{{ pageTitle }}"
    show-back="{{ showBack }}"
    theme="white"
  />

  <view class="head">
    <view class="bg" style="background:{{ themeColor }}"></view>
    <view style="height: {{ navBarHeight }}px;"></view>
    <view class="score">
      <view class="lbl">我的积分</view>
      <view class="val">{{ score }}</view>
    </view>
    <view class="detailbtn" bindtap="onRecordBtnHandler">查看消费记录</view>
  </view>

  <view class="container">
    <view wx:if="{{ !companyId }}">
      <button
        class="companybtn"
        bindtap="onCompanyBtnHandler"
      >选择企业获取积分兑换信息</button>
    </view>
    <block wx:else>
      <mx-card
        title="兑换优惠券"
        more="{{ hasCouponsMore }}"
        theme="box"
        bindmore="onCouponMoreHandler"
      >
        <view wx:if="{{ coupons }}" class="coupon-view">
          <view wx:if="{{ coupons.length }}" class="coupon-items">
            <view
              wx:for="{{ coupons }}"
              wx:key="index"
              class="item"
            >
              <CouponItem model="{{ item }}" />
            </view>
          </view>
          <view wx:elif="{{ !couponsLoading }}" class="empty">暂无优惠券</view>
        </view>
      </mx-card>
      <mx-space/>
      <mx-card title="积分换购" theme="box">
        <view class="product-view">
          <view wx:if="{{ !netId }}">
            <mx-button
              type="primary"
              size="small"
              custom-cls="netbtn"
              bindtap="onNetBtnHandler"
            >请选择网点</mx-button>
          </view>
          <view wx:elif="{{ products.length }}" class="product-items">
            <view
              wx:for="{{ products }}"
              wx:key="index"
              class="item"
            >
              <ProductItem netId="{{ netId }}" model="{{ item }}" />
            </view>
            <view
              wx:if="{{ hasProductsMore }}"
              class="morebtn"
              bindtap="onProductMoreHandler"
            >更多</view>
          </view>
          <view wx:elif="{{ !productsLoading }}" class="empty">暂无商品</view>
        </view>
      </mx-card>
    </block>
  </view>

  <view wx:if="{{ !showBack }}" class="share">
    <button
      class="sharebtn"
      open-type="share"
    >分享给小伙伴</button>
  </view>
</view>
