东风启辰小程序端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 5 roky
před 5 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 app.sharePack();
  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. console.log(this.data.getSecondGuessInfoV2);
  119. var lucky_result = 0;
  120. if(this.data.getSecondGuessInfoV2.lucky_result==-2){
  121. lucky_result = this.data.getSecondGuessInfoV2.lucky_result;
  122. }else if(this.data.getSecondGuessInfoV2.lucky_result==1){
  123. lucky_result = this.data.getSecondGuessInfoV2.lucky_result;
  124. }else if(this.data.getSecondGuessInfoV2.lucky_result==2){
  125. lucky_result = this.data.getSecondGuessInfoV2.lucky_result;
  126. }
  127. if(lucky_result!=0){
  128. if(lucky_result==-2){
  129. var drawResult = 0;
  130. if(lucky_result==1){
  131. drawResult = 1;
  132. }else if(lucky_result==2){
  133. drawResult = 2;
  134. }else{
  135. drawResult = 3;
  136. }
  137. this.setData({
  138. drawResult:drawResult,
  139. drawState:lucky_result
  140. })
  141. }else{
  142. this.windowTipControl();
  143. }
  144. return;
  145. }
  146. if(this.data.httpState){
  147. return;
  148. }
  149. this.data.httpState = true;
  150. app.wxRequest(app.globalData.urlRoot + "guessPrice/getSecondPriceLucky", {}, res => {
  151. this.data.httpState = false;
  152. if (res.code == 200) {
  153. var drawResult = 0;
  154. if(res.data.lucky_result==1){
  155. drawResult = 1;
  156. }else if(res.data.lucky_result==2){
  157. drawResult = 2;
  158. }else{
  159. drawResult = 3;
  160. }
  161. this.setData({
  162. drawResult:drawResult,
  163. drawState:res.data.lucky_result
  164. })
  165. app.globalData.getSecondGuessInfoV2.lucky_result = res.data.lucky_result
  166. }
  167. }, this);
  168. },
  169. closeWindow:function(){//关闭抽奖结果弹窗
  170. this.setData({
  171. drawResult:0
  172. })
  173. },
  174. getAddress: function () {//获取地址
  175. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  176. if (res.code == 200) {
  177. if (res.data && res.data.agentDetail) {
  178. this.data.isUserAddress = true;
  179. }
  180. }
  181. }, this);
  182. },
  183. acceptPrize:function(){//马上领奖
  184. if(this.data.isUserAddress){
  185. wx.reLaunch({
  186. url: '/pages/myCenter/myCenter'
  187. })
  188. }else{
  189. wx.navigateTo({
  190. url: '/pages/perfectMsg/perfectMsg',
  191. })
  192. }
  193. },
  194. goLuckyStar:function(){//领取上市好礼
  195. wx.reLaunch({
  196. url: '/pages/index/index'
  197. })
  198. // if(app.globalData.getBuyState.success){
  199. // wx.navigateTo({
  200. // url: '/pages/luckyStar/luckyStar',
  201. // })
  202. // }else{
  203. // this.placingControl();
  204. // }
  205. },
  206. placingControl: function () {
  207. if (app.globalData.getBuyState){
  208. if (app.globalData.getBuyState.success != this.data.buyState) {
  209. this.setData({
  210. buyState: app.globalData.getBuyState.success
  211. })
  212. }
  213. }
  214. this.setData({
  215. placing: !this.data.placing
  216. })
  217. },
  218. enterGuess:function(){
  219. wx.navigateTo({
  220. url: '/pages/guessSecondPoster/guessSecondPoster',
  221. })
  222. },
  223. getUserWxMsg:function(e){//通过微信获取用户信息
  224. if (e.detail.errMsg == "getUserInfo:ok") {
  225. this.setData({
  226. isUserInfo:true
  227. })
  228. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  229. this.enterGuess();
  230. }
  231. },
  232. windowTipControl:function(){
  233. this.setData({
  234. windowTipShow:!this.data.windowTipShow
  235. })
  236. },
  237. lookConfigure: function () {
  238. wx.navigateTo({
  239. url: '/pages/configure/configure',
  240. })
  241. }
  242. })