物流+下单+地址修改

This commit is contained in:
@fawn-nine
2023-10-18 17:03:48 +08:00
parent bd998074a3
commit 39ec8fdb34
14 changed files with 142 additions and 76 deletions

View File

@@ -270,7 +270,7 @@
this.addressForm.areaidpathtext = e.value[0].UName + ' ' + e.value[1].UName + ' ' + e.value[2].UName
this.provId = e.value[0].provId
this.cityId = e.value[1].cityId
this.countyId = e.value[2].countyId
this.countyId = e.value[2].regionCode
},
addcancel() { //点击取消按钮
@@ -284,9 +284,9 @@
.then(res => {
let link_add = ''
if (!this.isShowDel) {
link_add = 'book/useraddress/save'
link_add = 'book/userAddress/save'
} else {
link_add = 'book/useraddress/update'
link_add = 'book/userAddress/update'
// this.addconfirm(e)
}
if (this.addressForm.areaidpath == '') {
@@ -296,15 +296,30 @@
});
return
}
this.addressForm.userid = this.userInfo.id
if(this.addressChanged){ // 如果修改过地址区域,就重新赋值,否则保持不变
this.addressForm.areaidpath = `${this.provId}_${this.cityId}_${this.countyId}`
this.addressChanged = false
}
this.addressForm.areaid = this.countyId
this.addressForm.isdefault = this.addressForm.isDafault ? 1 : 0
// this.addressForm.userId = this.userInfo.id
// this.addressForm.consigneePhone = this.addressForm.userphone
// this.addressForm.consigneeName = this.addressForm.username
// this.addressForm.regionCode = ''
// // this.addressForm.userid = this.userInfo.id
// if(this.addressChanged){ // 如果修改过地址区域,就重新赋值,否则保持不变
// this.addressForm.areaidpath = `${this.provId}_${this.cityId}_${this.countyId}`
// this.addressChanged = false
// }
// this.addressForm.areaid = this.countyId
// this.addressForm.isDefault = this.addressForm.isDafault ? 1 : 0
let data = this.addressForm
// let data = this.addressForm
let data = {
'id':this.addressForm.addressid,
'detailAddress' : this.addressForm.useraddress,
'regionCode':this.countyId,
'userId':this.userInfo.id,
'consigneePhone':this.addressForm.userphone,
'consigneeName': this.addressForm.username,
'isDefault':this.addressForm.isDafault ? 1 : 0
}
console.log(data,'保存参数')
$http.request({
url: link_add,
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
@@ -315,7 +330,7 @@
}).then(res => {
if (res.code == 0) {
uni.showToast({
title: '地址添加成功',
title: '操作成功',
duration: 1000,
});
setTimeout(function() {
@@ -334,17 +349,28 @@
},
changeSwitch(e) {
e ? this.addressForm.isdefault = 1 : this.addressForm.isdefault = 0
this.addressForm.isDafault = e
console.log(this.addressForm)
console.log(this.addressForm, e)
},
// 编辑地址获取信息
getAddress() {
this.$http
.post(`book/useraddress/getUserAddress?userId=${this.userInfo.id}`)
.post(`book/userAddress/getUserAddress?userId=${this.userInfo.id}`)
.then(res => {
if (res.code == 0) {
this.addressForm = res.list[this.editIndex]
this.addressForm = {
'useraddress':res.list[this.editIndex].detailAddress,
'userphone':res.list[this.editIndex].consigneePhone,
'username':res.list[this.editIndex].consigneeName,
'isdefault':res.list[this.editIndex].isDefault,
'isDafault':res.list[this.editIndex].isDefault == 1 ? true : false,
'areaidpathtext':res.list[this.editIndex].province + res.list[this.editIndex].city + res.list[this.editIndex].county
,'addressid':res.list[this.editIndex].id
}
this.countyId = res.list[this.editIndex].regionCode
// this.addressForm = res.list[this.editIndex]
if (this.addressForm.isdefault == 1) {
this.addressForm.isDafault = true
}

View File

@@ -10,18 +10,19 @@
<view class="addrContent">
<view class="addrContentTop">
<view class="userName">
{{item.username}}
{{item.consigneeName}}
</view>
<view class="userTel">
{{item.userphone}}
{{item.consigneePhone}}
</view>
<view class="userMoren" v-if="item.isdefault==1">
<view class="userMoren" v-if="item.isDefault==1">
默认
</view>
</view>
<view class="addrContentBottom">
<view class="userAddress">
{{item.areaidpathtext}} {{item.useraddress}}
{{item.province}} {{item.city}} {{item.county}}
{{item.detailAddress}}
</view>
</view>
</view>
@@ -63,7 +64,8 @@
methods: {
getUserAddress() {
this.$http
.post(`book/useraddress/getUserAddress?userId=${this.userInfo.id}`)
.post(`book/userAddress/getUserAddress?userId=${this.userInfo.id}`)
// .post(`book/useraddress/getUserAddress?userId=${this.userInfo.id}`)
.then(res => {
if (res.code == 0) {
this.addressList = res.list