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

161 line
3.7KB

  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. isShowFun:false
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. app.globalData.nowPage = 3;
  18. if (app.globalData.openid) {
  19. this.loadFun();
  20. } else {
  21. app.globalData.openidSuccessFuc = this.loadFun;
  22. }
  23. },
  24. loadFun:function(){
  25. if (!app.globalData.addPageEnterState.guessPrize) {
  26. app.addPageEnter("7C8AAA38F8D85EFC48C2995FB6EBAC19");
  27. app.globalData.addPageEnterState.guessPrize = true;
  28. }
  29. this.getSecondGuessInfo();
  30. },
  31. /**
  32. * 生命周期函数--监听页面初次渲染完成
  33. */
  34. onReady: function () {
  35. },
  36. /**
  37. * 生命周期函数--监听页面显示
  38. */
  39. onShow: function () {
  40. // if(app.globalData.getSecondGuessInfo.firstData){
  41. // this.data.userType = 1;
  42. // }
  43. if(this.data.isShowFun){
  44. var getSecondGuessInfo = app.globalData.getSecondGuessInfo;
  45. var userType = 1;
  46. if(getSecondGuessInfo.secondData){
  47. userType = 1;
  48. // console.log("查看第二轮价格")
  49. }else if(!getSecondGuessInfo.firstData && !getSecondGuessInfo.secondData){
  50. userType = 2;
  51. // console.log("开始竞猜");
  52. }else if(getSecondGuessInfo.firstData.lucky_result==-1){
  53. userType = 3;
  54. // console.log("调整价格");
  55. }else{
  56. userType = 4;
  57. // console.log("去抽大奖");
  58. }
  59. this.setData({
  60. userType:userType
  61. })
  62. }
  63. },
  64. /**
  65. * 生命周期函数--监听页面隐藏
  66. */
  67. onHide: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面卸载
  71. */
  72. onUnload: function () {
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh: function () {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom: function () {
  83. },
  84. /**
  85. * 用户点击右上角分享
  86. */
  87. onShareAppMessage: function () {
  88. },
  89. enterLucky:function(){//每日抽奖
  90. wx.navigateTo({
  91. url: '/pages/luckyStar/luckyStar'
  92. })
  93. },
  94. yuyueControl:function(){//预约
  95. this.setData({
  96. yuyueShow: !this.data.yuyueShow
  97. })
  98. },
  99. enterGuessPrize:function(){//开始竞猜
  100. if(this.data.userType == 1 || this.data.userType == 2){
  101. wx.navigateTo({
  102. url: '/pages/guessSecondPrize/guessSecondPrize'
  103. })
  104. }else if(this.data.userType == 3){
  105. wx.navigateTo({
  106. url: '/pages/guessSecond/guessSecond?type=1'
  107. })
  108. }else{
  109. wx.navigateTo({
  110. url: '/pages/guessSecond/guessSecond?type=2'
  111. })
  112. }
  113. },
  114. getSecondGuessInfo:function(){
  115. app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => {
  116. if (res.code == 200) {
  117. app.globalData.getSecondGuessInfo = res.data;
  118. // if(res.data.secondData || !res.data.firstData){
  119. // this.data.userType = 1;
  120. // }else if(res.data.firstData.lucky_result==-1){
  121. // this.data.userType = 2;
  122. // }else{
  123. // this.data.userType = 3;
  124. // }
  125. var userType = 1;
  126. if(res.data.secondData){
  127. userType = 1;
  128. // console.log("查看第二轮价格")
  129. }else if(!res.data.firstData && !res.data.secondData){
  130. userType = 2;
  131. // console.log("开始竞猜");
  132. }else if(res.data.firstData.lucky_result==-1){
  133. userType = 3;
  134. // console.log("调整价格");
  135. }else{
  136. userType = 4;
  137. // console.log("去抽大奖");
  138. }
  139. this.setData({
  140. userType:userType,
  141. isShowFun:true
  142. })
  143. }
  144. }, this);
  145. }
  146. })