You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

245 lines
4.7 KiB
JavaScript

// pages/myAgentNew/index.js
let app = getApp();
const commonUtil = require("../../utils/commonUtil.js");
Page({
/**
* 页面的初始数据
*/
data: {
chaShowed:false,
navigatorHeight:wx.getStorageSync("navigationBarHeight"),
inputShowed: false,
inputVal: "搜索我的项目",
active:3,
smallShow:false,
smallText:"按活跃",
hasMoreData: false,
isLoading: true,
recordList:[],
searchParam: {
pageNum: 1,
pageSize: 20,
keys: '',
deletedTag:2
},
},
inputTyping: function (e) {
this.setData({
inputVal: e.detail.value,
});
console.log(this.data.inputVal == "");
if (this.data.inputVal == "") {
this.data.recordList = [];
this.data.searchParam.pageNum = 1;
this.data.searchParam.keys = "";
this.getJobList();
}
},
searchKey: function (e) {
console.log(e);
this.data.recordList = [];
this.data.searchParam.pageNum = 1;
this.data.searchParam.keys = this.data.inputVal;
this.getJobList();
},
showInput: function () {
this.setData({
inputShowed: true,
});
},
hideInput: function () {
this.setData({
inputVal: "",
inputShowed: false,
});
},
clearInput: function () {
this.setData({
inputVal: "搜索我的项目",
chaShowed: false,
});
this.data.recordList = [];
this.data.searchParam.pageNum = 1;
this.data.searchParam.keys = "";
this.getJobList();
},
showSmall(){
this.setData({
smallShow: true,
});
},
hideSmall(){
this.setData({
smallShow: false,
});
},
goSearch(){
wx.navigateTo({
url: '../search/index?from=myProject',
})
},
getJobList(){
var that = this;
that.setData({
isLoading: true
});
wx.showLoading({
title: '加载中...',
})
that.data.searchParam.keys = that.data.inputVal == '搜索我的项目' ? '' : that.data.inputVal;
wx.request({
url: app.globalData.ip + '/store/project/list',
data: that.data.searchParam,
header: app.globalData.header,
method: "post",
success: function (res) {
console.log(res.data);
if (res.data.status == 200) {
that.setData({
isLoading: false
});
if ((res.data.data.recordList != null && res.data.data.recordList.length < 20) || res.data.data.recordList == null || res.data.data.recordList.length == 0) {
var recordListTemp = res.data.data.recordList;
that.data.recordList = that.data.recordList.concat(recordListTemp);
that.setData({
hasMoreData: false
});
} else {
var recordListTemp = res.data.data.recordList;
that.data.recordList = that.data.recordList.concat(recordListTemp);
that.setData({
hasMoreData: true
});
}
that.data.recordList.forEach(item => {
item["distanceKm"] = commonUtil.getDistanceName(
item.distance
);
})
that.setData({
recordList: that.data.recordList,
isLoading: false,
});
// debugger;
// wx.hideLoading();
} else {
app.showTips(that, res.data.msg);
}
wx.hideLoading({
success: (res) => {},
})
},
fail: function (res) {
console.log(res);
}
})
},
onScrollToLower() {
console.log(this.data.searchParam);
this.data.searchParam.pageNum = this.data.searchParam.pageNum + 1;
this.getJobList();
},
onScrollRefresh: function () {
var that = this;
that.data.searchParam.pageNum = 1;
that.setData({
recordList: [],
});
that.getJobList();
// setTimeout(function(){
// that.setData({
// recordList: [],: false,
// })
// },2000);
},
onLoad(options) {
},
toDetail(e){
wx.navigateTo({
url: './myProjectDetail/index?id='+e.mark.id,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
// wx.showLoading({
// title: '加载中...',
// })
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
var that = this;
that.setData({
recordList:[],
["searchParam.pageNum"]:1
})
// wx.hideLoading({
// success: (res) => {},
// })
// that.data.recordList = []
that.getJobList();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})