信达小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.7 KiB

6 months ago
const app = getApp<IAppOption>();
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}`,
});
});
},
});