
<a-modal
v-model="addressVisiable"
:footer="false"
width="800px"
:bodyStyle="{ height: '400px' }"
:afterClose="afterClose"
>
<a-tabs
v-model="activeKey"
:animated="false"
@change="tabChange(activeKey)"
>
<a-tab-pane
v-for="pane in panes"
:key="pane.key"
:tab="pane.title"
:disabled="pane.show"
>
<div>
<a-spin :spinning="spanLoading" tip="loading..." />
<span
v-for="item in pane.ItemData"
:key="item.code"
style="display: inline-block; margin: 20px; cursor: pointer"
@click="clickChoice(item)"
>{{ item.name }}</span
>
</div>
</a-tab-pane>
</a-tabs>
</a-modal>
async getProvince (params, index) {
this.spanLoading = true
try {
const res = await getProvince({
code: params
})
if (res.code === 200) {
this.panes[index].ItemData = res.data
this.spanLoading = false
} else {
throw res
}
} catch (err) {
this.$message.error(err.desc)
} finally {
this.spanLoading = false
}
},
async getJdCounty (params) {
this.spanLoading = true
try {
const res = await getJdCounty({
code: params
})
if (res.code === 200) {
this.panes[3].ItemData = res.data
} else {
throw res
}
} catch (err) {
this.$message.error(err.desc)
} finally {
this.spanLoading = false
}
},
openAddressRange () {
this.getProvince('0', 0)
this.addressVisiable = true
this.activeKey = '1'
},
async clickChoice (item) {
if (this.activeKey === '4') {
this.choiceAddressArray.push(item.name)
let str = ''
this.choiceAddressStr = ''
for (let i = 0; i < this.choiceAddressArray.length; i++) {
str += this.choiceAddressArray[i] + ' '
}
this.choiceAddressStr = str
this.choiceAddressArray = []
this.reqGetJdStock()
this.addressVisiable = false
} else {
let index = parseInt(this.activeKey)
if (this.activeKey === '3') {
this.getJdCounty(item.code)
this.choiceAreaCode = item.code
} else {
this.getProvince(item.code, index)
}
this.panes[parseInt(this.activeKey) - 1].title = item.name
this.panes[parseInt(this.activeKey)].show = false
this.activeKey = (parseInt(this.activeKey) + 1).toString()
this.choiceAddressArray.push(item.name)
}
},
tabChange (activeKey) {
let index = parseInt(activeKey)
if (this.choiceAddressArray.length >= index) {
for (let i = index; i <= this.choiceAddressArray.length; i++) {
this.panes[i].show = true
}
this.choiceAddressArray.length = index - 1
}
},
afterClose () {
this.panes = [
{
title: '选择省/自治区', key: '1', show: false, ItemData: []
},
{
title: '选择城市', key: '2', show: true, ItemData: []
},
{
title: '选择市区', key: '3', show: true, ItemData: []
},
{
title: '选择街道', key: '4', show: true, ItemData: []
}
]
},
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?