123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472 |
- 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: {
- pageNum: 1,
- pageSize: 10,
- city: '',
- area: '',
- category: '', //兼职分类(不传查所有 01周末兼职 02日常兼职)
- type: '', //兼职特点
- sexlimit: '', //性别要求
- status: '', //兼职状态
- cashMethod: '' //结算方式
- },
- total: {
- currPage: 0,
- totalPage: 0
- },
- noMore: false,
- listData: [],
- statusBarHeight: 0,
- titleHeight: 0,
- conTop: 0,
- timeListIndex: 0,
- statusListIndex: 0,
- timeList: [{
- code: 'createTime',
- name: '发布时间',
- order: 'desc'
- }, {
- code: 'workdateStart',
- name: '兼职开始时间',
- order: 'desc'
- }],
- statusList: [],
- statusBarHeight: 0,
- staHeight: 0,
- shaiHeight: 0
- },
- onShow() {
- // let index = getApp().params.pePageToIndex;
- // let nameIndex = this.data.nameIndex;
- // console.log(nameIndex,'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)
- // }
- },
- onLoad() {
- // this.getFilterList();
- this.height()
- this.getJobList()
- let index = getApp().params.pePageToIndex;
- let nameIndex = this.data.nameIndex;
- console.log(nameIndex, 'nameIndex')
- this.setData({
- nameIndex: ''
- })
- if (this.data.nameList.length == 1) {
- this.getNameList(0)
- } else {
- this.scroll(0)
- }
- this.loadList(true);
- },
- //选择时间排序
- timePickerChange(e) {
- let timeListIndex = e.detail.value;
- this.setData({
- timeListIndex,
- })
- console.log(timeListIndex)
- this.loadList(true)
- },
- getJobList() {
- let that = this;
- app._get('bizcatelog/apiSelectBizcatelog/workStatus', '',
- function(res) {
- if (res.code == 0) {
- console.log(res)
- that.setData({
- statusList: [{ itemname: '兼职状态', itemcode: '' }, ...res.dictList]
- })
- }
- })
- },
- //选择报名状态
- statusPickerChange(e) {
- let statusListIndex = e.detail.value;
- this.setData({
- statusListIndex,
- ['params.status']: this.data.statusList[statusListIndex].itemcode
- })
- this.loadList(true)
- },
- // 自定义高度处理
- 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 状态栏高度
- // 胶囊高度 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',
- titleHeight: (height - res.statusBarHeight) + 'px',
- conTop: 50 + 'px',
- shaiHeight: (navHeight + 48) + 'px',
- staHeight: res.statusBarHeight,
- })
- }
- })
- },
- onReachBottom: function() {
- this.loadList();
- },
- toPartDetail(e) {
- wx.navigateTo({
- url: `/pages/home/index/partDetail/partDetail?id=${e.currentTarget.dataset.id}`
- })
- },
- nameHandler(e) {
- let nameIndex = e.currentTarget.dataset.index;
- getApp().params.pePageToIndex = nameIndex;
- this.setData({
- nameIndex
- })
- 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,
- pageNum: isRefresh ? 1 : this.data.params.pageNum + 1,
- category: this.data.nameIndex == 0 ? '' : `0${this.data.nameIndex}`,
- city: nowCity.cityId,
- area: nowCity.areaId,
- isHome: 0,
- sidx: that.data.timeList[that.data.timeListIndex].code,
- order: 'desc'
- // timeListIndex
- }
- })
- wx.showLoading({
- title: '努力加载中...',
- })
- app._post_form('home/label', '', 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;
- }
- res.page.list.map(v => {
- v.workdateStart = v.workdateStart.replace(/-/g, '.')
- v.workdateEnd = v.workdateEnd.replace(/-/g, '.')
- })
- // let listData = that.data.listData;
- // listData.push(...res.page.list);
- that.setData({
- listData: []
- })
- setTimeout(() => {
- const dataList = res.page.list || []
- const page = {
- currPage: res.page.currPage,
- totalPage: res.page.totalPage,
- }
- that.setData({
- listData: dataList,
- total: page,
- noMore: res.page.totalPage == res.page.currPage
- })
- },0)
- // that.setData({
- // listData,
- // currPage: res.page.currPage,
- // totalPage: res.page.totalPage,
- // total: {
- // currPage: res.page.currPage,
- // totalPage: res.page.totalPage,
- // },
- // noMore: res.page.totalPage == res.page.currPage
- // })
- }
- },
- function(res) {
- wx.hideLoading()
- })
- },
- getNameList(index) {
- let that = this;
- app._post_form('home/navigation', '', null,
- function(res) {
- if (res.code == 0) {
- that.setData({
- nameList: [{ itemname: '全部' }, ...res.data]
- })
- 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
- })
- },
- getFilterList() {
- let that = this;
- app._post_form('home/filter', '', null,
- function(res) {
- if (res.code == 0) {
- let filterList = that.data.filterList;
- //兼职特点
- filterList[0].list = [{
- itemname: '全部',
- itemcode: '',
- checked: false
- }];
- for (let i in res.data.typeList) {
- filterList[0].list.push({
- itemname: res.data.typeList[i].itemname,
- itemcode: res.data.typeList[i].itemcode,
- checked: false
- })
- }
- //性别要求
- filterList[1].list = [{
- itemname: '全部',
- itemcode: '',
- checked: false
- }];
- for (let i in res.data.sexList) {
- filterList[1].list.push({
- itemname: res.data.sexList[i].itemname,
- itemcode: res.data.sexList[i].itemcode,
- checked: false
- })
- }
- //兼职状态
- filterList[2].list = [{
- itemname: '全部',
- itemcode: '',
- checked: false
- }];
- for (let i in res.data.statusList) {
- filterList[2].list.push({
- itemname: res.data.statusList[i].itemname,
- itemcode: res.data.statusList[i].itemcode,
- checked: false
- })
- }
- //结算方式
- filterList[3].list = [{
- itemname: '全部',
- itemcode: '',
- checked: false
- }];
- for (let i in res.data.cashMethodList) {
- filterList[3].list.push({
- itemname: res.data.cashMethodList[i].itemname,
- itemcode: res.data.cashMethodList[i].itemcode,
- checked: false
- })
- }
- that.setData({
- filterList
- })
- }
- })
- },
- 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();
- },
- onPreviousPage() {
- let num = this.data.params.pageNum
- if (num <= 1) return;
- num -= 2;
- this.setData({
- params: {
- ...this.data.params,
- pageNum: num
- },
- noMore: false
- });
- this.loadList();
- },
- onNextPage() {
- this.loadList();
- },
- onPullDownRefresh: function() {
- let nameIndex = this.data.nameIndex;
- this.getNameList(nameIndex ? nameIndex : 0)
- this.loadList(true);
- // this.getFilterList();
- this.getJobList()
- // 处理完成后,终止下拉刷新
- wx.stopPullDownRefresh();
- },
- onShareAppMessage: function() {
- }
- })
|