|
|
|
|
//turning.js
|
|
|
|
|
//获取应用实例
|
|
|
|
|
let animation = wx.createAnimation({
|
|
|
|
|
duration: 2000,
|
|
|
|
|
timingFunction: 'linear'
|
|
|
|
|
})
|
|
|
|
|
const app=getApp()
|
|
|
|
|
const userid=app.globalData.openid
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
rotate: 0, //度数
|
|
|
|
|
list:[],
|
|
|
|
|
turning: false //是否点击
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
//事件处理函数
|
|
|
|
|
start: function() {
|
|
|
|
|
let _this = this;
|
|
|
|
|
let cat = 60;
|
|
|
|
|
if (!this.data.turning) {
|
|
|
|
|
let rdm = 0; //随机度数
|
|
|
|
|
rdm = Math.floor(Math.random() * 3600); //最大10圈
|
|
|
|
|
//rdm = 1200;//直接确定转的度数
|
|
|
|
|
animation.rotate(rdm).step();
|
|
|
|
|
this.setData({
|
|
|
|
|
rotate: animation.export(),
|
|
|
|
|
turning: true
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.setData({
|
|
|
|
|
turning: false
|
|
|
|
|
});
|
|
|
|
|
let num = rdm % 360; //转了多少度
|
|
|
|
|
//console.log(num);
|
|
|
|
|
function showModal(str) {
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: str,
|
|
|
|
|
success: function() { //点击确定后还原到0度
|
|
|
|
|
let animation = wx.createAnimation({
|
|
|
|
|
duration: 100,
|
|
|
|
|
timingFunction: 'linear'
|
|
|
|
|
});
|
|
|
|
|
animation.rotate(0).step();
|
|
|
|
|
_this.setData({
|
|
|
|
|
rotate: animation.export(),
|
|
|
|
|
turning: false
|
|
|
|
|
});
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url:'/pages/pay/pay',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
fail: function(res) {
|
|
|
|
|
console.log(res)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/* if (num <= cat * 0.5 && num>=cat*0 || num>=cat*5.5 ) {
|
|
|
|
|
showModal('今天就吃自选餐吧!不要再想了!GOGO');
|
|
|
|
|
}else if (num <= cat * 1.5 && num >= cat * 0.5) {
|
|
|
|
|
showModal('今天就吃麻辣烫吧!不要再想了!GOGO');
|
|
|
|
|
} else if (num <= cat * 2.5 && num >= cat * 1.5) {
|
|
|
|
|
showModal('今天就吃汉堡炸鸡吧!不要再想了!GOGO');
|
|
|
|
|
} else if (num <= cat * 3.5 && num >= cat * 2.5) {
|
|
|
|
|
showModal('今天就吃面食吧!不要再想了!GOGO');
|
|
|
|
|
} else if (num <= cat * 4.5 && num >= cat * 3.5) {
|
|
|
|
|
showModal('今天就吃烤盘饭吧!不要再想了!GOGO');
|
|
|
|
|
} else if (num <= cat * 5.5 && num >= cat * 4.5) {
|
|
|
|
|
showModal('今天就吃煎饼果子吧!不要再想了!GOGO');
|
|
|
|
|
} */
|
|
|
|
|
console.log(num)
|
|
|
|
|
var a= wx.getStorageSync('i')
|
|
|
|
|
console.log(a)
|
|
|
|
|
showModal('今天吃'+a)
|
|
|
|
|
}, 2000)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onLoad: function() {
|
|
|
|
|
const db=wx.cloud.database()
|
|
|
|
|
var that=this
|
|
|
|
|
db.collection("user")
|
|
|
|
|
.where({
|
|
|
|
|
"_openid":userid
|
|
|
|
|
})
|
|
|
|
|
.get({
|
|
|
|
|
success: (res) => {
|
|
|
|
|
console.log('请求成功',res);
|
|
|
|
|
var o=res.data[0].cartlist.length-1
|
|
|
|
|
console.log(o)
|
|
|
|
|
var p=Math.round(Math.random()*o)
|
|
|
|
|
console.log(p)
|
|
|
|
|
that.setData({
|
|
|
|
|
list:res.data[0].cartlist[p].food_name
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
console.log('请求成功2',res.data[0].cartlist[p].food_name);
|
|
|
|
|
wx.setStorageSync('i', res.data[0].cartlist[p].food_name)
|
|
|
|
|
},
|
|
|
|
|
fail(err) {
|
|
|
|
|
console.log("请求失败", err)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|