166 lines
3.6 KiB
JavaScript
166 lines
3.6 KiB
JavaScript
|
const app = getApp();
|
|||
|
|
|||
|
Page({
|
|||
|
data: {
|
|||
|
moretab: 0,
|
|||
|
countDownHour: 0,
|
|||
|
countDownMinute: 0,
|
|||
|
countDownSecond: 0,
|
|||
|
// 活动列表
|
|||
|
goodsList: [],
|
|||
|
noMore: false, // 没有更多数据
|
|||
|
isLoading: true, // 是否正在加载中
|
|||
|
page: 1, // 当前页码
|
|||
|
step:0,
|
|||
|
sign: !0,
|
|||
|
activityUserCount:0
|
|||
|
},
|
|||
|
|
|||
|
onLoad: function() {
|
|||
|
let _this = this;
|
|||
|
// 获取活动列表
|
|||
|
_this.getGoodsList();
|
|||
|
_this.setData({
|
|||
|
step: wx.getStorageSync('step')
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* Api:获取活动列表
|
|||
|
*/
|
|||
|
getGoodsList(isPage, pageNum) {
|
|||
|
let _this = this;
|
|||
|
app._get('goods/listsMy', {
|
|||
|
page: pageNum || 1,
|
|||
|
user_id: wx.getStorageSync('user_id')
|
|||
|
}, result => {
|
|||
|
let resList = result.data.list,
|
|||
|
dataList = _this.data.goodsList;
|
|||
|
console.log('活动列表',resList);
|
|||
|
if (isPage == true) {
|
|||
|
_this.setData({
|
|||
|
goodsList: dataList.data.concat(resList.data),
|
|||
|
isLoading: false,
|
|||
|
});
|
|||
|
} else {
|
|||
|
_this.setData({
|
|||
|
goodsList: resList.data,
|
|||
|
isLoading: false,
|
|||
|
});
|
|||
|
}
|
|||
|
});
|
|||
|
},
|
|||
|
submitInfotwo: function(t) {
|
|||
|
console.log("获取id");
|
|||
|
var a = t.detail.formId;
|
|||
|
var user_id = wx.getStorageSync('user_id');
|
|||
|
console.log(a), console.log("获取formid结束"), this.setData({
|
|||
|
formid: a
|
|||
|
}), app._get('index/formid', {
|
|||
|
user_id: user_id,
|
|||
|
formid: this.data.formid
|
|||
|
}, function(result) {});
|
|||
|
},
|
|||
|
submitInming: function(t) {
|
|||
|
var id = t.currentTarget.dataset.id;
|
|||
|
this.submitInfotwo(t), this.challenge(id);
|
|||
|
},
|
|||
|
challenge: function(id) {
|
|||
|
wx.navigateTo({
|
|||
|
url: "/pages/category/challenge?id=" + id
|
|||
|
});
|
|||
|
},
|
|||
|
//签到弹窗显示
|
|||
|
sing: function(e) {
|
|||
|
var a = this.data.sign;
|
|||
|
var aid = e.target.dataset.aid;
|
|||
|
var activityStep = e.target.dataset.step;
|
|||
|
this.setData({
|
|||
|
sign: !a,
|
|||
|
aid: aid,
|
|||
|
activityStep
|
|||
|
});
|
|||
|
let _this = this;
|
|||
|
app._post_form('goods/getSignCountByUser', {
|
|||
|
user_id: wx.getStorageSync('user_id'),
|
|||
|
aid: aid
|
|||
|
}, result => {
|
|||
|
console.log(result.data.data);
|
|||
|
this.setData({
|
|||
|
signCount: result.data.data
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
},
|
|||
|
//关闭签到弹窗
|
|||
|
guanbilsig: function() {
|
|||
|
var a = this.data.sign;
|
|||
|
this.setData({
|
|||
|
sign: !a
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
submitTeam: function(t) {
|
|||
|
var id = t.currentTarget.dataset.id;
|
|||
|
this.team(id);
|
|||
|
},
|
|||
|
team: function(id) {
|
|||
|
wx.navigateTo({
|
|||
|
url: "/pages/category/team?id=" + id
|
|||
|
});
|
|||
|
},
|
|||
|
|
|||
|
mySignRecord: function(e){
|
|||
|
var aid = e.target.dataset.aid;
|
|||
|
wx.navigateTo({
|
|||
|
url: '/pages/user/sign?aid=' + aid
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
//签到保存
|
|||
|
goSign: function() {
|
|||
|
let _this = this;
|
|||
|
let activityStep = _this.data.activityStep;
|
|||
|
let step = wx.getStorageSync('step')
|
|||
|
if( step < activityStep ){
|
|||
|
wx.showToast({
|
|||
|
title: '您的步数不达标',
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
})
|
|||
|
}else{
|
|||
|
App._post_form('goods/goSign', {
|
|||
|
user_id: wx.getStorageSync('user_id'),
|
|||
|
step: wx.getStorageSync('step'),
|
|||
|
aid: _this.data.aid
|
|||
|
}, result => {
|
|||
|
console.log(result.data.data);
|
|||
|
let mstatus = result.data.result, msg;
|
|||
|
switch(mstatus) {
|
|||
|
case 0:
|
|||
|
msg = '签到失败';
|
|||
|
break;
|
|||
|
case 1:
|
|||
|
msg = '同步成功';
|
|||
|
break;
|
|||
|
case 2:
|
|||
|
msg = '同步成功';
|
|||
|
break;
|
|||
|
default:
|
|||
|
msg = '签到失败';
|
|||
|
}
|
|||
|
wx.showToast({
|
|||
|
title: msg,
|
|||
|
icon: 'none',
|
|||
|
duration: 2000
|
|||
|
})
|
|||
|
});
|
|||
|
}
|
|||
|
},
|
|||
|
onShow: function() {},
|
|||
|
onHide: function() {},
|
|||
|
onUnload: function() {},
|
|||
|
onReachBottom: function() {},
|
|||
|
onShareAppMessage: function() {}
|
|||
|
|
|||
|
});
|