yuxingxing 2 years ago
parent
commit
4af2f80242
2 changed files with 15 additions and 3 deletions
  1. 1 0
      pages/goods_details/index.vue
  2. 14 3
      pages/users/user_address_list/index.vue

+ 1 - 0
pages/goods_details/index.vue

@@ -533,6 +533,7 @@ export default {
 		},
 		selectAddr: {
 			handler: function (newV, oldV) {
+				console.log(newV);
 				this.attrAddrValue = newV
 			},
 			deep: true,

+ 14 - 3
pages/users/user_address_list/index.vue

@@ -271,14 +271,21 @@ export default {
 			}).then(res => {
 				let list = res.data;
 				let loadend = list.length < that.limit;
-				that.addressList = that.$util.SplitArray(list, that.addressList);
+				that.addressList = that.$util.SplitArray(list, that.addressList);// 判断是否选择地址
+				if(this.type && that.addressList.length == 0){
+					this.$store.commit('SETSELECTADDR', {});
+				}
+				if(this.type && that.addressList.length == 1){
+					that.addressList[0].defaultState = 2
+					this.$store.commit('SETSELECTADDR', that.addressList[0]);
+				}
 				if (that.type && that.selectAddr.id != undefined) {
 					//找出已经的地址
 					that.addressList.forEach((value,index) => {
 						if(that.selectAddr.id == value.id) {
-							that.addressList[index].defaultState = '2'
+							that.addressList[index].defaultState = 2
 						}else{
-							that.addressList[index].defaultState = '1'
+							that.addressList[index].defaultState = 1
 						}
 					})
 				}
@@ -350,12 +357,16 @@ export default {
 			if (address == undefined) return that.$util.Tips({
 				title: that.$t(`您删除的地址不存在!`)
 			});
+			that.$set(that, 'addressList', that.addressList);
 			postUserAddressRemove({ ids: address.id }).then(res => {
 				that.$util.Tips({
 					title: that.$t(`删除成功`),
 					icon: 'success'
 				}, function () {
 					that.addressList.splice(index, 1);
+					if(that.type && address.id == that.selectAddr.id){
+						that.$store.commit('SETSELECTADDR', {});
+					}
 					that.$set(that, 'addressList', that.addressList);
 				});
 			}).catch(err => {