storeDetail.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { storeDetail } from '../../api/other';
  2. import { MAKE_PHONE_CALL } from '../../utils/util.js';
  3. Page({
  4. data: {
  5. dataInfo:{},
  6. latitude:0,
  7. longitude:0
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad(options) {
  13. wx.getLocation({
  14. type: 'wgs84',
  15. success: (res) => {
  16. this.setData({
  17. latitude: res.latitude,
  18. longitude: res.longitude
  19. })
  20. this.loadData(options.id)
  21. },
  22. fail: (err) => {
  23. wx.showModal({
  24. title: '提示',
  25. content: '获取定位失败,请检查是否开启定位权限',
  26. showCancel: false,
  27. confirmText: '我知道了'
  28. })
  29. this.loadData(options.id)
  30. }
  31. })
  32. },
  33. async loadData(id){
  34. const res = await storeDetail(id,{longitude:this.data.longitude,latitude:this.data.latitude});
  35. if(res.code == 200){
  36. this.setData({
  37. dataInfo:res.data
  38. })
  39. }else{
  40. wx.showToast({ title: res.message || '加载失败', icon: 'none' });
  41. }
  42. },
  43. onPhone(){
  44. MAKE_PHONE_CALL(this.data.dataInfo.phone);
  45. },
  46. /**
  47. * 生命周期函数--监听页面初次渲染完成
  48. */
  49. onReady() {
  50. },
  51. /**
  52. * 生命周期函数--监听页面显示
  53. */
  54. onShow() {
  55. },
  56. /**
  57. * 生命周期函数--监听页面隐藏
  58. */
  59. onHide() {
  60. },
  61. /**
  62. * 生命周期函数--监听页面卸载
  63. */
  64. onUnload() {
  65. },
  66. /**
  67. * 页面相关事件处理函数--监听用户下拉动作
  68. */
  69. onPullDownRefresh() {
  70. },
  71. /**
  72. * 页面上拉触底事件的处理函数
  73. */
  74. onReachBottom() {
  75. },
  76. /**
  77. * 用户点击右上角分享
  78. */
  79. onShareAppMessage() {
  80. }
  81. })