Chazhaodizhi.nvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <customNav shownav="true" title="map" titledetl=""></customNav>
  4. <view class="">
  5. <web-view style="background-color: #fafafa;" :style="{ height: statusBarHeight + 'px' }" @onPostMessage="getMessage" :src="webUrl"></web-view>
  6. </view>
  7. <view v-if="Keyboar" class="bottomfloatV">
  8. <view class="contentInRowC" style="align-items: center;">
  9. <view class="dizhixx">
  10. <text style="font-size: 26rpx;">{{addrObj.cityInfo.name}}</text>
  11. </view>
  12. <text class="xuanzBt" @click="addrselect">{{i18n('order.queding')}}</text>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. webUrl: '',
  22. lng:0,
  23. lat:0,
  24. statusBarHeight:0,
  25. Keyboar:false,
  26. addrObj:'',
  27. lg:0
  28. }
  29. },
  30. onLoad() {
  31. this.statusBarHeight = uni.getSystemInfoSync().screenHeight;
  32. this.lng = 113.64360881345777;
  33. this.lat = 34.738282020827825;
  34. this.webUrl = '/hybrid/html/maps/mapindex.html?sstate=1&&lat=' + this.lat + '&lng=' + this.lng+'&nlng=0&nlat=0';
  35. var language = uni.getStorageSync('language');
  36. if(language=='yuenan'){
  37. this.lg = 1;
  38. }
  39. if(language=='zh-Hans'){
  40. this.lg = 2;
  41. }
  42. if(language=='zh-Hant'){
  43. this.lg = 3;
  44. }
  45. this.getlocetion();
  46. },
  47. onShow() {
  48. this.getlocetion();
  49. console.log(this.webUrl);
  50. },
  51. methods: {
  52. i18n(str){
  53. return getApp().globalData.$t(str);
  54. },
  55. /**
  56. * 获取当前定位
  57. *
  58. * */
  59. getlocetion() {
  60. const self = this;
  61. // 使用高德地图 也可以使用下方的原生插件定位
  62. uni.getLocation({
  63. geocode: true,
  64. type: 'wgs84',
  65. accuracy: "best",
  66. isHighAccuracy: true,
  67. success: (res) => {
  68. console.log('当前位置的经度11:' + JSON.stringify(res));
  69. self.lat = res.latitude;
  70. self.lng = res.longitude;
  71. self.webUrl = '/hybrid/html/maps/mapindex.html?sstate=1&&lat=' + self.lat +'&lng=' +self.lng+'&nlng=0&nlat=0&lg='+self.lg;
  72. }
  73. });
  74. return
  75. },
  76. getMessage(e) {
  77. console.log("--getMessage--",e.detail.data[0]);
  78. var obj = e.detail.data[0];
  79. if(obj.type==0){
  80. this.Keyboar=true;
  81. this.addrObj=obj;
  82. this.addrObj.cityInfo.name=obj.cityInfo.address
  83. return;
  84. }
  85. if(obj.type==1){
  86. this.Keyboar=true;
  87. this.addrObj=obj;
  88. return;
  89. }
  90. //this.Keyboar=false;
  91. },
  92. addrselect(){
  93. var addr={
  94. address:this.addrObj.cityInfo.address,
  95. name:this.addrObj.cityInfo.name,
  96. longitude:this.addrObj.position.lng,
  97. latitude:this.addrObj.position.lat,
  98. }
  99. uni.setStorageSync('tempLocation',addr);
  100. uni.setStorageSync('userAddrLocation',addr);
  101. uni.navigateBack();
  102. },
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. .dizhixx{
  108. padding: 8rpx;
  109. width: 500rpx;
  110. border-radius: 8rpx;
  111. border: solid lavender;
  112. border-width: 0px 0px 6rpx 0px;
  113. text-align: center;
  114. color:black;
  115. box-shadow: 0rpx 0rpx 10rpx 0rpx lavender;
  116. }
  117. .xuanzBt{
  118. background-color: #00A6FF;
  119. color: white;
  120. font-size: 28rpx;
  121. padding-left: 16rpx;
  122. padding-right: 16rpx;
  123. line-height: 46rpx;
  124. border-radius: 23rpx;
  125. text-align: center;
  126. margin-left: 10rpx;
  127. }
  128. .bottomfloatV{
  129. position: fixed;
  130. flex-direction: row;
  131. justify-content: center;
  132. align-items: center;
  133. left: 0;
  134. right: 0;
  135. bottom: 80rpx;
  136. z-index: 999;
  137. }
  138. </style>