myNewsDetail.js 3.75 KB
// pages/myNewsDetail/myNewsDetail.js
import Toast from '../../dist/toast/toast';
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // attach_dat_type: "ORGNAZATION",
    // attach_dat_type: "CIRCLE",
    attach_dat_type: "",
    circle:false,
    volunteer:false,
    orgnazation:false,
    attachDat:{},
    messageDat:{},
    msgId:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (this.data.attach_dat_type =="CIRCLE"){
      this.setData({
        circle:true
      })
    } else if (this.data.attach_dat_type == "ORGNAZATION"){
      this.setData({
        orgnazation: true
      })
    }else{
      this.setData({
        volunteer: true
      })
    }
    var that=this;
    var messageId=options.messageId;
    this.setData({
      msgId:messageId
    })
    this.getInfo(messageId);
  },
  getInfo(messageId){
    var that=this;
    wx.getStorage({
      key: 'config',
      success: function (res) {
        if (res.data.unionId) {
          wx.request({
            url: app.url + 'ajax_get_user_message_detail.php',
            header: { 'content-type': 'application/json' },
            data: {
              unionId: res.data.unionId,
              messageId: messageId
            },
            success: function (res) {
              console.log(res)
              if (res.data.status == 'OK') {
                console.log(res.data.result.userMessageDat.attach_dat_type)
                that.setData({
                  attach_dat_type: res.data.result.userMessageDat.attach_dat_type,
                  messageDat: res.data.result.userMessageDat,
                  attachDat: res.data.result.attachDat
                })
              }
            },
            fail: function (res) { },
            complete: function (res) { },
          })
        }
      },
    })
  },

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

  },

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

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

  },

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

  },

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

  },

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

  },

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

  },
  //拒绝加入圈子
  jujue() {
    var that = this;
    wx: wx.request({
      url: app.url + 'ajax_refuse_user_join_circle.php',
      data: {
        userId: that.data.messageDat.user_id,
        circleId: that.data.attachDat.id,
        msgId: that.data.msgId
      },
      success: function (res) {
        if (res.data.status == 'OK') {
          Toast.success(res.data.result.message);
        } else {
          Toast.fail(res.data.result.message);
        }
        that.getInfo(that.data.msgId);
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  //同意加入圈子
  tongyi() {
    var that = this;
    wx.request({
      url: app.url + 'ajax_accept_user_join_circle.php',
      data: {
        userId: that.data.messageDat.user_id,
        circleId: that.data.attachDat.id,
        msgId: that.data.msgId
      },
      success: function (res) {
        if(res.data.status=='OK'){
          Toast.success(res.data.result.message);
        }else{
          Toast.fail(res.data.result.message);
        }
        that.getInfo(that.data.msgId);
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  into(){
    var that=this;
    wx.navigateTo({
      url: this.data.messageDat.attach_dat_path
    })
  }
})