|
@@ -0,0 +1,107 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+Component({
|
|
|
+ options: {
|
|
|
+ addGlobalClass: true
|
|
|
+ },
|
|
|
+ properties: {
|
|
|
+ list: Array
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组件的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ radio: 0, //默认
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 组件的方法列表
|
|
|
+ */
|
|
|
+ methods: {
|
|
|
+ // 修改默认
|
|
|
+ radioChange({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let list = this.data.list,
|
|
|
+ data = list.find(v => v.contactsid == detail)
|
|
|
+ _Http.basic({
|
|
|
+ "id": "20221018144702",
|
|
|
+ "content": {
|
|
|
+ "contactsid": data.contactsid,
|
|
|
+ "sys_enterpriseid": data.sys_enterpriseid
|
|
|
+ }
|
|
|
+ }, false).then(res => {
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ list = list.map((v, i) => {
|
|
|
+ v.isdefault = v.contactsid == data.contactsid ? 1 : 0
|
|
|
+ return v
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ list
|
|
|
+ })
|
|
|
+ console.log(list)
|
|
|
+ })
|
|
|
+ }, //处理操作
|
|
|
+ handleItem(e) {
|
|
|
+ const {
|
|
|
+ name,
|
|
|
+ item
|
|
|
+ } = e.target.dataset,
|
|
|
+ that = this;
|
|
|
+ if (!name) return;
|
|
|
+ switch (name) {
|
|
|
+ case 'copy':
|
|
|
+ let str = `收货人:${item.name}\n手机号码:${item.phonenumber}\n所在地区:${item.province+item.city+item.county}\n详细地址:${item.province+item.city+item.county+item.address}`
|
|
|
+ wx.setClipboardData({
|
|
|
+ data: str,
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 'edit':
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/packageA/setclient/modules/address/add/index?data=' + JSON.stringify(item),
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 'delete':
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: `是否确认删除"${item.name}"`,
|
|
|
+ complete: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ _Http.basic({
|
|
|
+ "id": "20221018145502",
|
|
|
+ "content": {
|
|
|
+ "contactsid": item.contactsid,
|
|
|
+ "sys_enterpriseid": item.sys_enterpriseid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("删除地址", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ wx.showToast({
|
|
|
+ title: `删除成功!`,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ list: that.data.list.filter(v => v.contactsid != item.contactsid),
|
|
|
+ "content.total": that.data.content.total - 1
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initRadio() {
|
|
|
+ let data = this.data.list.find(v => v.isdefault == 1);
|
|
|
+ this.setData({
|
|
|
+ radio: data ? data.contactsid : 0
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+})
|