<template>
    <view>
        <view class="statistics yellow-bg uni-list-cell-pd" style="color: #fff">共18张券被领取，合计金额100.00元，其中已使用16张</view>


        <view class="uni-list">
            <view class="uni-list-cell">
                <view class="uni-list-cell-left">
                    所有类型
                </view>
                <view class="uni-list-cell-db">
                    <picker @change="bindPickerChange" :value="index" :range="array">
                        <view class="uni-input">{{array[index]}}</view>
                    </picker>
                </view>
            </view>
        </view>

        <view class="uni-list">
            <view class="uni-list-cell">
                <view class="uni-list-cell-left">
                    所有状态
                </view>
                <view class="uni-list-cell-db">
                    <picker @change="bindPickerChangeWay" :value="indexWay" :range="arrayWay">
                        <view class="uni-input">{{arrayWay[indexWay]}}</view>
                    </picker>
                </view>
            </view>
        </view>


        <view class="uni-list">
            <view class="uni-list-cell">
                <view class="uni-list-cell-left">
                    开始时间
                </view>
                <view class="uni-list-cell-db">
                    <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindStartDateChange">
                        <view class="uni-input">{{benginDate}}</view>
                    </picker>
                </view>
            </view>
        </view>

        <view class="uni-list">
            <view class="uni-list-cell">
                <view class="uni-list-cell-left">
                    结束时间
                </view>
                <view class="uni-list-cell-db">
                    <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindEndDateChange">
                        <view class="uni-input">{{overDate}}</view>
                    </picker>
                </view>
            </view>
        </view>

        <uni-section title="8折（折扣券）" type="line">
            <uni-list>
                <uni-list-item>
                    <template v-slot:body>
                        <view class="slot-box uni-con-width">
                            <view class="uni-flex uni-space-between ">
                                <view class="color-blue">
                                    JE000100011
                                </view>
                                <view class="color-blue">
                                    京A123456
                                </view>
                            </view>
                            <view class="uni-flex uni-space-between" style="padding: 10px 0">
                                <view>
                                    <text class="color-blue paddingRight" >领取时间</text>
                                    2020-11-01 01:01:01
                                </view>
                                <view class="color-green">
                                    已使用
                                </view>
                            </view>
                            <view class="uni-flex uni-space-between">
                                <view>
                                    <text class="color-red paddingRight">使用时间</text>
                                    2020-11-01 01:01:01
                                </view>
                                <view class="color-green">
                                    5元/张
                                </view>
                            </view>
                        </view>
                    </template>
                </uni-list-item>
            </uni-list>
        </uni-section>


        <uni-section title="8折（折扣券）" type="line">
            <uni-list>
                <uni-list-item>
                    <template v-slot:body>
                        <view class="slot-box uni-con-width">
                            <view class="uni-flex uni-space-between ">
                                <view class="color-blue">
                                    JE000100011
                                </view>
                                <view class="color-blue">
                                    京A123456
                                </view>
                            </view>
                            <view class="uni-flex uni-space-between" style="padding: 10px 0">
                                <view>
                                    <text class="color-blue paddingRight" >领取时间</text>
                                    2020-11-01 01:01:01
                                </view>
                                <view class="color-red">
                                    已失效
                                </view>
                            </view>
                            <view class="uni-flex uni-space-between">
                                <view>
                                    <text class="color-red paddingRight">失效时间</text>
                                    2020-11-01 01:01:01
                                </view>
                                <view class="color-green">
                                    5元/张
                                </view>
                            </view>
                        </view>
                    </template>
                </uni-list-item>
            </uni-list>
        </uni-section>

        <uni-section title="8折（折扣券）" type="line">
            <uni-list>
                <uni-list-item>
                    <template v-slot:body>
                        <view class="slot-box uni-con-width">
                            <view class="uni-flex uni-space-between ">
                                <view class="color-blue">
                                    JE000100011
                                </view>
                                <view class="color-blue">
                                    京A123456
                                </view>
                            </view>
                            <view class="uni-flex uni-space-between" style="padding: 10px 0">
                                <view>
                                    <text class="color-blue paddingRight" >领取时间</text>
                                    2020-11-01 01:01:01
                                </view>
                                <view class="color-blue">
                                    未使用
                                </view>
                            </view>
                            <view class="uni-flex uni-space-between">
                                <view>
                                    <text class="color-green paddingRight">有效截止</text>
                                    2020-11-01 01:01:01
                                </view>
                                <view class="color-green">
                                    5元/张
                                </view>
                            </view>
                        </view>
                    </template>
                </uni-list-item>
            </uni-list>
        </uni-section>


    </view>
