2025-03-28 15:46:11 +08:00
|
|
|
<template>
|
2025-04-25 18:10:54 +08:00
|
|
|
<view class="page">
|
|
|
|
<view class="line"></view>
|
|
|
|
<scroll-view scroll-y="true">
|
|
|
|
<view
|
|
|
|
v-for="(item, index) in districtList"
|
|
|
|
class="item"
|
|
|
|
:class="{ active: index == activeIndex }"
|
|
|
|
:key="index"
|
|
|
|
@click="chooseLocation(item.district_id, item.district_name)"
|
|
|
|
@touchstart="touchstartLocation(index)"
|
|
|
|
@touchend="touchendLocation"
|
|
|
|
>
|
|
|
|
<text class="item-text">
|
|
|
|
{{ item.district_name }}
|
|
|
|
</text>
|
|
|
|
</view>
|
|
|
|
</scroll-view>
|
|
|
|
</view>
|
2025-03-28 15:46:11 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2025-04-25 18:10:54 +08:00
|
|
|
import districtList from '@/json/area_district.js';
|
2025-03-28 15:46:11 +08:00
|
|
|
export default {
|
2025-04-25 18:10:54 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
districtList: [],
|
|
|
|
activeIndex: -1
|
|
|
|
};
|
|
|
|
},
|
|
|
|
onLoad(params) {
|
|
|
|
let cityId = params.cityId;
|
|
|
|
let realDistrictList = [];
|
|
|
|
for (let i = 0; i < districtList.length; i++) {
|
|
|
|
let tempCityId = districtList[i].city_id;
|
|
|
|
if (tempCityId == cityId) {
|
|
|
|
realDistrictList.push(districtList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.districtList = realDistrictList;
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
touchstartLocation(index) {
|
|
|
|
this.activeIndex = index;
|
|
|
|
},
|
|
|
|
touchendLocation() {
|
|
|
|
this.activeIndex = -1;
|
|
|
|
},
|
|
|
|
chooseLocation(districtId, districtName) {
|
|
|
|
uni.setStorageSync('myLocationDistrict', districtName);
|
|
|
|
uni.navigateBack({
|
|
|
|
delta: 3
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2025-03-28 15:46:11 +08:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2025-04-25 18:10:54 +08:00
|
|
|
<style scoped>
|
|
|
|
.line {
|
|
|
|
height: 1rpx;
|
|
|
|
background-color: #393a41;
|
|
|
|
width: 750rpx;
|
|
|
|
}
|
|
|
|
.item-text {
|
|
|
|
color: #ffffff;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 30rpx;
|
|
|
|
}
|
|
|
|
.item {
|
|
|
|
padding-left: 30rpx;
|
|
|
|
padding-right: 30rpx;
|
|
|
|
width: 750rpx;
|
|
|
|
height: 120rpx;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
}
|
2025-03-28 15:46:11 +08:00
|
|
|
|
2025-04-25 18:10:54 +08:00
|
|
|
.active {
|
|
|
|
background-color: #4a4c52;
|
|
|
|
}
|
|
|
|
.page {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
bottom: 0;
|
|
|
|
background-color: #181b27;
|
2025-03-28 15:46:11 +08:00
|
|
|
}
|
|
|
|
</style>
|