<template>
  <div>
    <div class="box">
      <div class="row allAlignment center head_on_box">
        <p
          class="logo"
          style="font-size:.6rem;color:#E1E1DF;font-family:  'Franklin Gothic Medium'"
        >
          <i style="color:#F76649;">HX</i>669
        </p>
        <p style="color:#fffffe;font-size:.36rem">入账记录</p>
        <!-- <img class="log" src="../assets/st-imges/indexlogo.png" alt=""> -->
        <div class="row allAlignment center">
          <img class="user-ion" @click="toRouter()" src="@/assets/st-imges/close.png" alt>
          <!-- <div v-if="nameShow" class="row allAlignment center username">
              {{name}}
          </div>-->
          <img
            style="margin-left: 0.44rem;"
            class="user-ion"
            src="@/assets/st-imges/contact.png"
            alt
          >
        </div>
      </div>
    </div>
    <div class="boxIn row item-center">
      <div class="date row center">
        <yd-button-group>
          <yd-button size="large" bgcolor="rgba(0,0,0,0)" @click.native="openStart">{{startTime}}</yd-button>
        </yd-button-group>
      </div>
      <p style="margin:0 .22rem">至</p>
      <div class="date row center">
        <yd-button-group>
          <yd-button size="large" bgcolor="rgba(0,0,0,0)" @click.native="openEnd">
            <div>{{endTime}}</div>
          </yd-button>
        </yd-button-group>
      </div>
      <button class="dateBtn" @click="reset()">查询</button>
    </div>
    <div class="row average box-btn item-center">
      <button @click="classify(0)" :class="classnum==0?'active':''">充值记录</button>
      <button @click="classify(1)" :class="classnum==1?'active':''">转账记录</button>
    </div>

    <!-- <div
      class="row center"
      style="height:.88rem;color:#ebebeb;font-size:.32rem;background:#666;margin-top:.1rem;"
      v-if="!list.list"
    >对不起，您当前没有数据</div> -->
    <div>
      <div class="datalist">
        <div>
          <yd-infinitescroll :callback="loadList" ref="infinitescrollDemo">
            <yd-list theme="5" slot="list">
              <yd-list-item>
                <yd-list-other slot="other">
                  <div class="datalistbox" v-for="(item,index) in list" :key="index">
                    <div class="row" v-if="code" :style="code?'':'display:none'">
                      <div style="margin-right:.3rem;">
                        <p>充值时间 :</p>
                        <p>订&nbsp; 单&nbsp;&nbsp;号 :</p>
                        <p>充值金额 :</p>
                        <p>充值方式 :</p>
                      </div>
                      <div>
                        <p>{{item.apply_time}}</p>
                        <p>{{item.order_id}}</p>
                        <p style="color:#f76649">{{item.money}}元</p>
                        <p>{{item.recharge_type}}</p>
                      </div>
                    </div>
                    <div class="row" v-if="!code" :style="!code?'':'display:none'">
                      <div style="margin-right:.3rem;">
                        <p>转账金额：</p>
                        <p>提交时间：</p>
                        <p>审核时间：</p>
                        <p>打款时间：</p>
                        <p>银行卡号：</p>
                        <p>银行信息：</p>
                        <p>平台余额：</p>
                      </div>
                      <div>
                        <p style="color: rgb(247, 102, 73);">{{item.money}}元</p>
                        <p>{{item.apply_time}}</p>
                        <p>{{item.status==1?item.apply_time:item.status==0?'待审核':'未通过'}}</p>
                        <p>{{item.give_time}}</p>
                        <p>{{item.bank_no}}</p>
                        <p>{{item.bank_info}}</p>
                        <p>{{item.money_cash}}</p>
                      </div>
                    </div>
                  </div>
                </yd-list-other>
              </yd-list-item>
            </yd-list>
          </yd-infinitescroll>
        </div>
      </div>
    </div>
    <yd-cell-group style="display:none;">
      <yd-cell-item arrow>
        <yd-datetime
          type="date"
          ref="datetimeStart"
          :end-date="endTime"
          slot="right"
          v-model="startTime"
        ></yd-datetime>
      </yd-cell-item>
    </yd-cell-group>
    <yd-cell-group style="display:none;">
      <yd-cell-item arrow>
        <yd-datetime
          type="date"
          ref="datetimeEnd"
          :start-date="startTime"
          :end-date="date"
          slot="right"
          v-model="endTime"
        ></yd-datetime>
      </yd-cell-item>
    </yd-cell-group>
  </div>
