This commit is contained in:
aihe 2024-03-05 00:19:56 +08:00
parent 7ee98eeb19
commit 8ad91d60d4
2 changed files with 56 additions and 24 deletions

View File

@ -62,14 +62,10 @@ function handleResponse({
if ((code == 200)) {
resolve(data)
} else {
// TODO
if (
true
// code == '-1'
) { // 统一判断需要认证, 并作页面跳转
if ( code == 401) { // 统一判断需要认证, 并作页面跳转
showToast(msg)
setTimeout(() => {
goto(`TODO`, 1)
goto("login/login", 2)
}, 3500)
return reject({
code: {}

View File

@ -1,28 +1,30 @@
<template>
<tpx-dialog :show="show" title="请选择地区" @onClose="handleCloseModal()">
<view style="position: relative;height: calc(70vh);">
<view style="position: relative;height: calc(75vh);">
<tpx-layout>
<template v-slot:body>
<u-steps direction="column" activeColor="#B12D29" inactiveColor="#B12D29" dot="true">
<template v-slot:header>
<u-steps v-if="!regnameLoading" direction="column" activeColor="#B12D29" inactiveColor="#B12D29" dot="true">
<u-steps-item v-for="(item, index) in submitVals.regNames">
<template v-slot:desc>
<view :class="`pl-20 ${curTabIndex == index?'clr-prm':''}`" @click="changeCurTab(index)">
{{item}}
<view :class="`pl-20 pb-20 ${curTabIndex == index?'clr-prm':''}`" @click="changeCurTab(index)">
<u-row>
<view style="flex: 1;">{{item}}</view>
<u-icon name="arrow-right" size="32" color="rgb(214, 215, 217)"></u-icon>
</u-row>
</view>
</template>
</u-steps-item>
</u-steps>
</template>
<template v-slot:body>
<view class="showselect-list">
<view v-for="(item, index) in curShowData" class="showselect-group">
<view v-if="item.letters" class="pr-20">{{item.letters}}</view>
<view>
<view v-for="(sItem, sIndex) in item.data" :class="`showselect-item`" @click="selectItemRegion(sItem)">
<view style="flex: 1;">
<view v-for="(sItem, sIndex) in item.data" :class="`showselect-item ${submitVals.regIds.indexOf(sItem.id) > -1?'active':''}`" @click="selectItemRegion(sItem)">
{{sItem.name}}
<view v-if="submitVals.regIds.indexOf(sItem.id) > -1?'active':''">
<u-icon name="checkbox-mark" size="32" :bold="true"
:custom-style="`'color:#B12D29;'`"
></u-icon>
<view class="chk">
<u-icon name="checkbox-mark" size="32" :bold="true" color="inherit"></u-icon>
</view>
</view>
</view>
@ -94,6 +96,7 @@
},
data() {
return {
regnameLoading: false,
curTabIndex: 0,
curCountryList: [], // { id , name, nameEn }
curList: [], // { id , name, nameEn }
@ -115,6 +118,7 @@
methods: {
initData() {
if (this.submitVals.regIds.length == 0) {
this.curTabIndex = 0
let item = this.curCountryList.filter(t => t.name == '中国')[0]
// 默认选择中国
this.selectItemRegion(item)
@ -136,7 +140,10 @@
t.name = t.regionName
t.nameEn = t.regionNameEn
})
this.curList = list
if(list.length > 0) {
this.curList = list
}
return list
},
changeCurTab(index) {
this.curTabIndex = index
@ -146,17 +153,34 @@
this.getListData()
}
},
selectItemRegion(item = {}) {
async addEmptyItem(item){
const list = await this.getListData({
parentId: item.id
})
if(list.length > 0) {
this.curTabIndex = this.curTabIndex + 1
this.submitVals.regIds.push()
this.submitVals.regNames.push('请选择')
this.hackUpdateRgnames()
}
},
async selectItemRegion(item = {}) {
// 选择数据变化,需清除下所有层级选中数据
if (item.id != this.submitVals[this.curTabIndex]) {
this.submitVals.regIds.length = this.curTabIndex
this.submitVals.regNames.length = this.curTabIndex
this.submitVals.regIds.push(item.id)
this.submitVals.regNames.push(item.name)
this.hackUpdateRgnames()
}
this.getListData({
parentId: item.id
})
// 选中后切换下一层级视图
this.addEmptyItem(item)
},
hackUpdateRgnames() {
this.regnameLoading = true
setTimeout(()=> {
this.regnameLoading = false
});
},
handleCloseModal() {
this.$emit('update:show', false)
@ -180,6 +204,18 @@
}
.showselect-item{
display: flex;
margin-bottom: 20rpx;;
align-items: center;
justify-content: space-between;
margin-bottom: 20rpx;
.chk{
display: none;
}
&.active{
font-weight: bold;
color: #B12D29;
.chk{
display: block;
}
}
}
</style>