<template>
|
<view class="city">
|
<!-- 搜索框 -->
|
<view class="city_input">
|
<view class="city_input_left">
|
<image src="@/static/icon/ic_search@2x.png" mode="widthFix"></image>
|
<input type="text" placeholder="搜索城市" placeholder-style="font-size:28rpx; color:#999999;" />
|
</view>
|
<text>取消</text>
|
</view>
|
<!-- 常用城市 -->
|
<view class="city_list">
|
<view class="title">常用城市</view>
|
<view class="list">
|
<view class="list_item active">
|
<image src="@/static/icon/city_dangqian@2x.png" mode="widthFix"></image>
|
上海市
|
</view>
|
<view class="list_item">
|
北京市
|
</view>
|
</view>
|
</view>
|
<!-- 选择城市 -->
|
<view class="city_selectCity">
|
<view class="title">选择城市</view>
|
<view class="city_selectCity_content">
|
<view class="brands_list" v-if="data.length > 0">
|
<view class="brands_list_item" v-for="(item, index) in data" :key="index">
|
<view class="brands_list_item_title" id="top">{{item.firstLetter}}</view>
|
<view class="brands_list_item_childer" v-for="(childer, i) in item.brandList" :key="i" @click="clickItem(childer)">
|
<view class="brands_list_item_childer_item">
|
<text>{{childer.brandName}}</text>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
</view>
|
<!-- 侧边索引 -->
|
<view class="brands_Indexes">
|
<view :class="active === index ? 'brands_Indexes_item active' : 'brands_Indexes_item'" v-for="(item, index) in indexes" :key="index" @click="pageScrollTo(index)">
|
<text>{{item}}</text>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
indexes: ['A', 'B', 'C', 'D'],
|
data: [
|
{
|
firstLetter: 'A',
|
brandList: [
|
{
|
brandName: '合肥市'
|
},
|
{
|
brandName: '巢湖市'
|
}
|
]
|
},
|
{
|
firstLetter: 'B',
|
brandList: [
|
{
|
brandName: '合肥市'
|
},
|
{
|
brandName: '巢湖市'
|
},
|
{
|
brandName: '合肥市'
|
},
|
{
|
brandName: '巢湖市'
|
}
|
]
|
}
|
],
|
indexList: [],
|
active: 0,
|
letter: ''
|
}
|
},
|
methods: {
|
pageScrollTo(scrollTop) {
|
var that = this
|
this.active = scrollTop
|
uni.pageScrollTo({
|
scrollTop: this.indexList[scrollTop],
|
duration: 500
|
})
|
}
|
},
|
onPageScroll(e) {
|
this.indexList.forEach((element, index) => {
|
if (e.scrollTop > (index === 0 ? -1 : parseInt(element)) && this.letter != this.data[index].firstLetter) {
|
this.letter = this.data[index].firstLetter
|
this.active = index
|
}
|
})
|
}
|
}
|
</script>
|
|
<style>
|
page {
|
background-color: #FFFFFF !important;
|
}
|
</style>
|
|
<style lang="scss" scoped>
|
.city {
|
width: 100%;
|
padding: 20rpx 32rpx;
|
box-sizing: border-box;
|
|
.brands_Indexes {
|
position: fixed;
|
top: 50%;
|
right: 30rpx;
|
display: flex;
|
flex-direction: column;
|
transform: translate(0, -50%);
|
.active {
|
background-color: #222222;
|
border-radius: 50%;
|
}
|
.active text {
|
color: white !important;
|
}
|
.brands_Indexes_item {
|
width: 34rpx;
|
height: 34rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
text {
|
font-size: 24rpx;
|
font-weight: 400;
|
color: #222222;
|
}
|
}
|
}
|
|
.city_input {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
|
.city_input_left {
|
flex: 1;
|
height: 64rpx;
|
background: #F5F5F5;
|
border-radius: 32rpx;
|
margin-right: 16rpx;
|
display: flex;
|
align-items: center;
|
box-sizing: border-box;
|
padding: 0 28rpx;
|
|
image {
|
flex-shrink: 0;
|
width: 28rpx;
|
height: 28rpx;
|
margin-right: 12rpx;
|
}
|
|
input {
|
flex: 1;
|
height: 100%;
|
font-size: 28rpx;
|
color: black;
|
}
|
}
|
|
text {
|
flex-shrink: 0;
|
font-size: 28rpx;
|
font-family: PingFang SC-Medium, PingFang SC;
|
font-weight: 500;
|
color: #999999;
|
}
|
}
|
|
.city_list {
|
width: 100%;
|
margin-top: 40rpx;
|
|
.title {
|
font-size: 32rpx;
|
font-family: PingFang SC-Semibold, PingFang SC;
|
font-weight: 600;
|
color: #333333;
|
}
|
|
.list {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
flex-wrap: wrap;
|
|
.active {
|
background: rgba(210, 10, 10, 0.12) !important;
|
color: #D20A0A !important;
|
}
|
|
.list_item {
|
padding: 14rpx 32rpx;
|
background: #F5F5F5;
|
border-radius: 28rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 28rpx;
|
font-family: PingFang SC-Medium, PingFang SC;
|
font-weight: 500;
|
color: #333333;
|
margin-top: 24rpx;
|
margin-left: 30rpx;
|
|
&:first-child {
|
margin-left: 0 !important;
|
}
|
|
image {
|
width: 36rpx;
|
height: 36rpx;
|
margin-right: 16rpx;
|
}
|
}
|
}
|
}
|
|
.city_selectCity {
|
width: 100%;
|
margin-top: 40rpx;
|
|
.title {
|
font-size: 32rpx;
|
font-family: PingFang SC-Semibold, PingFang SC;
|
font-weight: 600;
|
color: #333333;
|
}
|
|
.city_selectCity_content {
|
width: 100%;
|
margin-top: 20rpx;
|
|
.brands_list {
|
width: 100%;
|
.brands_list_item {
|
display: flex;
|
flex-direction: column;
|
.brands_list_item_title {
|
width: 100%;
|
height: 30rpx;
|
margin-top: 40rpx;
|
font-size: 30rpx;
|
font-weight: 500;
|
color: #222200;
|
}
|
.brands_list_item_childer {
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
.brands_list_item_childer_item {
|
width: 100%;
|
height: 96rpx;
|
display: flex;
|
align-items: center;
|
border-bottom: 1px solid #E5E5E5;
|
image {
|
width: 40rpx;
|
height: 40rpx;
|
margin-right: 20rpx;
|
}
|
text {
|
font-size: 30rpx;
|
font-weight: 400;
|
color: #222222;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
</style>
|