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

185 lines
4.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: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 {
  92. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  93. imageUrl:this.data.imgUrl+'/newImages5/56.jpg',
  94. path: "/pages/guess/guess"
  95. }
  96. },
  97. enterLucky:function(){//每日抽奖
  98. wx.navigateTo({
  99. url: '/pages/luckyStar/luckyStar'
  100. })
  101. },
  102. yuyueControl:function(){//预约
  103. this.setData({
  104. yuyueShow: !this.data.yuyueShow
  105. })
  106. },
  107. enterGuessPrize:function(){//开始竞猜
  108. if(this.data.userType == 1 || this.data.userType == 2){
  109. wx.navigateTo({
  110. url: '/pages/guessSecondPrize/guessSecondPrize'
  111. })
  112. }else if(this.data.userType == 3){
  113. wx.navigateTo({
  114. url: '/pages/guessSecond/guessSecond?type=1'
  115. })
  116. }else{
  117. wx.navigateTo({
  118. url: '/pages/guessSecond/guessSecond?type=2'
  119. })
  120. }
  121. },
  122. getSecondGuessInfo:function(){
  123. app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfo", {}, res => {
  124. if (res.code == 200) {
  125. app.globalData.getSecondGuessInfo = res.data;
  126. // if(res.data.secondData || !res.data.firstData){
  127. // this.data.userType = 1;
  128. // }else if(res.data.firstData.lucky_result==-1){
  129. // this.data.userType = 2;
  130. // }else{
  131. // this.data.userType = 3;
  132. // }
  133. var userType = 1;
  134. if(res.data.secondData){
  135. userType = 1;
  136. // console.log("查看第二轮价格")
  137. }else if(!res.data.firstData && !res.data.secondData){
  138. userType = 2;
  139. // console.log("开始竞猜");
  140. }else if(res.data.firstData.lucky_result==-1){
  141. userType = 3;
  142. // console.log("调整价格");
  143. }else{
  144. userType = 4;
  145. // console.log("去抽大奖");
  146. }
  147. this.setData({
  148. userType:userType,
  149. isShowFun:true
  150. })
  151. }
  152. }, this);
  153. },
  154. tipWindowControl2:function(){
  155. this.setData({
  156. tipWindow2:!this.data.tipWindow2
  157. })
  158. },
  159. getSecondResult:function(){//获取第二轮竞猜结果
  160. app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondGuessInfoV2", {}, res => {
  161. if (res.code == 200) {
  162. app.globalData.getSecondGuessInfoV2 = res.data;
  163. }
  164. }, this);
  165. },
  166. enterGuessSecondResult:function(){//进入第二轮竞猜结果页面
  167. wx.navigateTo({
  168. url: '/pages/guessSecondResult/guessSecondResult',
  169. })
  170. }
  171. })