1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <template>
- <!-- 选择城市 -->
- <view class="page-main">
- <liu-indexed-list :dataList="dataList" @click="click"></liu-indexed-list>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- dataList: [],
- searchlist:[],//搜索历史
- };
- },
- onShow() {
- this.getCountryList()
- if(uni.getStorageSync('searchlist')){
- this.searchlist = uni.getStorageSync('searchlist')
- }
- },
- methods: {
- //根据国家获取城市
- getCountryList() {
- uni.$u.http.get(`/api/area?is_domestic=0&pid=`).then((res) => {
- this.dataList = res;
- });
- },
- //点击列表回调事件
- click(e) {
- const eventchannel = this.getOpenerEventChannel();
- eventchannel.emit('getadd', e)
- if(this.searchlist.includes(e)){
-
- }else{
- this.searchlist.unshift(e)
- uni.setStorageSync('searchlist',this.searchlist.slice(0,6))
- }
- uni.navigateBack()
- }
- }
- }
- </script>
- <style lang="scss">
- </style>
|