From 8aa9b942670c48dfd6dcf9061425454182e6436f Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Sat, 9 Jun 2018 18:10:50 +0800 Subject: [PATCH] no message --- pages/activity_detail/activity_detail.js | 110 ++++++++++++----------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/pages/activity_detail/activity_detail.js b/pages/activity_detail/activity_detail.js index 5f65ad3..46f3987 100644 --- a/pages/activity_detail/activity_detail.js +++ b/pages/activity_detail/activity_detail.js @@ -1,6 +1,6 @@ //获取应用实例 const app = getApp() - +let interval var WxParse = require('../../wxParse/wxParse.js');//主要为了能够显示获取的html代码 Page({ @@ -13,7 +13,7 @@ Page({ memberList: [], activityDetail: {}, currentMemberType: -1,//参与人角色,-1游客,0发起者,10参与者 - groupStatus:0,//团状态,0发起拼团,10正在拼团,20拼团成功,90拼团失败 + groupStatus: 0,//团状态,0发起拼团,10正在拼团,20拼团成功,90拼团失败 rule_image_height: 0,//活动规则图片高度 detail_image_height: 0,//活动详情图片高度 bannerImage: '/images/activity_banner.png', @@ -32,7 +32,7 @@ Page({ buttomText: '我要开团', tagColor: "#F8B551", remark: "none", - remarkText:"已退款", + remarkText: "已退款", //分享 show: false, cancelWithMask: true, @@ -99,15 +99,15 @@ Page({ groupNo: data.response.groupNo == undefined ? that.data.groupNo : data.response.groupNo, memberList: data.response.memberList == undefined ? [] : data.response.memberList, groupStatus: data.response.status, - currentMemberType: data.response.currentMemberType== undefined ? -1 : data.response.currentMemberType, + currentMemberType: data.response.currentMemberType == undefined ? -1 : data.response.currentMemberType, countdownSec: data.response.countdownSec, - }); + }); let activityContent = data.response.activityContent; WxParse.wxParse('activityContent', 'html', activityContent, that); //根据状态切换样式 - if (that.data.groupNo !=""){ + if (that.data.groupNo != "") { //开团后页面变化 - if (that.data.groupStatus == 10){ + if (that.data.groupStatus == 10) { //团倒计时时 that.countActivityTime(data.response.countdownSec); //正在拼团 @@ -117,14 +117,14 @@ Page({ remark: "block", tagColor: "#F8B551", }); - if (that.data.currentMemberType == -1){ + if (that.data.currentMemberType == -1) { //游客 that.setData({ one_content: "none", two_content: "block", buttomText: '参与拼团', }); - } else if (that.data.currentMemberType == 0 || that.data.currentMemberType == 10){ + } else if (that.data.currentMemberType == 0 || that.data.currentMemberType == 10) { //发起人和邀请人 that.setData({ one_content: "block", @@ -133,33 +133,33 @@ Page({ buttomText: '邀请好友拼团', }); } - } else if (that.data.groupStatus == 20){ - //拼团成功 - if (that.data.currentMemberType == -1) { - //游客 - that.setData({ - one_content: "block", - two_content: "none", - bottomBGColor: '#F36619', - buttomText: '我要开团', - grounpInfo: "none", - grounpInfo2: "block", + } else if (that.data.groupStatus == 20) { + //拼团成功 + if (that.data.currentMemberType == -1) { + //游客 + that.setData({ + one_content: "block", + two_content: "none", + bottomBGColor: '#F36619', + buttomText: '我要开团', + grounpInfo: "none", + grounpInfo2: "block", - }); - } else if (that.data.currentMemberType == 0 || that.data.currentMemberType == 10) { - //发起人和邀请人 - that.setData({ - tagColor: "#21BE8D", - one_content: "block", - two_content: "none", - bottomBGColor: '#21BE8D', - buttomText: '立即预约', - grounpInfo: "block", - grounpInfo2: "none", - remarkText: "", - }); - } - } else if (that.data.groupStatus == 90){ + }); + } else if (that.data.currentMemberType == 0 || that.data.currentMemberType == 10) { + //发起人和邀请人 + that.setData({ + tagColor: "#21BE8D", + one_content: "block", + two_content: "none", + bottomBGColor: '#21BE8D', + buttomText: '立即预约', + grounpInfo: "block", + grounpInfo2: "none", + remarkText: "", + }); + } + } else if (that.data.groupStatus == 90) { //拼团失败 if (that.data.currentMemberType == -1) { //游客 @@ -187,11 +187,11 @@ Page({ } } - }else{ + } else { that.countActivityTime(data.response.countdownSec); that.setData({ one_content: "block", - grounpInfo: "none", + grounpInfo: "none", grounpInfo2: "none", }); } @@ -217,15 +217,19 @@ Page({ }) }, + /** *活动倒计时方法 */ countActivityTime: function (timeStamp) { - var totalSecond = timeStamp - 1; - var interval = setInterval(function () { + var totalSecond = timeStamp - 1; + console.log("countActivityTime>>>" + timeStamp) + if (totalSecond < 0 || interval != undefined) { + return + } + interval = setInterval(function () { // 秒数 var second = totalSecond; - // 天数位 var day = Math.floor(second / 3600 / 24); var dayStr = day.toString(); @@ -255,9 +259,6 @@ Page({ totalSecond--; if (totalSecond < 0) { clearInterval(interval); - wx.showToast({ - title: '活动已结束', - }); this.getActivityDetail(); this.setData({ countDownDay: '00', @@ -282,7 +283,7 @@ Page({ }) }, -//点击团按钮操作 + //点击团按钮操作 groupTap: function (e) { if (wx.getStorageSync('sessionId') == '') { wx.navigateTo({ @@ -292,23 +293,23 @@ Page({ } let that = this; var url = ""; - if (that.data.groupNo == ""){ + if (that.data.groupNo == "") { url = '/mall/wxa/activity/group/open'; //首次开团 this.groupOpenOrJoin(url); - }else{ + } else { if (that.data.groupStatus == 10) { //正在拼团 if (that.data.currentMemberType == -1) { //游客 url = '/mall/wxa/activity/group/join'; this.groupOpenOrJoin(url); - }else{ + } else { //团长与参与人点击分享 this.openActionsheet(); } } else if (that.data.groupStatus == 20) { - //拼团成功 + //拼团成功 if (that.data.currentMemberType == -1) { //游客 url = '/mall/wxa/activity/group/open'; @@ -322,20 +323,20 @@ Page({ success: function (res) { if (res.confirm) { //用户点击确定 - } + } } }) wx.sh } - } else if (that.data.groupStatus == 90){ + } else if (that.data.groupStatus == 90) { //拼团失败 url = '/mall/wxa/activity/group/open'; this.groupOpenOrJoin(url); - } + } } }, -//开团与参团 + //开团与参团 groupOpenOrJoin: function (url) { let that = this; @@ -432,7 +433,10 @@ Page({ * 生命周期函数--监听页面卸载 */ onUnload: function () { - + if (interval != undefined){ + clearInterval(interval); + interval = undefined + } }, /**