// miniprogram/pages/indexapp/indexapp.js Page({ /** * 页面的初始数据 */ data: { deviceloglist: [], longitude: 113.324520, latitude: 23.099994, markers: [{ id: 0, iconPath: "/resources/location.png", latitude: 23.099994, longitude: 113.324520, width: 50, height: 50 }], controls: [{ id: 1, iconPath: '../../images/write.png', position: { left: 0, top: 300 - 50, width: 50, height: 50 }, clickable: true }] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; wx.getLocation({ type: "gcj02", success: function (res) { var latitude = res.latitude; var longitude = res.longitude; //console.log(res.latitude); that.setData({ latitude: res.latitude, longitude: res.longitude, markers: [{ latitude: res.latitude, longitude: res.longitude }] }) } }), wx.cloud.callFunction({ name: 'devicelog' }).then(res => { var that = this; that.setData({ deviceloglist: res.result.data.rows }) console.log(res); }).catch(err => { console.error(err); }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, showLatest: function () { wx.cloud.callFunction({ name: 'devicelog' }).then(res => { var that = this; that.setData({ deviceloglist: res.result.data.rows }) console.log(res); }).catch(err => { console.error(err); }) }, jump: function (event) { var that = this; var latitude = event.target.dataset.pointLat; var longitude = event.target.dataset.pointLon; that.setData({ latitude: latitude, longitude: longitude, markers: [{ latitude: latitude, longitude: longitude }] }) } })