123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <template>
- <view class="main-Location">
- <!-- 字母区域 -->
- <view class="Location-Letter">
- <view hover-class="Click-Latter" @tap="getLetter('ScrollTop')">*</view>
- <view v-for="(l,i) in LatterName" :key="i" hover-class="Click-Latter" @tap="getLetter(l)"
- :style="{'color': LetterId === l ? '#ffbc00' : '#000' }">{{l}}</view>
- </view>
- <scroll-view scroll-y="true" class="ynq-ScrollView" :scroll-into-view="LetterId">
- <!-- 城市列表 -->
- <view class="ynq-CityList">
- <block v-for="(item,index) in CityList" :key="index">
- <view class="ynq-CityLetter" :id="item.initial">{{item.initial}}</view>
- <view class="ynq-CityLine">
- <text @tap="getStorage(item_city)" v-for="(item_city,name_index) in item.list"
- :key="name_index">{{item_city.name}}</text>
- </view>
- </block>
- </view>
- </scroll-view>
- </view>
- </template>
- <script setup lang="ts">
- import { getCurrentInstance, ref } from 'vue';
- //该依赖已内置不需要单独安装
- import { onLoad } from "@dcloudio/uni-app";
- // 请求接口
- const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
- const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
- // 基本信息
- const config = ref({ logoUrl: [] });
- const CityName = ref('');
- const LatterName = ref(['全', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']);
- const CityList = ref($config.china);
- const LetterId = ref('');
- onLoad(async () => {
- await searchConfig();
- await search();
- })
- // config信息
- const searchConfig = async () => {
- config.value = uni.getStorageSync('config');
- };
- // 查询
- const search = async () => {
- };
- // 获取定位点
- const getLetter = (name) => {
- LetterId.value = name
- // 跳转城市首字母定位
- uni.pageScrollTo({
- selector: '#' + name,
- duration: 300
- })
- };
- // 存储城市缓存(点击城市)
- const getStorage = (item) => {
- uni.$emit('toCity', item)
- // 4. 返回上一页面
- uni.navigateBack({
- delta: 1 // 返回的页面数
- })
- };
- </script>
- <style lang="scss" scoped>
- .main-Location {
- height: 100vh;
- }
- // 侧边字母选择栏
- .Location-Letter {
- position: fixed;
- right: 5px;
- top: 80px;
- width: 15px;
- z-index: 100;
- color: #c8c9cc;
- view {
- display: block;
- width: 15px;
- text-align: center;
- padding: 1px 0 0 0;
- font-size: var(--font12Size);
- transition: ease .3s;
- -webkit-transition: ease .3s;
- }
- }
- // 城市列表
- .ynq-CityList {
- padding: 10px 0;
- .ynq-CityLetter {
- font-size: var(--font16Size);
- border-bottom: 1px solid #f7f7f7;
- padding: 5px;
- background-color: #f4f4f5;
- border-bottom: 0.5px solid #dadbde;
- }
- .ynq-CityLine {
- background-color: #fff;
- margin: 10px 0;
- text {
- display: block;
- line-height: 30px;
- padding: 10px 15px;
- font-size: var(--font14Size);
- border-bottom: 1px solid var(--f4Color);
- }
- }
- }
- </style>
|