当前位置: 首页 > news >正文

选择省市区

<view class="">
								<view class="" @click="handleSheng()" v-if="shengZi==''">
									选择省
								</view>
								<view class="" v-else @click="handleSheng()">
									{{shengZi}}
								</view>
							</view>
							<view class="" v-if="selectioncitys">
								<view class="" v-if="shiZi==''" @click="handleShi">
									选择市
								</view>
								<view class="" v-else @click="handleShi">
									{{shiZi}}
								</view>
							</view>
							<view class="" v-if="selectiondQu">
								<view class="" v-if="QuZi==''" @click="handleQu">
									选择区
								</view>
								<view class="" v-else @click="handleQu">
									{{QuZi}}
								</view>
							</view>
<u-popup :show="showHide" closeable :round="10" @close="close" @open="open">
			<view class="popupConter">
				<view class="popupTitle">
					选择城市
				</view>
				<view class="popupFixed" v-if="selection">
					<view class="popupProvince" @click="handleProvince1(index,item,0)"
						v-for="(item,index) in newProvinceDataList[0]" :key="index">
						{{item}}
					</view>
				</view>
				<view class="popupFixed" v-if="selectioncity">
					<view class="popupProvince" @click="handleProvince1(index,item,1)"
						v-for="(item,index) in newProvinceDataList[1]" :key="index">
						{{item}}
					</view>
				</view>
				<!-- 区 -->
				<view class="popupFixed" v-if="selectiondistrict">
					<view class="popupProvince" @click="handleProvince1(index,item,2)"
						v-for="(item,index) in newProvinceDataList[2]" :key="index">
						{{item}}
					</view>
				</view>
			</view>
		</u-popup>

 



multiIndex: [0, 0, 0],
				oldpProvinceDataList: provinceData.data,
				newProvinceDataList: [
					[],
					[],
					[]
				],




onLoad(){
// 省
			for (let i = 0; i < that.oldpProvinceDataList.length; i++) {
				that.newProvinceDataList[0].push(that.oldpProvinceDataList[i].name)
			}
			console.log(that.newProvinceDataList[0])

			// 市
			for (let i = 0; i < that.oldpProvinceDataList[0].children.length; i++) {
				that.newProvinceDataList[1].push(that.oldpProvinceDataList[0].children[i].name)
			}
			// 区县
			for (let i = 0; i < that.oldpProvinceDataList[0].children[0].children.length; i++) {
				that.newProvinceDataList[2].push(that.oldpProvinceDataList[0].children[0].children[i].name)
			}
}


// 选择省
			handleSheng() {
				this.showHide = true,
					this.selection = true
			},
			// 选择市
			handleShi() {
				this.showHide = true
				// 市弹窗
				this.selectioncity = true
			},
			// 选择区
			handleQu() {
				this.showHide = true
				this.selectiondistrict = true
			},
handleProvince1(index, items, column) {
				// 省框
				if (column == 0) {
					this.shengZi = items
					this.selectioncitys = true
					this.shiZi = ''
					this.QuZi = ''

				} else if (column == 1) {
					this.shiZi = items
					this.selectiondQu = true
					this.QuZi = ''
				} else {
					this.QuZi = items
				}
				this.showHide = false
				// 省
				this.selection = false
				// 市
				this.selectioncity = false
				// 区
				this.selectiondistrict = false
				this.handleProvince(index, column)
			},
	// 省
			handleProvince(index, column) {
				console.log(index, column, '市份选择');
				var that = this
				// 第一列滑动
				if (column === 0) {
					that.multiIndex[0] = index
					// 第二列更新相应的数据
					that.newProvinceDataList[1] = that.oldpProvinceDataList[that.multiIndex[0]].children.map((
						item,
						index) => {
						return item.name
					})
					if (that.oldpProvinceDataList[that.multiIndex[0]].children.length === 1) {
						that.newProvinceDataList[2] = that.oldpProvinceDataList[that.multiIndex[0]].children[0]
							.children
							.map((
								item,
								index) => {
								return item.name
							})
					} else {
						that.newProvinceDataList[2] = that.oldpProvinceDataList[that.multiIndex[0]].children[
							that
							.multiIndex[
								1]].children.map((item, index) => {
							return item.name
						})
					}
					// 第一列滑动 第二列 和第三列 都变为第一个
					that.multiIndex.splice(1, 1, 0)
					that.multiIndex.splice(2, 1, 0)
				}
				// 第二列滑动
				if (column === 1) {
					that.multiIndex[1] = index
					that.newProvinceDataList[2] = that.oldpProvinceDataList[that.multiIndex[0]].children[that
						.multiIndex[
							1]].children.map((item, index) => {
						return item.name
					})
					// 第二列 滑动 第三列 变成第一个
					that.multiIndex.splice(2, 1, 0)
				}
				// 第三列滑动
				if (column === 2) {
					that.multiIndex[2] = index
				}
			}

相关文章:

  • 图基RAG方法全景分析 | 高级检索增强生成技术Graph-based RAG
  • deepseek v3-0324实现浏览器插件:图片抓取与下载工具
  • 【MathType】MathType安装和嵌入word
  • 如何在 WordPress 中查找帖子、分类、标签、评论或用户 ID
  • 《数据王国的记忆家族》
  • ChatGPT 迎来 4o模型:更强大的图像生成能力与潜在风险
  • OpenCV界面编程
  • Sora 2.0商业应用:从文本生成可交互的3D数字人
  • SSH服务
  • I/O多路复用 + Reactor和Proactor + 一致性哈希
  • JUC中的所有类详解
  • 架构设计基础:面向对象设计的原则
  • 【FPGA实战】基于DE2-115实现数字秒表
  • 【C++】自实现简谱播放
  • ESP-IDF中调用xEventGroupWaitBits函数失效问题的分析(1)
  • 碰一碰发视频网页版本开发的源码搭建指南
  • 三、FFmpeg学习笔记
  • 26--DHCP Snooping:网络世界的“房产中介资格认证系统“
  • 解锁健康密码,踏上养生旅程
  • YOLOV8 训练姿态检测模型
  • 机器人为啥热衷“搞体育”,经济日报:是向加速融入日常生活发起的冲锋
  • 多个“首次”!上市公司重大资产重组新规落地
  • 李强:把做强国内大循环作为推动经济行稳致远的战略之举
  • 当番茄霸总遇上晋江古言,短剧IP小变局
  • 浙能集团原董事长童亚辉被查,还是杭州市书法家协会主席
  • 专访|茸主:杀回UFC,只为给自己一个交代