const app = getApp(); import { parseScene } from "@/utils/util"; Page({ data: { PatientId: "", RelationType: "", resetBind: false, reload: false, mpPatientInfo: {}, ignoreAgreement: {}, userInfo: {} as any, }, onLoad(options) { this.setData({ ignoreAgreement: options.ignoreAgreement, }); }, onShow() { // const options = wx.getEnterOptionsSync(); const scene = app.globalData.scene; if (scene?.pId) { this.setData({ PatientId: scene.pId, }); } app.waitLogin({ isReg: false }).then(() => { app.getUserInfo(this, true, () => { this.getMpPatientInfo(); }); }); }, getMpPatientInfo() { const { UserType } = this.data.userInfo; wx.ajax({ method: "GET", url: "?r=zd/account/mp-patient-info", data: { PatientId: this.data.PatientId, }, loading: true, }).then((res) => { let RelationType = res.HasSelf == 1 ? "2" : ""; if (!res.PatientId) { if (!this.data.ignoreAgreement) { if (UserType >= 2) { wx.navigateTo({ url: `/pages/privacyAgreement/index?page=/pages/familyScan/index`, }); } else { wx.navigateTo({ url: `/pages/login/index?page=/pages/familyScan/index`, }); } } } this.setData({ mpPatientInfo: res, RelationType: res.HasSelf ? "2" : RelationType, reload: true, }); }); }, handleHome() { wx.reLaunch({ url: "/pages/index/index", }); }, handleResetBind() { this.setData({ resetBind: true, }); }, handleSwitchRType(e) { const { type } = e.currentTarget.dataset; this.setData({ RelationType: type, }); }, handleSubmit() { const { PatientId, RelationType } = this.data; if (!RelationType) { wx.showToast({ title: "请选择身份", icon: "none", }); return; } // wx.reLaunch({ // url: "/pages/login/index", // }); // return; wx.ajax({ method: "POST", url: "?r=zd/account/bind-patient", data: { PatientId, RelationType, }, loading: true, }).then(() => { app.getUserInfo(this, true, (userInfo) => { wx.reLaunch({ url: "/pages/index/index", }); }); }); }, });