You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.8 KiB

2 years ago
Page({
data: {
foodname: "今天吃什么呢?",
fooditems: [ "呀,今天没饭吃", "花甲粉", "牛杂煲", "煎饼果子", "凉面", "焗饭", "意大利面", "烤鱼", "猪肚鸡", "潮汕牛肉火锅", "重庆火锅", "四川火锅", "麻辣香锅", "酸菜鱼", "兰州拉面", "炒粿条", "奶茶", "煎饺", "肉包", "沙拉", "猪杂粉", "牛腩面", "白切鸡", "螺蛳粉", "麻辣烫", "蛋包饭", "本帮菜", "甜点", "桂林米粉", "粥", "铁板烧", "海鲜", "烤肉", "烤鱼", "沙县酒店", "汉堡王", "肯德基", "麦当劳", "披萨", "菜饭骨头汤", "扬州炒饭", "面包", "家常豆腐", "手撕包菜", "泡椒鸡杂", "红烧回肠", "酸菜魔芋", "干煸土豆丝", "肉夹馍", "涮羊肉", "日料", "水饺", "方便面", "烧烤", "馄饨", "炒面", "抄手", "小炒肉", "猪脚饭", "大盘鸡", "酸菜粉丝汤", "番茄炒蛋", "鱼香茄子", "青椒土豆丝", "蒜苔炒肉", "清蒸鲈鱼", "土豆烧排骨", "蚝油生菜", "爆炒猪肝", "麻婆豆腐", "回锅肉", "麻辣烫", "糖醋排骨", "猪肉炖粉条", "红烧肉", "红烧肉", "盖浇饭", "包子", "馒头", "水煮牛肉", "棒棒鸡" ],
animate: !1,
isclick: !1,
dateMonth: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ][new Date().getMonth()],
dateDay: new Date().getDate(),
dateWeek: [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" ][new Date().getDay()]
},
onLoad: function(e) {
wx.request({
url: 'https://z1.ypjt.work/wm.php',
header: {
'content-type': 'application/json'
},
success: res => {
console.log(res.data)
this.setData({
//第一个data为固定用法
icps: res.data
})
}
})
},
onReady: function() {
this.getTimeFood();
},
getTimeFood: function() {
var e = this, t = new Date().getHours() + ":" + new Date().getMinutes();
console.log(t), wx.request({
url: "https://res.guqule.com/time.json?v=" + new Date().getMinutes(),
method: "get",
data: {},
success: function(a) {
console.log(a.data), a.data.map(function(a, o) {
(e.equalDate(t, a.start_time) || e.compareDate(a.start_time, t)) && e.compareDate(t, a.end_time) && e.setData({
foodname: a.text,
fooditems: a.menus
});
}), "今天吃什么呢?" == e.foodname && (e.foodname = a.data[4].text, e.fooditems = a.data[4].menus);
}
});
},
compareDate: function(e, t) {
var a = new Date(), o = e.split(":"), n = t.split(":");
return a.setHours(o[0], o[1]) < a.setHours(n[0], n[1]);
},
equalDate: function(e, t) {
var a = new Date(), o = e.split(":"), n = t.split(":");
return a.setHours(o[0], o[1]) == a.setHours(n[0], n[1]);
},
rolledUp: function() {
console.log(this.data.animate), this.data.animate || (this.setData({
isclick: !0,
animate: !0
}), this.bbb(100, 10, 0));
},
bbb: function(e, t, a) {
var o = this;
o.setData({
foodname: o.data.fooditems[Math.floor(Math.random() * o.data.fooditems.length)]
}), o.timer = setInterval(function() {
o.setData({
foodname: o.data.fooditems[Math.floor(Math.random() * o.data.fooditems.length)]
}), clearInterval(o.timer), o.timer = null, t > a ? o.bbb(e, t, a + 1) : o.setData({
animate: !1
});
}, e);
},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {}
});