const app = getApp(); var util = require("../../utils/util.js"); Page({ data: { appAssetsUrl: app.appAssetsUrl, appAssetsUrl2: app.appAssetsUrl2, nodata: util.nodata(), nameList: [ { itemname: "全部", }, ], nameListEle: [], nameIndex: 0, navScrollWidth: 0, showFilterBox: false, filterList: [ { name: "兼职特点", list: [], }, { name: "性别要求", list: [], }, { name: "兼职状态", list: [], }, { name: "结算方式", list: [], }, ], params: { page: 1, limit: 10, city: "", goodLabelsId: "", // area:'', // category:'',//兼职分类(不传查所有 01周末兼职 02日常兼职) // type:'',//兼职特点 // sexlimit:'',//性别要求 // status:'',//兼职状态 // cashMethod:''//结算方式 }, total: { currPage: 0, totalPage: 0, }, noMore: false, listData: [], statusBarHeight: 0, staHeight: 0, }, onShow() { // let index = getApp().params.pePageToIndex; // let nameIndex = this.data.nameIndex; // this.setData({ // nameIndex: index || 0 // }) // this.setData({ // nameIndex: "", // }); // if (this.data.nameList.length == 1) { // this.getNameList(index ? index : 0) // } else { // this.scroll(index ? index : 0) // } // if (this.data.nameList.length == 1) { // this.getNameList(0); // } else { // this.scroll(0); // } }, onLoad() { this.height(); let index = getApp().params.pePageToIndex; let nameIndex = this.data.nameIndex; this.setData({ nameIndex: "", }); if (this.data.nameList.length == 1) { this.getNameList(0); } else { this.scroll(0); } this.loadList(true); }, onReachBottom: function () { this.loadList(); }, // 自定义高度处理 height() { let that = this; const { platform, statusBarHeight } = wx.getSystemInfoSync(); let height = statusBarHeight + 4; //ios 24px let mH = statusBarHeight + 4; if (platform.toLowerCase() == "android") { height += 4; //android 28px mH += 4; } height = height + 38; // 胶囊高度 32px 下边框6px height 状态栏高度 const ButtonBounding = wx.getMenuButtonBoundingClientRect(); wx.getSystemInfo({ success: (res) => { let navHeight = ButtonBounding.height + res.statusBarHeight + (ButtonBounding.top - res.statusBarHeight) * 2; that.setData({ statusBarHeight: ButtonBounding.height + res.statusBarHeight + (ButtonBounding.top - res.statusBarHeight) * 2 + "px", conTop: 50 + 48 + "px", shaiHeight: navHeight + 48 + "px", staHeight: res.statusBarHeight, }); }, }); }, toPartDetail(e) { wx.navigateTo({ url: `/expert/detail/detail?id=${e.currentTarget.dataset.id}`, }); }, nameHandler(e) { console.log(e); let nameIndex = e.currentTarget.dataset.index; let goodLabelsId = e.currentTarget.dataset && e.currentTarget.dataset.guid ? e.currentTarget.dataset.guid : ""; getApp().params.pePageToIndex = nameIndex; this.setData({ nameIndex, params: { ...this.data.params, goodLabelsId, }, }); this.scroll(nameIndex); this.loadList(true); }, showFilter(e) { this.setData({ showFilterBox: !this.data.showFilterBox, }); }, clickMask() { this.setData({ showFilterBox: false, }); }, setChecked(e) { let index = e.currentTarget.dataset.index; let index2 = e.currentTarget.dataset.index2; let filterList = this.data.filterList; for (let i in filterList) { let list = filterList[i].list; for (let m in list) { if (i == index) { if (m == index2) { list[m].checked = !list[m].checked; } else { //兼职特点可以多选 if (i == 0) { continue; } list[m].checked = false; } } } } this.setData({ filterList, }); }, loadList(isRefresh) { let that = this; if (!isRefresh && this.data.noMore) { wx.showToast({ title: "没有更多了~", icon: "none", }); return false; } let nowCity = wx.getStorageSync("CHOOSECITY"); this.setData({ listData: isRefresh ? [] : this.data.listData, noMore: isRefresh ? false : this.data.noMore, params: { ...this.data.params, page: isRefresh ? 1 : this.data.params.page + 1, // category: this.data.nameIndex == 0 ? '' : `0${this.data.nameIndex}`, // city: nowCity.cityId, city: "", // area: nowCity.areaId }, }); wx.showLoading({ title: "努力加载中...", }); // app._post_form('home/label', '', this.data.params, app._get( "expert/greatGodGangPage", this.data.params, function (res) { if (res.code == 0) { 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, }); } }, function (res) { wx.hideLoading(); }, function () { wx.hideLoading(); } ); }, getNameList(index) { let that = this; // app._post_form('home/navigation', '', null, app._post_form("bizlibrary/infoList/maven_label", "", null, function (res) { if (res.code == 0) { that.setData({ nameList: [ { itemname: "全部", }, ...res.dictList, ], }); wx.nextTick(() => { let query = wx.createSelectorQuery(); query .selectAll(".nameitem") .boundingClientRect() .exec(function (res) { let nameListEle = []; for (let i in res[0]) { nameListEle.push(res[0][i].width * 1); } that.setData({ nameListEle, }); }); setTimeout(() => { that.scroll(index); }, 500); }); } }); }, scroll(index) { let that = this; let leftNum = 0; if (index > 0) { for (let i in that.data.nameListEle) { if (i < index) { leftNum += that.data.nameListEle[i]; leftNum += (20 / 750) * wx.getSystemInfoSync().windowWidth; } } } that.setData({ navScrollWidth: leftNum, }); }, clearFilterBox() { let filterList = this.data.filterList; for (let i in filterList) { let list = filterList[i].list; for (let m in list) { list[m].checked = false; } } this.setData({ filterList, }); }, filter() { this.setData({ showFilterBox: false, }); let filterList = this.data.filterList; let params = this.data.params; let type = []; let sexlimit = ""; let status = ""; let cashMethod = ""; for (let i in filterList) { let list = filterList[i].list; for (let m in list) { if (list[m].checked && i == 0) { type.push(list[m].itemcode); } if (list[m].checked && i == 1) { sexlimit = list[m].itemcode; } if (list[m].checked && i == 2) { status = list[m].itemcode; } if (list[m].checked && i == 3) { cashMethod = list[m].itemcode; } } } this.setData({ params: { ...this.data.params, type: type.length > 0 ? type.join(",") : "", sexlimit: sexlimit, status: status, cashMethod: cashMethod, }, }); this.loadList(true); }, onReachBottom: function () { this.loadList(); }, onPullDownRefresh: function () { let nameIndex = this.data.nameIndex; this.getNameList(nameIndex ? nameIndex : 0); this.loadList(true); // 处理完成后,终止下拉刷新 wx.stopPullDownRefresh(); }, onShareAppMessage: function () {}, });