yuminge-app/yun-min-program-plugin-master/packageI/supplierDist/distributionEntrance/distributionEntrance.js

198 lines
4.2 KiB
JavaScript

// packageG/supplierDist/distributionEntrance/distributionEntrance.js
var location = require("../../../mybehaviors/location/location");
const app = getApp();
import util from "../../../utils/util";
Page({
behaviors: [location],
/**
* 页面的初始数据
*/
data: {
keyWord: '',
delivery_status: 0,
lat: '',
lng: '',
listData: [],
address: '',
timer: '',
point: {
lng: "",
lat: ""
},
page: 1,
current_page: 1,
last_page: 1
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.setNavigationBarTitle({
title: '配送入口',
});
},
searchGo(e) {
this.setData({
keyWord: e.detail
});
// 防抖
if (this.timer) clearTimeout(this.timer);
this.timer = setTimeout(() => {
util.debounce(this.getdata());
}, 500);
},
tapStatus(e) {
this.init();
let ind = e.detail.index;
this.setData({
delivery_status: ind,
listData: [],
page: 1,
current_page: 1,
last_page: 1
});
this.getdata();
},
init() {
this.setData({
listData: [],
page: 1,
total_page: 0
});
},
tolocation(e) {
wx.navigateTo({
url: '/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=suppligoodsOrde',
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this._getLocation((res) => {
let point = app.BMapTransqqMap(parseFloat(res.location.lng), parseFloat(res.location.lat));
this.setData({
address: res.address,
'point.lat': point.lat,
'point.lng': point.lng,
});
this.getdata();
});
this.getdata();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
if (this.data.current_page >= this.data.last_page) {
return;
} else {
this.setData({
page: Number(this.data.page) + 1
});
this.getMore();
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
reverseGet() {
this.getdata();
},
getMore() {
let urlStr = app.getNetAddresss('plugin.supplier-driver-distribution.frontend.delivery-order.deliveryOrderList');
app._postNetWork({
url: urlStr,
data: {
keyWord: this.data.keyWord,
delivery_status: this.data.delivery_status == 0 ? 1 : 2,
lng: this.data.point.lng,
lat: this.data.point.lat,
page: this.data.page
},
success: (resdata) => {
let res = resdata.data;
if (res.result == 1) {
this.setData({
info: res.data,
listData: this.data.listData.concat(res.data.list.data),
current_page: res.data.list.current_page,
last_page: res.data.list.last_page
});
} else {
wx.showToast({
title: res.msg,
icon: 'none',
duration: 1000
});
}
},
fail: function (res) {}
});
},
getdata() {
let urlStr = app.getNetAddresss('plugin.supplier-driver-distribution.frontend.delivery-order.deliveryOrderList');
app._postNetWork({
url: urlStr,
data: {
keyWord: this.data.keyWord,
delivery_status: this.data.delivery_status == 0 ? 1 : 2,
lng: this.data.point.lng,
lat: this.data.point.lat
},
success: (resdata) => {
let res = resdata.data;
if (res.result == 1) {
this.setData({
info: res.data,
listData: res.data.list.data,
current_page: res.data.list.current_page,
last_page: res.data.list.last_page
});
} else {
wx.showToast({
title: res.msg,
icon: 'none',
duration: 1000
});
}
},
fail: function (res) {}
});
}
});