jobfairdetail.js 8.12 KB
var app = getApp();
var WxParse = require('../../wxParse/wxParse.js');
Page({

  data: {
    id: '',
    skey: '',
    information: '',
    tanchuang: false,
    tanchuang1: false,
    con: '',
    disabled: false,
    disabled1: false,
  },
  scroll: function (e) {
    console.log('eeeee', e)
    console.log(e.detail.scrollTop)
    var that = this
    var scrollTop = e.detail.scrollTop
    that.setData({
      scrollTop: e.detail.scrollTop
    })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var id = options.id
    that.setData({
      id: id
    })
 
    var con = that.data.con
    console.log('con',con)
    var skey = wx.getStorageSync('key')
    var information = that.data.information
    wx.request({
      url: app.url + '/mpapi/1.0.0/user/profile',
      method: 'GET',
      header: {
        'content-type': 'application/json',
        'x-wx-skey': skey
      },
      data: {
        // type:'job_fair,academic_conference,writing_training',
        // offset: 0,
        // limit: 4
        // id:'1'
      },
      success: function (res) {
        
        console.log('xinxi', res.data)
        that.setData({
          information: res.data
        })
      }
    })
    console.log('id', id)
    if (id == "") {
      wx.showToast({
        title: '访问错误!',
        icon: 'success',
        duration: 2000
      })
      return false;
    }
    console.log('skey', skey)
    that.setData({
      skey: skey
    })

    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          windowHeight: res.windowHeight
        })
      },
    })
    console.log('idddddd',id)
    wx.request({
      url: app.url + '/mpapi/1.0.0/job-fair/' + id,
      method: 'GET',
      header: {
        'content-type': 'application/json',
        'x-wx-skey': skey
      },
      data: {
        // tag:'junior',
        // offset:4,
        // limit:4
      },
      success: function (res) {
        wx.setNavigationBarTitle({
          title: res.data.data.title
        })
        console.log('con', res.data.data)
        that.setData({
          con: res.data.data
        })
        var body = res.data.data.content;
        WxParse.wxParse('body', 'html', body, that, 5);
        var body1 = res.data.data.extendContent;
        WxParse.wxParse('body1', 'html', body1, that, 5);
        var time = Date.parse(new Date)
        console.log('time', time)
        var shijian = Date.parse(res.data.data.eventDateEnd)
        var shijian1 = Date.parse(res.data.data.eventDateStart)
        console.log('shijian', shijian)
       
        if (time>shijian) {
          console.log(213214234345435645)
          // console.log('disabled1', disabled1)
          that.setData({
            disabled1: true,
          })
          return false
        } else {
          wx.request({
            url: app.url + '/mpapi/1.0.0/user/favorite?type=&offset=&limit=',
            method: 'GET',
            header: {
              'content-type': 'application/json',
              'x-wx-skey': skey
            },
            data: {
              // tag:'junior',
              // offset:4,
              // limit:4
              // tag: 'join',
              // contentId: id,
              // type: 'join'
              type: 'job_fair ',
              offset: 0,
              limit: 100
            },
            success: function (res) {
              console.log('res', res)
              var res = res.data.data
              var disabled = that.data.disabled
              // var res = res.data.data
              for (var x in res) {
                console.log('res[x]', res[x])
                if (id == res[x].contentId) {
                  console.log('bbb', res[x].contentId)
                  that.setData({
                    disabled: true
                  })
                } 
              }
            }
          })
        }
      }
    })
    // wx.request({
    //   url: app.url + '/mpapi/1.0.0/user/favorite?type=&offset=&limit=',
    //   method: 'GET',
    //   header: {
    //     'content-type': 'application/json',
    //     'x-wx-skey': skey
    //   },
    //   data: {
    //     // tag:'junior',
    //     // offset:4,
    //     // limit:4
    //     // tag: 'join',
    //     // contentId: id,
    //     // type: 'join'
    //     type: 'job_fair  ',
    //     offset: 0,
    //     limit: 100
    //   },
    //   success: function (res) {
    //     console.log('res', res)
    //     var res = res.data.data
    //     var disabled = that.data.disabled
    //     // var res = res.data.data

    //     for (var x in res) {
    //       console.log('res[x]', res[x])
    //       var time = Date.parse(new Date)
    //       console.log('time', time)
    //       var shijian = Date.parse(res[x].content.eventDateEnd)
    //       console.log('shijian', shijian)
    //       if (time >= shijian) {
    //         // console.log('disabled1', disabled1)
    //         that.setData({
    //           disabled1: true,
    //         })
    //       } else {
    //         if (id == res[x].contentId) {
    //           console.log('bbb', res[x].contentId)
    //           that.setData({
    //             disabled: true
    //           })
    //         } if (id == res[x].contentId) {
    //           console.log('bbb', res[x].contentId)
    //           that.setData({
    //             disabled: true
    //           })
    //         }
    //       }
    //     }
    //   }
    // })
  },

  adduserfavorite: function () {
    var that = this
    var skey = that.data.skey
    var tanchuang = that.data.tanchuang
    var id = that.data.id
    console.log('id',id)
    var disabled = that.data.disabled
    var information = that.data.information
    console.log('information1', information)
    if (information.agency && information.major && information.mobile && information.name && information.email && information.position) {
      console.log(1111)
      console.log('that.data.id', that.data.id)
      wx.request({
        url: app.url + '/mpapi/1.0.0/user/favorite',
        method: 'POST',
        header: {
          'content-type': 'application/json',
          'x-wx-skey': skey
        },
        data: {
          // tag:'junior',
          // offset:4,
          // limit:4
          tag: 'join',
          contentId: id,
          type: 'job_fair'
        },
        success: function (res) {
          console.log(res)
          that.setData({
            tanchuang: true,
            disabled: true
          })
        }
      })
    } else {
      console.log(222)
      that.setData({
        tanchuang1: true
      })
    }
  },
  yincang: function () {
    var that = this
    var tanchuang = that.data.tanchuang
    that.setData({
      tanchuang: false
    })
  },
  yincang1: function () {
    var that = this
    var tanchuang1 = that.data.tanchuang1
    that.setData({
      tanchuang1: false
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log('onshow')
    var that = this
    var skey = wx.getStorageSync('key')
    var tanchuang1 = that.data.tanchuang1
    that.setData({
      tanchuang1: false
    })
    wx.request({
      url: app.url + '/mpapi/1.0.0/user/profile',
      method: 'GET',
      header: {
        'content-type': 'application/json',
        'x-wx-skey': skey
      },
      data: {
        // type:'job_fair,academic_conference,writing_training',
        // offset: 0,
        // limit: 4
        // id:'1'
      },
      success: function (res) {
        console.log('xinxi', res.data)
        that.setData({
          information: res.data
        })
      }
    })

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})