You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
2.3 KiB
126 lines
2.3 KiB
|
5 years ago
|
// pages/pbService/PRpark/index.js
|
||
|
|
import commonApi from "../../../utils/https/common"
|
||
|
|
Page({
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
page_no:1,
|
||
|
|
lat:"",
|
||
|
|
lon:"",
|
||
|
|
list:[],
|
||
|
|
total:1
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad: function (options) {
|
||
|
|
let that = this;
|
||
|
|
wx.getLocation({
|
||
|
|
type: 'gcj02',
|
||
|
|
success: function (res) {
|
||
|
|
console.log(res)
|
||
|
|
that.setData({
|
||
|
|
lat:res.latitude,
|
||
|
|
lon:res.longitude
|
||
|
|
})
|
||
|
|
that.getList()
|
||
|
|
},
|
||
|
|
fail:function(){
|
||
|
|
wx.showToast({
|
||
|
|
title: '请先开启定位',
|
||
|
|
icon:'none'
|
||
|
|
})
|
||
|
|
setTimeout(()=>{
|
||
|
|
wx.navigateBack()
|
||
|
|
},1500)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
getList:function(){
|
||
|
|
let list = this.data.list;
|
||
|
|
if(list.length>=this.data.total) return;
|
||
|
|
commonApi._post("pbservice/Prpark/getList",{
|
||
|
|
map_type:"gd",
|
||
|
|
lon:this.data.lon,
|
||
|
|
lat:this.data.lat,
|
||
|
|
page_no:this.data.page_no,
|
||
|
|
page_num:20
|
||
|
|
}).then(res=>{
|
||
|
|
res.data.rows.map(item=>{
|
||
|
|
item.distance = item.distance?item.distance.toFixed(2):""
|
||
|
|
})
|
||
|
|
this.setData({
|
||
|
|
total:res.data.total,
|
||
|
|
list:list.concat(res.data.rows)
|
||
|
|
})
|
||
|
|
})
|
||
|
|
},
|
||
|
|
gotoLocation:function(e){
|
||
|
|
let info = e.currentTarget.dataset.item;
|
||
|
|
wx.showModal({
|
||
|
|
title:"提示",
|
||
|
|
content:"到"+info.name+"去?",
|
||
|
|
success:function(res){
|
||
|
|
if(res.confirm){
|
||
|
|
wx.openLocation({
|
||
|
|
latitude: Number(info.gdlat),
|
||
|
|
longitude: Number(info.gdlon),
|
||
|
|
name:info.name
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
|
*/
|
||
|
|
onReady: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面显示
|
||
|
|
*/
|
||
|
|
onShow: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面隐藏
|
||
|
|
*/
|
||
|
|
onHide: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面卸载
|
||
|
|
*/
|
||
|
|
onUnload: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
|
*/
|
||
|
|
onPullDownRefresh: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面上拉触底事件的处理函数
|
||
|
|
*/
|
||
|
|
onReachBottom: function () {
|
||
|
|
this.getList()
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 用户点击右上角分享
|
||
|
|
*/
|
||
|
|
onShareAppMessage: function () {
|
||
|
|
|
||
|
|
}
|
||
|
|
})
|