|
@@ -75,12 +75,18 @@
|
|
|
if(option.type==='edit'){
|
|
|
title = '编辑收货地址'
|
|
|
this.isConfirm = false;
|
|
|
- this.addType = 2;
|
|
|
- this.addressData = JSON.parse(option.data)
|
|
|
- this.addressData.allAddress = `${this.addressData.province}-${this.addressData.city}-${this.addressData.town}`
|
|
|
- this.addressData.addressDetail = this.addressData.address
|
|
|
- this.addressData.defaultFlag = this.addressData.defaultFlag;
|
|
|
- if(this.addressData.defaultFlag == 1){
|
|
|
+ this.addType = 2;
|
|
|
+ let optionData = JSON.parse(option.data)
|
|
|
+ this.addressData.allAddress = `${optionData.province}-${optionData.city}-${optionData.town}`
|
|
|
+ this.addressData.addressDetail = optionData.address
|
|
|
+ this.addressData.defaultFlag = optionData.defaultFlag;
|
|
|
+ this.addressData.userID = optionData.userID;
|
|
|
+ this.addressData.mobile = optionData.mobile;
|
|
|
+ this.addressData.townID = optionData.townID;
|
|
|
+ this.addressData.addressID = optionData.addressID;
|
|
|
+ this.addressData.shouHuoRen = optionData.shouHuoRen;
|
|
|
+ this.addressData.addressID = optionData.addressID;
|
|
|
+ if(optionData.defaultFlag == 1){
|
|
|
this.switchDefault = true
|
|
|
}else{
|
|
|
this.switchDefault = false
|
|
@@ -105,40 +111,39 @@
|
|
|
},
|
|
|
onConfirm(e) {
|
|
|
this.addressData.allAddress = e.name;
|
|
|
- this.addressData.townID = e.cityCode;
|
|
|
+ this.addressData.townID = e.townCode;
|
|
|
},
|
|
|
//提交
|
|
|
confirm(){
|
|
|
- let data = this.addressData;
|
|
|
- if(!data.shouHuoRen){
|
|
|
+ if(!this.addressData.shouHuoRen){
|
|
|
this.$util.msg('请填写收货人');
|
|
|
}
|
|
|
- if(data.address =='所在地区'){
|
|
|
+ if(this.addressData.address =='所在地区'){
|
|
|
this.$util.msg('请选择所在地区');
|
|
|
}
|
|
|
- if(!/(^1[0-9][0-9]{9}$)/.test(data.mobile)){
|
|
|
+ if(!/(^1[0-9][0-9]{9}$)/.test(this.addressData.mobile)){
|
|
|
this.$util.msg('请输入正确的手机号码');
|
|
|
return;
|
|
|
}
|
|
|
if(this.addType ==1){
|
|
|
this.params ={
|
|
|
- userID:data.userID , //用户id ,只在新增收货地址时传
|
|
|
- shouHuoRen:data.shouHuoRen ,//收货人
|
|
|
- townID:data.townID, //区ID
|
|
|
- addressDetail:data.addressDetail,//地址
|
|
|
- mobile:data.mobile, //手机
|
|
|
- defaultFlag:data.defaultFlag//是否默认收货地址(0 不是默认,1 默认)
|
|
|
+ userID:this.addressData.userID , //用户id ,只在新增收货地址时传
|
|
|
+ shouHuoRen:this.addressData.shouHuoRen ,//收货人
|
|
|
+ townID:this.addressData.townID, //区ID
|
|
|
+ addressDetail:this.addressData.addressDetail,//地址
|
|
|
+ mobile:this.addressData.mobile, //手机
|
|
|
+ defaultFlag:this.addressData.defaultFlag//是否默认收货地址(0 不是默认,1 默认)
|
|
|
}
|
|
|
this.postAddressData(this.params)
|
|
|
}else{
|
|
|
- this.params = this.addressData;
|
|
|
+ this.params = this.addressData;
|
|
|
this.postAddressData(this.params)
|
|
|
}
|
|
|
},
|
|
|
postAddressData(res){
|
|
|
this.btnText(true)
|
|
|
addNewAddress(res).then( response=>{
|
|
|
- this.$util.msg('添加成功',2000);
|
|
|
+ this.$util.msg('保存成功',2000,true,'success')
|
|
|
this.btnText(false)
|
|
|
setTimeout(()=>{
|
|
|
uni.navigateBack();
|