70 lines
2.4 KiB
JavaScript
70 lines
2.4 KiB
JavaScript
var e = getApp(), i = require("../../utils/login.js"), t = require("../../utils/common.js");
|
|
|
|
Page({
|
|
data: {
|
|
showLoding: !0,
|
|
info: {},
|
|
id: ""
|
|
},
|
|
onLoad: function (t) {
|
|
var o = this;
|
|
wx.showLoading({
|
|
title: ""
|
|
}), this.setData({
|
|
id: t.id || 0
|
|
}), i.pageStart(e).then(function (e) {
|
|
o.getList();
|
|
});
|
|
},
|
|
getList: function () {
|
|
var o = this;
|
|
wx.showLoading({
|
|
title: ""
|
|
}), i.request('/miniprogram/coupons/details', {
|
|
id: this.data.id
|
|
}, !0).then(function (e) {
|
|
if (wx.hideLoading(), 200 != e.code) return wx.showModal({
|
|
title: "提示",
|
|
content: e.message
|
|
}), !1;
|
|
e.data.starttime = t.changeTimeyear(new Date(1e3 * e.data.starttime)), e.data.deadline = t.changeTimeyear(new Date(1e3 * e.data.deadline)),
|
|
o.setData({
|
|
info: e.data,
|
|
showLoding: !1
|
|
}, function () { });
|
|
}).catch(function (e) {
|
|
wx.hideLoading();
|
|
});
|
|
},
|
|
isSubmit: !1,
|
|
received: function () {
|
|
if (this.isSubmit) return !1;
|
|
var t = this;
|
|
this.isSubmit = !0, wx.showLoading(), console.log("received"), i.request('/miniprogram/coupons/receive', {
|
|
id: t.data.id,
|
|
token: t.data.info.token
|
|
}, !0).then(function (e) {
|
|
console.log("receiveddqta", e), wx.hideLoading(), t.isSubmit = !1, console.log("recief"),
|
|
wx.showModal({
|
|
title: "提示",
|
|
content: e.message,
|
|
success: function (e) {
|
|
e.confirm && wx.redirectTo({
|
|
url: "/pages/index/index"
|
|
});
|
|
}
|
|
});
|
|
}).catch(function (e) {
|
|
wx.hideLoading(), t.isSubmit = !1, console.log("提示提示提示提示", e), 201 == e.code && wx.showModal({
|
|
title: "提示",
|
|
content: e.message,
|
|
success: function (e) {
|
|
if (!e.confirm) return console.log("弹窗取消"), !1;
|
|
wx.redirectTo({
|
|
url: "/pages/index/index"
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}); |