东风启辰小程序端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

181 lines
4.3KB

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