|
@@ -8,7 +8,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<!-- 搜索 -->
|
|
<!-- 搜索 -->
|
|
|
<div class="map-search">
|
|
<div class="map-search">
|
|
|
- <app-search-module placeholder="请输入你的收货地址" @input="searchFn" />
|
|
|
|
|
|
|
+ <app-search-module ref="aaaaa" placeholder="请输入你的收货地址" :focus="true" @input="searchFn" />
|
|
|
</div>
|
|
</div>
|
|
|
<!-- 地图 -->
|
|
<!-- 地图 -->
|
|
|
<!-- <div class="map-box">
|
|
<!-- <div class="map-box">
|
|
@@ -20,7 +20,7 @@
|
|
|
</cover-view>
|
|
</cover-view>
|
|
|
</cover-view>
|
|
</cover-view>
|
|
|
</map>
|
|
</map>
|
|
|
- </div> -->
|
|
|
|
|
|
|
+ </div>-->
|
|
|
<!-- 列表 -->
|
|
<!-- 列表 -->
|
|
|
<scroll-view class="near-list" scroll-y>
|
|
<scroll-view class="near-list" scroll-y>
|
|
|
<view v-for="(item,index) in nearListData" :key="index" @click="switchAddress(item,index)" class="near-item">
|
|
<view v-for="(item,index) in nearListData" :key="index" @click="switchAddress(item,index)" class="near-item">
|
|
@@ -37,131 +37,139 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import BottomPopup from '@/components/plugin/bottom-popup'
|
|
|
|
|
-import AppClose from '@/components/module/app-close'
|
|
|
|
|
-import AppSearchModule from '@/components/module/app-search'
|
|
|
|
|
-// api
|
|
|
|
|
-import { suggestion } from '@/api/common'
|
|
|
|
|
-export default {
|
|
|
|
|
- name: 'app-area-sel',
|
|
|
|
|
- components: {
|
|
|
|
|
- BottomPopup,
|
|
|
|
|
- AppClose,
|
|
|
|
|
- AppSearchModule
|
|
|
|
|
- },
|
|
|
|
|
- props: {
|
|
|
|
|
- show: {
|
|
|
|
|
- type: Boolean,
|
|
|
|
|
- default: false
|
|
|
|
|
|
|
+ import BottomPopup from '@/components/plugin/bottom-popup'
|
|
|
|
|
+ import AppClose from '@/components/module/app-close'
|
|
|
|
|
+ import AppSearchModule from '@/components/module/app-search'
|
|
|
|
|
+ // api
|
|
|
|
|
+ import { suggestion } from '@/api/common'
|
|
|
|
|
+ export default {
|
|
|
|
|
+ name: 'app-area-sel',
|
|
|
|
|
+ components: {
|
|
|
|
|
+ BottomPopup,
|
|
|
|
|
+ AppClose,
|
|
|
|
|
+ AppSearchModule
|
|
|
},
|
|
},
|
|
|
- city: {
|
|
|
|
|
- type: String,
|
|
|
|
|
- default: ''
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- showPopup: false,
|
|
|
|
|
- keyword: '',
|
|
|
|
|
- // 地图
|
|
|
|
|
- // latitude: 24.44579,
|
|
|
|
|
- // longitude: 118.08243,
|
|
|
|
|
- // 列表
|
|
|
|
|
- currentSelectAddress: null,
|
|
|
|
|
- nearListData: []
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- // onLoad(val) {
|
|
|
|
|
- // this.mapCtx = uni.createMapContext('myMap')
|
|
|
|
|
- // this.query = val
|
|
|
|
|
- // this.reload()
|
|
|
|
|
- // },
|
|
|
|
|
- watch: {
|
|
|
|
|
- show(val) {
|
|
|
|
|
- this.showPopup = val
|
|
|
|
|
- if (val) {
|
|
|
|
|
- this.getAreaList()
|
|
|
|
|
|
|
+ props: {
|
|
|
|
|
+ show: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: false
|
|
|
|
|
+ },
|
|
|
|
|
+ city: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: ''
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- methods: {
|
|
|
|
|
- getAreaList() {
|
|
|
|
|
- suggestion({ region: this.city, keyword: this.keyword }).then(res => {
|
|
|
|
|
- this.nearListData = res.data.data
|
|
|
|
|
- })
|
|
|
|
|
},
|
|
},
|
|
|
- // 搜索
|
|
|
|
|
- searchFn(e) {
|
|
|
|
|
- this.keyword = e
|
|
|
|
|
- this.getAreaList()
|
|
|
|
|
- // this.$emit('search', e)
|
|
|
|
|
- // uni.reverseGeocode({
|
|
|
|
|
- // latitude: 25.661333498914413,
|
|
|
|
|
- // longitude: 117.5537109375
|
|
|
|
|
- // }, (e) => {
|
|
|
|
|
- // console.log(e)
|
|
|
|
|
- // })
|
|
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ showPopup: false,
|
|
|
|
|
+ keyword: '',
|
|
|
|
|
+ // 地图
|
|
|
|
|
+ // latitude: 24.44579,
|
|
|
|
|
+ // longitude: 118.08243,
|
|
|
|
|
+ // 列表
|
|
|
|
|
+ currentSelectAddress: null,
|
|
|
|
|
+ nearListData: []
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
- hidePopup() {
|
|
|
|
|
- this.$emit('update:show', false)
|
|
|
|
|
- this.$emit('hide')
|
|
|
|
|
|
|
+ // onLoad(val) {
|
|
|
|
|
+ // this.mapCtx = uni.createMapContext('myMap')
|
|
|
|
|
+ // this.query = val
|
|
|
|
|
+ // this.reload()
|
|
|
|
|
+ // },
|
|
|
|
|
+
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ show(val) {
|
|
|
|
|
+ this.showPopup = val
|
|
|
|
|
+
|
|
|
|
|
+ // #ifdef H5
|
|
|
|
|
+ this.$nextTick(function() {
|
|
|
|
|
+ this.$refs.aaaaa.$refs.searchInput._focusInput()
|
|
|
|
|
+ })
|
|
|
|
|
+ // #endif
|
|
|
|
|
+
|
|
|
|
|
+ // if (val) {
|
|
|
|
|
+ // this.getAreaList()
|
|
|
|
|
+ // }
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
- switchAddress(item, index) {
|
|
|
|
|
- this.currentSelectAddress = index
|
|
|
|
|
- // this.latitude = item.location.lat
|
|
|
|
|
- // this.longitude = item.location.lng
|
|
|
|
|
- // if (!this.$util.isEmpty(item.province) && !this.$util.isEmpty(item.city)) {
|
|
|
|
|
- // this.currentRegion = [item.province, item.city, item.district]
|
|
|
|
|
- // }
|
|
|
|
|
- this.$emit('change', item)
|
|
|
|
|
- this.hidePopup()
|
|
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ getAreaList() {
|
|
|
|
|
+ suggestion({ region: this.city, keyword: this.keyword }).then(res => {
|
|
|
|
|
+ this.nearListData = res.data.data
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // 搜索
|
|
|
|
|
+ searchFn(e) {
|
|
|
|
|
+ this.keyword = e
|
|
|
|
|
+ this.getAreaList()
|
|
|
|
|
+ // this.$emit('search', e)
|
|
|
|
|
+ // uni.reverseGeocode({
|
|
|
|
|
+ // latitude: 25.661333498914413,
|
|
|
|
|
+ // longitude: 117.5537109375
|
|
|
|
|
+ // }, (e) => {
|
|
|
|
|
+ // console.log(e)
|
|
|
|
|
+ // })
|
|
|
|
|
+ },
|
|
|
|
|
+ hidePopup() {
|
|
|
|
|
+ this.$emit('update:show', false)
|
|
|
|
|
+ this.$emit('hide')
|
|
|
|
|
+ },
|
|
|
|
|
+ switchAddress(item, index) {
|
|
|
|
|
+ this.currentSelectAddress = index
|
|
|
|
|
+ // this.latitude = item.location.lat
|
|
|
|
|
+ // this.longitude = item.location.lng
|
|
|
|
|
+ // if (!this.$util.isEmpty(item.province) && !this.$util.isEmpty(item.city)) {
|
|
|
|
|
+ // this.currentRegion = [item.province, item.city, item.district]
|
|
|
|
|
+ // }
|
|
|
|
|
+ this.$emit('change', item)
|
|
|
|
|
+ this.hidePopup()
|
|
|
|
|
+ }
|
|
|
|
|
+ // 地图操作
|
|
|
|
|
+ // reload() {
|
|
|
|
|
+ // uni.getLocation({
|
|
|
|
|
+ // type: 'wgs84',
|
|
|
|
|
+ // success: res => {
|
|
|
|
|
+ // this.latitude = res.latitude
|
|
|
|
|
+ // this.longitude = res.longitude
|
|
|
|
|
+ // // this.nearList()
|
|
|
|
|
+ // },
|
|
|
|
|
+ // // eslint-disable-next-line handle-callback-err
|
|
|
|
|
+ // fail: err => {
|
|
|
|
|
+ // this.$msg('定位失败')
|
|
|
|
|
+ // // setTimeout(function() {
|
|
|
|
|
+ // // uni.navigateBack({
|
|
|
|
|
+ // // delta: 1
|
|
|
|
|
+ // // })
|
|
|
|
|
+ // // }, 1500)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ // },
|
|
|
|
|
+ // mapChange(e) {
|
|
|
|
|
+ // if (e.type == 'end' && (e.causedBy == 'scale' || e.causedBy == 'drag')) {
|
|
|
|
|
+ // this.mapCtx.getCenterLocation({
|
|
|
|
|
+ // success: res => {
|
|
|
|
|
+ // this.longitude = res.longitude
|
|
|
|
|
+ // this.latitude = res.latitude
|
|
|
|
|
+ // // this.nearList()
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ // }
|
|
|
|
|
+ // },
|
|
|
|
|
+ // 获取列表
|
|
|
|
|
+ // nearList() {
|
|
|
|
|
+ // geocoder({
|
|
|
|
|
+ // latitude: this.latitude,
|
|
|
|
|
+ // longitude: this.longitude
|
|
|
|
|
+ // }).then(res => {
|
|
|
|
|
+ // console.log(res)
|
|
|
|
|
+ // let data = res.result
|
|
|
|
|
+ // this.currentSelectAddress = 0
|
|
|
|
|
+ // this.nearListData = data.pois
|
|
|
|
|
+ // // this.currentRegion = [data.address_component.province, data.address_component.city, data.address_component.district]
|
|
|
|
|
+ // })
|
|
|
|
|
+ // },
|
|
|
}
|
|
}
|
|
|
- // 地图操作
|
|
|
|
|
- // reload() {
|
|
|
|
|
- // uni.getLocation({
|
|
|
|
|
- // type: 'wgs84',
|
|
|
|
|
- // success: res => {
|
|
|
|
|
- // this.latitude = res.latitude
|
|
|
|
|
- // this.longitude = res.longitude
|
|
|
|
|
- // // this.nearList()
|
|
|
|
|
- // },
|
|
|
|
|
- // // eslint-disable-next-line handle-callback-err
|
|
|
|
|
- // fail: err => {
|
|
|
|
|
- // this.$msg('定位失败')
|
|
|
|
|
- // // setTimeout(function() {
|
|
|
|
|
- // // uni.navigateBack({
|
|
|
|
|
- // // delta: 1
|
|
|
|
|
- // // })
|
|
|
|
|
- // // }, 1500)
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
- // },
|
|
|
|
|
- // mapChange(e) {
|
|
|
|
|
- // if (e.type == 'end' && (e.causedBy == 'scale' || e.causedBy == 'drag')) {
|
|
|
|
|
- // this.mapCtx.getCenterLocation({
|
|
|
|
|
- // success: res => {
|
|
|
|
|
- // this.longitude = res.longitude
|
|
|
|
|
- // this.latitude = res.latitude
|
|
|
|
|
- // // this.nearList()
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
- // }
|
|
|
|
|
- // },
|
|
|
|
|
- // 获取列表
|
|
|
|
|
- // nearList() {
|
|
|
|
|
- // geocoder({
|
|
|
|
|
- // latitude: this.latitude,
|
|
|
|
|
- // longitude: this.longitude
|
|
|
|
|
- // }).then(res => {
|
|
|
|
|
- // console.log(res)
|
|
|
|
|
- // let data = res.result
|
|
|
|
|
- // this.currentSelectAddress = 0
|
|
|
|
|
- // this.nearListData = data.pois
|
|
|
|
|
- // // this.currentRegion = [data.address_component.province, data.address_component.city, data.address_component.district]
|
|
|
|
|
- // })
|
|
|
|
|
- // },
|
|
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|