daofu-applet/pages/emergency/t-x/index/index.js

133 lines
2.7 KiB
JavaScript
Raw Normal View History

2024-01-29 17:42:38 +08:00
// pages/emergency/resourse/index/index.js
const app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
condition: '',
2024-01-30 16:35:55 +08:00
2024-01-29 17:42:38 +08:00
canChange: false,
freshIng: false,
2024-01-30 16:35:55 +08:00
latlng: {},
2024-01-29 17:42:38 +08:00
page: 1,
pageSize: 10,
2024-01-30 16:35:55 +08:00
list: []
2024-01-29 17:42:38 +08:00
},
pageLifetimes: {
show: function () {
2024-01-30 16:35:55 +08:00
this.getLoc();
2024-01-29 17:42:38 +08:00
},
},
/**
* 组件的方法列表
*/
methods: {
/**
* 搜索
*/
inputSearch: function (e) {
this.data.condition = e.detail.value;
this.refresh();
},
/**
* 切换筛选
*/
tabSelect: function (params) {
if (!this.data.canChange) return
this.data.canChange = false;
const index = Number.parseInt(params.currentTarget.dataset.index);
this.data.curTab = index;
this.setData(this.data)
this.refresh()
},
/**
* 刷新
* @param {*} params
*/
refresh: function (params) {
this.data.page = 1;
2024-01-30 16:35:55 +08:00
this.data.list = [];
2024-01-29 17:42:38 +08:00
this.setData(this.data)
this.getList();
},
2024-01-30 16:35:55 +08:00
/**
* 获取定位
*/
getLoc: function () {
wx.getLocation({
altitude: true,
highAccuracyExpireTime: 0,
isHighAccuracy: true,
type: 'type',
success: (result) => {
this.data.latlng = result;
},
complete: () => {
this.getList();
}
})
},
toGuid: function (params) {
const item = params.currentTarget.dataset.item;
2024-06-04 14:45:44 +08:00
console.log(item,'item===>');
if (!item.lat || !item.lon) {
2024-01-30 16:35:55 +08:00
wx.showToast({
title: '未采集位置',
icon: 'none',
duration: 2000
})
return
}
wx.openLocation({
2024-06-04 14:45:44 +08:00
latitude: item.lat,
longitude: item.lon,
2024-01-30 16:35:55 +08:00
scale: 18,
});
},
2024-01-29 17:42:38 +08:00
/**
* 获取列表
*/
2024-01-30 16:35:55 +08:00
getList: function () {
const params = {
page: this.data.page,
limit: this.data.pageSize,
lat: this.data.latlng.latitude,
lon: this.data.latlng.longitude,
teamname: this.data.condition
}
app.axios("GET", "app", "/Othteam/getOthteamPage", params, false).then(res => {
this.data.freshIng = false;
if (res.code == 1) {
2024-06-04 14:45:44 +08:00
2024-01-30 16:35:55 +08:00
let page = Number.parseInt(res.data.pageNum);
if (this.data.page == 1) {
this.data.list = res.data.list;
} else {
var list = this.data.list;
if (this.data.page == page) this.data.list = [...list, ...res.data.list]
}
if (res.data.list?.length > 0) this.data.page = page + 1
}
2024-06-04 14:45:44 +08:00
this.setData(this.data);
console.log(this.data.list,'this.data.list===>');
2024-01-30 16:35:55 +08:00
})
},
2024-01-29 17:42:38 +08:00
}
})