// pages/myAgent/index.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { pageBean: {}, inputShowed: false, inputVal: "", recordList: [], dataLoading:false, searchParam: { pageNum: 1, pageSize: 100, lat: '', lng: '', phoneDialog:false, phone:'', keys: '', } }, showInput: function () { this.setData({ inputShowed: true }); }, hideInput: function () { this.setData({ inputVal: "", inputShowed: false }); }, clearInput: function () { console.log(123); this.setData({ inputVal: "" }); this.data.searchParam.keys = ''; this.data.searchParam.pageNum = 1; this.getList(); }, inputTyping: function (e) { console.log(e.detail.value); this.setData({ inputVal: e.detail.value }); this.data.searchParam.keys = e.detail.value; this.data.searchParam.pageNum = 1; this.getList(); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { //this.getLocation(); }, goEditAgent:function(e){ var id = e.currentTarget.dataset.id; wx.navigateTo({ // url: '/pages/editAgent/index?agencyId=' + id, url:'/pages/agentDetail/index?agencyId=' + id }) }, getDistanceNum: function (distance) { console.log(distance) return 111; }, getLocation: function() { var that = this; // 注释 // wx.getLocation({ // type: 'wgs84', // success (res) { // const latitude = res.latitude // const longitude = res.longitude // const speed = res.speed // const accuracy = res.accuracy // that.data.searchParam.lat = latitude // that.data.searchParam.lng = longitude; // that.setData({ // searchParam: that.data.searchParam, // }); // that.getList(); // }, // fail (res) { // that.getList(); // } // }) }, getList: function () { var that = this; wx.request({ url: app.globalData.ip + '/agency/list', data: that.data.searchParam, header: app.globalData.header, method: "POST", success: function (res) { console.log(res.data); if (res.data.status == 200) { that.setData({ pageBean: res.data.data.pageBean, recordList: res.data.data.pageBean.recordList, }); } else { app.showTips(that, res.data.msg); } that.setData({ dataLoading:true }); wx.hideLoading() }, fail: function (res) { console.log(res); that.setData({ dataLoading:true }); wx.hideLoading() }, }) }, close: function () { this.setData({ phoneDialog:false, }) }, makePhone:function(e){ var that = this; console.log(e); that.setData({ phoneDialog:true, phone:e.currentTarget.dataset.phone }) // wx.makePhoneCall({ // phoneNumber: e.currentTarget.dataset.phone // }); }, makePhoneCall:function(e){ var that = this; wx.makePhoneCall({ phoneNumber: that.data.phone }); }, bindCode:function(e){ console.log(e) wx.navigateToMiniProgram({ appId: 'wxb1f7c694803f6f00', //appid path: '/pages/scanQrcode/index?agencyUserId=' + e.currentTarget.dataset.userid,//path extraData: { //参数 agencyUserId: e.currentTarget.dataset.userid }, envVersion: 'release', //develop 开发版 trial 体验版 release 正式版 success(res) { console.log('成功') // 打开成功 } }) }, openMap:function(e){ let lng = Number(e.currentTarget.dataset.lng); let lat = Number(e.currentTarget.dataset.lat); console.log(lng + " === "+ lat ) // 注释 // wx.getLocation({ // type: 'gcj02', //返回可以用于wx.openLocation的经纬度 // success (res) { // wx.openLocation({ // latitude:lat, // longitude:lng, // scale: 18 // }) // } // }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { wx.showLoading({ title: '加载中...', }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getLocation(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })