| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- import {
- getBanner,
- getIndexList
- } from '../../services/index.js'
- import {
- imgServerUrl,
- imgServerUrl_new
- } from '../../config/config.js'
- var app = getApp();
- Page({
- data: {
- //banner图
- imgList: [],
- activity: [{
- src: imgServerUrl + "/images/home/quanzhi.png",
- text: "全职工作"
- },
- {
- src: imgServerUrl + "/images/home/jianzhi.png",
- text: "兼职工作"
- },
- {
- src: imgServerUrl + "/images/home/fanxian.png",
- text: "入职奖励"
- },
- {
- src: imgServerUrl + "/images/home/jipin.png",
- text: "高薪急聘"
- }
- ],
- activity_two: [{
- src: imgServerUrl + "/images/home/fuli.png"
- },
- {
- src: imgServerUrl + "/images/home/quanmin.png"
- }
- ],
- cityCode: '',
- keyWord: '',
- pageNo: 1, //当前分页
- isScroll: true, //是否可以滚动
- filter: -1, //岗位类型
- userInfo: {},
- hasUserInfo: false,
- canIUse: wx.canIUse('button.open-type.getUserInfo'),
- list: [],
- showNoMore: "没有更多信息...", //显示已无更多
- broadcastList: [
- '热心达人!用户孟潞帮朋友找到工作,获得500元推荐入职奖励!',
- '棒棒哒!用户沈佳宜努力工作了30天,获得3000元入职奖励!',
- '恭喜恭喜!用户秦寒推荐新用户注册,获得5元推荐注册奖励!',
- '给你点赞!用户张汉文完成拼工在职30天,获得1000元拼工团奖励!',
- '厉害了!用户李丽刚刚完善了个人简历,好工作正在赶来的路上!'
- ],
- imgServerUrl: imgServerUrl,
- hasLocation1: false,
- },
- onLoad: function(options) {
- this.start();
- },
- start() {
- let cityName = wx.getStorageSync('city') || app.globalData.userInfo.city || '无锡'
- let cityCode = wx.getStorageSync('cityCode') || '320200';
- console.log(cityName)
- console.log(cityCode)
- this.setData({
- cityName: cityName,
- cityCode: cityCode
- })
- this.fetchBanner();
- this.fetchList();
- },
- onShow: function() {
- var self = this;
- if (self.data.hasLocation1) {
- self.setData({
- pageNo: 1, //当前分页
- isScroll: true, //是否可以滚动
- filter: -1, //岗位类型
- list: [],
- hasLocation1: false
- })
- self.start();
- }
- },
- //下拉刷新
- onPullDownRefresh: function() {
- this.setData({
- pageNo: 1, //当前分页
- isScroll: true, //是否可以滚动
- filter: -1, //岗位类型
- list: [],
- })
- this.start();
- wx.stopPullDownRefresh();
- },
- //上拉加载
- onReachBottom: function() {
- var pageNo = this.data.pageNo + 1;
- this.setData({
- pageNo
- })
- this.fetchList();
- },
- onShareAppMessage: function(e) {
- console.log(e)
- },
- // 获取banner图
- fetchBanner() {
- let paramsObj = {
- application: 0
- }
- Object.assign(paramsObj);
- getBanner(paramsObj).then(data => {
- this.setData({
- imgList: data.data.bannerList
- })
- })
- },
- //获取热门列表数据
- fetchList(params) {
- if (!this.data.isScroll) {
- return false
- }
- let paramsObj = {
- cityCode: this.data.cityCode,
- pageNo: this.data.pageNo
- }
- Object.assign(paramsObj);
- getIndexList(paramsObj).then(data => {
- var pageNo = data.data.pageNo;
- let setData = {};
- // 是否可以滚动加载数据
- if (data.data.isLast) {
- setData.isScroll = false
- }
- if (data.data.hotPosition.length != 0) {
- setData.list = this.data.list.concat(data.data.hotPosition)
- setData.pageNo = pageNo;
- } else {
- setData.list = this.data.list;
- }
- this.setData({
- ...setData
- })
- })
- },
- //改变列表
- changeList(e) {
- const {
- index
- } = e.currentTarget.dataset
- this.workType(index)
- },
- //判断当前工作类型
- workType(index) {
- switch (index) {
- case 0:
- wx.navigateTo({
- url: '../fulltime/index',
- })
- break;
- case 1:
- wx.navigateTo({
- url: '../parttime/index',
- })
- break;
- case 2:
- wx.navigateTo({
- url: '../reward/index',
- })
- break;
- case 3:
- wx.navigateTo({
- url: '../jipin/index',
- })
- break;
- }
- },
- changeList2(e) {
- const {
- index
- } = e.currentTarget.dataset
- this.workType2(index)
- },
- workType2(index) {
- switch (index) {
- case 0:
- wx.navigateTo({
- url: '../fuli/index',
- })
- break;
- case 1:
- wx.navigateTo({
- url: '../agent/index',
- })
- break;
- }
- },
- //去详情页
- toDetail(e) {
- const {
- id,
- cate
- } = e.currentTarget.dataset
- wx.navigateTo({
- url: '../detail/index?hpPositionId=' + id + "&cate=" + cate,
- })
- },
- //轮播图跳转详情页
- toDetail_slide(e) {
- var id = e.currentTarget.dataset.id;
- var arr;
- if (id) {
- arr = id.split(",");
- var positionId = arr[1];
- var cate = arr[0];
- wx.navigateTo({
- url: '../detail/index?hpPositionId=' + positionId + "&cate=" + cate,
- })
- }
- },
- // 去搜索页
- toSearch() {
- wx.navigateTo({
- url: '../search/index',
- })
- },
- // 去城市选择页
- toCity() {
- wx.navigateTo({
- url: '../city/index',
- })
- },
- imageLoad() {
- var that = this
- var query = wx.createSelectorQuery()
- query.select('.slide-image').boundingClientRect()
- query.exec(function(res) {
- console.log(res)
- that.setData({
- swiperH: res[0].height
- })
- })
- }
- })
|