jiemeng/pages/fortune_sx/fortune_info.js

199 lines
7.5 KiB
JavaScript

!function() {
function a(a, t, e) {
return t in a ? Object.defineProperty(a, t, {
value: e,
enumerable: !0,
configurable: !0,
writable: !0
}) : a[t] = e, a;
}
var t, e = getApp(), o = require("../../utils/util.js");
Page({
data: (t = {
currMon: 0,
curryear: "2020",
select: 0,
list: e.globalData.sxdata,
infodata: null,
modalHidden: !1,
showModalStatus: !1,
mengshow: !1,
bottom: "-100%",
sharelayer: !1,
sharebox: !1,
sharemodal: !1
}, a(t, "bottom", "-100%"), a(t, "openSettingBtnHidden", !0), a(t, "hide_qcode", 1),
a(t, "id", 1), a(t, "name", "鼠"), a(t, "month", [ "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊" ]),
a(t, "userInfo", ""), a(t, "hasUserInfo", !1), a(t, "canIUse", wx.canIUse("button.open-type.getUserInfo")),
a(t, "monthCon", !1), a(t, "foldShow", !1), a(t, "date", []), a(t, "swiperHeight", 150),
t),
onLoad: function(a) {
var t = this, n = this, s = n.options.id || n.data.id;
if (isNaN(s)) for (var i = s.toLowerCase(), d = 0; d < n.data.list.length; d++) i == n.data.list[d].en && (s = d + 1);
var r = decodeURIComponent(this.options.scene), h = new Date().getFullYear();
r && ((i = e._get(r, "id")) && (s = i), n.setData({
id: s,
curryear: h
})), o.getData(s, n, "sxys", function() {
encodeURIComponent("id=" + s), n.setData({
infodata: n.data.infodata.data
}), console.log("数据", n.data.infodata);
}), e.globalData.userInfo ? this.setData({
userInfo: e.globalData.userInfo,
hasUserInfo: !0
}) : this.data.canIUse ? e.userInfoReadyCallback = function(a) {
t.setData({
userInfo: a.userInfo,
hasUserInfo: !0
});
} : wx.getUserInfo({
success: function(a) {
e.globalData.userInfo = a.userInfo, t.setData({
userInfo: a.userInfo,
hasUserInfo: !0
});
}
}), n.data.infodata && drawImg.downImg(img_user, "user_" + n.data.userInfo.nickName);
},
onChangeYear: function(a) {
var t = a.currentTarget.dataset.index, e = this, o = (e.options.id || e.data.id,
2020);
e.data.select > 0 && (o = e.data.infodata.year[e.data.select - 1]), e.setData({
select: t,
year: o,
currMon: 0,
foldShow: !1,
monthCon: !1
}), e.getData1();
},
getData1: function() {
var a = this, t = {
id: a.data.id,
vc: "wxcode",
token: "Mdozp+aZobSx2jK0JeglmiYkHqpuWeT3JzStGWapYqe"
};
a.data.select > 0 && (t.year = a.data.infodata.year[a.data.select - 1]), wx.request({
url: "https://api.xzw.com/com/json/shengxiao_fortune.js",
data: t,
success: function(t) {
var e = t.data.data.data;
a.setData({
infodata: e
}), console.log("数据", a.data.infodata);
}
});
},
viewMonth: function(a) {
var t = a.currentTarget.dataset.index;
this.setData({
foldShow: !0,
monthCon: !0,
currMon: t
}), this.setSwiperHeight();
},
hideMonth: function(a) {
this.setData({
currMon: 0,
foldShow: !1,
monthCon: !1
});
},
handleChange: function(a) {
this.setData({
currMon: a.detail.current + 1
}), this.setSwiperHeight();
},
clicksx: function(a) {
var t = this, e = a.currentTarget.dataset.index;
if (e === t.data.id) return o.hideModal(t), !1;
o.getData(e, t, "sxys", function() {
t.setData({
infodata: t.data.infodata.data,
select: 0,
currMon: 0,
foldShow: !1,
monthCon: !1
});
}), o.hideModal(t, "showModalStatus", "mengshow", "bottom");
},
showModal: function() {
o.showModal(this, "modalHidden", "showModalStatus", "mengshow", "bottom");
},
hideModal: function() {
o.hideModal(this, "showModalStatus", "mengshow", "bottom");
},
showShareModal: function() {
this.setData({
showTabs: !1
}), o.showModal(this, "sharebox", "sharemodal", "sharelayer", "bot");
},
hideShareModal: function() {
o.hideModal(this, "sharemodal", "sharelayer", "bot");
},
setSwiperHeight: function() {
var a = this, t = wx.createSelectorQuery().in(this);
t.select(".month_swiper .cur").boundingClientRect(), t.exec(function(t) {
var e = t[0].height;
a.setData({
swiperHeight: e
});
});
},
getUserInfo: function(a) {
console.log(a), e.globalData.userInfo = a.detail.userInfo, this.setData({
userInfo: a.detail.userInfo,
hasUserInfo: !0
}), drawImg.downImg(a.detail.userInfo.avatarUrl, "user_" + a.detail.userInfo.nickName),
drawImg.setData({
userInfo: a.detail.userInfo
});
},
share: function() {
var a = this;
o.hideModal(a, "sharemodal", "sharelayer", "bot"), drawImg.setData({
xzimg: wx.getStorageSync("xzimg_" + a.data.id),
img_user: wx.getStorageSync("user_" + a.data.userInfo.nickName),
qcode: wx.getStorageSync("qcode_" + a.data.id),
userInfo: a.data.userInfo,
desc: a.data.infodata[a.data.currentTab],
currentTab: a.data.currentTab,
xzname: a.data.name,
date: a.data.date
}), a.setData({
hide_qcode: 0
}), drawImg.draw(a);
},
closeQcode: function() {
this.setData({
hide_qcode: 1
});
},
handleSetting: function(a) {
a.detail.authSetting["scope.writePhotosAlbum"] && (this.setData({
openSettingBtnHidden: !0
}), drawImg.save_file(this));
},
inbtn: function(a) {
console.log("in");
},
onShareAppMessage: function(a) {
return "button" === a.from && console.log(a.target), {
title: "生肖详情",
path: "/pages/fortune_sx/fortune_info?id=" + this.data.id,
success: function(a) {},
fail: function(a) {}
};
},
showTabs: function() {
var a = !this.data.showTabs;
this.setData({
showTabs: a
});
},
hideTabs: function() {
this.setData({
showTabs: !1
});
}
});
}();