</template>
<script>
import "@/css/index.css";
export default {
  name: "AccessRecords",
  data() {
    return {
      img: require("@/assets/st-imges/date.png"),
      img1: require("@/assets/st-imges/home.png"),
      img2: require("@/assets/st-imges/gengduo-1.png"),
      close: require("@/assets/st-imges/close.png"),
      kefu: require("@/assets/st-imges/kefu.png"),
      list: "",
      // 当前时间 同时也是日历结束时间
      date: "",
      classnum: 0,
      // 日历开始时间
      startDate: "",
      //   查询开始时间
      startTime: "",
      //   查询结束时间
      endTime: "",
      // 是否请求
      isrequest: true,
      code: "",
      // 分页
      page: 1,
      pageSize: 5,
      timers: true
    };
  },
  created() {
    this.initialTime();
  },
  methods: {
    //判断登录是否过期
    getuserData() {
      if (localStorage.getItem("token")) {
        this.$http
          .post(this.$ports.login.getAgent, {
            token: localStorage.getItem("token")
          })
          .then(res => {
            if (res.data.status == -4001) {
              this.$store.dispatch("SET_TOKEN", "");
              this.$store.dispatch("GET_ISSHOW", false);
              this.$dialog.toast({
                mes: "对不起您的登录已过期，请您重新登录",
                timeout: 3000
              });
              this.$router.push("/");
            }
          });
      }
    },
    reset() {
      this.list = [];
      this.page = 1;
      // 重置下拉加载
      this.$refs.infinitescrollDemo.$emit("ydui.infinitescroll.reInit");
      this.loadList();
    },
    classify(num) {
      this.classnum = num;
      this.reset();
    },
    initialTime() {
      // 现在的时间
      let date = new Date();
      //  日历开始时间
      let date2 = new Date(date);
      date2.setMonth(date.getMonth() - 3);
      this.startDate += `${date2.getFullYear()}-${
        date2.getMonth() + 1 < 10
          ? "0" + (date2.getMonth() + 1)
          : date2.getMonth() + 1
      }-${date2.getDate() < 10 ? "0" + date2.getDate() : date2.getDate()}`;
      this.date += `${date.getFullYear()}-${
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1
      }-${date.getDate() < 10 ? "0" + date.getDate() : date.getDate()}`;
      //  查询结束时间
      this.endTime += `${date.getFullYear()}-${
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1
      }-${date.getDate() < 10 ? "0" + date.getDate() : date.getDate()}`;
      this.startTime = `${date.getFullYear()}-${
        date.getMonth() - 2 < 10
          ? "0" + (date.getMonth() - 2)
          : date.getMonth() - 2
      }-${date.getDate() < 10 ? "0" + date.getDate() : date.getDate()}`;
      // console.log(this.startDate);
    },
    // 导航
    toRouter() {
      this.$router.go(-2);
    },
    loadList() {
      // 补全时间
      let date = new Date();
      let hours = date.getHours();
      let min = date.getMinutes();
      let sec = date.getSeconds();
      if (this.isrequest) {
        this.$http.post(
            this.classnum == 0? this.$ports.login.rechargeRecord
              : this.$ports.login.moneyOutRecord,
            {
              currentPage: this.page,
              pageSize: this.pageSize,
              startTime: this.startTime + " 00:00:00", //此处是补全开始时间的时间
              endTime:
                this.endTime +
                " " +
                (hours < 10 ? "0" + hours : hours) +
                ":" +
                (min < 10 ? "0" + min : min) +
                ":" +
                (sec < 10 ? "0" + sec : sec),
              token: localStorage.getItem("token")
            }
          ).then(res => {
            if(res.data.status){
              /* 单次请求数据完毕 */
              if (res.data.data) {
                let table = res.data.data.list;
                this.list = [...this.list, ...table];
                if (res.data.data.code == 1) {
                  this.code = true;
                } else {
                  this.code = false;
                }
              }
              if (res.data.data.list.length < 10) {
                this.$dialog.toast({ mes: "没有更多记录", timeout: 1000 });
                /* 所有数据加载完毕 */
                this.$refs.infinitescrollDemo.$emit(
                  "ydui.infinitescroll.loadedDone"
                );
                return;
              } else {
                /* 单次请求数据完毕 */
                this.$refs.infinitescrollDemo.$emit(
                  "ydui.infinitescroll.finishLoad"
                );
                this.page++;
              }
            }
          });
      }
    },
    // 日历开关
    openStart() {
      this.$refs.datetimeStart.open();
    },
    openEnd() {
      this.$refs.datetimeEnd.open();
    }
  },
  mounted() {
    this.loadList();
    let _this = this;
    this.$public.ajaxTimerFun(function(timing) {
      if (_this.timers) {
        _this.getuserData();
      } else {
        clearInterval(timing);
      }
    }, 1000 * 60);
  },
  beforeDestroy() {
    this.timers = false;
  }
};
</script>
<style  scoped>
div /deep/ .yd-list-theme5 .yd-list-item .yd-list-mes {
  padding: 0;
}
div /deep/ .yd-list-theme5 .yd-list-item .yd-list-other {
  padding: 0;
}
div /deep/ .yd-list-other {
  display: block;
}
.yd-list-theme5 .yd-list-item {
  padding: 0;
}
div /deep/ .yd-list-img {
  display: none;
}
.box-btn {
  width: 100%;
  height: 1rem;
  background: #fff;
}
.box-btn button {
  width: 2rem;
  height: 0.6rem;
  border: none;
  background: #dcdcdc;
  color: #363636;
  font-size: 0.24rem;
  border-radius: 0.05rem;
}
.box-btn button.active {
  background: #a0a0a0;
  color: #dcdcdc !important;
}
.yd-btn-block {
  height: 100%;
  width: 100%;
}
.dateBtn {
  width: 0.94rem;
  height: 0.6rem;
  border: none;
  border-radius: 0.08rem;
  background-image: linear-gradient(7deg, #565656 0%, #999999 100%),
    linear-gradient(#4a4949, #4a4949);
  color: #ffffff;
  margin-left: 0.22rem;
}
.boxIn {
  background: #e4e4e4;
  height: 0.88rem;
  padding: 0 0.32rem;
}
.date {
  height: 0.6rem;
  border-radius: 0.25rem;
  background: #ccc;
}
.listbox p {
  width: 5rem;
  height: 0.45rem;
}
.paging {
  width: 100%;
  height: 0.88rem;
  position: absolute;
  bottom: 0;
}
.paging p {
  width: 0.6rem;
  height: 0.6rem;
  margin-left: 0.05rem;
  border-radius: 0.08rem;
  background: #ccc;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #363636;
}
.paging p input {
  width: 0.6rem;
  height: 0.6rem;
  background: #ebebeb;
  border: 2px solid #ccc;
  border-radius: 0.08rem;
}
.paging p button {
  width: 0.6rem;
  height: 0.6rem;
  border: none;
  background: #555;
  color: #efefef;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0.08rem;
}
.paging p button:active {
  background: rgb(126, 125, 125);
  color: #ccc;
}
.datalistbox {
  width: 100%;
  margin-top: 0.3rem;
  background: #efefef;
  padding: 0.2rem 0.3rem;
  font-size: 0.28rem;
  color: #555555;
  line-height: 0.4rem;
}
.datalistbox div p {
  height: 0.5rem;
  font-size: 0.3rem;
  line-height: 0.45 rem;
  font-weight: bold;
}
.datalist {
  position: relative;
}
.datalistlet {
  background-color: #cccccc;
}
.datalist .active {
  background: #f76649 !important;
  color: #efefef !important;
}
.msg {
  height: 0.88rem;
  margin-top: 0.3rem;
  color: #ccc;
  background: #333;
}
.classifyactive {
  color: #f76649;

  border-bottom: 2px solid #f76649;
}
.classify {
  height: 0.88rem;
  font-size: 0.3rem;
  line-height: 0.66rem;
  font-weight: normal;
  color: #777777;
  background-color: #efefef;
  padding: 0.1rem 0;
}
.active {
  color: rgb(247, 102, 73) !important;
}
.box {
  background: #ebebeb;
  padding-left: 0.14rem;
}
.date {
  width: 2.5rem;
  background: #ccc;
  height: 0.6rem;
}
#NavSlide {
  width: 100%;
  overflow: hidden;
}
#NavSlide nav {
  padding-top: 0.1rem;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: middle;
  -ms-flex-align: middle;
  align-items: middle;
  overflow: auto;
}
div /deep/ .yd-datetime-content,
div /deep/ .yd-datetime-shade,
div /deep/ .yd-datetime-indicator {
  height: 2rem !important;
}
div /deep/ .yd-button {
  padding: 0;
  width: 100%;
  height: 100%;
}
div /deep/ .yd-button button {
  margin: 0;
  border-radius: 0;
}
#NavSlide p {
  text-align: center;
  font-size: 0.28rem;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  padding: 0 0.1rem;
  color: #b8b8b8;
}
/* #NavSlide p a{
	color: #E5E5E5;
	text-decoration: none;
} */
#NavSlide p span.active {
  color: #363636;
}

.head_on_box {
  padding: 0 0.32rem;
}
.box {
  height: 0.88rem;
  background: linear-gradient(to bottom, #999999, #6a6a6b);
  overflow: hidden;
}
.user-ion {
  width: 0.3rem;
  height: 0.3rem;
}
#NavSlide p {
  width: 1.1rem;
}
</style>

