map.vue 5.3 KB

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