// packageE/maps/maps.js Component({ properties: { datas: { type: null, }, component_id: { type: null, }, }, // 私有数据,可用于模板渲染 data: { emptyImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png", clientWidth: "375", markers: [], scaleData: 16, }, lifetimes: { // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached() {}, moved() {}, detached() {}, }, // 生命周期函数,可以为函数,或一个在methods段中定义的方法名 attached() {}, // 此处attached的声明会被lifetimes字段中的声明覆盖 ready() { let marker = []; marker.push({ // 获取返回结果,放到mks数组中 title: this.data.datas.business_title, id: this.data.component_id, latitude: this.data.datas.map_position.lat, longitude: this.data.datas.map_position.lng, iconPath: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", //图标路径 width: 20, height: 25, callout: { padding: "10rpx", borderRadius: "5rpx", content: this.data.datas.business_title, }, }); this.setData({ markers: marker, clientWidth: wx.getSystemInfoSync().windowWidth, }); }, pageLifetimes: { // 组件所在页面的生命周期函数 show() {}, hide() {}, resize() {}, }, methods: { addressButton() { let latitude = this.data.datas.map_position.lat; let longitude = this.data.datas.map_position.lng; let store_name = this.data.datas.business_title; wx.openLocation({ latitude: latitude, longitude: longitude, scale: 16, name: store_name, }); }, phoneButton() { let mobile = this.data.datas.phone_title; wx.makePhoneCall({ phoneNumber: mobile, }); }, }, });