181 lines
3.2 KiB
JavaScript
181 lines
3.2 KiB
JavaScript
// packageE/wechat_card/index.js
|
|
var app = getApp();
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
ticket: {},
|
|
color: "",
|
|
kFootshow: true,
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.getData();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {},
|
|
tabrshowbtn(e) {
|
|
console.log(e);
|
|
let bol = e.detail;
|
|
if (bol) {
|
|
this.setData({
|
|
kFootshow: false,
|
|
});
|
|
}
|
|
},
|
|
getColor(col) {
|
|
switch (col) {
|
|
case "Color010":
|
|
this.setData({
|
|
color: "#63B359",
|
|
});
|
|
|
|
break;
|
|
case "Color020":
|
|
this.setData({
|
|
color: "#2C9F67",
|
|
});
|
|
break;
|
|
case "Color030":
|
|
this.setData({
|
|
color: "#509FC9",
|
|
});
|
|
|
|
break;
|
|
case "Color040":
|
|
this.setData({
|
|
color: "#5885CF",
|
|
});
|
|
|
|
break;
|
|
case "Color050":
|
|
this.setData({
|
|
color: "#9062C0",
|
|
});
|
|
|
|
break;
|
|
case "Color060":
|
|
this.setData({
|
|
color: "#D09A45",
|
|
});
|
|
|
|
break;
|
|
case "Color070":
|
|
this.setData({
|
|
color: "#E4B138",
|
|
});
|
|
|
|
break;
|
|
case "Color080":
|
|
this.setData({
|
|
color: "#EE903C",
|
|
});
|
|
|
|
break;
|
|
case "Color090":
|
|
this.setData({
|
|
color: "#DD6549",
|
|
});
|
|
|
|
break;
|
|
case "Color100":
|
|
this.setData({
|
|
color: "#CC463D",
|
|
});
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
},
|
|
getData() {
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.wx-card-ticket.frontend.controllers.sign.getTicket"
|
|
);
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {},
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
this.setData({
|
|
ticket: res.data.ticket,
|
|
});
|
|
if (this.data.ticket.color) {
|
|
this.getColor(this.data.ticket.color);
|
|
}
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
});
|
|
console.log(res.msg);
|
|
}
|
|
},
|
|
});
|
|
},
|
|
getType() {
|
|
let urlStr = app.getNetAddresss(
|
|
"plugin.wx-card-ticket.frontend.controllers.sign.wxJsSdkConfig"
|
|
);
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data: {},
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
wx.addCard({
|
|
cardList: res.data.cardPackage,
|
|
success(res) {
|
|
console.log(res.cardList); // 卡券添加结果
|
|
},
|
|
});
|
|
} else {
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: "none",
|
|
});
|
|
console.log(res.msg);
|
|
}
|
|
},
|
|
});
|
|
},
|
|
});
|