地址bug修复

This commit is contained in:
@fawn-nine
2023-11-14 14:21:11 +08:00
parent 3b57f0aeb0
commit 1172043635

View File

@@ -19,7 +19,7 @@
<u-form-item label="所在地区 :" prop=""> <u-form-item label="所在地区 :" prop="">
<view class="add_arrow" @click="addreShow=true">{{addressForm.areaidpathtext}}</view> <view class="add_arrow" @click="addreShow=true">{{addressForm.areaidpathtext}}</view>
<u-picker @cancel="addcancel" :show="addreShow" ref="uPicker" :columns="columns" keyName="UName" --> <u-picker @cancel="addcancel" :show="addreShow" ref="uPicker" :columns="columns" keyName="UName"
@confirm="addconfirm" @change="changeHandler" ></u-picker> @confirm="addconfirm" @change="changeHandler" ></u-picker>
</u-form-item> </u-form-item>
<u-form-item label="详细地址 :" prop="useraddress"> <u-form-item label="详细地址 :" prop="useraddress">
@@ -50,6 +50,7 @@
</template> </template>
<script> <script>
import musicPlay from '@/components/music.vue' import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js'; import $http from '@/config/requestConfig.js';
import addressList1 from "@/static/json/address.json" import addressList1 from "@/static/json/address.json"
@@ -63,14 +64,14 @@
// indexp:0, // indexp:0,
// indexq:0, // indexq:0,
// indexc:0, // indexc:0,
playData: {}, playData:{},
addreShow: false, //是否显示 addreShow: false, //是否显示
columns: [], //省份数据显示,三级联动需要三维数组,展示初始数据 columns: [], //省份数据显示,三级联动需要三维数组,展示初始数据
columnData: [], //市数据 columnData: [], //市数据
columnDatas: [], //区地址 columnDatas: [], //区地址
switchTrue: true, switchTrue: true,
switchFalse: false, switchFalse: false,
addressChanged: false, // 地址修改标记 addressChanged:false, // 地址修改标记
navName: '', // 顶部导航栏标题 navName: '', // 顶部导航栏标题
provId: '', // 存储省id provId: '', // 存储省id
cityId: '', // 存储市id cityId: '', // 存储市id
@@ -90,51 +91,6 @@
isShowDel: false, isShowDel: false,
editIndex: 0, editIndex: 0,
deleteShow: false, deleteShow: false,
list: [{
value: 1,
label: '中国',
children: [{
value: 2,
label: '广东',
children: [{
value: 3,
label: '深圳'
},
{
value: 4,
label: '广州'
}
]
},
{
value: 5,
label: '广西',
children: [{
value: 6,
label: '南宁'
},
{
value: 7,
label: '桂林'
}
]
}
]
},
{
value: 8,
label: '美国',
children: [{
value: 9,
label: '纽约',
children: [{
value: 10,
label: '皇后街区'
}]
}]
}
],
rules: { rules: {
username: [{ username: [{
required: true, required: true,
@@ -192,7 +148,7 @@
onReady() { onReady() {
this.$refs.addForm.setRules(this.rules) this.$refs.addForm.setRules(this.rules)
}, },
components: { components:{
musicPlay musicPlay
}, },
methods: { methods: {
@@ -297,7 +253,7 @@
}, },
changeHandler(e) { //城市选择时触发 changeHandler(e) { //城市选择时触发
console.log(e, '变化了', this.columnData, this.columnDatas) // console.log(e,'变化了',this.columnData, this.columnDatas)
this.addressChanged = true this.addressChanged = true
const { const {
columnIndex, //当前选择的列,省 / 市 / 区 columnIndex, //当前选择的列,省 / 市 / 区
@@ -322,7 +278,7 @@
}, },
addconfirm(e) { //点击确定按钮 addconfirm(e) { //点击确定按钮
console.log(e, '选中的值') // console.log(e,'选中的值')
this.addressChanged = true this.addressChanged = true
this.addreShow = false; this.addreShow = false;
this.addressForm.areaidpathtext = e.value[0].UName + '-' + e.value[1].UName + '-' + e.value[2].UName this.addressForm.areaidpathtext = e.value[0].UName + '-' + e.value[1].UName + '-' + e.value[2].UName
@@ -369,15 +325,15 @@
// let data = this.addressForm // let data = this.addressForm
let data = { let data = {
'id': this.addressForm.addressid, 'id':this.addressForm.addressid,
'detailAddress': this.addressForm.useraddress, 'detailAddress' : this.addressForm.useraddress,
'regionCode': this.countyId, 'regionCode':this.countyId,
'userId': this.userInfo.id, 'userId':this.userInfo.id,
'consigneePhone': this.addressForm.userphone, 'consigneePhone':this.addressForm.userphone,
'consigneeName': this.addressForm.username, 'consigneeName': this.addressForm.username,
'isDefault': this.addressForm.isDafault ? 1 : 0 'isDefault':this.addressForm.isDafault ? 1 : 0
} }
console.log(data, '保存参数') console.log(data,'保存参数')
$http.request({ $http.request({
url: link_add, url: link_add,
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档 method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
@@ -419,14 +375,13 @@
.then(res => { .then(res => {
if (res.code == 0) { if (res.code == 0) {
this.addressForm = { this.addressForm = {
'useraddress': res.list[this.editIndex].detailAddress, 'useraddress':res.list[this.editIndex].detailAddress,
'userphone': res.list[this.editIndex].consigneePhone, 'userphone':res.list[this.editIndex].consigneePhone,
'username': res.list[this.editIndex].consigneeName, 'username':res.list[this.editIndex].consigneeName,
'isdefault': res.list[this.editIndex].isDefault, 'isdefault':res.list[this.editIndex].isDefault,
'isDafault': res.list[this.editIndex].isDefault == 1 ? true : false, 'isDafault':res.list[this.editIndex].isDefault == 1 ? true : false,
'areaidpathtext': res.list[this.editIndex].province + '-' + res.list[this 'areaidpathtext':res.list[this.editIndex].province +'-'+ res.list[this.editIndex].city +'-'+ res.list[this.editIndex].county
.editIndex].city + '-' + res.list[this.editIndex].county, ,'addressid':res.list[this.editIndex].id
'addressid': res.list[this.editIndex].id
} }
this.countyId = res.list[this.editIndex].regionCode this.countyId = res.list[this.editIndex].regionCode
// this.addressForm = res.list[this.editIndex] // this.addressForm = res.list[this.editIndex]
@@ -461,19 +416,10 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.flexbox { .flexbox{display: flex;}
display: flex; .selectAdd{ justify-content: space-between;
.addItem{ display: block;width: 30%}
} }
.selectAdd {
justify-content: space-between;
.addItem {
display: block;
width: 30%
}
}
.add_arrow { .add_arrow {
height: 28px; height: 28px;
line-height: 28px; line-height: 28px;