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

252 lines
6.3KB

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