|
- // pages/guessSecond/guessSecond.js
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.urlStatic,//图片路径
- guessResult:true,//第一轮竞猜是否猜中
- drawResult:0,//1:京东卡,2:升舱卡,3:未抽中
- drawState:false,//是否抽过奖
- guessPriceArr:[1,2,3,4,5,6],
- ruleShow:false,//是否显示竞猜规则
- isUserAddress:false,//用户是否有地址
- httpState:false,//是否正在进行http请求
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- app.globalData.nowPage = 3;
- var getSecondGuessInfo = app.globalData.getSecondGuessInfo;
- this.data.guessPriceArr = getSecondGuessInfo.firstData.guess_price.toString().split("");
- for(let i=0;i<this.data.guessPriceArr.length;i++){
- this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
- }
- this.setData({
- guessPriceArr:this.data.guessPriceArr
- })
- if(options.type==1){
- this.setData({
- guessResult:false
- })
- }else if(options.type==2){
- this.setData({
- guessResult:true
- })
- }
- if(this.data.guessResult && app.globalData.getSecondGuessInfo.firstData.lucky_result!=0){
- this.setData({
- drawState:true
- })
- }
- },
- loadFun:function(){
- this.getAddress();
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if (app.globalData.openid) {
- this.loadFun();
- } else {
- app.globalData.openidSuccessFuc = this.loadFun;
- }
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- },
- enterLucky:function(){//每日抽奖
- wx.navigateTo({
- url: '/pages/luckyStar/luckyStar'
- })
- },
- ruleControl:function(){//规则显示控制
- this.setData({
- ruleShow:!this.data.ruleShow
- })
- },
- enterGuess:function(){//去竞猜
- wx.navigateTo({
- url: '/pages/guessSecondPrize/guessSecondPrize',
- })
- },
- startDraw:function(){//抽奖
- if(this.data.httpState){
- return;
- }
- this.data.httpState = true;
- app.wxRequest(app.globalData.urlRoot+"guessPrice/getFirstGuessLucky",{},res =>{
- this.data.httpState = false;
- if(res.code==200){
- app.globalData.getSecondGuessInfo.firstData.lucky_result = 1;
- // res.data.lucky_result = 1;
- if(res.data.lucky_result==1){
- this.setData({
- drawResult:2
- })
- }else if(res.data.lucky_result==2){
- this.setData({
- drawResult:1
- })
- }else if(res.data.lucky_result==-2){
- app.globalData.getSecondGuessInfo.firstData.lucky_result = -2;
- this.setData({
- drawResult:3
- })
- }
- }else{
- wx.showToast({
- title: res.msg,
- icon:'none'
- })
- }
- },this);
- },
- prizeWindowControl:function(){//关闭抽奖弹窗
- this.setData({
- drawResult:0
- })
- },
- enterPerfectMsg:function(){//马上领取
- if(this.data.isUserAddress){
- // this.enterGuess();
- wx.reLaunch({
- url: '/pages/myCenter/myCenter'
- })
- }else{
- wx.navigateTo({
- url: '/pages/perfectMsg/perfectMsg',
- })
- }
- },
- getAddress: function () {//获取地址
- app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
- if (res.code == 200) {
- if (res.data && res.data.agentDetail) {
- this.data.isUserAddress = true;
- }
- }
- }, this);
- },
- lookConfigure: function () {
- wx.navigateTo({
- url: '/pages/configure/configure',
- })
- },
- closePeiceWindow:function(){
- this.setData({
- drawResult:0,
- drawState:true
- })
- }
- })
|