<template>
  <view>
		<navbar title="我的钱包" leftClick @leftClick="$utils.navigateBack" />

    <view class="content">
      <view class="card overview">
        <image class="bg" src="../static/center/overview-bg.png"></image>

        <view class="overview-info">
          <view class="flex user-info">
            <image class="avatar" :src="userInfo.headImage"></image>
            <text class="nick-name">{{ userInfo.nickName }}</text>
          </view>
          <view class="account">
            <view class="account-count">{{ `￥${userInfoVip.money}` }}</view>
            <view class="account-desc">可提现余额（元）</view>
          </view>
        </view>
        
        <button class="flex btn-withdraw" @click="$utils.navigateTo('/pages_order/mine/withdraw')">
          <text>去提现</text>
          <image class="btn-withdraw-arrow" src="../static/center/arrow.png"></image>
        </button>

        <view class="flex overview-summary">
            <view>总收益：<text class="highlight">{{ `￥${userInfoVip.sum_money}` }}</text></view>
            <view>已提现：<text class="highlight">{{ `￥${userInfoVip.get_money}` }}</text></view>
        </view>
      </view>
      <view class="detail">
        <view class="flex detail-header">
          <view class="detail-title">
            <image class="bg" src="../static/center/title-bg.png"></image>
            <text class="text">收支明细</text>
          </view>
          <view class="detail-tools">
            <uv-calendars ref="calendars" @confirm="onSelectDate" />
            <button plain class="flex btn-calendar" @click="openCalendars">
              <text>{{ queryParams.time || '日期选择' }}</text>
              <image class="btn-calendar-arrow" src="../static/center/down.png"></image>
            </button>
          </view>
        </view>
        <view class="detail-list">
          <view class="card detail-list-item"
            v-for="item in list"
            :key="item.id"
          >
            <view class="flex detail-list-item-row highlight">
              <text>{{ item.title }}</text>
              <!-- status: 0-收 1-支 -->
              <template v-if="item.type === 0">
                <text class="count count-in">{{ `+${item.price}` }}</text>
              </template>
              <template v-else>
                <text class="count count-out">{{ `-${item.price}` }}</text>
              </template>
            </view>
            <view class="flex detail-list-item-row">
              <text>{{ item.createTime }}</text>
              <text>{{ `余额：${item.money || 0}` }}</text>
            </view>
          </view>
        </view>
      </view>
    </view>

  </view>
</template>

<script>
	import { mapState } from 'vuex'
	import mixinsList from '@/mixins/list.js'

	export default {
		mixins : [mixinsList],
		data() {
			return {
				mixinsListApi : 'getWalletList',
      }
    },
		computed: {
			...mapState(['userInfo', 'userInfoVip']),
		},
    onShow() {
      this.$store.commit('getUserInfoVip')
    },
    methods: {
      openCalendars() {
        this.$refs.calendars.open();
      },
      onSelectDate(e) {
        this.queryParams.time = e.fulldate
        this.queryParams.pageNo = 1
        this.getData()
      }
    },
  }
</script>

<style scoped lang="scss">
.content {
  padding: 20rpx;
}

.overview {
  position: relative;
  border-radius: 14rpx;
  padding: 0;
  height: 462rpx;
  width: 100%;

  color: #04D6A3;

  .bg {
    width: 100%;
    height: 374rpx;
  }

  &-info {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;

    padding: 43rpx 0 0 54rpx;
  }

  .user-info {
    justify-content: flex-start;
  }

  .avatar {
    width: 80rpx;
    height: 80rpx;
    border-radius: 40rpx;
  }

  .nick-name {
    font-size: 32rpx;
    font-weight: 700;
    margin-left: 20rpx;
  }

  .account {
    margin-top: 44rpx;

    &-count {
      font-size: 78rpx;
      font-weight: 900;
      margin-left: -8rpx;
    }

    &-desc {
      font-size: 24rpx;
    }

  }

  .btn-withdraw {
    position: absolute;
    top: 223rpx;
    right: 0;

    background-color: #04D6A3;
    line-height: 1;
    font-size: 32rpx;
    padding: 20rpx 6rpx 20rpx 30rpx;
    border-top-left-radius: 42rpx;
    border-bottom-left-radius: 42rpx;

    &-arrow {
      width: 28rpx;
      height: 28rpx;
      margin-left: 22rpx;
    }
  }
  
  &-summary {
    position: absolute;
    left: 0;
    bottom: 0;

    width: 100%;
    padding: 28rpx 48rpx;
    box-sizing: border-box;

    justify-content: space-between;

    color: #1B1B1B;
    font-size: 24rpx;

    .highlight {
      color: #04D6A3;
    }
  }
}

.detail {

  &-header {
    align-items: flex-start;
    justify-content: space-between;
    margin-top: 20rpx;
  }

  &-title {
    position: relative;
    
    .bg {
      width: 139rpx;
      height: 13rpx;
      vertical-align: text-bottom;
    }

    .text {
      white-space: nowrap;
      color: #1B1B1B;
      font-size: 36rpx;
      font-weight: 900;
      position: absolute;
      top: 0;
      left: 0;
    }
  }

  &-tools {
    .btn-calendar {
      display: inline-block;
      width: auto;
      height: auto;
      background-color: #FFFFFF;
      border: none;
      padding: 21rpx 19rpx;
      box-sizing: border-box;
      margin: 0;
      line-height: 1;
      font-size: 24rpx;
      color: #999999;
      border-radius: 33rpx;

      &-arrow {
        width: 26rpx;
        height: 12rpx;
        margin-left: 10rpx;
      }
    }
  }

  &-list {
    margin-top: 25rpx;

    &-item {
      color: #999999;
      font-size: 24rpx;

      & + & {
        margin-top: 11rpx;
      }

      .highlight {
        color: #1B1B1B;
        font-size: 32rpx;
        font-weight: 700;
      }

      &-row {
        justify-content: space-between;
      }

      .count {
        &-in {
          color: #FF2020;
        }
      }
    }
  }
}
</style>