东风启辰小程序端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

214 lines
5.1KB

  1. // pages/guessSecondResult/guessSecondResult.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. ruleShow:false,//是否显示竞猜规则
  10. isUserAddress:false,//用户是否有地址
  11. guessPriceArr:[1,2,3,4,5,6],//用户的竞猜价格
  12. guessResult:3,//用户竞猜结果1:猜中,2:未猜中,3:未参加
  13. drawResult:0,//竞猜成功的用户抽奖结果1:升舱卡,2:京东卡,3:未中奖
  14. drawState:false,//是否抽过奖
  15. placing: false,
  16. buyState: false,
  17. httpState:false,//是否正在进行http请求
  18. isUserInfo:false,//是否有个人信息
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. app.globalData.nowPage = 3;
  25. var getSecondGuessInfoV2 = app.globalData.getSecondGuessInfoV2;
  26. var userType = 3;
  27. console.log(getSecondGuessInfoV2);
  28. if(getSecondGuessInfoV2){
  29. if(getSecondGuessInfoV2.lucky_result==-1){
  30. userType = 2
  31. }else{
  32. userType = 1;
  33. if(getSecondGuessInfoV2.lucky_result!=0){
  34. this.setData({
  35. drawState:getSecondGuessInfoV2.lucky_result
  36. })
  37. }
  38. }
  39. this.data.guessPriceArr = getSecondGuessInfoV2.guess_price.toString().split("");
  40. for(let i=0;i<this.data.guessPriceArr.length;i++){
  41. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  42. }
  43. this.setData({
  44. guessPriceArr:this.data.guessPriceArr
  45. })
  46. }
  47. if(app.globalData.userInfoData && app.globalData.userInfoData.nickName){
  48. this.setData({
  49. isUserInfo:true
  50. })
  51. }
  52. this.setData({
  53. guessResult:userType
  54. })
  55. },
  56. loadFun:function(){
  57. this.getAddress();
  58. this.setData({
  59. buyState: app.globalData.getBuyState?app.globalData.getBuyState.success:false
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {
  71. if (app.globalData.openid) {
  72. this.loadFun();
  73. } else {
  74. app.globalData.openidSuccessFuc = this.loadFun;
  75. }
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. return {
  102. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  103. imageUrl: this.data.imgUrl+'/newImages5/56.jpg',
  104. path: "/pages/guess/guess"
  105. }
  106. },
  107. ruleControl:function(){//规则显示控制
  108. this.setData({
  109. ruleShow:!this.data.ruleShow
  110. })
  111. },
  112. enterLucky:function(){//每日抽奖
  113. wx.navigateTo({
  114. url: '/pages/luckyStar/luckyStar'
  115. })
  116. },
  117. drawBtn:function(){//立即抽取大奖
  118. if(this.data.httpState){
  119. return;
  120. }
  121. this.data.httpState = true;
  122. app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondPriceLucky", {}, res => {
  123. this.data.httpState = false;
  124. if (res.code == 200) {
  125. var drawResult = 0;
  126. if(res.data.lucky_result==1){
  127. drawResult = 1;
  128. }else if(res.data.lucky_result==2){
  129. drawResult = 2;
  130. }else{
  131. drawResult = 3;
  132. }
  133. this.setData({
  134. drawResult:drawResult,
  135. drawState:res.data.lucky_result
  136. })
  137. }
  138. }, this);
  139. },
  140. closeWindow:function(){//关闭抽奖结果弹窗
  141. this.setData({
  142. drawResult:0
  143. })
  144. },
  145. getAddress: function () {//获取地址
  146. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  147. if (res.code == 200) {
  148. if (res.data && res.data.agentDetail) {
  149. this.data.isUserAddress = true;
  150. }
  151. }
  152. }, this);
  153. },
  154. acceptPrize:function(){//马上领奖
  155. if(this.data.isUserAddress){
  156. wx.reLaunch({
  157. url: '/pages/myCenter/myCenter'
  158. })
  159. }else{
  160. wx.navigateTo({
  161. url: '/pages/perfectMsg/perfectMsg',
  162. })
  163. }
  164. },
  165. goLuckyStar:function(){//领取上市好礼
  166. if(app.globalData.getBuyState.success){
  167. wx.navigateTo({
  168. url: '/pages/luckyStar/luckyStar',
  169. })
  170. }else{
  171. this.placingControl();
  172. }
  173. },
  174. placingControl: function () {
  175. if (app.globalData.getBuyState){
  176. if (app.globalData.getBuyState.success != this.data.buyState) {
  177. this.setData({
  178. buyState: app.globalData.getBuyState.success
  179. })
  180. }
  181. }
  182. this.setData({
  183. placing: !this.data.placing
  184. })
  185. },
  186. enterGuess:function(){
  187. wx.navigateTo({
  188. url: '/pages/guessSecondPoster/guessSecondPoster',
  189. })
  190. },
  191. getUserWxMsg:function(e){//通过微信获取用户信息
  192. if (e.detail.errMsg == "getUserInfo:ok") {
  193. this.setData({
  194. isUserInfo:true
  195. })
  196. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  197. this.enterGuess();
  198. }
  199. }
  200. })