businessdetail.js 3.9 KB
// pages/backpeopledetail/backpeopledetail.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    office: '',
    protectarr: [],
    materials: [],
    status:""

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(options)
    this.setData({
      id: options.id
    })

    this.getdetail()

  },
  getdetail() {
    let that = this;
    var url = '/api/office/office_admin_detail';
    var params = {
      admin_token: wx.getStorageSync("usertoken"),
      office_id: this.data.id
    }
    app.post(url, params, "post").then((res) => {
      console.log(res);

      that.setData({
        protectarr: res.materials
      })
      that.data.protectarr.forEach(function(value, index, array) {
        value.sel = false
      })

      console.log(that.data.protectarr)

      that.setData({
        office: res.office,
        materials: res.office.materials,
        status:res.office.status
      })
      that.data.protectarr.forEach(function(value, index, array) {
        that.data.materials.forEach(function(valuek, indexk, arrayk) {
          if (value.id == valuek) {
            value.sel = true
          }
        })
      })

      that.setData({
        protectarr: that.data.protectarr,

      })


    }).catch((err) => {

    })
  },
  // 通过
  tongguo() {
    let that = this;

    wx.showModal({
      title: '提示',
      content: '是否通过审核',
      success(res) {
        if (res.confirm) {

          var url = '/api/office/office_examine';
          var params = {
            admin_token: wx.getStorageSync('usertoken'),
            office_id: that.data.id,
            status: 2

          }
          app.post(url, params, "post").then((res) => {
            console.log(res);
            wx.showToast({
              title: '审核通过',
              icon: 'none'
            })
            setTimeout(function(){
              wx.navigateBack({
                checked: true
              })
            },1500)
           



          }).catch((err) => {
            console.log(err)
            wx.showToast({
              title: err.data.msg,
              icon: 'none'
            })

          })

        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })

  },
  bohui() {
    let that = this;
    wx.showModal({
      title: '提示',
      content: '是否驳回审核',
      success(res) {
        if (res.confirm) {
          var url = '/api/office/office_examine';
          var params = {
            admin_token: wx.getStorageSync('usertoken'),
            office_id: that.data.id,
            status: 3

          }
          app.post(url, params, "post").then((res) => {
            console.log(res);
            wx.showToast({
              title: '审核驳回',
              icon: 'none'
            })

            setTimeout(function(){
              wx.navigateBack({
                checked: true
              })
            },1500)

           



          }).catch((err) => {
            console.log(err)
            wx.showToast({
              title: err.data.msg,
              icon: 'none'
            })

          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})