|
|
|
|
const app = getApp<IAppOption>();
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
id: "",
|
|
|
|
|
detail: {},
|
|
|
|
|
specVecItem: {} as any,
|
|
|
|
|
num: 1,
|
|
|
|
|
allPrice: "",
|
|
|
|
|
|
|
|
|
|
toastShow: false,
|
|
|
|
|
toastType: "giftEnter",
|
|
|
|
|
|
|
|
|
|
toastParams: {
|
|
|
|
|
doc: "",
|
|
|
|
|
},
|
|
|
|
|
protocol: false,
|
|
|
|
|
},
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
this.setData({
|
|
|
|
|
id: options.id,
|
|
|
|
|
toastParams: {
|
|
|
|
|
doc: `<p style="text-indent: 24pt; line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 宋体;">为让用户更好的享受再鼎愈见昕生的服务,愈见昕生平台向用户提供了能量兑换服务,并提供了丰富的礼品,平台注册用户可使用有效的能量兑换礼品。</span></p><p style="text-indent: 24pt; line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 宋体;">愈见昕生的礼品库将提供:</span></p><p style="text-indent: 24pt; line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 微软雅黑;">1) </span><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 宋体;">查看用户在能量商城选择兑换的商品信息;</span></p><p style="text-indent: 24pt; line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 微软雅黑;">2) </span><span style="color: rgb(89, 89, 89); font-size: 14p ... (very long line, trimmed to 1000 chars)
|
|
|
|
|
// doc:` <p style="line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 宋体;">为让用户更好的享受再鼎愈见昕生的服务,愈见昕生平台向用户提供了能量兑换服务,并提供了丰富的礼品,平台注册用户可使用有效的能量兑换礼品。</span></p><p style="line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 宋体;">愈见昕生的礼品库将提供:</span></p><p style="line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 微软雅黑;">1) </span><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 宋体;">查看用户在能量商城选择兑换的商品信息;</span></p><p style="line-height: 1.5;"><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 微软雅黑;">2) </span><span style="color: rgb(89, 89, 89); font-size: 14px; font-family: 宋体;">确认兑换商品的订单信息;</span></p>< ... (very long line, trimmed to 1000 chars)
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
app.waitLogin().then(() => {
|
|
|
|
|
this.setView();
|
|
|
|
|
this.getDetail();
|
|
|
|
|
this.getProtocol();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
setView() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: "POST",
|
|
|
|
|
url: "?r=igg4/gift-spu/set-visit-num",
|
|
|
|
|
data: { spuId: this.data.id },
|
|
|
|
|
showMsg: false,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getDetail() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: "GET",
|
|
|
|
|
url: "?r=igg4/gift-spu/get-detail",
|
|
|
|
|
data: {
|
|
|
|
|
spuId: this.data.id,
|
|
|
|
|
},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
detail: {
|
|
|
|
|
...res,
|
|
|
|
|
detailList: JSON.parse(res.detail),
|
|
|
|
|
},
|
|
|
|
|
specVecItem: res.specVec[0],
|
|
|
|
|
allPrice: res.specVec[0].score,
|
|
|
|
|
num: res.specVec[0].stock >= 1 ? 1 : 0,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getProtocol() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: "GET",
|
|
|
|
|
url: "?r=igg4/agreement/get-user-agreement",
|
|
|
|
|
data: {},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
protocol: res,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
setProtocol() {
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: "POST",
|
|
|
|
|
url: "?r=igg4/agreement/set-user-agreement",
|
|
|
|
|
data: {},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleSpec(e: any) {
|
|
|
|
|
const { index } = e.currentTarget.dataset;
|
|
|
|
|
const specVecItem: any = this.data.detail.specVec[index];
|
|
|
|
|
console.log(specVecItem.stock>=1)
|
|
|
|
|
this.setData({
|
|
|
|
|
specVecItem: specVecItem,
|
|
|
|
|
allPrice: specVecItem.score,
|
|
|
|
|
num: specVecItem.stock >= 1 ? 1 : 0,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onChangeNumber(e: any) {
|
|
|
|
|
this.setData({
|
|
|
|
|
num: e.detail,
|
|
|
|
|
allPrice: this.data.specVecItem.score * e.detail,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleDoc() {
|
|
|
|
|
this.setData({
|
|
|
|
|
toastShow: true,
|
|
|
|
|
toastType: "giftEnter",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleToastOk(e) {
|
|
|
|
|
if (!e.detail.protocol) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: "请先勾选《用户须知》",
|
|
|
|
|
icon: "none",
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.setProtocol();
|
|
|
|
|
this.setData({
|
|
|
|
|
protocol: e.detail.protocol,
|
|
|
|
|
});
|
|
|
|
|
this.handleToastCancel();
|
|
|
|
|
},
|
|
|
|
|
handleToastCancel() {
|
|
|
|
|
this.setData({
|
|
|
|
|
toastShow: false,
|
|
|
|
|
toastType: "",
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleProtocol() {
|
|
|
|
|
if (!this.data.protocol) {
|
|
|
|
|
this.setProtocol();
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
protocol: !this.data.protocol,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleSubmit() {
|
|
|
|
|
if (!this.data.protocol) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
icon: "none",
|
|
|
|
|
title: "请先同意《用户须知》",
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: "POST",
|
|
|
|
|
url: "?r=igg4/gift-order/place-order",
|
|
|
|
|
data: {
|
|
|
|
|
giftId: this.data.specVecItem.giftId,
|
|
|
|
|
count: this.data.num,
|
|
|
|
|
},
|
|
|
|
|
loading: true,
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: `/gift/pages/conformOrder/index?id=${res}`,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|