From 58ae2ba21efcd85df331cf996a94038a77302b51 Mon Sep 17 00:00:00 2001 From: Mr Ke <kelq@hugeinfo.com.cn> Date: Wed, 27 May 2020 17:07:48 +0800 Subject: [PATCH] 修改报错问题 --- SunshineLnsMinApp/pages/activityDetail/activityDetail.js | 121 +++++++++++++++++++++++++++++----------- 1 files changed, 88 insertions(+), 33 deletions(-) diff --git a/SunshineLnsMinApp/pages/activityDetail/activityDetail.js b/SunshineLnsMinApp/pages/activityDetail/activityDetail.js index a51efc1..0bbf3a2 100644 --- a/SunshineLnsMinApp/pages/activityDetail/activityDetail.js +++ b/SunshineLnsMinApp/pages/activityDetail/activityDetail.js @@ -14,18 +14,21 @@ flag: true, hiddenApply: true, // canApply: true, - statusWord: '' - + statusWord: '', + signStatus: '', + id: "" }, onLoad: function (options) { var that = this; that.setData({ id: options.id, + signStatus: options.signStatus || '', flag: options.flag }) + wx.request({ - url: app.globalData.url + '/api/activityInfo/find?id=' + options.id, + url: app.globalData.url + '/api/activity/find?id=' + options.id, success: function (res) { console.log(res) if (res.data.code == 0) { @@ -36,47 +39,99 @@ 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 (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: '活动已结束' + }) + } } - if (res.data.data.activityStatus == 2) { + else{ that.setData({ canApply: false, - statusWord: '活动正在进行' + statusWord: '报名人数已满' }) } - if (res.data.data.activityStatus == 3) { - that.setData({ - canApply: false, - statusWord: '活动已结束' - }) - } - } - else{ + + }else{ + //不可报名 + console.log('不可报名') that.setData({ canApply: false, - statusWord: '报名人数已满' + statusWord: '您已报名' }) } - - }else{ - //不可报名 - console.log('不可报名') - that.setData({ - canApply: false, - statusWord: '您已报名' - }) } } } }) + }, + + // 签到 + 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 + }); }, apply: function () { @@ -126,7 +181,7 @@ } var that = this; wx.request({ - url: app.globalData.url + '/api/activityInfo/activityApply', + url: app.globalData.url + '/api/activity/activityApply', data: peopleInfo, method: 'POST', header: { @@ -134,8 +189,8 @@ }, success: function (res) { if (res.data.code == 0) { - wx.reLaunch({ - url: '../index/index', + wx.navigateBack({ + delta: 1 }, wx.showToast({ title: '报名成功!', icon: 'success', -- Gitblit v1.8.0