var i = require("../../../utils/util.js") var e = getApp(), a = e.globalData.setting, os = a, t = e.request, d = e.globalData; Page({ /** * 页面的初始数据 */ data: { url: a.url, //接口网址 iurl: a.imghost, //图片前缀网址 switch_head: 0, //0:我的任务,1:活动说明 zl_act: null, //助力活动 zl_user_list: [], //任务列表 is_load: 0, //是否已经加载 cur_page: 1, //页码 page_num: 5, //每页多少个 is_show_more: 0, //是否加载更多 }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { var th = this; var nav_b = th.selectComponent("#nav_b"); //组件的id nav_b.set_name("助力", ""); }, /** * 生命周期函数--监听页面显示 */ onShow: function() { var th = this; e.request.get("http://172.20.3.102:8022/api/weshop/zl_act", { success: function(res) { if (res.data.code == 0) { th.setData({ zl_act: res.data.data }); } } }) this.get_list(); }, switch_head: function(e) { var th = this; var index = e.currentTarget.dataset.index; //获取当前选择的是任务还是活动说明 var switch_head = th.data.switch_head; //0任务,1活动说明 if (index != switch_head) { th.setData({ switch_head: index }) } }, //关闭导航 close: function() { var th = this; var nav_b = th.selectComponent("#nav_b"); //组件的id nav_b.close_box(); }, //--点击获取用户任务列表-- get_list: function() { var th = this; e.request.get("http://172.20.3.102:8022/api/weshop/zl_user_list", { success: function(res) { if (!th.data.is_load) th.setData({ is_load: 1 }) if (res.data.code == 0) { var list = th.data.zl_user_list; list = list.concat(res.data.data.pageData) //连接数组 th.setData({ zl_user_list: list }); var n_all_num = th.data.cur_page * th.data.page_num; if (res.data.data.total > n_all_num) th.setData({ is_show_more: 1 }) else th.setData({ is_show_more: 0 }) //页吗要更新一下 th.data.cur_page++; } else { th.setData({ is_show_more: 0 }) } } }) }, //-----跳转到领取礼包的页面------ go_task: function() { getApp().goto("/pages/user/assistance/task_assistance"); } })