no message

This commit is contained in:
2025-11-26 21:26:03 +08:00
parent ad548c7910
commit 853aa578b8
3 changed files with 315 additions and 40 deletions
@@ -1,9 +1,8 @@
<template>
<view class="address_add_warp">
<Header
:leftTitle="$t('address.add.title')"
left-path-type="navigateTo"
:leftPath="leftPath"
:leftTitle="titleText"
leftPath="1"
/>
<view class="address_form">
<view class="add_form_item add_form_item_but">
@@ -67,7 +66,7 @@
</view> -->
<view class="add_but" @click="addAddress"> 保存地址 </view>
<up-toast ref="uToastRef"></up-toast>
<up-picker
<!-- <up-picker
:show="regionShow"
ref="uPickerRef"
:columns="regionColumns"
@@ -78,19 +77,23 @@
itemHeight="34"
@cancel="regionShow = false"
@close="regionShow = false"
></up-picker>
></up-picker> -->
<AddressPopup @ok="onOk"
:show="regionShow" @itemSelect="onItemSelect" @select="onSelect" :curSelect="curSelect" :selectList="curSelectList" :dataList="addressList" @close="onClose"></AddressPopup>
</view>
</template>
<script>
import { editAddress, getAddressDetail } from "@/api/address.js";
import { getCascadeRegion } from "@/api/common.js";
import AddressPopup from '@/components/common/address-popup.vue'
import Header from "@/components/header.vue";
export default {
components: { Header },
components: { Header,AddressPopup },
data() {
return {
titleText:'添加地址',
form: {
id: 0,
name: null, // 收货人
@@ -104,6 +107,9 @@ export default {
address: null, // 详细地址
},
regionShow: false,
curSelect:-1,
addressList:[],
curSelectList:[],
regionColumns: [],
regionLoading: false,
// leftPath: "/pages/mine_package/mine_address/mine_address",
@@ -115,20 +121,77 @@ export default {
const detail = option.detail;
if (id && id !== 0) {
this.getById(id);
}
const ids = option.ids;
if (ids && ids !== 0) {
this.leftPath =
"/pages/order_package/order_submit/order_submit?ids=" +
ids +
"&addressShow=true";
} else if (detail) {
this.leftPath = "";
} else {
this.leftPath = "/pages/mine_package/mine_address/mine_address";
this.titleText = '修改地址';
}
},
methods: {
onItemSelect(item,xItem){
this.curSelectList.push(xItem);
this.curSelect++;
this.getAddressList(xItem.id);
},
onSelect(item,index){
this.curSelectList.splice(index + 1);
this.curSelect = index;
this.getAddressList(this.curSelectList[this.curSelectList.length - 1].id);
},
async getAddressList(id = 0){
const params = {
parentId: id,
};
const resp = await getCascadeRegion(params);
if (resp.bizcode === 100) {
this.addressList = [];
resp.data.forEach(item=>{
if(this.addressList.length){
let index = this.addressList.findIndex(i=>i.zi == item.firstLetter);
if(index != -1){
this.addressList[index].data.push({id:item.id,pId:item.parentId,name:item.name});
}else{
this.addressList.push({zi:item.firstLetter,data:[{id:item.id,pId:item.parentId,name:item.name}]});
}
}else{
this.addressList.push({zi:item.firstLetter,data:[{id:item.id,pId:item.parentId,name:item.name}]});
}
})
this.addressList.sort((a,b)=>{
if (a.zi < b.zi) return -1;
if (a.zi > b.zi) return 1;
return 0;
});
}
},
onOk(){
this.form.regionStr = [];
this.curSelectList.forEach((item,index)=>{
if(index == 0){
this.form.countryId = item.id;
this.form.regionStr.push(item.name);
}else if(index == 1){
this.form.provinceId = item.id;
this.form.regionStr.push(item.name);
}else if(index == 2){
this.form.cityId = item.id;
this.form.regionStr.push(item.name);
}else if(index == 3){
this.form.areaId = item.id;
this.form.regionStr.push(item.name);
}else if(index == 4){
this.form.townshipId = item.id;
this.form.regionStr.push(item.name);
}
})
console.log('areaId',this.form)
this.onClose();
},
onClose(){
this.regionShow=false;
this.curSelect=false;
this.addressList=[];
this.curSelectList=[];
},
/**
* 用作编辑
*/
@@ -172,25 +235,43 @@ export default {
},
// 选择地址的弹框
async regionShowCheck(status) {
if (status) {
const nation = await this.getRegion(0);
const province =
nation && nation.length !== 0
? await this.getRegion(nation[0].id)
: [];
const city =
province && province.length !== 0
? await this.getRegion(province[0].id)
: [];
const area =
city && city.length !== 0 ? await this.getRegion(city[0].id) : [];
console.log("选择地址的弹框", nation, province, city, area, status);
this.regionColumns = [nation, province, city, area];
} else {
this.regionColumns = [[], [], [], []];
}
this.regionShow = status;
async regionShowCheck() {
this.curSelectList = [];
this.curSelect = -1;
if(this.form.townshipId){
this.curSelectList.push({id:this.form.countryId,name:this.form.regionStr[0]});
this.curSelectList.push({id:this.form.provinceId,name:this.form.regionStr[1]});
this.curSelectList.push({id:this.form.cityId,name:this.form.regionStr[2]});
this.curSelectList.push({id:this.form.areaId,name:this.form.regionStr[3]});
this.curSelectList.push({id:this.form.townshipId,name:this.form.regionStr[4]});
this.curSelect = 4;
await this.getAddressList(this.form.townshipId);
}else if(this.form.areaId){
this.curSelectList.push({id:this.form.countryId,name:this.form.regionStr[0]});
this.curSelectList.push({id:this.form.provinceId,name:this.form.regionStr[1]});
this.curSelectList.push({id:this.form.cityId,name:this.form.regionStr[2]});
this.curSelectList.push({id:this.form.areaId,name:this.form.regionStr[3]});
this.curSelect = 3;
await this.getAddressList(this.form.areaId);
}else if(this.form.cityId){
this.curSelectList.push({id:this.form.countryId,name:this.form.regionStr[0]});
this.curSelectList.push({id:this.form.provinceId,name:this.form.regionStr[1]});
this.curSelectList.push({id:this.form.cityId,name:this.form.regionStr[2]});
this.curSelect = 2;
await this.getAddressList(this.form.cityId);
}else if(this.form.provinceId){
this.curSelectList.push({id:this.form.countryId,name:this.form.regionStr[0]});
this.curSelectList.push({id:this.form.provinceId,name:this.form.regionStr[1]});
this.curSelect = 1;
await this.getAddressList(this.form.provinceId);
}else if(this.form.countryId){
this.curSelectList.push({id:this.form.countryId,name:this.form.regionStr[0]});
this.curSelect = 0;
await this.getAddressList(this.form.countryId);
}else{
await this.getAddressList();
}
this.regionShow = true;
},
// 数据交互
async getRegion(pId) {