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

191 lines
4.3KB

  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. return {
  88. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  89. imageUrl: this.data.imgUrl+'/newImages5/56.jpg',
  90. path: "/pages/guess/guess"
  91. }
  92. },
  93. enterLucky:function(){//每日抽奖
  94. wx.navigateTo({
  95. url: '/pages/luckyStar/luckyStar'
  96. })
  97. },
  98. ruleControl:function(){//规则显示控制
  99. this.setData({
  100. ruleShow:!this.data.ruleShow
  101. })
  102. },
  103. enterGuess:function(){//去竞猜
  104. wx.navigateTo({
  105. url: '/pages/guessSecondPrize/guessSecondPrize',
  106. })
  107. },
  108. startDraw:function(){//抽奖
  109. if(this.data.httpState){
  110. return;
  111. }
  112. this.data.httpState = true;
  113. app.wxRequest(app.globalData.urlRoot+"guessPrice/getFirstGuessLucky",{},res =>{
  114. this.data.httpState = false;
  115. if(res.code==200){
  116. app.globalData.getSecondGuessInfo.firstData.lucky_result = 1;
  117. // res.data.lucky_result = 1;
  118. if(res.data.lucky_result==1){
  119. this.setData({
  120. drawResult:2
  121. })
  122. }else if(res.data.lucky_result==2){
  123. this.setData({
  124. drawResult:1
  125. })
  126. }else if(res.data.lucky_result==-2){
  127. app.globalData.getSecondGuessInfo.firstData.lucky_result = -2;
  128. this.setData({
  129. drawResult:3
  130. })
  131. }
  132. }else{
  133. wx.showToast({
  134. title: res.msg,
  135. icon:'none'
  136. })
  137. }
  138. },this);
  139. },
  140. prizeWindowControl:function(){//关闭抽奖弹窗
  141. this.setData({
  142. drawResult:0
  143. })
  144. },
  145. enterPerfectMsg:function(){//马上领取
  146. if(this.data.isUserAddress){
  147. // this.enterGuess();
  148. wx.reLaunch({
  149. url: '/pages/myCenter/myCenter'
  150. })
  151. }else{
  152. wx.navigateTo({
  153. url: '/pages/perfectMsg/perfectMsg',
  154. })
  155. }
  156. },
  157. getAddress: function () {//获取地址
  158. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  159. if (res.code == 200) {
  160. if (res.data && res.data.agentDetail) {
  161. this.data.isUserAddress = true;
  162. }
  163. }
  164. }, this);
  165. },
  166. lookConfigure: function () {
  167. wx.navigateTo({
  168. url: '/pages/configure/configure',
  169. })
  170. },
  171. closePeiceWindow:function(){
  172. this.setData({
  173. drawResult:0,
  174. drawState:true
  175. })
  176. }
  177. })