<block wx:if="{{ bindMobileStatus == 2 }}">
  <view class="login-box">
    <image class="logo" src="/images/wx.jpg" mode="widthFix"></image>
    <view class="line"></view>
    <view class="title">申请获取以下权限</view>
    <view class="profile">授权绑定手机号码</view>
    <view class="btn">
      <van-button type="primary" block round open-type="getPhoneNumber" bind:getphonenumber="getPhoneNumber">绑定手机号码</van-button>
    </view>
  </view>
</block>
<block wx:if="{{ bindMobileStatus == 1 }}">
  <block wx:if="{{ orderType != 'buyNow' }}"> <!-- 购物车 -->
    <van-cell-group wx:for="{{shopList}}" wx:for-item="shop" wx:for-index="shopIndex" wx:key="id" title="{{ shop.name }}">
      <van-card
        wx:for="{{goodsList}}" wx:key="index"
        wx:if="{{ item.shopId == shop.id }}"
        num="{{item.number}}"
        price="{{item.price}}"
        title="{{item.name}}"
        thumb="{{ item.pic }}"
        centered
        >
        <view slot="desc">
          {{item.label}}
          <block wx:for="{{item.sku}}" wx:for-item="option" wx:key="index">
            {{option.optionName}}:{{option.optionValueName}}
          </block>
          <block wx:for="{{item.additions}}" wx:for-item="option" wx:key="index">
            {{option.pname}}:{{option.name}}
          </block>
        </view>
      </van-card>
      <view class="peisong-way" hidden="{{ shop.hasNoCoupons }}">
        <view class="row-box" style="border-bottom:none;">
          <view class="row-label t">使用优惠券</view>
        </view>
        <picker data-sidx="{{ shopIndex }}" bindchange="bindChangeCouponShop" range="{{ shop.coupons }}" range-key="nameExt">
          <view class="row-box" style="border-bottom:none;">      
            <view class="row-label">{{ shop.curCouponShowText }}</view>
            <image class="next" src="/images/icon/next.png"></image>
          </view>
        </picker>
      </view>
    </van-cell-group>
  </block>
  <block wx:else> <!-- 立即购买 -->
    <van-card
      wx:for="{{goodsList}}" wx:key="index"
      num="{{item.number}}"
      price="{{item.price}}"
      title="{{item.name}}"
      thumb="{{ item.pic }}"
      centered
      >
      <view slot="desc">
        {{item.label}}
        <block wx:for="{{item.sku}}" wx:for-item="option" wx:key="index">
          {{option.optionName}}:{{option.optionValueName}}
        </block>
        <block wx:for="{{item.additions}}" wx:for-item="option" wx:key="index">
          {{option.pname}}:{{option.name}}
        </block>
      </view>
    </van-card>
  </block>
  <view class="container-box cell-group">
    <view class="peisong-way">
      <van-cell wx:if="{{shopCarType == 0 && isNeedLogistics > 0}}" title="配送方式">
        <view slot="">
          <radio-group bindchange="radioChange">
            <label class="radio">
              <radio value="kd" checked="{{peisongType == 'kd'}}" /> 快递
            </label>
            <label class="radio">
              <radio value="zq" checked="{{peisongType == 'zq'}}" /> 到店自取
            </label>
          </radio-group>
        </view>
      </van-cell>
      <van-cell wx:if="{{shopCarType == 1}}" title="配送地址" />
      <picker wx:if="{{peisongType == 'zq' && shops}}" bindchange="shopSelect" value="{{shopIndex}}" range="{{shops}}" range-key="name">
        <van-cell title="选择自提门店" value="{{shopIndex == -1 ? '请选择':shops[shopIndex].name}}" required is-link />
      </picker>
      <van-cell wx:if="{{peisongType == 'zq' && shopIndex != -1}}" title="电话" value="{{shops[shopIndex].linkPhone}}" is-link bind:click="callMobile" />
      <van-cell wx:if="{{peisongType == 'zq' && shopIndex != -1}}" title="地址" title-width="64rpx" value="{{shops[shopIndex].address}}" is-link bind:click="goMap" />
      
      <view class="address-box" wx:if="{{peisongType == 'kd' && isNeedLogistics > 0}}">
        <van-cell wx:if="{{!curAddressData}}" icon="add-o" title="新增收货地址" is-link bind:click="addAddress" />
        <view class="show-address" hidden="{{!curAddressData}}" bindtap="selectAddress">
          <view class="l">
            <view class="name-tel">{{curAddressData.linkMan}} {{curAddressData.mobile}}</view>
            <view class="addr-text">{{curAddressData.address}}</view>
          </view>
          <view class="r">
            <image class="next" src="/images/icon/next.png"></image>
          </view>
        </view>
      </view>
      <van-field
        wx:if="{{peisongType == 'zq'}}"
        size="large"
        model:value="{{ name }}"
        label="联系人"
        focus
        clearable
        required
        placeholder="请输入联系人"
      />
      <van-field
        wx:if="{{peisongType == 'zq'}}"
        size="large"
        model:value="{{ mobile }}"
        label="联系电话"
        type="number"
        clearable
        required
        placeholder="请输入手机号码">
        <van-button slot="button" size="small" type="danger" open-type="getPhoneNumber" bind:getphonenumber="getPhoneNumber">自动获取</van-button>
      </van-field>
      <view wx:if="{{shopCarType == 0}}" class="row-box">
        <view class="row-label">备注</view>
        <view class="right-text">
          <input bindinput="remarkChange" type="text" class="liuyan" placeholder="如需备注请输入" />
        </view>
      </view>
      <van-cell wx:if="{{ orderPeriod_open == 1 }}" title="订阅">
        <view slot="">
          <radio-group bindchange="dyChange">
            <label class="radio">
              <radio value="1" checked="{{ dyopen == 1 }}" /> 开启
            </label>
            <label class="radio">
              <radio value="0" checked="{{ dyopen == 0 }}" /> 关闭
            </label>
          </radio-group>
        </view>
      </van-cell>
      <van-cell wx:if="{{ dyopen == 1 }}" title="订阅周期">
        <view slot="">
          <radio-group bindchange="dyunitChange">
            <label class="radio">
              <radio value="0" checked="{{ dyunit == 0 }}" /> 天
            </label>
            <label class="radio">
              <radio value="1" checked="{{ dyunit == 1 }}" /> 月
            </label>
            <label class="radio">
              <radio value="2" checked="{{ dyunit == 2 }}" /> 年
            </label>
          </radio-group>
        </view>
      </van-cell>
      <van-field
        wx:if="{{ dyopen == 1 }}"
        label="订阅间隔"
        model:value="{{ dyduration }}"
        type="number"
        placeholder="请输入数字"
        input-align="right"
        use-button-slot
      >
        <view slot="button">
          {{ dyunit == 0 ? '天': '' }}
          {{ dyunit == 1 ? '月': '' }}
          {{ dyunit == 2 ? '年': '' }}
        </view>
      </van-field>
      <van-field
        wx:if="{{ dyopen == 1 }}"
        label="订阅次数"
        model:value="{{ dytimes }}"
        type="number"
        placeholder="请输入数字"
        input-align="right"
        use-button-slot
      >
        <view slot="button">次</view>
      </van-field>
      <van-field
        wx:if="{{ dyopen == 1 }}"
        label="首次扣费"
        is-link
        readonly
        value="{{ dateStart }}"
        type="number"
        placeholder="请输入数字"
        input-align="right"
        bind:click-input="dateStartclick"
      />
    </view>
    <view class="peisong-way" hidden="{{hasNoCoupons}}">
      <view class="row-box" style="border-bottom:none;">
        <view class="row-label t">使用优惠券</view>
      </view>
      <picker bindchange="bindChangeCoupon" range="{{coupons}}" range-key="nameExt">
        <view class="row-box" style="border-bottom:none;">      
          <view class="row-label">{{curCouponShowText}}</view>
          <image class="next" src="/images/icon/next.png"></image>
        </view>
      </picker>
    </view>
  </view>

  <!-- 选择积分抵扣 -->
  <van-radio-group wx:if="{{ scoreDeductionRules && scoreDeductionRules.length > 0 }}" value="{{ deductionScore }}" bind:change="deductionScoreChange">
    <van-cell-group title="积分抵扣">
      <van-cell title="不使用积分" clickable data-name="0" bind:click="deductionScoreClick">
        <van-radio slot="right-icon" name="0" />
      </van-cell>
      <van-cell wx:for="{{scoreDeductionRules}}" wx:key="id" title="使用{{ item.score }}积分抵扣¥{{ item.money }}" clickable data-name="{{ item.score }}" bind:click="deductionScoreClick">
        <van-radio slot="right-icon" name="{{ item.score }}" />
      </van-cell>
    </van-cell-group>
  </van-radio-group>

  <van-radio-group wx:if="{{ myCards }}" value="{{ cardId }}" bind:change="cardChange">
    <van-cell-group title="使用水卡支付">
      <van-cell title="不使用水卡" clickable data-name="0" bind:click="cardClick">
        <van-radio slot="right-icon" name="0" />
      </van-cell>
      <van-cell wx:for="{{ myCards }}" wx:key="id" title="{{ item.cardInfo.name }} - 剩余：{{ item.amount }}桶" clickable data-name="{{ item.id }}" bind:click="cardClick">
        <van-radio slot="right-icon" name="{{ item.id }}" />
      </van-cell>
    </van-cell-group>
  </van-radio-group>

  <van-cell-group wx:if="{{ yunPrice || deductionMoney || couponAmount || balance }}" title="小计">
    <van-cell wx:if="{{ yunPrice }}" title="运费" value="¥{{yunPrice}}" />
    <van-cell wx:if="{{deductionMoney}}" title="积分抵扣" value="-¥{{deductionMoney}}" />
    <van-cell wx:if="{{couponAmount}}" title="优惠金额" value="-¥{{couponAmount}}" />
    <van-cell wx:if="{{order_pay_user_balance == '1' && balance}}" title="账户余额" value="¥{{balance}}" />
  </van-cell-group>
  <view class="bottom-box"></view>
  <van-submit-bar
    price="{{ allGoodsAndYunPrice*100 }}"
    suffix-label="{{ totalScoreToPay ? '+' + totalScoreToPay + ' 积分' : '' }}"
    button-text="提交订单"
    loading="{{ btnLoading }}"
    bind:submit="goCreateOrder"
  />
</block>

<van-popup
  show="{{ dateStartpop }}"
  position="bottom"
>
  <van-datetime-picker
    type="datetime"
    value="{{ currentDate }}"
    min-date="{{ minDate }}"
    max-date="{{ maxDate }}"
    formatter="{{ formatter }}"
    bind:confirm="dateStartconfirm"
    bind:cancel="dateStartcancel"
  />
</van-popup>