forked from nsjcy/frontEnd/nsjcy

liuwh
2020-03-30 8d68b6a1dcdf5008fba6bdac5858d1085a0e63e7
SunshineLnsMinApp/pages/zhghInfo/zhghInfo.js
@@ -13,19 +13,19 @@
    id: "",
    status: 4,
    disabled: false,
    taskReport: ''
    socialTaskObject: {}
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  onLoad: function(options) {
    var that = this;
    console.log(options.id)
    wx.showLoading();
    wx.request({
      url: app.globalData.url + '/api/social/find/' + options.id,
      success: function (res) {
      success: function(res) {
        wx.hideLoading();
        console.log('res', res);
        if (res.data.code == 0) {
@@ -37,14 +37,15 @@
          };
          for (var i in evalList) {
            evalList[i] = evalList[i].map(({
              imgPath: pic,
              attachmentId: id
              url: pic,
              uid: id
            }) => ({
              pic,
              id
            }))
          }
          console.log('48', evalList)
          console.log('48', res.data.data.status)
          that.setData({
            data: {
              ...res.data.data,
@@ -52,11 +53,13 @@
              startTime: app.formatDate(res.data.data.startTime),
              endTime: app.formatDate(res.data.data.endTime),
              status: res.data.data.status == 0 ? '未开始' : res.data.data.status == 1 ? '进行中' : res.data.data.status == 2 ? '已结束' : res.data.data.status == 99 ? '结束' : '(未知)',
            },
            disabled: res.data.data.status == 2 ? true : false,
            id: res.data.data.id,
            evalList,
            taskReport: res.data.data.taskReport || ''
            taskReport: res.data.data.taskReport || '',
            socialTaskObject: res.data.data.socialTaskObject
          })
        } else {
          wx.showToast({
@@ -67,16 +70,20 @@
    })
  },
  //输入框
  inputChange: function (e) {
  inputChange: function(e) {
    console.log(e)
    var that = this;
    var taskReport = e.detail.value;
    this.setData({
      taskReport
      socialTaskObject: {
        ...that.data.socialTaskObject,
        taskReport
      }
    })
  },
  //添加图片
  joinPicture: function (e) {
  joinPicture: function(e) {
    console.log(e)
    var that = this;
    console.log(that)
@@ -84,13 +91,13 @@
  },
  // 删除图片
  clearImg: function (e) {
  clearImg: function(e) {
    var that = this;
    app.clearImg(e, that);
  },
  //预览图片
  previewImage: function (e) {
  previewImage: function(e) {
    app.previewImage(e);
  },
@@ -128,7 +135,7 @@
              attId: file.id,
              owenId: id
            },
            success: function (res) {
            success: function(res) {
              console.log('res', res);
              that.data.item.supplyAttachmentList = supplyAttachmentList.filter((n) => n.uid !== file.uid)
              that.setData({
@@ -143,36 +150,49 @@
  },
  // 提交
  linkFunction: function () {
  linkFunction: function() {
    var that = this;
    wx.showLoading();
    wx.request({
      url: app.globalData.url + '/api/social/submitTask',
      method: 'GET',
      data: {
        taskId: that.data.id,
        userId: wx.getStorageSync('id'),
        taskReport: that.data.taskReport
      },
      success: function (res) {
        wx.hideLoading();
        console.log('res', res);
        if (res.data.code == 0) {
          wx.showToast({
            title: '提交成功',
            icon: 'success',
            duration: 2000
          })
          wx.navigateBack({
            delta: 1
          })
        } else {
          wx.showToast({
            title: res.data.msg,
          })
    var data = {
      taskId: that.data.id,
      userId: wx.getStorageSync('id'),
      taskReport: that.data.socialTaskObject.taskReport
    }
    console.log(that.data.data.startTime)
    console.log(app.formatDate(new Date()))
    if (app.formatDate(new Date()) < that.data.data.startTime) {
      wx.hideLoading();
      return app.showModal("任务还未开始,暂时无法提交");
    } else {
      wx.request({
        url: app.globalData.url + '/api/social/submitTask',
        method: 'GET',
        data: {
          taskId: that.data.id,
          userId: wx.getStorageSync('id'),
          taskReport: that.data.socialTaskObject.taskReport
        },
        success: function(res) {
          wx.hideLoading();
          console.log('res', res);
          if (res.data.code == 0) {
            wx.showToast({
              title: '提交成功',
              icon: 'success',
              duration: 2000
            })
            wx.navigateBack({
              delta: 1
            })
          } else {
            wx.showToast({
              title: res.data.msg,
            })
          }
        }
      }
    })
      })
    }
  },