SearchAddress.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="container" :class="['qn-page-' + theme]">
  3. <view class="header">
  4. <text class="ibonfont ibonsousuo1 sear-icon"></text>
  5. <input type="text" @input="bindInput" @confirm="bindConfirm" v-model="address_key" placeholder="请输入地址" class="ars_input" />
  6. </view>
  7. <view class="bg-ff">
  8. <view class="list-title">从下面列表中选择</view>
  9. <view class="list-li" v-for="(item, index) in list" :key="index" @click="address(item)">
  10. <view class="adrs-label">{{ item.name }}</view>
  11. <view class="adrs-val">{{ item.address.length ? item.address : item.name }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import amap from '@/access/amap-wx.js';
  18. import webUrl from '../../config.js';
  19. export default {
  20. data() {
  21. return {
  22. list: [],
  23. address_key: ''
  24. };
  25. },
  26. onLoad() {
  27. //在 onLoad 中初始化一个高德小程序 SDK 的实例对象。
  28. this.amapPlugin = new amap.AMapWX({
  29. key: webUrl.GDMap_key
  30. });
  31. },
  32. methods: {
  33. bindConfirm() {},
  34. bindInput() {
  35. // #ifdef MP-TOUTIAO
  36. if(['xijinping','xi jin ping','jinping','jin ping','习近平','近平','彭丽媛','丽媛'].includes(this.address_key)){
  37. return
  38. }
  39. // #endif
  40. this.amapPlugin.getInputtips({
  41. keywords: this.address_key,
  42. location: '',
  43. success: data => {
  44. if (data && data.tips) {
  45. this.list = data.tips;
  46. console.log(this.list);
  47. }
  48. }
  49. });
  50. },
  51. address(item) {
  52. console.log(item);
  53. const location = item.location.split(',');
  54. const locationD = this.$_utils.getArea(item.district);
  55. // {"provinceName":"陕西省","cityName":"西安市","districtName":"莲湖区","address":"北院门街道","latitude":34.267011,"longitude":108.940245}
  56. const longitude = location[0];
  57. const latitude = location[1];
  58. this.$store.commit('commit_locationObj', {
  59. ...locationD,
  60. address: item.address.length ? item.address : item.name,
  61. latitude: latitude,
  62. longitude: longitude
  63. });
  64. this.isLoding=true
  65. setTimeout(() => {
  66. this.isLoding=false
  67. uni.switchTab({
  68. url: '/pages/index/index'
  69. });
  70. }, 100);
  71. }
  72. }
  73. };
  74. </script>
  75. <style scoped lang="scss">
  76. .container {
  77. padding-top: 20rpx;
  78. }
  79. .header {
  80. // position: fixed;
  81. // z-index: 999;
  82. // top: 0;
  83. // left: 0;
  84. line-height: 70upx;
  85. border-bottom: 1px solid #eee;
  86. background-color: #fff;
  87. padding: 0 20upx;
  88. .sear-icon {
  89. font-size: 32upx;
  90. color: #999;
  91. vertical-align: middle;
  92. }
  93. .ars_input {
  94. margin-left: 20upx;
  95. width: 600upx;
  96. display: inline-block;
  97. height: 70upx;
  98. line-height: 70upx;
  99. vertical-align: middle;
  100. font-size: 28upx;
  101. }
  102. }
  103. .bg-ff {
  104. margin-top: 20upx;
  105. background-color: #fff;
  106. padding: 0 20upx;
  107. .list-title {
  108. font-size: 26upx;
  109. color: #999;
  110. padding: 16upx 0;
  111. }
  112. .list-li {
  113. font-size: 28upx;
  114. border-top: 1px solid #eee;
  115. padding: 20upx 0;
  116. .adrs-val {
  117. font-size: 26upx;
  118. color: #666;
  119. padding-top: 10upx;
  120. }
  121. }
  122. }
  123. </style>