storeDetail.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { storeDetail } from '../../api/other';
  2. import { MAKE_PHONE_CALL } from '../../utils/util.js';
  3. // import amapFile from '../../utils/amap-wx.130.js';
  4. Page({
  5. data: {
  6. dataInfo:{},
  7. latitude:0,
  8. longitude:0
  9. },
  10. onLoad(options) {
  11. wx.getLocation({
  12. type: 'wgs84',
  13. success: (res) => {
  14. this.setData({
  15. latitude: res.latitude,
  16. longitude: res.longitude
  17. })
  18. this.loadData(options.id)
  19. },
  20. fail: (err) => {
  21. wx.showModal({
  22. title: '提示',
  23. content: '获取定位失败,请检查是否开启定位权限',
  24. showCancel: false,
  25. confirmText: '我知道了'
  26. })
  27. this.loadData(options.id)
  28. }
  29. })
  30. },
  31. async loadData(id){
  32. const res = await storeDetail(id,{longitude:this.data.longitude,latitude:this.data.latitude});
  33. if(res.code == 200){
  34. this.setData({
  35. dataInfo:res.data
  36. })
  37. }else{
  38. wx.showToast({ title: res.message || '加载失败', icon: 'none' });
  39. }
  40. },
  41. onAddress(){
  42. wx.openLocation({
  43. latitude: this.data.dataInfo.latitude * 1, // 纬度
  44. longitude: this.data.dataInfo.longitude * 1, // 经度
  45. name:this.data.dataInfo.name,
  46. address: this.data.dataInfo.address,
  47. })
  48. // const myAmap = new amapFile.AMapWX({ key: '9570ea64f637d1744ec4944bc909176a' });
  49. // myAmap.getPoiAround({
  50. // success: data => {
  51. // console.log('周边POI:', data);
  52. // },
  53. // fail: info => {
  54. // console.error(info);
  55. // }
  56. // });
  57. },
  58. onPhone(){
  59. MAKE_PHONE_CALL(this.data.dataInfo.phone);
  60. },
  61. })