From aba05ff402b2b6a7ed9e3eedee43addc1b7eee44 Mon Sep 17 00:00:00 2001
From: liuwh <hugeinfo123>
Date: Tue, 26 May 2020 18:09:49 +0800
Subject: [PATCH] 1

---
 SunshineLnsMinApp/pages/zhghInfo/zhghInfo.js |  120 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 77 insertions(+), 43 deletions(-)

diff --git a/SunshineLnsMinApp/pages/zhghInfo/zhghInfo.js b/SunshineLnsMinApp/pages/zhghInfo/zhghInfo.js
index 67cc594..f703e13 100644
--- a/SunshineLnsMinApp/pages/zhghInfo/zhghInfo.js
+++ b/SunshineLnsMinApp/pages/zhghInfo/zhghInfo.js
@@ -11,21 +11,21 @@
     del: app.globalData.imgUrl + '/image/del.svg',
     evalList: {},
     id: "",
-    status: 4,
+    status: null,
     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,25 +37,30 @@
           };
           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,
               createTime: app.formatDate(res.data.data.createTime),
               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 ? '结束' : '(未知)'
+              status: res.data.data.status == 0 ? '正常' : '暂停',
+
             },
+            disabled: res.data.data.status == 2 ? true : false,
+            status: res.data.data.status,
             id: res.data.data.id,
             evalList,
-            taskReport: res.data.data.taskReport || ''
+            taskReport: res.data.data.taskReport || '',
+            socialTaskObject: res.data.data.socialTaskObject
           })
         } else {
           wx.showToast({
@@ -66,15 +71,20 @@
     })
   },
   //输入框
-  inputChange: function (e) {
-    var taskReport = e.currentTarget.dataset.name;
+  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)
@@ -82,13 +92,13 @@
   },
 
   // 删除图片
-  clearImg: function (e) {
+  clearImg: function(e) {
     var that = this;
     app.clearImg(e, that);
   },
 
   //预览图片
-  previewImage: function (e) {
+  previewImage: function(e) {
     app.previewImage(e);
   },
 
@@ -126,7 +136,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({
@@ -140,38 +150,62 @@
     })
   },
 
+  // 跳转
+  linkcFunction: function(event) {
+    var that = this;
+    var status = that.data.status;
+    var str = event.currentTarget.dataset['str'];
+    var id = event.currentTarget.dataset['id'];
+    wx.navigateTo({
+      url: '../' + str + '/' + str + '?id=' + id + '&status=' + status
+    })
+  },
+
   // 提交
-  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,
+            })
+          }
         }
-      }
-    })
+      })
 
-   
+    }
+
+
   },
 })
\ No newline at end of file

--
Gitblit v1.8.0