|
|
|
@ -26,13 +26,16 @@ Component({ |
|
|
|
lifetimes: { |
|
|
|
attached: function () { |
|
|
|
// 在组件实例进入页面节点树时执行
|
|
|
|
// 获取默认联系人
|
|
|
|
// 获取默认联系人 如果有临时存储的联系人则不获取默认联系人
|
|
|
|
commonApi.user_post("token/check").then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
console.log(wx.getStorageSync('linkMan')); |
|
|
|
if (wx.getStorageSync('linkMan')) { |
|
|
|
this.getLinkmanList() |
|
|
|
} else { |
|
|
|
userApi.user_post("user/getDefaultContact", { |
|
|
|
contactType: "CONSIGNEE" |
|
|
|
}).then(res => { |
|
|
|
console.log(res) |
|
|
|
this.setData({ |
|
|
|
selectLinkman: res.data |
|
|
|
}) |
|
|
|
@ -42,6 +45,8 @@ Component({ |
|
|
|
this.getLinkmanList() |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
@ -57,7 +62,8 @@ Component({ |
|
|
|
userApi.user_post("user/getContactInfoById", { |
|
|
|
id: editId |
|
|
|
}).then(res => { |
|
|
|
let selectLinkman = this.data.selectLinkman,linkmanList = this.data.linkmanList; |
|
|
|
let selectLinkman = this.data.selectLinkman, |
|
|
|
linkmanList = this.data.linkmanList; |
|
|
|
if (selectLinkman.id == editId) { |
|
|
|
selectLinkman.name = res.data.name; |
|
|
|
selectLinkman.tel = res.data.tel; |
|
|
|
@ -70,8 +76,7 @@ Component({ |
|
|
|
item.tel = res.data.tel; |
|
|
|
item.address = res.data.address; |
|
|
|
item.is_default = res.data.is_default; |
|
|
|
} |
|
|
|
else if(res.data.is_default==1 && item.is_default==1){ |
|
|
|
} else if (res.data.is_default == 1 && item.is_default == 1) { |
|
|
|
item.is_default = 0; |
|
|
|
} |
|
|
|
}) |
|
|
|
@ -81,11 +86,18 @@ Component({ |
|
|
|
}) |
|
|
|
this.triggerEvent("setAddress", res.data) |
|
|
|
}) |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
commonApi.user_post("token/check").then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
if (!wx.getStorageSync('linkMan')) { |
|
|
|
this.getDefault() |
|
|
|
}else{ |
|
|
|
this.setData({ |
|
|
|
selectLinkman: wx.getStorageSync('linkMan') |
|
|
|
}) |
|
|
|
this.triggerEvent("setAddress",wx.getStorageSync('linkMan')) |
|
|
|
this.getLinkmanList() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
@ -132,7 +144,8 @@ Component({ |
|
|
|
this.showLinkman() |
|
|
|
}, |
|
|
|
confirm: function () { |
|
|
|
let linkmanList = this.data.linkmanList,selectLinkman = null; |
|
|
|
let linkmanList = this.data.linkmanList, |
|
|
|
selectLinkman = null; |
|
|
|
linkmanList.map(linkman => { |
|
|
|
if (linkman.selected == 1) { |
|
|
|
selectLinkman = (linkman); |
|
|
|
@ -158,7 +171,8 @@ Component({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
setDefault: function (e) { |
|
|
|
let item = e.currentTarget.dataset.item,linkmanList = this.data.linkmanList; |
|
|
|
let item = e.currentTarget.dataset.item, |
|
|
|
linkmanList = this.data.linkmanList; |
|
|
|
userApi.user_post("user/setDefaultConsignee", { |
|
|
|
id: item.id |
|
|
|
}).then(res => { |
|
|
|
@ -170,8 +184,7 @@ Component({ |
|
|
|
linkmanList.map(linkman => { |
|
|
|
if (linkman.id == item.id) { |
|
|
|
linkman.is_default = 1; |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
linkman.is_default = 0; |
|
|
|
} |
|
|
|
}) |
|
|
|
@ -185,7 +198,8 @@ Component({ |
|
|
|
wx.showLoading({ |
|
|
|
title: '加载中', |
|
|
|
}) |
|
|
|
let index = e.currentTarget.dataset.index,selectLinkman = this.data.selectLinkman; |
|
|
|
let index = e.currentTarget.dataset.index, |
|
|
|
selectLinkman = this.data.selectLinkman; |
|
|
|
selectLinkman.splice(index, 1); |
|
|
|
this.setData({ |
|
|
|
selectLinkman: selectLinkman |
|
|
|
@ -193,7 +207,10 @@ Component({ |
|
|
|
wx.hideLoading() |
|
|
|
}, |
|
|
|
del: function (e) { |
|
|
|
let item = e.currentTarget.dataset.item,index = e.currentTarget.dataset.index,that = this,linkmanList=this.data.linkmanList; |
|
|
|
let item = e.currentTarget.dataset.item, |
|
|
|
index = e.currentTarget.dataset.index, |
|
|
|
that = this, |
|
|
|
linkmanList = this.data.linkmanList; |
|
|
|
wx.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "确定删除吗?", |
|
|
|
@ -226,6 +243,8 @@ Component({ |
|
|
|
selectLinkman: item, |
|
|
|
showMask: false |
|
|
|
}) |
|
|
|
wx.setStorageSync('linkMan', item) |
|
|
|
console.log(wx.getStorageSync('linkMan')); |
|
|
|
this.triggerEvent("setAddress", item) |
|
|
|
}, |
|
|
|
getDefault: function (e) { |
|
|
|
|