store-detail.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { imgServerUrl } from '../../config/config.js'
  2. import { showToast } from '../../utils/tips.js'
  3. import { getStoreDetail, getIp } from '../../services/index.js'
  4. var $ = require('../../libs/gdconf.js');
  5. Page({
  6. data: {
  7. imgServerUrl:imgServerUrl
  8. },
  9. onLoad: function (options) {
  10. this.fetchData()
  11. },
  12. onShareAppMessage: function () {
  13. },
  14. fetchData(){
  15. this.setData({
  16. hpCompanyStoreId: this.options.hpCompanyStoreId
  17. })
  18. getStoreDetail({
  19. hpCompanyStoreId: this.data.hpCompanyStoreId
  20. }).then(data=>{
  21. this.setData({
  22. data:data.data
  23. })
  24. if(data.data.storeAddr ){
  25. this.fetchIp()
  26. }
  27. })
  28. },
  29. fetchIp(){
  30. let addrIndex = this.data.data.storeAddr.indexOf("市")
  31. let cityName = this.data.data.storeAddr.substring(0,addrIndex+1)
  32. this.data.cityName = cityName
  33. getIp({
  34. city:cityName,
  35. addr:this.data.data.storeAddr
  36. }).then(data=>{
  37. this.setData({
  38. comLocation:data.data
  39. })
  40. })
  41. },
  42. tomap() {
  43. if(!this.data.data.storeAddr ){
  44. showToast('没有门店位置')
  45. return
  46. }
  47. var that = this
  48. wx.showLoading({ title: 'loading', mask: true });
  49. //获得当前位置坐标
  50. $.map.getRegeo({
  51. success(data) {
  52. wx.hideLoading();
  53. var data = data[0], cityd = data.regeocodeData.addressComponent.province;
  54. let POIlongitude = that.data.comLocation.split(",")[0]
  55. let POIlatitude = that.data.comLocation.split(",")[1]
  56. let obj = {
  57. POIlocation: that.data.comLocation,
  58. POIlongitude: POIlongitude,
  59. POIlatitude: POIlatitude,
  60. address: '',
  61. city: that.data.cityName,
  62. cityd: cityd,
  63. fromhistory: "0",
  64. latitude: data.latitude,
  65. longitude: data.longitude,
  66. name: that.data.data.storeAddr,
  67. saddress: data.name,
  68. sname: "我的位置",
  69. }
  70. let params = ''
  71. for (let key in obj) {
  72. params += key + "=" + obj[key] + "&"
  73. }
  74. wx.navigateTo({
  75. url: '../gdmap/index?' + params,
  76. })
  77. },
  78. fail(data){
  79. wx.hideLoading();
  80. that.setData({
  81. authMask:true
  82. })
  83. }
  84. });
  85. },
  86. hideAuth(){
  87. this.setData({
  88. authMask:false
  89. })
  90. },
  91. })