jiemeng/pages/index2/index.js

105 lines
2.8 KiB
JavaScript

var t;
t = getApp(), Page({
data: {
api: t.globalData.api_host,
data: "",
placeholder: "蛇、打雷",
value: "",
category: t.globalData.category,
tip: !1,
tipShow: !1,
tradition: !1,
teleShow: !0,
backtop: !1
},
onLoad: function() {
for (var a = this, e = a.data.category, o = 0; o < e.length; o++) !function(o) {
t.request({
cate: e[o].id,
attr: 1,
ps: 30,
detail: 0,
order: "level DESC,update_time DESC"
}, function(t) {
e[o].list = t.data;
for (var i = 0; i < e[o].list.length; i++) {
var n = e[o].list[i].title, l = n ? n.split("、") : [];
e[o].list[i].title = l[0];
}
a.setData({
category: e
}), console.log("category", e);
});
}(o);
this.mengjian();
},
mengjian: function() {
var a = this;
t.request({
attr: 8,
field: "id,title,cate_id",
order: "level DESC,update_time DESC"
}, function(e) {
var o = t.group(e.data, 5);
a.setData({
mengList: e.data,
newArray: o
}), console.log("梦册", o);
});
},
telesClick: function() {
this.setData({
teleShow: !1
});
},
tapChange: function() {
this.setData({
tradition: !0
}), wx.pageScrollTo({
scrollTop: 0
});
},
onPageScroll: function(t) {
var a = !1;
t.scrollTop >= 300 && (a = !0), this.setData({
backtop: a
});
},
handleBacktop: function() {
wx.pageScrollTo({
scrollTop: 0,
duration: 300
});
},
onShareAppMessage: function(t) {
return {
title: "梦册分析",
content: "解释你的梦境,感悟你的人生,了解你的心情,梦就是现实的写照!",
path: "/pages/index2/index"
};
},
onShareTimeline: () => ({
title: "梦册分析"
}),
formSubmitHandle: function(t) {
var a = this, e = t.detail.value.keywords;
if (!e) return a.setData({
tip: !0,
tipShow: !0
}), setTimeout(function() {
a.setData({
tip: !1
}), setTimeout(function() {
a.setData({
tipShow: !1
});
}, 300);
}, 3e3), !1;
a.setData({
value: e
}), wx.navigateTo({
url: encodeURI("/pages/search/search?q=" + e)
});
}
});