|
|
// import { getYHStorageSync } from '../../../utils/util';
|
|
|
// import objectAssign from '../../../vendors/object-assign';
|
|
|
// import { API_HOST, SERVICE_HOST } from '../../../libs/config';
|
|
|
// import { GET, POST } from '../../../libs/request';
|
|
|
// import Promise from '../../../vendors/es6-promise';
|
|
|
import AddressService from '../addressService.js'
|
|
|
import user from '../../../../utils/user';
|
|
|
|
...
|
...
|
@@ -69,23 +64,24 @@ Page({ |
|
|
},
|
|
|
|
|
|
editPageOnLoad: function (level,id) {
|
|
|
let param = {
|
|
|
method: APP_ADDRESS_PROVINCES,
|
|
|
uid: app.getUid(),
|
|
|
let params = {
|
|
|
fromPage: 'addressEditer',
|
|
|
id: id
|
|
|
id: id,
|
|
|
uid: '500031152',
|
|
|
debug: 'XYZ'
|
|
|
};
|
|
|
let that = this;
|
|
|
let api = new AddressService().yohoApi();
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
GET(API_HOST, param)
|
|
|
api.fetchAddressProvinces(params)
|
|
|
.then(json => {
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
let value = json.data;
|
|
|
if (json) {
|
|
|
let value = json;
|
|
|
let newEditeAddressPage = that.data.editeAddressPage;
|
|
|
let key = 'address_' + level;
|
|
|
newEditeAddressPage[key] = value;
|
|
|
|
|
|
|
|
|
|
|
|
//比对_area_code 解决 “其他” 被选中后,后台自动过滤掉address文字的返回但是_area_code没过滤的情况,导致我们显示上就没有选中 “其他”
|
|
|
if (level == 3) {
|
|
|
let list = value;
|
...
|
...
|
@@ -97,16 +93,16 @@ Page({ |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
that.setData({
|
|
|
editeAddressPage: newEditeAddressPage,
|
|
|
});
|
|
|
|
|
|
resolve(json);
|
|
|
}
|
|
|
resolve(json);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
reject(error);
|
|
|
});
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
|
...
|
...
|
@@ -126,26 +122,15 @@ Page({ |
|
|
},
|
|
|
|
|
|
defaultButtonTapped: function(e) {
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
let params = {
|
|
|
id: id,
|
|
|
uid: '500031152',
|
|
|
debug: 'XYZ'
|
|
|
};
|
|
|
let that = this;
|
|
|
let api = new AddressService().yohoApi();
|
|
|
api.fetchAddressDefault(params)
|
|
|
.then(data => {
|
|
|
|
|
|
let editeAddressPage = that.data.editeAddressPage;
|
|
|
editeAddressPage._is_default = 'Y';
|
|
|
that.setData({
|
|
|
editeAddressPage
|
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error);
|
|
|
})
|
|
|
let editeAddressPage = this.data.editeAddressPage;
|
|
|
if (editeAddressPage._is_default == 'Y') {
|
|
|
editeAddressPage._is_default = 'N';
|
|
|
} else {
|
|
|
editeAddressPage._is_default = 'Y';
|
|
|
}
|
|
|
this.setData({
|
|
|
editeAddressPage
|
|
|
});
|
|
|
},
|
|
|
|
|
|
onDeleteButtonTapped: function () {
|
...
|
...
|
@@ -158,30 +143,28 @@ Page({ |
|
|
confirmColor: '#000000',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
let param = {
|
|
|
method: "app.address.del",
|
|
|
uid: app.getUid(),
|
|
|
id: that.data.editeAddressPage._id
|
|
|
let params = {
|
|
|
id: that.data.editeAddressPage._id,
|
|
|
uid: "500031152",
|
|
|
debug: 'XYZ'
|
|
|
};
|
|
|
POST(API_HOST, param).then((json) => {
|
|
|
let api = new AddressService().yohoApi();
|
|
|
api.delAddressRequest(params)
|
|
|
.then(data => {
|
|
|
let prePage = getCurrentPages();
|
|
|
if (prePage.length > 1 && prePage[prePage.length - 2].getAddressList != undefined) {
|
|
|
prePage[prePage.length - 2].getAddressList();
|
|
|
}
|
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
}).catch((e) => {
|
|
|
// console.log(e);
|
|
|
if (prePage.length > 1 && prePage[prePage.length - 2].getAddressList != undefined) {
|
|
|
prePage[prePage.length - 2].getAddressList();
|
|
|
}
|
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
|
|
|
},
|
|
|
/**
|
|
|
* 保存按钮点击事件
|
...
|
...
|
@@ -190,18 +173,19 @@ Page({ |
|
|
this.hiddenPicker();
|
|
|
|
|
|
if (this.data.editeAddressPage.currentEditMode == modeAdd) {
|
|
|
let param = {
|
|
|
method: "app.address.add",
|
|
|
let params = {
|
|
|
consignee: this.data.editeAddressPage._consignee,
|
|
|
mobile: this.data.editeAddressPage._mobile,
|
|
|
area_code: this.data.editeAddressPage._area_code,
|
|
|
address: this.data.editeAddressPage._detailAddress,
|
|
|
uid: app.getUid()
|
|
|
is_default:this.data.editeAddressPage._is_default,
|
|
|
uid: "500031152",
|
|
|
debug: 'XYZ'
|
|
|
};
|
|
|
|
|
|
POST(API_HOST, param).then((json) => {
|
|
|
if (json.code == 200) {
|
|
|
|
|
|
let api = new AddressService().yohoApi();
|
|
|
api.addAddressRequest(params)
|
|
|
.then(data => {
|
|
|
let prePage = getCurrentPages();
|
|
|
if (prePage.length > 1 && prePage[prePage.length - 2].getAddressList != undefined) {
|
|
|
prePage[prePage.length - 2].getAddressList();
|
...
|
...
|
@@ -209,31 +193,30 @@ Page({ |
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error);
|
|
|
// this.wetoast.toast({
|
|
|
// title: json.message,
|
|
|
// titleClassName: 'wetoast-title',
|
|
|
// duration: 1500
|
|
|
// });
|
|
|
}
|
|
|
}).catch((e) => {
|
|
|
// console.log(e);
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
else if (this.data.editeAddressPage.currentEditMode == modeEdit) {
|
|
|
let param = {
|
|
|
method: "app.address.update",
|
|
|
let params = {
|
|
|
consignee: this.data.editeAddressPage._consignee,
|
|
|
mobile: this.data.editeAddressPage._mobile,
|
|
|
area_code: this.data.editeAddressPage._area_code,
|
|
|
address: this.data.editeAddressPage._detailAddress,
|
|
|
uid: app.getUid(),
|
|
|
id: this.data.editeAddressPage._id
|
|
|
is_default:this.data.editeAddressPage._is_default,
|
|
|
id: this.data.editeAddressPage._id,
|
|
|
uid: "500031152",
|
|
|
debug: 'XYZ'
|
|
|
};
|
|
|
|
|
|
POST(API_HOST, param).then((json) => {
|
|
|
if (json.code == 200) {
|
|
|
let api = new AddressService().yohoApi();
|
|
|
api.updateAddressRequest(params)
|
|
|
.then(data => {
|
|
|
let prePage = getCurrentPages();
|
|
|
if (prePage.length > 1 && prePage[prePage.length - 2].getAddressList != undefined) {
|
|
|
prePage[prePage.length - 2].getAddressList();
|
...
|
...
|
@@ -241,18 +224,16 @@ Page({ |
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
} else {
|
|
|
})
|
|
|
.catch(error => {
|
|
|
console.log(error);
|
|
|
// this.wetoast.toast({
|
|
|
// title: json.message,
|
|
|
// titleClassName: 'wetoast-title',
|
|
|
// duration: 1500
|
|
|
// });
|
|
|
}
|
|
|
}).catch((e) => {
|
|
|
// console.log(e);
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
},
|
|
|
/**
|
|
|
* 页面选址触发事件
|
...
|
...
|
@@ -303,6 +284,9 @@ Page({ |
|
|
let newEditeAddressPage3 = that.data.editeAddressPage;
|
|
|
newEditeAddressPage3.isShow = true;
|
|
|
newEditeAddressPage0.currentLevel = 3;
|
|
|
console.log('====================================');
|
|
|
console.log(newEditeAddressPage3);
|
|
|
console.log('====================================');
|
|
|
that.setData({
|
|
|
editeAddressPage: newEditeAddressPage3,
|
|
|
});
|
...
|
...
|
@@ -384,7 +368,7 @@ Page({ |
|
|
},
|
|
|
|
|
|
hiddenPicker: function () {
|
|
|
let newEditeAddressPage = objectAssign(this.data.editeAddressPage, {
|
|
|
let newEditeAddressPage = Object.assign(this.data.editeAddressPage, {
|
|
|
isShow: false, // 显示区域选择框
|
|
|
});
|
|
|
this.setData({
|
...
|
...
|
|