const app = getApp(); Page({ data: { toastShow: false, toastType: "", // toastShow:true, // toastType:"familyUnbind", familyList: [], userInfo: {}, UserId: "", }, onLoad() { app.waitLogin().then(() => { this.getFamilyList(); app.getUserInfo(this); }); }, getFamilyList(loading = true) { wx.ajax({ method: "GET", url: "?r=igg4/account/relatives", data: {}, loading, }).then((res) => { this.setData({ familyList: res, }); }); }, handleUnbind(e) { const { id } = e.currentTarget.dataset; this.setData({ UserId: id, toastShow: true, toastType: "familyUnbind", }); }, handleUnbinOk() { const { UserId } = this.data; this.handleUnbindCancel(); wx.ajax({ method: "POST", url: "?r=igg4/account/unbind-user", data: { UserId, }, loading: true, }).then(() => { wx.showToast({ icon: "none", title: "解绑成功", success: () => { app.getUserInfo(this, true, (_userInfo) => { app.waitLogin().then(() => { this.getFamilyList(false); }); }); }, }); }); }, handleUnbindCancel() { this.setData({ toastShow: false, toastType: "", }); }, handleBack() { wx.navigateBack({ fail() { wx.reLaunch({ url: "/pages/index/index", }); }, }); }, });