// subPackages/techanNew/selfPickPoint/index.js import commonApi from "../../../utils/https/common" let device = wx.getSystemInfoSync(); const ratio = device.windowWidth / 750; let app = getApp() Page({ /** * 页面的初始数据 */ data: { list: [], pickupId: null, goodsId: null, skuId: null, selectIndex: null, lat:23, lon:113, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ goodsId: options.goodsId, skuId: options.skuId, }) let _this = this wx.getLocation({ type: 'gcj02', success: function (res) { _this.getList() }, fail: function(e) { _this.getList() }, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, getList() { let param = { product_id: this.data.goodsId, lon: this.data.lon || '113', lat: this.data.lat || '23', } commonApi.user_post("product/getDeliverShop", param).then(res => { let resData = res.data || [] resData.forEach(x=>{ if (x.distance) { x.distance = (x.distance / 1000).toFixed(2) } }) this.setData({ list: res.data || [] }) }) }, selectPoint (e) { let index = e.currentTarget.dataset.index; this.setData({ selectIndex: index }) }, goMap (e) { let item = e.currentTarget.dataset.item; console.log(123) wx.openLocation({ latitude: Number(item.lat), longitude: Number(item.lon), name:item.title, address:item.address, fail: function (e) { console.log(e) } }) }, confirmPoint () { if(this.data.selectIndex==null) { wx.showToast({icon: "none",title: "请先选择自提点"}) return; } // 返回上一个页面并带回selectItem let selectItem = this.data.list[this.data.selectIndex] const pages = getCurrentPages(); const prevPage = pages[pages.length - 2]; if (prevPage && prevPage.setPickUpPoint) { console.log(prevPage) prevPage.setPickUpPoint(selectItem) } wx.navigateBack() }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })