// pages/spacelog/index.js
import {
  queryAllspace,
} from "../../requests/api";
import $ from './../../utils/Tool'
import router from './../../utils/router'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    projectId:"",
    tenantId:"",
    userId:"",
    alllistContent:[],
    noDate:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    options = JSON.parse(decodeURIComponent(JSON.stringify(options)))||{};
    let arr = [];
    for (let i in options) {
        arr.push(options[i]); //属性
        //arr.push(obj[i]); //值
    }
    console.log(options,"options");
    this.getData(arr);
  },
  async getData(value=[]) {
    // $.loading()
    wx.showLoading({
      title:"加载中"
    })
    let projectId = $.store.get('projectId') ||$.storage.get('projectId');
    let tenantId = $.store.get('tenantId')||$.storage.get('tenantId');
    let userId = $.store.get('userId') || $.storage.get('userId');
    let data={
      "criteria": {
        "userId": userId,
        "projectId":projectId,
        "tenantId":  tenantId,
          spaceId:value
      },
      orders:[
        {
          column:"localName",
          asc:"true"
        }
      ]
    };
    let res = await queryAllspace(data);
    if(res.count){
      this.setData({alllistContent:res.content})
    }else{
      this.setData({noDate:true,alllistContent:[]})
    }
    wx.hideLoading()
  },
  listClick(e){
    let data = e.detail.cardDate;
    data.outLine&&(data.outLine="");
    router.push("adjust",data);
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})