东风启辰小程序端
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.

122 lines
2.5KB

  1. // pages/guess/guess.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. yuyueShow:false,
  10. userType:1,
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. app.globalData.nowPage = 3;
  17. if (app.globalData.openid) {
  18. this.loadFun();
  19. } else {
  20. app.globalData.openidSuccessFuc = this.loadFun;
  21. }
  22. },
  23. loadFun:function(){
  24. if (!app.globalData.addPageEnterState.guessPrize) {
  25. app.addPageEnter("7C8AAA38F8D85EFC48C2995FB6EBAC19");
  26. app.globalData.addPageEnterState.guessPrize = true;
  27. }
  28. this.getSecondGuessInfo();
  29. },
  30. /**
  31. * 生命周期函数--监听页面初次渲染完成
  32. */
  33. onReady: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面显示
  37. */
  38. onShow: function () {
  39. if(app.globalData.getSecondGuessInfo.firstData){
  40. this.data.userType = 1;
  41. }
  42. },
  43. /**
  44. * 生命周期函数--监听页面隐藏
  45. */
  46. onHide: function () {
  47. },
  48. /**
  49. * 生命周期函数--监听页面卸载
  50. */
  51. onUnload: function () {
  52. },
  53. /**
  54. * 页面相关事件处理函数--监听用户下拉动作
  55. */
  56. onPullDownRefresh: function () {
  57. },
  58. /**
  59. * 页面上拉触底事件的处理函数
  60. */
  61. onReachBottom: function () {
  62. },
  63. /**
  64. * 用户点击右上角分享
  65. */
  66. onShareAppMessage: function () {
  67. },
  68. enterLucky:function(){//每日抽奖
  69. wx.navigateTo({
  70. url: '/pages/luckyStar/luckyStar'
  71. })
  72. },
  73. yuyueControl:function(){//预约
  74. this.setData({
  75. yuyueShow: !this.data.yuyueShow
  76. })
  77. },
  78. enterGuessPrize:function(){//开始竞猜
  79. if(this.data.userType == 1){
  80. wx.navigateTo({
  81. url: '/pages/guessSecondPrize/guessSecondPrize'
  82. })
  83. }else if(this.data.userType == 2){
  84. wx.navigateTo({
  85. url: '/pages/guessSecond/guessSecond?type=1'
  86. })
  87. }else{
  88. wx.navigateTo({
  89. url: '/pages/guessSecond/guessSecond?type=2'
  90. })
  91. }
  92. },
  93. getSecondGuessInfo:function(){
  94. app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => {
  95. if (res.code == 200) {
  96. app.globalData.getSecondGuessInfo = res.data;
  97. if(res.data.secondData || !res.data.firstData){
  98. this.data.userType = 1;
  99. }else if(res.data.firstData.lucky_result==-1){
  100. this.data.userType = 2;
  101. }else{
  102. this.data.userType = 3;
  103. }
  104. }
  105. }, this);
  106. }
  107. })