<!--pages/home/index.wxml-->
<page-meta page-style="{{ show ? 'overflow: hidden;' : '' }}" />

<view>
  <view class="top">
  
  <custom-status-bar transparent="{{true}}" />
  <view class="chooseParkWrapper">
    用电管理服务 · 
    <view class="parkContent" bind:tap="choosePark" wx:if="{{park.id}}">
      <view class="park">
        {{park.name}}
      </view>
      <van-icon name="arrow-down" style="margin-left: 16rpx;" />
    </view>
  </view>
</view>
<custom-status-bar />
  <view class="chooseParkWrapper">
   
  </view>
<view class="login" wx:if="{{!user || !user.id}}" class="notLoginWrapper">
  <van-image width="80rpx" height="80rpx" src="/assets/images/defaultAvatar.png" class="defaultAvatar"/>
  <van-button type="primary" size="small" plain="{{true}}" class="loginBtn" bind:tap="jumpToLogin">请登录</van-button>
</view>
<view class="logined" wx:else>
  <avatar text="{{ user.nickName }}" />
  <view>
    <view class="company" bind:tap="chooseTenement">
      <view class="companyName"> {{tenement.name}}   </view>
      <van-icon name="arrow-down" style="margin-left: 16rpx;" />
    </view>
    <!-- <view class="welcome"> 欢迎使用华昌宝能用电管理系统！ </view> -->
  </view>
</view>
<banner type="{{1}}" wx:if="{{park.id}}" park="{{park.id}}" />
<view class="rechargeWrapper">
  <view class="card">
    <view class="cardTop">
      <view class="cardTopLeft">
        <view wx:if="{{user.id}}"> {{  tenement.shortName}} - {{ meter.address }} </view>
        <view wx:else> -- </view>
      </view>
      <van-button type="info" size="small" plain="{{true}}" class="loginBtn" bind:click="changeMeter" wx:if="{{user.id}}" >
        <view style="width: 160rpx;display: flex;justify-content: center;"><van-icon name="exchange" />
        切换电表</view>
      </van-button>
    </view>
    <view class="cardContent">
      <!-- <view class="cardItem">
        <view class="cardItemLabel"> 电表编号： </view>
        <view class="cardItemValue" wx:if="{{user.id}}"> {{meter.code}} </view>
        <view class="cardItemValue" wx:else> -- </view>
      </view>
      <view class="cardItem">
        <view class="cardItemLabel"> 电表地址： </view>
        <view class="cardItemValue" wx:if="{{user.id}}"> {{meter.address}} </view>
        <view class="cardItemValue" wx:else> -- </view>
      </view> -->
      <view class="cardItem">
        <view class="cardItemLabel"> 电表余额： </view>
        <view class="cardItemValue" style="position: relative;">
          <view class="text"  wx:if="{{user.id}}"> {{meter.money}} </view>
          <view class="text"  wx:else> --- </view>
            <!--     bind:click="refreshMeter" -->
          <van-button 
            type="info" 
            size="small" 
            plain="{{true}}" 
            custom-style="position: absolute; right: -20rpx; bottom: -20rpx;z-index: 99;" 
            wx:if="{{user.id}}"
            bind:click="jumpToMeterList"
          >
            <view style="width: 160rpx;display: flex;justify-content: center;">
            <!-- <van-icon name="replay" /> -->
            查看全部
            <!-- 刷新 -->
            </view>
          </van-button>
        </view>
      </view>
    </view>
  </view>
  <view class="recharge">
    <view> 请输入金额： </view>
    <view class="moneyBox">
      <view class="money" bind:tap="changeMoney" data-money="30"> ￥30 </view>
      <view class="money" bind:tap="changeMoney" data-money="50"> ￥50 </view>
      <view class="money" bind:tap="changeMoney" data-money="100"> ￥100 </view>
      <view class="money" style="margin-right: 0;" bind:tap="changeMoney" data-money="200"> ￥200 </view>
    </view>
    <view class="moneyInput">
      <van-field
        value="{{ money }}"
        placeholder="请输入充值金额"
        border="{{true}}"
        bind:change="onChangeMoney"
        size="large"
        type="digit"
      />
      <van-button color="rgb(88, 165, 141)" bind:click="recharge">
        <view style="width: 100rpx"> 去缴费 </view>
      </van-button>
    </view>
  </view>
  <!-- <view class="operate">

  </view> -->
  <view class="others">
    <van-grid direction="horizontal" column-num="2">
      <van-grid-item icon="balance-list-o" text="电费账单" bind:click="jumpToOrder">
      </van-grid-item>
      <van-grid-item icon="after-sale" text="缴费记录" bind:click="jumpToRecord" />
      <van-grid-item icon="bar-chart-o" text="用电查询" bind:click="jumpToElectric" />
      <van-grid-item icon="bill-o" text="去开票" bind:click="jumpToInvoice" />
    </van-grid>
  </view>

</view>
</view>
<picker show="{{show}}" valueKey="name" columns="{{columns}}" bind:ok="onOk" bind:cancel="onCancel" type="{{pickerType}}" />

<van-action-sheet
  show="{{ rechargeVisible }}"
  actions="{{ actions }}"
  bind:close="onCloseRechargeWay"
  bind:select="onSelectRechargeWay"
/>
