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.

323 lines
6.7 KiB
JavaScript

// pages/myAgentNew/index.js
let app = getApp();
const commonUtil = require("../../utils/commonUtil.js");
Page({
/**
* 页面的初始数据
*/
data: {
inputShowed: false,
inputVal: "",
active:3,
smallShow:false,
smallText:"按活跃",
hasMoreData: false,
isLoading: true,
recordList:[],
searchParam: {
pageNum: 1,
pageSize: 20,
keys: '',
sortType: 3,
lat:'',
lng:''
},
},
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: "",
inputShowed: false,
hasMoreData: true,
});
this.data.recordList = [];
this.data.searchParam.pageNum = 1;
this.data.searchParam.keys = "";
this.getJobList();
},
showSmall(){
this.setData({
smallShow: true,
});
},
hideSmall(){
this.setData({
smallShow: false,
});
},
ahyTap(e){
var that = this;
that.data.searchParam.pageNum = 1;
that.data.recordList = [];
// console.log(e.currentTarget.dataset.id);
this.setData({
active:e.currentTarget.dataset.id
});
if(e.currentTarget.dataset.id == 5){
wx.authorize({
scope: 'scope.userLocation',
success: (res) => {
// 注释
// wx.getLocation({
// type: "gcj02",
// success(res1) {
// console.log("获取位置");
// console.log(res1);
// app.globalData.lng = res1.longitude;
// app.globalData.lat = res1.latitude;
// that.data.searchParam.lng = app.globalData.lng;
// that.data.searchParam.lat = app.globalData.lat;
// that.getJobList();
// },
// fail() {},
// });
},
fail: (err) => {
console.log(err)
}
})
// that.getLocation();
}else{
that.getJobList();
}
this.data.searchParam.sortType = e.currentTarget.dataset.id
setTimeout(()=>{
that.setData({
smallShow: false,
});
},500)
},
getLocation() {
var that = this;
console.log(app.globalData.lng);
if (app.isNotEmptyCheck(app.globalData.lng) && app.isNotEmptyCheck(app.globalData.lat)) {
that.data.searchParam.lng = app.globalData.lng;
that.data.searchParam.lat = app.globalData.lat;
} else {
wx.getSetting({
success: (res) => {
console.log(res); // res.authSetting.location
if (res.authSetting["scope.userLocation"]) {
// 注释
// wx.getLocation({
// type: "gcj02",
// success(res1) {
// console.log("获取位置");
// console.log(res1);
// app.globalData.lng = res1.longitude;
// app.globalData.lat = res1.latitude;
// that.data.searchParam.lng = app.globalData.lng;
// that.data.searchParam.lat = app.globalData.lat;
// },
// fail() {},
// });
that.data.searchParam.lng = app.globalData.lng;
that.data.searchParam.lat = app.globalData.lat;
} else {
console.log("11111111");
wx.openSetting({
success(res) {
console.log(res.authSetting);
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
},
});
// that.getStoreJobDetailById();
}
},
});
}
},
getJobList(){
var that = this;
that.setData({
isLoading: true
});
wx.showLoading({
title: '加载中...',
})
wx.request({
url: app.globalData.ip + '/agency/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.pageBean.recordList != null && res.data.data.pageBean.recordList.length < 20) {
var recordListTemp = res.data.data.pageBean.recordList;
that.data.recordList = that.data.recordList.concat(recordListTemp);
that.setData({
hasMoreData: false
});
} else {
var recordListTemp = res.data.data.pageBean.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);
}
})
},
loadMoreData() {
console.log(this.data.searchParam);
this.data.searchParam.pageNum = this.data.searchParam.pageNum + 1;
this.getJobList();
},
makePhoneCall(e){
wx.makePhoneCall({
phoneNumber: e.currentTarget.dataset.tel,
});
},
onLoad(options) {
},
toDetail(e){
wx.navigateTo({
url: './myAgentDetailNew/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() {
}
})