144 lines
3.0 KiB
JavaScript
144 lines
3.0 KiB
JavaScript
// pages/nearbyStore/nearbyStore.js
|
|
const app = getApp();
|
|
const regeneratorRuntime = app.loadAsync()
|
|
const model = app.loadModel("index")
|
|
const http = app.loadHttp()
|
|
const util = app.loadUtils('util')
|
|
const { StorageSync } = app.loadModel("getSetting")
|
|
const storage = new StorageSync()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
system: app.globalData.system, //设备相关信息
|
|
pageTitle: "伊莎洗衣", //头部标题
|
|
isBack: true,//显示返回
|
|
markers: [{
|
|
id: 1,
|
|
latitude: 23.099994,
|
|
longitude: 113.324520
|
|
}],
|
|
longitude: "",
|
|
latitude: "",
|
|
addList: [],// 全部门店列表
|
|
reallyList: [],// 渲染列表
|
|
isAdd: 3,// 控制渲染数量
|
|
},
|
|
/**
|
|
* 传入经纬度和目的地名称简介打开地图
|
|
* @param {Object} data latitude精度 longitude纬度 name目的地名称 address目的地介绍
|
|
*/
|
|
intoMap: function (data) {
|
|
let item = data.currentTarget.dataset.item
|
|
wx.openLocation({
|
|
latitude: item.latitude,
|
|
longitude: item.longitude,
|
|
name: item.name,
|
|
address: item.address,
|
|
scale: 28,//缩放比例
|
|
})
|
|
},
|
|
/**
|
|
* 获取当前用户经纬度
|
|
*/
|
|
async getAdd() {
|
|
let data = await model.storage.getSetting("position")
|
|
this.setData({
|
|
longitude: data.longitude,
|
|
latitude: data.latitude
|
|
})
|
|
},
|
|
/**
|
|
* 获取全部门店列表
|
|
*/
|
|
async getStoreList() {
|
|
let data = await model.storage.getSetting("position")
|
|
let res = await http.http.request1({
|
|
url: `${http.api.shoplist}`, method: "POST", data: {
|
|
lat: data.latitude,
|
|
lng: data.longitude
|
|
}
|
|
})
|
|
let rel = res.data.data;
|
|
this.setData({
|
|
addList: [...rel],
|
|
reallyList: [...rel.slice(0, 5)]
|
|
})
|
|
|
|
},
|
|
// 拨打电话
|
|
makePhoneCall(e) {
|
|
let tel = e.currentTarget.dataset.item.telnum
|
|
wx.makePhoneCall({
|
|
phoneNumber: tel
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: async function (options) {
|
|
await model.getauth.userLocation()
|
|
this.getAdd()
|
|
this.getStoreList()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
onPageScroll: function (e) {
|
|
if (this.data.addList.length > this.data.isAdd) {
|
|
let isAdd = this.data.isAdd
|
|
this.setData({
|
|
isAdd: isAdd + 2,
|
|
reallyList: [...this.data.reallyList, ...this.data.addList.slice(isAdd, isAdd + 2)]
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |