const app = getApp(); Page({ data: { id: "", detail: {}, select: false, addressDetail: {} as any, remark: "", }, onLoad(options) { this.setData({ id: options.id, }); }, onShow() { app.waitLogin().then(() => { this.getDetail(); if (!this.data.select) { this.getDefaultAddress(); } else { this.setData({ select: false, }); } }); }, getDefaultAddress() { wx.ajax({ method: "GET", url: "?r=zd/patient-address/get-default-address", data: {}, }).then((res) => { this.setData({ addressDetail: res, }); }); }, getDetail() { wx.ajax({ method: "GET", url: "?r=zd/gift-order/get-order-detail", data: { orderId: this.data.id, }, }).then((res) => { this.setData({ detail: res, }); }); }, handleSite() { if (this.data.addressDetail) { wx.navigateTo({ url: "/gift/pages/siteList/index", }); } else { wx.navigateTo({ url: "/gift/pages/siteEdit/index", }); } }, handleSubmit() { if (!this.data.addressDetail?.addressId) { wx.showToast({ icon: "none", title: "请选择地址", }); return; } wx.ajax({ method: "POST", url: "?r=zd/gift-order/confirm-order", data: { orderId: this.data.id, addressId: this.data.addressDetail.addressId, remark: this.data.remark, }, loading: true, }).then(() => { wx.reLaunch({ url: `/gift/pages/orderEnd/index?id=${this.data.id}`, }); }); }, });