map.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <app-layout>
  3. <view class="map" v-if="config && config.address">
  4. <!-- #ifdef MP -->
  5. <map :longitude="config.address.longitude" :latitude="config.address.latitude" :show-location="true"
  6. :polygons="polygons" :polygon="polygons" :scale="15"
  7. :include-points="polygons[0].points" :markers="markers"></map>
  8. <!-- #endif -->
  9. <!-- #ifdef H5 -->
  10. <map :longitude="config.address.longitude" :latitude="config.address.latitude" :show-location="true"
  11. :scale="15"
  12. :polyline="polyline"
  13. :include-points="polyline[0].points" :markers="markers"></map>
  14. <!-- #endif -->
  15. <cover-view class="bottom dir-left-nowrap" :style="{paddingBottom: iPhoneX.XBoolean ? '50rpx' : '24rpx'}">
  16. <cover-view class="box-grow-1">
  17. <cover-view class="t-omit">{{mall.name}}</cover-view>
  18. <cover-view class="general">{{config.address.address}}</cover-view>
  19. </cover-view>
  20. <cover-view class="box-grow-0 cross-center" @click="mobile">
  21. <cover-image class="mobile" src="/static/image/icon/store-tel.png"></cover-image>
  22. </cover-view>
  23. </cover-view>
  24. </view>
  25. </app-layout>
  26. </template>
  27. <script>
  28. import {mapState} from 'vuex';
  29. export default {
  30. name: "map",
  31. data() {
  32. return {
  33. config: null,
  34. };
  35. },
  36. onLoad() { this.$commonLoad.onload();
  37. this.loadData();
  38. },
  39. computed: {
  40. // #ifdef MP
  41. polygons() {
  42. let polygons = [];
  43. if (this.config && this.config.range && this.config.range.length > 0) {
  44. let points = [];
  45. for (let i in this.config.range) {
  46. points.push({
  47. latitude: this.config.range[i].lat,
  48. longitude: this.config.range[i].lng,
  49. });
  50. }
  51. polygons.push({
  52. points: points,
  53. // #ifndef MP-ALIPAY
  54. strokeColor: '#4d77ff',
  55. strokeWidth: 2,
  56. // #endif
  57. // #ifdef MP-ALIPAY
  58. color: '#4d77ff',
  59. width: 2,
  60. // #endif
  61. fillColor: '#4d77ff40',
  62. });
  63. }
  64. return polygons;
  65. },
  66. // #endif
  67. // #ifdef H5
  68. polyline() {
  69. let polyline = [];
  70. if (this.config && this.config.range && this.config.range.length > 0) {
  71. let points = [];
  72. for (let i in this.config.range) {
  73. points.push({
  74. latitude: this.config.range[i].lat,
  75. longitude: this.config.range[i].lng
  76. });
  77. }
  78. polyline.push({
  79. points: points,
  80. color: '#4d77ff',
  81. width: 2,
  82. borderWidth: 2
  83. });
  84. }
  85. return polyline;
  86. },
  87. // #endif
  88. markers() {
  89. let markers = [];
  90. if (this.config && this.config.range && this.config.address) {
  91. markers.push({
  92. latitude: this.config.address.latitude,
  93. longitude: this.config.address.longitude,
  94. // #ifndef MP-ALIPAY
  95. callout: {
  96. content: this.mall.name,
  97. color: '#353535',
  98. bgColor: '#ffffff',
  99. display: 'ALWAYS',
  100. fontSize: 13,
  101. padding: 4,
  102. borderWidth: 2,
  103. borderRadius: 10,
  104. borderColor: '#ffffff'
  105. },
  106. anchor: {
  107. x: 0.5,
  108. y: 1
  109. },
  110. // #endif
  111. // #ifdef MP-ALIPAY
  112. anchorX: 0.5,
  113. anchorY: 1,
  114. customCallout: {
  115. "type": 2,
  116. "descList": [{
  117. "desc": this.mall.name,
  118. "descColor": "#353535"
  119. }],
  120. "isShow": 1
  121. },
  122. // #endif
  123. iconPath: '/static/image/location.png',
  124. width: 20,
  125. height: 20,
  126. })
  127. }
  128. return markers;
  129. },
  130. ...mapState({
  131. mall: state => state.mallConfig.mall,
  132. iPhoneX: state => state.iPhoneX
  133. }),
  134. },
  135. methods: {
  136. loadData() {
  137. this.$request({
  138. url: this.$api.order.delivery,
  139. method: 'post',
  140. }).then(response => {
  141. if (response.code == 0) {
  142. this.config = response.data.config;
  143. } else {
  144. uni.showModal({
  145. content: response.msg,
  146. showCancel: false
  147. });
  148. }
  149. })
  150. },
  151. mobile() {
  152. uni.makePhoneCall({
  153. phoneNumber: this.config.contact_way,
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .map {
  161. map {
  162. width: 100%;
  163. height: #{1334rpx};
  164. }
  165. .bottom {
  166. position: fixed;
  167. bottom: 0;
  168. left: 0;
  169. width: #{750rpx};
  170. padding: #{24rpx};
  171. background-color: #ffffff;
  172. .mobile {
  173. width: #{40rpx};
  174. height: #{40rpx};
  175. display: block;
  176. }
  177. .general {
  178. color: $uni-general-color-two;
  179. font-size: $uni-font-size-weak-one;
  180. }
  181. }
  182. }
  183. </style>