
const app = getApp();
var network = require("../../utils/net.js");
const util  = require('../../utils/util.js')
var timechage = require("../../utils/dateTimeUtil.js")
var baseUrl = app.globalData.baseUrl;
var Customer_Name;
var Money;
var ID;
var LoadTime;
var AppID;
var Phone;

var pageindex=0;
var pagesize=10;

Page({
  data: {
    //页面高度
    winHeight: 0,
    
    currentData: 0,
    dates: "请选择日期",
    index: 0,
    list: [],
    list1: [],
    LoadTime: "",
    ID:"",
  },

  bindDateChange: function (e) {
    this.setData({
      dates: e.detail.value
    })
    this.arr();
  },

  onLoad: function(options) {
    var that = this;
    // 获取系统信息
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });
    var reslut = [];
    var method = '/MainSystem/B3MiniProgramRpc/Rpcs/CustomerRpc/OrderRpc/GetOrder';
    var params = [0, pageindex, pagesize];
    
    network.transfer_request(method, params, function(res) {
      for (var i = 0; i < res.result.length; i++) {
        let dmo = {
          LoadTime: timechage.formatTimeTwo(res.result[i].LoadTime.substring(6, 19), "Y/M/D h:m"),
          ID: res.result[i].ID,
          Customer_Name: res.result[i].Customer_Name,
          Money:res.result[i].Money,
        }
        reslut.push(dmo)
      }
      that.setData({
        list: reslut,
      })
    })
    
    var reslut1=[];
    var method = '/MainSystem/B3MiniProgramRpc/Rpcs/CustomerRpc/OrderRpc/GetOrder';
      var params = [20, pageindex, pagesize];
    network.transfer_request(method, params, function (res) {
        for (var i = 0; i < res.result.length; i++) {
          let dmo = {
            LoadTime: timechage.formatTimeTwo(res.result[i].LoadTime.substring(6, 19), "Y/M/D h:m"),
            ID: res.result[i].ID,
            Customer_Name: res.result[i].Customer_Name,
            Money: res.result[i].Money,
          }
          reslut1.push(dmo)
        }
        that.setData({
          list1: reslut1,
        })
      })
  },

  orderDetails: function (event) {
    let that=this
    var parm = event.currentTarget.dataset;
    wx.navigateTo({
      url: '/pages/orderDetails/orderDetails?ID=' + parm.id,
    })
  },

  //点击切换，滑块index赋值
  bindchange: function (e) {
    const that = this;
    that.setData({
      currentData: e.detail.current
    })
  },
 
  checkCurrent: function (e) {
    const that = this;
    if (that.data.currentData === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentData: e.target.dataset.current
      })
    }

  },
  
  jiazai:function(){

    console.log("323")
    var  reslut = [];
    var that = this;
    // 显示加载图标
    wx.showLoading({
      title: '玩命加载中',
    })
    // 页数+1
    pageindex = pageindex + 1;
    var myDate = new Date();
    var method = '/MainSystem/B3MiniProgramRpc/Rpcs/CustomerRpc/OrderRpc/GetOrder';
    var params = [0, pageindex, pagesize];

    network.transfer_request(method, params, function (res) {
      for (var i = 0; i < res.result.length; i++) {
        let dmo = {
          LoadTime: timechage.formatTimeTwo(res.result[i].LoadTime.substring(6, 19), "Y/M/D h:m"),
          ID: res.result[i].ID,
          Customer_Name: res.result[i].Customer_Name,
          Money: res.result[i].Money,
        }
        reslut.push(dmo)
        console.log(dmo)
      }
      that.setData({
        list: that.data.list.concat(reslut)
      })
    })

    wx.stopPullDownRefresh();
  },
 
  })

  

  


