|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- // pages/guessSecondResult/guessSecondResult.js
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.urlStatic,//图片路径
- ruleShow:false,//是否显示竞猜规则
- isUserAddress:false,//用户是否有地址
- guessPriceArr:[1,2,3,4,5,6],//用户的竞猜价格
- guessResult:3,//用户竞猜结果1:猜中,2:未猜中,3:未参加
- drawResult:0,//竞猜成功的用户抽奖结果1:升舱卡,2:京东卡,3:未中奖
- drawState:false,//是否抽过奖
- placing: false,
- buyState: false,
- httpState:false,//是否正在进行http请求
- isUserInfo:false,//是否有个人信息
- getSecondGuessInfoV2:null,
- windowTipShow:false,
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- app.globalData.nowPage = 3;
- this.setData({
- getSecondGuessInfoV2:app.globalData.getSecondGuessInfoV2
- })
- var getSecondGuessInfoV2 = app.globalData.getSecondGuessInfoV2;
- var userType = 3;
- if(getSecondGuessInfoV2){
- if(getSecondGuessInfoV2.lucky_result==-1){
- userType = 2
- }else{
- userType = 1;
- if(getSecondGuessInfoV2.lucky_result!=0){
- this.setData({
- drawState:getSecondGuessInfoV2.lucky_result
- })
- }
- }
- this.data.guessPriceArr = getSecondGuessInfoV2.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(app.globalData.userInfoData && app.globalData.userInfoData.nickName){
- this.setData({
- isUserInfo:true
- })
- }
- this.setData({
- guessResult:userType
- })
- },
- loadFun:function(){
- this.getAddress();
- this.setData({
- buyState: app.globalData.getBuyState?app.globalData.getBuyState.success:false
- })
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- 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 () {
- return app.sharePack();
- },
- ruleControl:function(){//规则显示控制
- this.setData({
- ruleShow:!this.data.ruleShow
- })
- },
- enterLucky:function(){//每日抽奖
- wx.navigateTo({
- url: '/pages/luckyStar/luckyStar'
- })
- },
- drawBtn:function(){//立即抽取大奖
- console.log(this.data.getSecondGuessInfoV2);
- var lucky_result = 0;
- if(this.data.getSecondGuessInfoV2.lucky_result==-2){
- lucky_result = this.data.getSecondGuessInfoV2.lucky_result;
- }else if(this.data.getSecondGuessInfoV2.lucky_result==1){
- lucky_result = this.data.getSecondGuessInfoV2.lucky_result;
- }else if(this.data.getSecondGuessInfoV2.lucky_result==2){
- lucky_result = this.data.getSecondGuessInfoV2.lucky_result;
- }
- if(lucky_result!=0){
- if(lucky_result==-2){
- var drawResult = 0;
- if(lucky_result==1){
- drawResult = 1;
- }else if(lucky_result==2){
- drawResult = 2;
- }else{
- drawResult = 3;
- }
- this.setData({
- drawResult:drawResult,
- drawState:lucky_result
- })
- }else{
- this.windowTipControl();
- }
- return;
- }
- if(this.data.httpState){
- return;
- }
- this.data.httpState = true;
- app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondPriceLucky", {}, res => {
- this.data.httpState = false;
- if (res.code == 200) {
- var drawResult = 0;
- if(res.data.lucky_result==1){
- drawResult = 1;
- }else if(res.data.lucky_result==2){
- drawResult = 2;
- }else{
- drawResult = 3;
- }
- this.setData({
- drawResult:drawResult,
- drawState:res.data.lucky_result
- })
- app.globalData.getSecondGuessInfoV2.lucky_result = res.data.lucky_result
- }
- }, this);
- },
- closeWindow:function(){//关闭抽奖结果弹窗
- this.setData({
- drawResult:0
- })
- },
- 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);
- },
- acceptPrize:function(){//马上领奖
- if(this.data.isUserAddress){
- wx.reLaunch({
- url: '/pages/myCenter/myCenter'
- })
- }else{
- wx.navigateTo({
- url: '/pages/perfectMsg/perfectMsg',
- })
- }
- },
- goLuckyStar:function(){//领取上市好礼
- wx.reLaunch({
- url: '/pages/index/index'
- })
- // if(app.globalData.getBuyState.success){
- // wx.navigateTo({
- // url: '/pages/luckyStar/luckyStar',
- // })
- // }else{
- // this.placingControl();
- // }
- },
- placingControl: function () {
- if (app.globalData.getBuyState){
- if (app.globalData.getBuyState.success != this.data.buyState) {
- this.setData({
- buyState: app.globalData.getBuyState.success
- })
- }
- }
- this.setData({
- placing: !this.data.placing
- })
- },
- enterGuess:function(){
- wx.navigateTo({
- url: '/pages/guessSecondPoster/guessSecondPoster',
- })
- },
- getUserWxMsg:function(e){//通过微信获取用户信息
- if (e.detail.errMsg == "getUserInfo:ok") {
- this.setData({
- isUserInfo:true
- })
- app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
- this.enterGuess();
- }
- },
- windowTipControl:function(){
- this.setData({
- windowTipShow:!this.data.windowTipShow
- })
- },
- lookConfigure: function () {
- wx.navigateTo({
- url: '/pages/configure/configure',
- })
- }
- })
|