...
|
...
|
@@ -45,8 +45,6 @@ Page({ |
|
|
},
|
|
|
onLoad:function(options){
|
|
|
// 生命周期函数--监听页面加载
|
|
|
// new app.WeToast;
|
|
|
|
|
|
this.data.currentMode = modeEdit;
|
|
|
if (options.currentMode == modeEdit || options.currentMode == modeSelect || options.currentMode == modeChange){
|
|
|
this.data.currentMode = options.currentMode
|
...
|
...
|
@@ -96,8 +94,6 @@ Page({ |
|
|
|
|
|
if (addType == 'normal') {
|
|
|
this.addButtonTapped();
|
|
|
} else if (addType == 'wechat') {
|
|
|
this.addFromWechatButtonTapped();
|
|
|
}
|
|
|
},
|
|
|
onReady:function(){
|
...
|
...
|
@@ -121,14 +117,14 @@ Page({ |
|
|
},
|
|
|
onPullDownRefresh: function() {
|
|
|
// 页面相关事件处理函数--监听用户下拉动作
|
|
|
let params = {
|
|
|
PAGE_NAME: this.data.current_page_name,
|
|
|
PAGE_PARAM: this.data.current_page_param,
|
|
|
FROM_PAGE_NAME: this.data.from_page_name,
|
|
|
FROM_PAGE_PARAM: this.data.from_page_param,
|
|
|
PV_ID: PV_ID,
|
|
|
};
|
|
|
logEvent(YB_PAGE_OPEN_L, params);
|
|
|
// let params = {
|
|
|
// PAGE_NAME: this.data.current_page_name,
|
|
|
// PAGE_PARAM: this.data.current_page_param,
|
|
|
// FROM_PAGE_NAME: this.data.from_page_name,
|
|
|
// FROM_PAGE_PARAM: this.data.from_page_param,
|
|
|
// PV_ID: PV_ID,
|
|
|
// };
|
|
|
// logEvent(YB_PAGE_OPEN_L, params);
|
|
|
},
|
|
|
onReachBottom: function() {
|
|
|
// 页面上拉触底事件的处理函数
|
...
|
...
|
@@ -148,8 +144,10 @@ Page({ |
|
|
|
|
|
}
|
|
|
else if (this.data.currentMode == modeChange) {
|
|
|
var _self = this;
|
|
|
var that = this;
|
|
|
var addressID = this.data.items[index].address_id;
|
|
|
let api = new AddressService().yohoApi();
|
|
|
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '关联订单的收货地址将一起修改且不可修改第二次,请确认是否修改',
|
...
|
...
|
@@ -158,15 +156,15 @@ Page({ |
|
|
confirmColor: '#000000',
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
let param = {
|
|
|
method: "app.SpaceOrders.updateDeliveryAddress",
|
|
|
order_code: _self.data.order_code,
|
|
|
uid: app.getUid(),
|
|
|
address_id: addressID
|
|
|
let params = {
|
|
|
order_code: that.data.order_code,
|
|
|
address_id: addressID,
|
|
|
uid: "500031152",
|
|
|
debug: 'XYZ'
|
|
|
}
|
|
|
GET(API_HOST, param)
|
|
|
.then((json) => {
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
api.delAddressRequest(params)
|
|
|
.then(data => {
|
|
|
if (data) {
|
|
|
wx.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
...
|
...
|
@@ -185,31 +183,6 @@ Page({ |
|
|
}
|
|
|
},
|
|
|
|
|
|
setDefaultButtonTapped: function(e) {
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
let param = {
|
|
|
method: "app.address.setdefault",
|
|
|
uid: app.getUid(),
|
|
|
id: id
|
|
|
};
|
|
|
let that = this;
|
|
|
POST(API_HOST, param).then((json) => {
|
|
|
let newItems = that.data.items;
|
|
|
newItems.map((item, index) => {
|
|
|
if (id == item.address_id) {
|
|
|
item.is_default = 'Y';
|
|
|
} else {
|
|
|
item.is_default = 'N';
|
|
|
}
|
|
|
});
|
|
|
that.setData({
|
|
|
items: newItems
|
|
|
});
|
|
|
}).catch((e) => {
|
|
|
|
|
|
})
|
|
|
},
|
|
|
|
|
|
editButtonTapped: function(e) {
|
|
|
// console.log(e)
|
|
|
let id = e.currentTarget.dataset.id;
|
...
|
...
|
@@ -242,47 +215,16 @@ Page({ |
|
|
})
|
|
|
},
|
|
|
|
|
|
deleteButtonTapped: function(e) {
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
let index = e.currentTarget.dataset.index;
|
|
|
let that = this;
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '确认删除收货地址?',
|
|
|
cancelText: '取消',
|
|
|
confirmText: '确认',
|
|
|
confirmColor: '#000000',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
let param = {
|
|
|
method: "app.address.del",
|
|
|
uid: app.getUid(),
|
|
|
id: id
|
|
|
};
|
|
|
POST(API_HOST, param).then((json) => {
|
|
|
that.getAddressList();
|
|
|
if (that.data.currentSelectedIndex == index) {
|
|
|
let prePage = getCurrentPages();
|
|
|
if (prePage.length > 1 && prePage[prePage.length - 2].selectComplete != undefined) {
|
|
|
prePage[prePage.length - 2].selectComplete(null);
|
|
|
}
|
|
|
that.setData({
|
|
|
currentSelectedIndex: -1,
|
|
|
})
|
|
|
}
|
|
|
}).catch((e) => {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
addButtonTapped: function() {
|
|
|
|
|
|
if (this.data.items.length >= 5) {
|
|
|
wx.showToast({
|
|
|
title: '地址不能超过5个',
|
|
|
icon: 'none',
|
|
|
duration: 1500,
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
// if (app.globalData.userInfo.uid == 0 || app.globalData.userInfo.uid == undefined){
|
|
|
// //未登录状态
|
|
|
// wx.showModal({
|
...
|
...
|
@@ -333,84 +275,6 @@ Page({ |
|
|
})
|
|
|
},
|
|
|
|
|
|
addFromWechatButtonTapped: function() {
|
|
|
if (wx.getSetting) {
|
|
|
let that = this;
|
|
|
wx.getSetting({
|
|
|
success(res) {
|
|
|
if (!res.authSetting['scope.address']) {
|
|
|
wx.authorize({
|
|
|
scope: 'scope.address',
|
|
|
success() {
|
|
|
that.chooseAddress();
|
|
|
},
|
|
|
fail(error) {
|
|
|
if (res.authSetting['scope.address'] == false) {
|
|
|
wx.showModal({
|
|
|
title: '',
|
|
|
content: '需要打开小程序的设置,重新授权获取您的收货地址',
|
|
|
confirmText: "去开启",
|
|
|
confirmColor: "#000000",
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.openSetting({
|
|
|
success: function (res) {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
})
|
|
|
} else {
|
|
|
that.chooseAddress();
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
chooseAddress: function() {
|
|
|
let that = this;
|
|
|
wx.chooseAddress({
|
|
|
success: function (res) {
|
|
|
let param = {
|
|
|
method: "app.address.sync",
|
|
|
uid: app.getUid(),
|
|
|
userName: res.userName,
|
|
|
postalCode: res.postalCode,
|
|
|
provinceName: res.provinceName,
|
|
|
cityName: res.cityName,
|
|
|
countyName: res.countyName,
|
|
|
detailInfo: res.detailInfo,
|
|
|
nationalCode: res.nationalCode,
|
|
|
telNumber: res.telNumber,
|
|
|
};
|
|
|
|
|
|
GET(API_HOST, param).then((json) => {
|
|
|
// console.log(json)
|
|
|
if (json.code == 200) {
|
|
|
that.getAddressList();
|
|
|
} else {
|
|
|
// that.wetoast.toast({
|
|
|
// title: json.message,
|
|
|
// titleClassName: 'wetoast-title',
|
|
|
// duration: 1500
|
|
|
// });
|
|
|
}
|
|
|
}).catch((e) => {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 获取地址列表
|
|
|
*/
|
...
|
...
|
|