东风启辰小程序端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

178 lines
4.0KB

  1. // pages/guessSecond/guessSecond.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. guessResult:true,//第一轮竞猜是否猜中
  10. drawResult:0,//1:京东卡,2:升舱卡,3:未抽中
  11. drawState:false,//是否抽过奖
  12. guessPriceArr:[1,2,3,4,5,6],
  13. ruleShow:false,//是否显示竞猜规则
  14. isUserAddress:false,//用户是否有地址
  15. httpState:false,//是否正在进行http请求
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. app.globalData.nowPage = 3;
  22. var getSecondGuessInfo = app.globalData.getSecondGuessInfo;
  23. this.data.guessPriceArr = getSecondGuessInfo.firstData.guess_price.toString().split("");
  24. for(let i=0;i<this.data.guessPriceArr.length;i++){
  25. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  26. }
  27. this.setData({
  28. guessPriceArr:this.data.guessPriceArr
  29. })
  30. if(options.type==1){
  31. this.setData({
  32. guessResult:false
  33. })
  34. }else if(options.type==2){
  35. this.setData({
  36. guessResult:true
  37. })
  38. }
  39. if(this.data.guessResult && app.globalData.getSecondGuessInfo.firstData.lucky_result!=0){
  40. this.setData({
  41. drawState:true
  42. })
  43. }
  44. },
  45. loadFun:function(){
  46. this.getAddress();
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow: function () {
  57. if (app.globalData.openid) {
  58. this.loadFun();
  59. } else {
  60. app.globalData.openidSuccessFuc = this.loadFun;
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面隐藏
  65. */
  66. onHide: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面卸载
  70. */
  71. onUnload: function () {
  72. },
  73. /**
  74. * 页面相关事件处理函数--监听用户下拉动作
  75. */
  76. onPullDownRefresh: function () {
  77. },
  78. /**
  79. * 页面上拉触底事件的处理函数
  80. */
  81. onReachBottom: function () {
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage: function () {
  87. },
  88. enterLucky:function(){//每日抽奖
  89. wx.navigateTo({
  90. url: '/pages/luckyStar/luckyStar'
  91. })
  92. },
  93. ruleControl:function(){//规则显示控制
  94. this.setData({
  95. ruleShow:!this.data.ruleShow
  96. })
  97. },
  98. enterGuess:function(){//去竞猜
  99. wx.navigateTo({
  100. url: '/pages/guessSecondPrize/guessSecondPrize',
  101. })
  102. },
  103. startDraw:function(){//抽奖
  104. if(this.data.httpState){
  105. return;
  106. }
  107. this.data.httpState = true;
  108. app.wxRequest(app.globalData.urlRoot+"guessPrice/getFirstGuessLucky",{},res =>{
  109. this.data.httpState = false;
  110. if(res.code==200){
  111. app.globalData.getSecondGuessInfo.firstData.lucky_result = 1;
  112. // res.data.lucky_result = 1;
  113. if(res.data.lucky_result==1){
  114. this.setData({
  115. drawResult:2
  116. })
  117. }else if(res.data.lucky_result==2){
  118. this.setData({
  119. drawResult:1
  120. })
  121. }else if(res.data.lucky_result==-2){
  122. app.globalData.getSecondGuessInfo.firstData.lucky_result = -2;
  123. this.setData({
  124. drawResult:3
  125. })
  126. }
  127. }else{
  128. wx.showToast({
  129. title: res.msg,
  130. icon:'none'
  131. })
  132. }
  133. },this);
  134. },
  135. prizeWindowControl:function(){//关闭抽奖弹窗
  136. this.setData({
  137. drawResult:0
  138. })
  139. },
  140. enterPerfectMsg:function(){//马上领取
  141. if(this.data.isUserAddress){
  142. this.enterGuess();
  143. }else{
  144. wx.navigateTo({
  145. url: '/pages/perfectMsg/perfectMsg',
  146. })
  147. }
  148. },
  149. getAddress: function () {//获取地址
  150. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  151. if (res.code == 200) {
  152. if (res.data && res.data.agentDetail) {
  153. this.data.isUserAddress = true;
  154. }
  155. }
  156. }, this);
  157. },
  158. lookConfigure: function () {
  159. wx.navigateTo({
  160. url: '/pages/configure/configure',
  161. })
  162. }
  163. })