// pages/experience/activityinfo/activityinfo.js var app = getApp(); var util = require("../../../utils/util.js") let cityList = []; Page({ data: { current: 'tab1', hidden: true, list: [], allcity: [], value: [], cityIndex: [0, 0], array: [{ itemcode: '', itemname: '全部' }], scrollTop: 0, scrollHeight: 0, totalCount: 0, loadingmore: false, partTrue: true, activityTrue: false, produindex: 0, produindexone: 0, totalPage: 0, nodata: util.nodata(), arraylist: [{ id: '', name: '全部排序' }, { id: '1', name: '最近三天' }, { id: '2', name: '最近七天' }, { id: '3', name: '最近一个月' }], arraystatus: [{ id: '', name: '全部' }, { id: '1', name: '报名中' }, { id: '2', name: '预告' }, { id: '3', name: '已结束' }], parm: { page: 1, limit: "10", city: "", time: "", status: "", }, parmtwo: { page: 1, limit: '10', city: null, category: null, name: null, }, }, /** * 生命周期函数--监听页面加载 */ cityExperience: function () { wx.switchTab({ url: '../../../pages/experience/index/index', //注意switchTab只能跳转到带有tab的页面,不能跳转到不带tab的页面 }) }, onLoad: function (options) { wx.setNavigationBarTitle({ title: '实践体验' }) let citystorage = wx.getStorageSync("CHOOSECITY") this.data.parmtwo.city = citystorage.cityId let _this = this; wx.getSystemInfo({ success: function (res) { _this.setData({ scrollHeight: res.windowHeight }); } }); _this.loadmsg(); _this.loadpartime(); }, bindMultiPickerColumnChange: function (e) { console.log(e) console.log(cityList) let _this = this; if (e.detail.column === 0) { let c = []; for (let i = 0; i < cityList[e.detail.column + 1].length; i++) { let id = cityList[e.detail.column][e.detail.value].code + "" let oneId = cityList[e.detail.column + 1][i].pid + "" if (id === oneId) { c.push(cityList[e.detail.column + 1][i]); } } _this.data.allcity[e.detail.column + 1] = c; } _this.data.cityIndex[e.detail.column] = e.detail.value _this.setData({ allcity: _this.data.allcity, cityIndex: _this.data.cityIndex }) }, bindMultiPickerChange: function (e) { let _this = this; if (_this.data.allcity[1].length) { _this.data.parm.city = _this.data.allcity[1][e.detail.value[1]].code + ""; } else { _this.data.parm.city = null; } _this.data.value = []; _this.loadActivity(); }, // 单列 价格 bindPickerChange: function (e) { console.log(e) this.setData({ index: e.detail.value }) this.data.value = []; this.setData({ produindex: parseInt(e.detail.value), }) if (this.data.arraylist[parseInt(e.detail.value)].id) { this.data.parm.time = this.data.arraylist[parseInt(e.detail.value)].id } else { this.data.parm.time = null; } this.loadActivity(); }, // 分类 bindPickerChanger: function (e) { console.log(e) this.setData({ index: e.detail.value }) this.data.value = []; this.setData({ produindexone: parseInt(e.detail.value), }) if (this.data.arraylist[parseInt(e.detail.value)].id) { this.data.parm.status = this.data.arraylist[parseInt(e.detail.value)].id } else { this.data.parm.status = null; } this.loadActivity(); }, loadmsg: function () { let _this = this; app._post_form('bizcatelog/apiSelectBizcatelog/cityEnjoyCategory', '', null, function (res) { // console.log(res) if (res.code === 0) { let gender = res.dictList _this.setData({ activitylist: gender }) _this.loadCity() _this.loadData() } }) }, loadpartime: function () { let _this = this; app._post_form('bizcatelog/apiSelectBizcatelog/workCategory', '', null, function (res) { console.log(res) if (res.code === 0) { let gender = res.dictList _this.setData({ partlist: gender }) } }) }, loadActivity: function () { wx.showLoading({ title: '努力加载中...', }) let _this = this; _this.data.parm.page = _this.data.parm.page + ""; app._post_form('act/list', "application/json", JSON.stringify(_this.data.parm), function (res) { console.log(res) // if (res.code === 0) { // _this.setData({ // listActivity: res.data.list, // totalPage: res.data.totalPage // }); // _this.data.totalPage = res.data.totalPage; // } if (res.code === 0) { _this.data.totalPage = res.data.totalPage; let d = _this.data.value; if (res.data.list.length) { d.push(...res.data.list); } else { d = []; } _this.setData({ listActivity: d, totalPage: res.data.totalPage, totalCount: res.data.totalCount, currPage: res.data.currPage }) wx.hideLoading(); } }) }, // tab 切换 tabs: function (e) { let _this = this _this.data.value = []; _this.data.parm.page = 1; _this.data.parmtwo.page = 1; _this.data.totalCount = 0; _this.data.totalPage = 0; let type = e.currentTarget.dataset.type _this.data.value = []; if (type === 0) { _this.setData({ partTrue: true, activityTrue: false }) _this.loadData() } else { _this.setData({ partTrue: false, activityTrue: true }) _this.loadActivity() } // if (e) { // // _this.data.parm.SPRODUCTTYPE = type // _this.loadData(); // } }, bindDownLoad: function () { // if (this.data.parm.page < this.data.totalPage) { // // this.loadNext() // this.loadData(); // } else { // this.setData({ // loadingmore: true // }) // } }, activeDetail: function (e) { // console.log(e.currentTarget.dataset.id) if (e.currentTarget.dataset.id) { wx.navigateTo({ url: '/pages/home/index/activityDetail/activityDetail?id=' + e.currentTarget.dataset.id, }) } }, // tab handleChange({ detail }) { let _this = this _this.data.value = []; _this.data.parmtwo.page = 1; _this.data.totalCount = 0; _this.data.totalPage = 0; this.setData({ current: detail.key }); if (detail.key == "tab1") { this.data.parmtwo.category = null } else { this.data.parmtwo.category = detail.key } this.loadData() }, handleChangeScroll({ detail }) { this.setData({ current_scroll: detail.key }); }, scroll: function (event) { //该方法绑定了页面滚动时的事件,我这里记录了当前的position.y的值,为了请求数据之后把页面定位到这里来。 let _this = this; _this.setData({ scrollTop: event.detail.scrollTop }); }, seeDetails: function (e) { // console.log(e.currentTarget.dataset.id) if (e.currentTarget.dataset.id) { wx.navigateTo({ url: '/pages/home/index/partDetail/partDetail?id=' + e.currentTarget.dataset.id, }) } }, // 兼职 loadData: function () { wx.showLoading({ title: '努力加载中...', }) let _this = this; _this.data.parmtwo.page = _this.data.parmtwo.page + ""; app._post_form('work/list', "application/json", JSON.stringify(_this.data.parmtwo), function (res) { for (let i = 0; i < res.data.list.length; i++) { res.data.list[i].workdateStart = util.changeTime(res.data.list[i].workdateStart) res.data.list[i].workdateEnd = util.changeTime(res.data.list[i].workdateEnd) } if (res.code === 0) { _this.data.totalPage = res.data.totalPage; let d = _this.data.value; if (res.data.list.length) { d.push(...res.data.list); } else { d = []; } _this.setData({ listitem: d, totalPage: res.data.totalPage, totalCount: res.data.totalCount, currPage: res.data.currPage }) wx.hideLoading(); } } ) }, loadCity() { let _this = this; app._post_form('act/area', '', null, function (res) { console.log(res) if (res.code === 0) { let prov = []; let city = []; let citycode = ''; for (let i = 0; i < res.data.length; i++) { let provCode = res.data[i].province.code; prov.push(res.data[i].province); for (let j = 0; j < res.data[i].area.length; j++) { res.data[i].area[j].pid = provCode; city.push(res.data[i].area[j]); citycode = res.data[0].area[0].code; } } if (citycode) { _this.data.parm.city = citycode } _this.data.allcity.push(prov) _this.data.allcity.push(city) cityList.push(prov) cityList.push(city) // _this.loadActivity(); /* console.log(cityList) _this.setData({ allcity: _this.data.allcity })*/ let e = {}; e["detail"] = { column: 0, value: 0 } _this.bindMultiPickerColumnChange(e) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if (this.data.parmtwo.page < this.data.totalPage) { this.data.parmtwo.page++; this.loadData(); } else if (this.data.parm.page < this.data.totalPage) { this.data.parm.page++; this.loadData(); } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })