// miniprogram/pages/indexapp/indexapp.js Page({ /** * 页面的初始数据 */ data: { value: "", deviceloglist: [], longitude: 113.324520, latitude: 23.099994, markers: [{ id: 0, iconPath: "../../images/point.png", latitude: 23.099994, longitude: 113.324520, width: 50, height: 50 }], }, /** * 生命周期函数--监听页面加载 */ 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: latitude, longitude: longitude, markers: [{ latitude: latitude, longitude: longitude }] }) } }), wx.cloud.callFunction({ name: 'devicelogs' }).then(res => { var that = this; if (res.result.data) { 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; if (data) { 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 }] }) }, onClick: function () { wx.scanCode({ success(res) { console.log(res) } }) }, onSearch: function (event) { wx.cloud.callFunction({ name: 'devicelog', data: { devcode: event.detail } }).then(res => { var that = this; that.setData({ deviceloglist: res.result.data.rows }) console.log(res); }).catch(err => { console.error(err); }) }, })