|
|
- <template>
- <view class="page">
-
-
- <PrivacyAgreementPoup/>
-
- <tabber select="0"/>
- </view>
- </template>
-
- <script>
- import PrivacyAgreementPoup from '@/components/config/PrivacyAgreementPoup.vue'
- import Position from '@/utils/position.js'
- import tabber from '@/components/base/tabbar.vue'
- import { mapGetters } from 'vuex'
- // import selectArea from '../../components/selectArea.vue';
- export default {
- components : {
- tabber,
- PrivacyAgreementPoup,
- },
- data() {
- return {
- bannerList: [
- {
- url: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
- },
- {
- url: 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
- },
- {
- url: 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
- },
- ],
- }
- },
- computed : {
- ...mapGetters(['userShop']),
- },
- methods: {
- //显示选择地区
- showSelectArea() {
- // this.$refs.selectArea.open()
- },
- //搜索地址
- searchAddress() {
- Position.getLocation(res => {
- Position.selectAddress(res.longitude, res.latitude, success => {
- let address = this.extractProvinceAndCity(success)
- this.queryParams.title = address.city
- })
- })
- },
- //提取用户选择的地址信息(省市县信息)
- extractProvinceAndCity(res) { //提取用户选择的地址信息(省市)
- if (!res.address && res.name) { //用户直接选择城市的逻辑
- return {
- province: '',
- city: res.name
- };
- }
-
- if (res.address) { //用户选择了详细地址,要从详细地址中提取出省市县信息
- // 使用正则表达式匹配省市县
- const regex = /(?<province>[\u4e00-\u9fa5]+?省)(?<city>[\u4e00-\u9fa5]+?(?:市|自治州|盟|地区))/;
- const match = res.address.match(regex);
- if (match) { // 如果匹配成功,则返回省和市的信息
- return {
- province: match.groups.province,
- city: match.groups.city
- };
- }
- }
-
- return { //用户没选择地址就点了确定按钮
- province: '',
- city: ''
- }
- },
- }
- }
- </script>
-
- <style scoped lang="scss">
-
- </style>
|