123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- // pages/experience/activityinfo/activityinfo.js
- var app = getApp();
- var util = require("../../../../utils/util.js")
- Page({
- data: {
- appAssetsUrl:app.appAssetsUrl,
- nodata: util.nodata(),
- typeList: [{
- name: '兼职'
- }, {
- name: '活动'
- }],
- typeListIndex: 0,
- //兼职
- params1:{
- pageNum:1,
- pageSize:10,
- city:''
- },
- //活动
- params2:{
- page:1,
- limit:10,
- city:'',
- status:'',
- time:''
- },
- keyword: '',
- total:{
- currPage: 0,
- totalPage: 0
- },
- noMore:false,
- listData:[]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let cityData = wx.getStorageSync("CHOOSECITY");
- this.setData({
- ['params1.city']: cityData.cityId,
- ['params2.city']: cityData.cityId,
- })
- let that = this;
- that.loadList(true);
- wx.getSystemInfo({
- success: function (res) {
- that.setData({
- scrollHeight: res.windowHeight
- });
- }
- });
- },
- loadList(isRefresh) {
- let that = this;
- if (!isRefresh && this.data.noMore) {
- wx.showToast({
- title: '没有更多了~',
- icon: 'none'
- })
- return false;
- }
- let nowCity = wx.getStorageSync("CHOOSECITY");
- let url = this.data.typeListIndex==0?'home/label':'act/list'
- let params = this.data.typeListIndex==0?{
- ...this.data.params1,
- pageNum: isRefresh?1:this.data.params1.pageNum+1
- }:{
- ...this.data.params2,
- page: isRefresh?1:this.data.params2.page+1
- };
- this.setData({
- listData:isRefresh?[]:this.data.listData,
- [this.data.typeListIndex==0?'params1':'params2']: params,
- noMore:isRefresh?false:this.data.noMore
- })
- this.setData({
- listData: isRefresh ? [] : this.data.listData,
- noMore: isRefresh ? false : this.data.noMore,
- params:{
- ...params,
- keyword: this.data.keyword
- }
- })
- wx.showLoading({
- title: '努力加载中...',
- })
- app._post_form(url, '', this.data.params,
- function(res) {
- if (res.code == 0) {
- //防止触发onReachBottom钩子导致数据重复
- if(res.page.list.length>0 && that.data.listData.length>0 && res.page.list[0].id == that.data.listData[0].id){
- return ;
- }
- let listData = that.data.listData;
- listData.push(...res.page.list);
- that.setData({
- listData,
- currPage: res.page.currPage,
- totalPage: res.page.totalPage,
- noMore: res.page.totalPage == res.page.currPage
- })
- }
- })
- },
- keywordInput(e){
- this.setData({
- keyword: e.detail.value
- })
- },
- search(){
- this.loadList(true)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.loadList();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- switchType(e) {
- if (e) {
- let typeListIndex = e.currentTarget.dataset.index;
- this.setData({
- typeListIndex
- })
- this.loadList(true);
- }
- }
- })
|