优化选择小区问题

This commit is contained in:
wuxw 2024-09-26 15:30:54 +08:00
parent d76efe7ccf
commit 7dba69fa00
5 changed files with 241 additions and 5 deletions

View File

@ -57,7 +57,7 @@ export function getCommunitys(dataObj) {
export function getMallCommunityId() {
let _currentCommunity = uni.getStorageSync(mapping.CURRENT_MALL_COMMUNITY_INFO)
let _currentCommunity = uni.getStorageSync("_selectCommunity")
if (_currentCommunity) {
return _currentCommunity.communityId;
}
@ -65,7 +65,7 @@ export function getMallCommunityId() {
}
export function getMallCommunityName() {
let _currentCommunity = uni.getStorageSync(mapping.CURRENT_MALL_COMMUNITY_INFO)
let _currentCommunity = uni.getStorageSync("_selectCommunity")
if (_currentCommunity) {
return _currentCommunity.name;
}

View File

@ -1078,6 +1078,20 @@
{
"navigationBarTitleText" : ""
}
},
{
"path" : "pages/mall/selectcommunity",
"style" :
{
"navigationBarTitleText" : ""
}
},
{
"path" : "pages/mall/viewCommunitys",
"style" :
{
"navigationBarTitleText" : ""
}
}
],
"tabBar": {

View File

@ -164,9 +164,9 @@
},
//
toSelectArea(e) {
this.vc.navigateToMall({
url: `/pages/selectcommunity/selectcommunity`
})
uni.navigateTo({
url:'/pages/mall/selectcommunity'
});
}
}
}

View File

@ -0,0 +1,117 @@
<template>
<view>
<view class="block__title">选择小区</view>
<view class="cu-form-group arrow">
<view class="title">/</view>
<pickerAddress @change="change" class="text-right" style="width:80%">{{areaName}}</pickerAddress>
<text class='cuIcon-right'></text>
</view>
<view class="cu-form-group" @tap="chooseCommunity">
<view class="title">小区名称</view>
<input v-model="communityName" required readonly label="小区名称" placeholder="请选择小区" name="communityName" icon="arrow"
></input>
<text class='cuIcon-right'></text>
</view>
<view class="padding flex flex-direction margin-top" >
<button class="cu-btn bg-green lg" @click="_doSure()">确定</button>
</view>
</view>
</template>
<script>
import pickerAddress from '@/components/pickerAddress/pickerAddress.vue'
export default {
components: {
pickerAddress
},
data() {
return {
title: 'Hello',
areaCode: '',
areaName: '请选择地区',
communityName: '',
communityId: '',
areaList: {
province_list: {
},
city_list: {
},
county_list: {
}
}
};
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let _that = this;
this.vc.onLoad(options);
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
if (this.areaCode == '' || this.areaCode == undefined) {
} else {
let community = uni.getStorageSync("_selectCommunity");
if (community != null && community != undefined) {
this.communityId = community.communityId;
this.communityName = community.name;
}
}
},
methods: {
_doSure: function(e) {
//console.log(e);
this.vc.navigateBack(true);
},
change: function(data) {
let _that = this;
_that.areaName = '';
data.data.forEach(function(_obj) {
_that.areaName += _obj.name;
});
_that.areaCode = data.data[2].code;
},
/**
* 选择小区
*/
chooseCommunity: function(e) {
if (this.areaCode == '' || this.areaCode == undefined) {
wx.showToast({
title: '请先选择地区',
icon: 'none'
});
return;
}
wx.navigateTo({
url: '/pages/mall/viewCommunitys?areaCode=' + this.areaCode,
})
}
}
};
</script>
<style>
.block__title {
margin: 0;
font-weight: 400;
font-size: 14px;
color: rgba(69, 90, 100, .6);
padding: 40rpx 30rpx 20rpx;
}
.button_up_blank {
height: 40rpx;
text-align: center;
}
</style>

View File

@ -0,0 +1,105 @@
<template>
<view>
<view class="cu-bar search bg-white">
<view class="search-form round">
<text class="cuIcon-search"></text>
<input v-model="searchValue" data-name="searchValue" name="searchValue" @focus="onChange" @blur="onSearch"
:adjust-position="false" placeholder="请输入小区名称" confirm-type="search"></input>
</view>
<view class="action">
<button class="cu-btn bg-green shadow-blur round" @tap="onSearch">搜索</button>
</view>
</view>
<view class="cu-list menu">
<view class="cu-item" v-for="(community, idx) in communitys" :key="idx" :label="community.address">
<view class="content padding-tb-sm" is-link @click="chooseCommunity(community)">
<view>
<text class="cuIcon-clothesfill text-blue margin-right-xs"></text> {{community.name}}</view>
<view class="text-gray text-sm">
<text class="cuIcon-infofill margin-right-xs"></text> {{community.address}}</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {getCommunitys} from "@/api/community/communityApi.js"
export default {
data() {
return {
appUserName: '',
areaCode: '',
searchValue: '',
communityName: "",
communitys: ""
};
},
components: {},
props: {},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.vc.onLoad(options);
let _areaCode = options.areaCode;
this.areaCode = _areaCode;
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
this.loadCommunityFun();
},
methods: {
onSearch() {
this.loadCommunityFun();
},
onClick() {
this.loadCommunityFun();
},
chooseCommunity: function(_community) {
let _title = {
action: "setCommunity",
data: _community,
url:''
}
uni.setStorageSync("_selectCommunity",_community);
wx.navigateBack({
delta: 2
});
},
loadCommunityFun: function() {
let _that = this;
let dataObj = {
page: 1,
row: 50,
cityCode: this.areaCode,
state: '1100',
name: this.searchValue
};
getCommunitys(dataObj)
.then((_communtiys) => {
_that.communitys = _communtiys;
})
}
}
};
</script>
<style>
/* pages/viewCommunitys/viewCommunitys.wxss */
.vc_community_search{
}
.vc_communitys{
margin-top: 20rpx;
}
</style>