东风启辰小程序端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

172 行
4.1KB

  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. 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. },
  33. /**
  34. * 生命周期函数--监听页面初次渲染完成
  35. */
  36. onReady: function () {
  37. },
  38. /**
  39. * 生命周期函数--监听页面显示
  40. */
  41. onShow: function () {
  42. // if(app.globalData.getSecondGuessInfo.firstData){
  43. // this.data.userType = 1;
  44. // }
  45. if(this.data.isShowFun){
  46. var getSecondGuessInfo = app.globalData.getSecondGuessInfo;
  47. var userType = 1;
  48. if(getSecondGuessInfo.secondData){
  49. userType = 1;
  50. // console.log("查看第二轮价格")
  51. }else if(!getSecondGuessInfo.firstData && !getSecondGuessInfo.secondData){
  52. userType = 2;
  53. // console.log("开始竞猜");
  54. }else if(getSecondGuessInfo.firstData.lucky_result==-1){
  55. userType = 3;
  56. // console.log("调整价格");
  57. }else{
  58. userType = 4;
  59. // console.log("去抽大奖");
  60. }
  61. this.setData({
  62. userType:userType
  63. })
  64. }
  65. },
  66. /**
  67. * 生命周期函数--监听页面隐藏
  68. */
  69. onHide: function () {
  70. },
  71. /**
  72. * 生命周期函数--监听页面卸载
  73. */
  74. onUnload: function () {
  75. },
  76. /**
  77. * 页面相关事件处理函数--监听用户下拉动作
  78. */
  79. onPullDownRefresh: function () {
  80. },
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. onReachBottom: function () {
  85. },
  86. /**
  87. * 用户点击右上角分享
  88. */
  89. onShareAppMessage: function () {
  90. return {
  91. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  92. imageUrl:this.data.imgUrl+'/newImages5/56.jpg',
  93. path: "/pages/guess/guess"
  94. }
  95. },
  96. enterLucky:function(){//每日抽奖
  97. wx.navigateTo({
  98. url: '/pages/luckyStar/luckyStar'
  99. })
  100. },
  101. yuyueControl:function(){//预约
  102. this.setData({
  103. yuyueShow: !this.data.yuyueShow
  104. })
  105. },
  106. enterGuessPrize:function(){//开始竞猜
  107. if(this.data.userType == 1 || this.data.userType == 2){
  108. wx.navigateTo({
  109. url: '/pages/guessSecondPrize/guessSecondPrize'
  110. })
  111. }else if(this.data.userType == 3){
  112. wx.navigateTo({
  113. url: '/pages/guessSecond/guessSecond?type=1'
  114. })
  115. }else{
  116. wx.navigateTo({
  117. url: '/pages/guessSecond/guessSecond?type=2'
  118. })
  119. }
  120. },
  121. getSecondGuessInfo:function(){
  122. app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => {
  123. if (res.code == 200) {
  124. app.globalData.getSecondGuessInfo = res.data;
  125. // if(res.data.secondData || !res.data.firstData){
  126. // this.data.userType = 1;
  127. // }else if(res.data.firstData.lucky_result==-1){
  128. // this.data.userType = 2;
  129. // }else{
  130. // this.data.userType = 3;
  131. // }
  132. var userType = 1;
  133. if(res.data.secondData){
  134. userType = 1;
  135. // console.log("查看第二轮价格")
  136. }else if(!res.data.firstData && !res.data.secondData){
  137. userType = 2;
  138. // console.log("开始竞猜");
  139. }else if(res.data.firstData.lucky_result==-1){
  140. userType = 3;
  141. // console.log("调整价格");
  142. }else{
  143. userType = 4;
  144. // console.log("去抽大奖");
  145. }
  146. this.setData({
  147. userType:userType,
  148. isShowFun:true
  149. })
  150. }
  151. }, this);
  152. },
  153. tipWindowControl2:function(){
  154. this.setData({
  155. tipWindow2:!this.data.tipWindow2
  156. })
  157. }
  158. })