Commit bf352663 by 谢中龙

修改地址提示相关

parent 52b2d6d1
......@@ -30,6 +30,7 @@ wxService.page({
address:'',
type:1
},
pageFrom : '',
},
/**
......@@ -38,6 +39,8 @@ wxService.page({
onLoad: function (options) {
wx.hideShareMenu()
if (options && options.id){
this.data.id = options.id;
this.data.pageFrom = options.from;
wx.setNavigationBarTitle({
title: '编辑地址'
})
......@@ -50,8 +53,6 @@ wxService.page({
title: '新增地址'
})
}
},
/**
* 生命周期函数--监听页面显示
......@@ -99,6 +100,13 @@ wxService.page({
}).then(res => {
const { result, data } = res.data
if (result == 0) {
//从订单那边直接过来的
if(this.data.pageFrom == 'order'){
this.data.cityView = '';
}
else{
this.data.cityView = data.province + ' ' + data.city + ' ' + data.district;
}
this.setData({
params: {
userId: data.userId,
......@@ -111,20 +119,8 @@ wxService.page({
type: data.type
},
isSelect: data.type,
cityView: data.province + ' ' + data.city + ' ' + data.district
})
// wxService.getC1().then((c1) => {
// return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
// }).then(res => {
// const citys = res.map(item => {
// return [...item]
// })
// this.setData({
// citys
// })
// })
cityView: this.data.cityView
});
}
}).finally(() => {
})
......@@ -159,24 +155,26 @@ wxService.page({
case 0:
cityName = this.data.citys[0][index]
this.data.selectCityName[0] = cityName
cityData.forEach((item)=>{
if(item.value == cityName){
item.children.forEach((cityItem)=>{
cityList.push(cityItem.value)
cityItem.children.forEach((districtItem) => {
district.push(districtItem.value)
})
})
//获取省份下的城市
cityList = cityData[index].children.map(item => {
return item.value;
});
//获取区
if (cityList.length > 0){
district = cityData[index].children[0].children.map(item => {
return item.value
});
}
})
this.setData({
'citys[1]': cityList,
'citys[2]': district
})
break
case 1:
cityName = this.data.citys[1][index]
this.data.selectCityName[1] = cityName
cityName = this.data.citys[1][index];
this.data.selectCityName[1] = cityName;
cityData.forEach((item) => {
item.children.forEach((cityItem) => {
if (cityName == cityItem.value) {
......@@ -246,39 +244,55 @@ wxService.page({
address: e.detail.value.address,
type: this.data.isSelect ? 1 : 0
}
})
});
wx.showLoading({
title: '加载中'
})
if (this.data.addressId){
this.setData({
'params.id': this.data.id
},() => {
this.sureUpdateAddress(this.data.params);
})
wxService.post(`/member/addressManage/update`, this.data.params).then(res => {
}else{
this.sureAddAddress(this.data.params);
}
},
//新增保存地址
sureAddAddress(params){
wxService.post(`/member/addressManage/save`, params).then(res => {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
wx.showToast({
title: `修改成功`,
title: `保存成功`,
icon: 'none'
})
wx.navigateBack({
delta : 1
delta: 1
})
}
}).finally(() => {
wx.hideLoading()
})
}else{
wxService.post(`/member/addressManage/save`, this.data.params).then(res => {
},
//更新地址
sureUpdateAddress(params){
wxService.post(`/member/addressManage/update`, params).then(res => {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
wx.showToast({
title: `保存成功`,
title: `修改成功`,
icon: 'none'
})
});
if(this.data.pageFrom == 'order'){
params.fullArea = params.province + ' ' + params.city + ' ' + params.district;
wx.setStorageSync('_defalutAddress',params);
}
wx.navigateBack({
delta: 1
})
......@@ -286,8 +300,5 @@ wxService.page({
}).finally(() => {
wx.hideLoading()
})
}
}
},
})
\ No newline at end of file
......@@ -44,6 +44,11 @@ wxService.page({
selected: 2
})
}
this.setData({
checkAll : false,
});
this.init()
},
......@@ -53,23 +58,9 @@ wxService.page({
})
// 1556108807316001
// 1556108807316000
this.getCartList()
// const trolleySku = {
// count: 1,
// skuId: '1556108807316000'
// }
// // 加入购物车
// wxService.post('/sale/trolley/put', trolleySku).then(res => {
// if (res) {
// const { result } = res.data
// if (result == 0) {
// wx.hideLoading()
// this.getCartList()
// }
// }
// })
this.getCartList();
},
// 查询 /trolley/query
getCartList() {
wx.showLoading({
......
......@@ -574,6 +574,11 @@ wxService.page({
title: '加载中'
});
//如果有couponId需要在预览接口传过去
if (this.data.couponId){
params.couponId = this.data.couponId;
}
wxService.post(`/sale/trade/buyer/preview`, params).then(res => {
if (res) {
const { result, data } = res.data
......@@ -646,7 +651,7 @@ wxService.page({
}
}
}
})
});
},
//跳转购买
handelGobuy() {
......@@ -934,8 +939,8 @@ wxService.page({
}
//校验当前选择的地址是否还有效 (判断是否是老地址,如果是的话 弹出提示,让用户去修改地址)
console.log(this.data.addressId)
console.log(this.data.addressInfo)
//校验地址库
this.validateAddress();
this.calPreferentialPrice(params)
}
......@@ -949,7 +954,10 @@ wxService.page({
res.name = res.userName
res.phone = res.telNumber
res.fullArea = res.provinceName + res.cityName + res.countyName
res.address = res.detailInfo
res.address = res.detailInfo;
res.city = res.cityName;
res.district = res.countyName;
res.province = res.provinceName;
this.setData({
goodsAddress: false,
wxAddress: true,
......@@ -997,5 +1005,51 @@ wxService.page({
this.setData({
showSelectCoupon: true
})
},
//校验地址库 原因是地址库发生过改变 老用户之前维护过地址 但是地址可能对不上影响邮费 若发现地址不对这里强制提示用户去更新
validateAddress(){
if (this.data.addressId){
let province = this.data.addressInfo.province,
cityName = this.data.addressInfo.city,
district = this.data.addressInfo.district;
let defaultCities = city.default;
//先处理省份
let filterProvince = defaultCities.filter(item => item.value == province);
if(filterProvince.length == 0){
//省份地址维护不对 提示用户去改
this.showEditAddressModal(this.data.addressId);
}
else{
//檢查市
let filterCity = filterProvince[0].children.filter(item => item.value == cityName);
if (filterCity.length == 0){
//市维护的地址不对 提示用户去修改
this.showEditAddressModal(this.data.addressId);
}
else{
//检查区是否正确
let filterDistinct = filterCity[0].children.filter(item => item.value == district);
if (filterDistinct.length == 0){
//区维护的地址不对 提示用户去修改
this.showEditAddressModal(this.data.addressId);
}
}
}
}
},
//展示地址修改弹框
showEditAddressModal(addressId){
wx.showModal({
title: '地址更改提示',
content: `您好,因地址库的修改,您当前的收货地址需要重新编辑才可下单,请先编辑此地址。感谢您的配合~`,
showCancel: false,
confirmText: '去更改',
confirmColor: '#cb3c3c',
success(res) {
if (res.confirm) {
wxService.router(`/pages/addAddress/addAddress?id=${addressId}&from=order`)
}
}
})
},
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment