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

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    peopledetail: '',
    uintid: '',
    unitname: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      id: options.id
    })
    this.getpeopledetail()
  },
  // 获取工作单位
  getdanweilist() {
    let that = this;
    var url = '/api/index/unit';
    var params = {


    }
    app.post(url, params).then((res) => {
      console.log(res);
      for (var obj of res.unit) {
        if (obj.id == that.data.unitid) {
          that.setData({
            unitname: obj.name
          })
        }
      }



    }).catch((err) => {

    })
  },
  // 获取单位
  getpeopledetail() {
    let that = this;
    var url = '/api/user/back_people_detail';
    var params = {
      admin_token: wx.getStorageSync("usertoken"),
      back_id: this.data.id
    }
    app.post(url, params, "post").then((res) => {
      console.log(res);

      that.setData({
        peopledetail: res.back,
        uintid: res.back.unit_id
      })

      that.getdanweilist()



    }).catch((err) => {

    })
  },
  tongguo() {
    let that = this;

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

          let url = '/api/user/back_people_examine',
            params = {
              admin_token: wx.getStorageSync("usertoken"),
              back_id: that.data.id,
              is_company: 1,
            }
          app.post(url, params, "post").then((res) => {
            console.log(res);
            wx.showToast({
              title: '审核通过',
              icon: 'none'
            })

            setTimeout(function() {
              that.getpeopledetail()
            }, 1500)



          }).catch((err) => {

          })

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

  },

  bohui() {
    let that = this;

    wx.showModal({
      title: '提示',
      content: '是否驳回审核',
      success(res) {
        if (res.confirm) {
          let url = '/api/user/back_people_examine',
            params = {
              admin_token: wx.getStorageSync("usertoken"),
              back_id: that.data.id,
              is_company: 2,
            }
          app.post(url, params, "post").then((res) => {
            console.log(res);
            wx.showToast({
              title: '审核驳回',
              icon: 'none'
            })

            setTimeout(function() {
              that.getpeopledetail()
            }, 1500)


          }).catch((err) => {

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

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})