// pages/guess/guess.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { imgUrl: app.globalData.urlStatic,//图片路径 yuyueShow:false, userType:1, isShowFun:false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { app.globalData.nowPage = 3; if (app.globalData.openid) { this.loadFun(); } else { app.globalData.openidSuccessFuc = this.loadFun; } }, loadFun:function(){ if (!app.globalData.addPageEnterState.guessPrize) { app.addPageEnter("7C8AAA38F8D85EFC48C2995FB6EBAC19"); app.globalData.addPageEnterState.guessPrize = true; } this.getSecondGuessInfo(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { // if(app.globalData.getSecondGuessInfo.firstData){ // this.data.userType = 1; // } if(this.data.isShowFun){ var getSecondGuessInfo = app.globalData.getSecondGuessInfo; var userType = 1; if(getSecondGuessInfo.secondData){ userType = 1; // console.log("查看第二轮价格") }else if(!getSecondGuessInfo.firstData && !getSecondGuessInfo.secondData){ userType = 2; // console.log("开始竞猜"); }else if(getSecondGuessInfo.firstData.lucky_result==-1){ userType = 3; // console.log("调整价格"); }else{ userType = 4; // console.log("去抽大奖"); } this.setData({ userType:userType }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, enterLucky:function(){//每日抽奖 wx.navigateTo({ url: '/pages/luckyStar/luckyStar' }) }, yuyueControl:function(){//预约 this.setData({ yuyueShow: !this.data.yuyueShow }) }, enterGuessPrize:function(){//开始竞猜 if(this.data.userType == 1 || this.data.userType == 2){ wx.navigateTo({ url: '/pages/guessSecondPrize/guessSecondPrize' }) }else if(this.data.userType == 3){ wx.navigateTo({ url: '/pages/guessSecond/guessSecond?type=1' }) }else{ wx.navigateTo({ url: '/pages/guessSecond/guessSecond?type=2' }) } }, getSecondGuessInfo:function(){ app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => { if (res.code == 200) { app.globalData.getSecondGuessInfo = res.data; // if(res.data.secondData || !res.data.firstData){ // this.data.userType = 1; // }else if(res.data.firstData.lucky_result==-1){ // this.data.userType = 2; // }else{ // this.data.userType = 3; // } var userType = 1; if(res.data.secondData){ userType = 1; // console.log("查看第二轮价格") }else if(!res.data.firstData && !res.data.secondData){ userType = 2; // console.log("开始竞猜"); }else if(res.data.firstData.lucky_result==-1){ userType = 3; // console.log("调整价格"); }else{ userType = 4; // console.log("去抽大奖"); } this.setData({ userType:userType, isShowFun:true }) } }, this); } })