Commit bf352663 by 谢中龙

修改地址提示相关

parent 52b2d6d1
...@@ -30,6 +30,7 @@ wxService.page({ ...@@ -30,6 +30,7 @@ wxService.page({
address:'', address:'',
type:1 type:1
}, },
pageFrom : '',
}, },
/** /**
...@@ -38,6 +39,8 @@ wxService.page({ ...@@ -38,6 +39,8 @@ wxService.page({
onLoad: function (options) { onLoad: function (options) {
wx.hideShareMenu() wx.hideShareMenu()
if (options && options.id){ if (options && options.id){
this.data.id = options.id;
this.data.pageFrom = options.from;
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: '编辑地址' title: '编辑地址'
}) })
...@@ -50,8 +53,6 @@ wxService.page({ ...@@ -50,8 +53,6 @@ wxService.page({
title: '新增地址' title: '新增地址'
}) })
} }
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
...@@ -99,6 +100,13 @@ wxService.page({ ...@@ -99,6 +100,13 @@ wxService.page({
}).then(res => { }).then(res => {
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
//从订单那边直接过来的
if(this.data.pageFrom == 'order'){
this.data.cityView = '';
}
else{
this.data.cityView = data.province + ' ' + data.city + ' ' + data.district;
}
this.setData({ this.setData({
params: { params: {
userId: data.userId, userId: data.userId,
...@@ -111,20 +119,8 @@ wxService.page({ ...@@ -111,20 +119,8 @@ wxService.page({
type: data.type type: data.type
}, },
isSelect: data.type, isSelect: data.type,
cityView: data.province + ' ' + data.city + ' ' + data.district cityView: this.data.cityView
}) });
// 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
// })
// })
} }
}).finally(() => { }).finally(() => {
}) })
...@@ -159,24 +155,26 @@ wxService.page({ ...@@ -159,24 +155,26 @@ wxService.page({
case 0: case 0:
cityName = this.data.citys[0][index] cityName = this.data.citys[0][index]
this.data.selectCityName[0] = cityName this.data.selectCityName[0] = cityName
cityData.forEach((item)=>{ //获取省份下的城市
if(item.value == cityName){ cityList = cityData[index].children.map(item => {
item.children.forEach((cityItem)=>{ return item.value;
cityList.push(cityItem.value) });
cityItem.children.forEach((districtItem) => {
district.push(districtItem.value) //获取区
}) if (cityList.length > 0){
}) district = cityData[index].children[0].children.map(item => {
} return item.value
}) });
}
this.setData({ this.setData({
'citys[1]': cityList, 'citys[1]': cityList,
'citys[2]': district 'citys[2]': district
}) })
break break
case 1: case 1:
cityName = this.data.citys[1][index] cityName = this.data.citys[1][index];
this.data.selectCityName[1] = cityName this.data.selectCityName[1] = cityName;
cityData.forEach((item) => { cityData.forEach((item) => {
item.children.forEach((cityItem) => { item.children.forEach((cityItem) => {
if (cityName == cityItem.value) { if (cityName == cityItem.value) {
...@@ -246,48 +244,61 @@ wxService.page({ ...@@ -246,48 +244,61 @@ wxService.page({
address: e.detail.value.address, address: e.detail.value.address,
type: this.data.isSelect ? 1 : 0 type: this.data.isSelect ? 1 : 0
} }
}) });
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
if (this.data.addressId){ if (this.data.addressId){
this.setData({ this.setData({
'params.id': this.data.id 'params.id': this.data.id
}) },() => {
wxService.post(`/member/addressManage/update`, this.data.params).then(res => { this.sureUpdateAddress(this.data.params);
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
wx.showToast({
title: `修改成功`,
icon: 'none'
})
wx.navigateBack({
delta : 1
})
}
}).finally(() => {
wx.hideLoading()
}) })
}else{ }else{
wxService.post(`/member/addressManage/save`, this.data.params).then(res => { this.sureAddAddress(this.data.params);
const { result, data } = res.data }
if (result == 0) { },
wx.hideLoading() //新增保存地址
wx.showToast({ sureAddAddress(params){
title: `保存成功`, wxService.post(`/member/addressManage/save`, params).then(res => {
icon: 'none' const { result, data } = res.data
}) if (result == 0) {
wx.navigateBack({
delta: 1
})
}
}).finally(() => {
wx.hideLoading() wx.hideLoading()
}) wx.showToast({
title: `保存成功`,
icon: 'none'
})
wx.navigateBack({
delta: 1
})
}
}).finally(() => {
wx.hideLoading()
})
},
//更新地址
sureUpdateAddress(params){
wxService.post(`/member/addressManage/update`, params).then(res => {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
wx.showToast({
title: `修改成功`,
icon: 'none'
});
} if(this.data.pageFrom == 'order'){
params.fullArea = params.province + ' ' + params.city + ' ' + params.district;
} wx.setStorageSync('_defalutAddress',params);
}
wx.navigateBack({
delta: 1
})
}
}).finally(() => {
wx.hideLoading()
})
},
}) })
\ No newline at end of file
...@@ -44,6 +44,11 @@ wxService.page({ ...@@ -44,6 +44,11 @@ wxService.page({
selected: 2 selected: 2
}) })
} }
this.setData({
checkAll : false,
});
this.init() this.init()
}, },
...@@ -53,23 +58,9 @@ wxService.page({ ...@@ -53,23 +58,9 @@ wxService.page({
}) })
// 1556108807316001 // 1556108807316001
// 1556108807316000 // 1556108807316000
this.getCartList() 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()
// }
// }
// })
}, },
// 查询 /trolley/query // 查询 /trolley/query
getCartList() { getCartList() {
wx.showLoading({ wx.showLoading({
......
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