From b72fc1b10b08cf2fea1626d32e1ca2cccabe2edd Mon Sep 17 00:00:00 2001
From: liuwh <hugeinfo123>
Date: Tue, 31 Mar 2020 23:49:35 +0800
Subject: [PATCH] bug修复

---
 SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js |  155 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 118 insertions(+), 37 deletions(-)

diff --git a/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js b/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
index 496552f..02d8830 100644
--- a/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
+++ b/SunshineLnsMinApp/pages/fzpxInfo/fzpxInfo.js
@@ -9,8 +9,14 @@
    * 页面的初始数据
    */
   data: {
+    user: app.globalData.imgUrl + '/image/user.svg',
     loading: false,
-    peopleInfo: {}
+    peopleInfo: {},
+    signStatus: '',
+    id: "",
+    topattList: [],
+    bottomattList: [],
+    statequeId: ''
   },
 
   /**
@@ -20,7 +26,8 @@
     var that = this;
     that.setData({
       id: options.id,
-      flag: options.flag,
+      signStatus: options.signStatus || '',
+      flag: options.flag || '',
       loading: true
     });
     wx.showLoading({
@@ -36,46 +43,66 @@
         wx.hideLoading();
         if (res.data.code == 0) {
           res.data.data.startTime = app.formatDate(res.data.data.startTime)
-          that.setData({
-            activity: res.data.data
-          })
-          console.log('传过来', options.flag)
-          // 处理报名状态
-          if (options.flag == 'true') {
-            //可报名
-            console.log('可报名')
-            if (res.data.data.activityPersonNum < res.data.data.activityPersonQuota) {
-              if (res.data.data.activityStatus == 1) {
-                that.setData({
-                  canApply: true
-                })
-              }
-              if (res.data.data.activityStatus == 2) {
-                that.setData({
-                  canApply: false,
-                  statusWord: '活动正在进行'
-                })
-              }
-              if (res.data.data.activityStatus == 3) {
-                that.setData({
-                  canApply: false,
-                  statusWord: '活动已结束'
-                })
-              }
-            } else {
+          if (res.data.data.activityStatus == 3) {
+            if (res.data.data.queId) {
               that.setData({
-                canApply: false,
-                statusWord: '报名人数已满'
+                statequeId: res.data.data.queId
               })
             }
-
           } else {
-            //不可报名
-            console.log('不可报名')
             that.setData({
-              canApply: false,
-              statusWord: '您已报名'
+              statequeId: ''
             })
+          }
+          that.setData({
+            activity: res.data.data,
+            bottomattList: res.data.data.attList.filter((item) => (item.associateType == 1020)),
+            topattList: res.data.data.attList.filter((item) => (item.associateType == 1000))
+          })
+          console.log('传过来', options.flag)
+          console.log('传过来', options.signStatus)
+          // 处理报名状态
+          if (options.signStatus) {
+            that.setData({
+              signStatus: options.signStatus
+            })
+          } else {
+            if (options.flag == 'true') {
+              //可报名
+              console.log('可报名')
+              if (res.data.data.activityPersonNum < res.data.data.activityPersonQuota) {
+                if (res.data.data.activityStatus == 1) {
+                  that.setData({
+                    canApply: true
+                  })
+                }
+                if (res.data.data.activityStatus == 2) {
+                  that.setData({
+                    canApply: false,
+                    statusWord: '活动正在进行'
+                  })
+                }
+                if (res.data.data.activityStatus == 3) {
+                  that.setData({
+                    canApply: false,
+                    statusWord: '活动已结束'
+                  })
+                }
+              } else {
+                that.setData({
+                  canApply: false,
+                  statusWord: '报名人数已满'
+                })
+              }
+
+            } else {
+              //不可报名
+              console.log('不可报名')
+              that.setData({
+                canApply: false,
+                statusWord: '您已报名'
+              })
+            }
           }
 
         }
@@ -100,6 +127,14 @@
     })
   },
 
+  //跳转问卷调查
+  businessSchedule: function(e) {
+    var id = e.currentTarget.dataset['id'];
+    wx.navigateTo({
+      url: '/pages/createSub/createSub?id=' + id,
+    })
+  },
+
   inputChange: function(e) {
     var name = e.currentTarget.dataset.name;
     this.setData({
@@ -108,6 +143,52 @@
         [name]: e.detail.value
       }
     })
+  },
+
+  // 签到
+  sign: function() {
+    var id = this.data.id;
+    var userinfo = wx.getStorageSync("user");
+    var userId = userinfo.id;
+    // 只允许从相机扫码
+    wx.scanCode({
+      onlyFromCamera: true,
+      success(res) {
+        console.log(res)
+        wx.showLoading({
+          title: '识别中',
+        })
+        wx.request({
+          url: app.globalData.url + '/api/activity/sign?id=' + id + '&code=' + res.result + '&userId=' + userId,
+          method: 'GET',
+          header: {
+            "Content-Type": "application/json"
+          },
+          success: function(res) {
+            wx.hideLoading();
+            if (res.data.code == 0) {
+              wx.showToast({
+                title: '签到成功!',
+                icon: 'success',
+                duration: 2000
+              })
+            } else {
+              wx.showToast({
+                title: '签到失败,请稍后重试!',
+                icon: 'none'
+              })
+            }
+          }
+        })
+      }
+    })
+  },
+
+  // 返回
+  goBack: function() {
+    wx.navigateBack({
+      delta: 1
+    });
   },
 
   // 提交报名
@@ -161,7 +242,7 @@
           }))
         } else {
           wx.showToast({
-            title: '报名失败,请稍后重试!',
+            title: res.data.msg,
             icon: 'none'
           })
         }

--
Gitblit v1.8.0