</template>

<script>
import common from "../../common/common.js";
export default {
  data() {
    const currentDate = this.getDate({
      format: true
    })
    return {
      title: 'picker',
      array: ['折扣券', '金额券', '单次券', '包天券', '满减券', '时长券'],
      arrayWay: ['所有状态', '已失效', '已使用', '未使用', '已失效'],
      index: 0,
      indexWay: 0,
      benginDate: currentDate,
      overDate: currentDate,
      rows: [],
      pageNum: 1,//当前页
      pageSize: 1,//每页条数
      reload: false,
      status: 'more',
      contentText: {
        contentdown: '上拉加载更多～',
        contentrefresh: '正在加载更多～',
        contentmore: '我是有底线的～'
      },
      iconType: 'auto', // 图标样式
    }
  },
  onLoad(params) {
    wx.showShareMenu({
      withShareTicket: true
    })
    // this.mycarNumber = params.carNumber;
    // this.myorderId = params.orderId;
    // this.myparkCode = params.parkCode;
    // this.myorderState = params.orderState;
    // this.totalFee = params.totalFee
    // this.unPayFee = params.unPayFee
    // if (params.orderState == 5) {
    //   //停车补缴单 103
    //   this.mypaySrcType = '103'
    // } else {
    //   this.mypaySrcType = '101'
    // }
    // // this.GetbillQueryInfo(this.mycarNumber, this.myorderId, this.myparkCode);
    // this.getWxCode();
    // this.PDlogin();
    //console.log("xxxmake = "+this.makedateFormat());
  },
  onShow() {
    var me = this;
    var userInfo = me.getGlobalUser("globalUser");
    if (userInfo != null) {
      me.phoneNumb = userInfo.userPhone;
    }
    var pages = getCurrentPages();
    var currPage = pages[pages.length - 1]; //当前页面
    console.log('currPage.data.selCoupon = ' + currPage.data.selCoupon);
    me.selCoupon = currPage.data.selCoupon;
    console.log(JSON.stringify(me.selCoupon));
    // me.GetbillQueryInfo(me.mycarNumber, me.myorderId, me.myparkCode, me.selCoupon.cardNo, me.selCoupon.couponType, me.selCoupon
    //   .discValue);
    // GetbillQueryInfo(carnum, orderId, parkCode, cardNo, couponType, disValue) {
  },
  computed: {
    startDate() {
      return this.getDate('start');
    },
    endDate() {
      return this.getDate('end');
    }
  },
  methods: {
    bindPickerChange: function (e) {
      console.log('picker发送选择改变，携带值为', e.detail.value)
      this.index = e.detail.value
    },
    bindPickerChangeWay: function (e) {
      console.log('picker发送选择改变，携带值为', e.detail.value)
      this.indexWay = e.detail.value
    },
    bindStartDateChange: function (e) {
      this.benginDate = e.detail.value
    },
    bindEndDateChange: function (e) {
      this.overDate = e.detail.value
    },
    getDate(type) {
      const date = new Date();
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      if (type === 'start') {
        year = year - 60;
      } else if (type === 'end') {
        year = year + 2;
      }
      month = month > 9 ? month : '0' + month;
      day = day > 9 ? day : '0' + day;
      return `${year}-${month}-${day}`;
    },
  }
}
</script>

<style lang="scss" scoped>
    .rechargeWrap {
        position: relative;
        .rechargeArrow {
            position: absolute;
            right: 10px;
            top: 30px;
            font-size: 20px;
            color: #999;
        }
    }

    .recordCon {
        padding-right: 35px;
        color: #999;
        display: flex;
        justify-content: space-between;
    }

    .paddingRight{
        padding-right: 20px;
    }
</style>
