// pages/dataScreening/dataScreening.js
const {
  ajaxForWaitOrder,
  lookCreditResult
} = require("../../../api/api")
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },


  onShow() {
    this.ajaxForWaitOrder()
  },

  /**
   * 
   * 获取电站列表
   * 
   * 
   * @param {*} e 
   */
  ajaxForWaitOrder(e) {
    ajaxForWaitOrder({
      userId: wx.getStorageSync('userId'),
      status: "w",
      page: 1,
      limit: 100,
    }).then((res) => {
      this.setData({
        list: res.data
      })
    })
  },

  /**
   * 
   * 信息校验
   * 
   * @param {*} e 
   */
  creditChecking(e) {
    wx.showLoading({
      title: '查询中',
    })
    lookCreditResult({
      entryId: e.currentTarget.dataset.id
    }).then((res) => {
      wx.hideLoading()
      if (res.code == 200) {
        if (res.data.credit == 1) {
          wx.showToast({
            title: '查询成功，征信通过',
            icon: "none"
          })
          this.setData({
            [`list[${e.currentTarget.dataset.index}].credit`]: 1,
          })
        } else {
          wx.showToast({
            title: res.data.creditDsc,
            icon: "none"
          })
        }
      } else {
        wx.showToast({
          title: res.errMsg,
          icon: "none"
        })
      }
    })
  },

  /**
   * 
   * 准入登记
   * 
   * @param {*} e 
   */
  goDataScreeningDetails(e) {
    wx.navigateTo({
      url: '/home/pages/dataScreeningDetails/dataScreeningDetails',
    })
  },

  /**
   * 
   * 信息登记
   * 
   * @param {*} e 
   */
  goEntryInfo(e) {
    wx.navigateTo({
      url: '/home/pages/entryInfo/entryInfo?projectId=' + e.currentTarget.dataset.projectid,
    })
  },


})