东风启辰小程序端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

252 lines
6.1KB

  1. // pages/guessSecondPrize/guessSecondPrize.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. ruleShow:false,//是否显示竞猜规则
  10. inputValue:"",//输入的价格
  11. stringValue:"",//输入的竞猜价格
  12. focusState:false,//输入框聚焦状态
  13. tipImgShow:true,//是否显示输入框提示
  14. isGuess:false,//是否竞猜过价格
  15. guessPrice:"",
  16. guessPriceArr:[1,2,3,4,5,6],
  17. slideDay:['0','0'],//距离上市时间
  18. randomNum:44,//随机数
  19. cartogramShow:false,//是否显示统计图
  20. getSecondGuessInfo:null,
  21. httpState:false,//是否正在进行http请求
  22. isUserInfo:false,//是否有个人信息
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. app.globalData.nowPage = 3;
  29. // this.distanceDay();
  30. if (app.globalData.openid) {
  31. this.loadFun();
  32. } else {
  33. app.globalData.openidSuccessFuc = this.loadFun;
  34. }
  35. this.setData({
  36. getSecondGuessInfo:app.globalData.getSecondGuessInfo
  37. })
  38. var getSecondGuessInfo = app.globalData.getSecondGuessInfo;
  39. if(getSecondGuessInfo.secondData){
  40. this.data.guessPriceArr = getSecondGuessInfo.secondData.guess_price.toString().split("");
  41. for(let i=0;i<this.data.guessPriceArr.length;i++){
  42. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  43. }
  44. console.log(getSecondGuessInfo.secondData);
  45. this.setData({
  46. isGuess:true,
  47. guessPriceArr:this.data.guessPriceArr
  48. })
  49. }
  50. if(app.globalData.userInfoData && app.globalData.userInfoData.nickName){
  51. this.setData({
  52. isUserInfo:true
  53. })
  54. }
  55. },
  56. loadFun:function(){
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function () {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function () {
  82. },
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function () {
  87. },
  88. /**
  89. * 用户点击右上角分享
  90. */
  91. onShareAppMessage: function () {
  92. return app.sharePack();
  93. },
  94. enterLucky:function(){//每日抽奖
  95. wx.navigateTo({
  96. url: '/pages/luckyStar/luckyStar'
  97. })
  98. },
  99. ruleControl:function(){//规则显示控制
  100. this.setData({
  101. ruleShow:!this.data.ruleShow
  102. })
  103. },
  104. focusControl:function(){
  105. this.setData({
  106. focusState:true
  107. })
  108. },
  109. focusControl2:function(){
  110. this.setData({
  111. focusState:false
  112. })
  113. },
  114. getValue:function(e){
  115. this.data.inputValue = e.detail.value;
  116. if(e.detail.value){
  117. this.setData({
  118. tipImgShow:false
  119. })
  120. }else{
  121. this.setData({
  122. tipImgShow:true
  123. })
  124. }
  125. this.setData({
  126. stringValue:e.detail.value
  127. })
  128. },
  129. submitPrice2:function(){
  130. if(this.data.inputValue>150000 || this.data.inputValue<110000){
  131. this.tipWindowControl();
  132. }else{
  133. this.data.guessPrice = this.data.inputValue;
  134. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  135. for(let i=0;i<this.data.guessPriceArr.length;i++){
  136. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  137. }
  138. this.setData({
  139. guessPriceArr:this.data.guessPriceArr
  140. })
  141. console.log(this.data.guessPrice);
  142. console.log(this.data.guessPriceArr);
  143. this.tipWindowControl2();
  144. }
  145. },
  146. tipWindowControl:function(){
  147. this.setData({
  148. tipWindow:!this.data.tipWindow
  149. })
  150. if(!this.data.tipWindow){
  151. this.setData({
  152. stringValue:"",
  153. tipImgShow:true
  154. })
  155. }
  156. },
  157. tipWindowControl2:function(){
  158. this.setData({
  159. tipWindow2:!this.data.tipWindow2
  160. })
  161. },
  162. tipWindowControl3:function(){
  163. this.setData({
  164. stringValue:"",
  165. tipImgShow:true
  166. })
  167. this.setData({
  168. tipWindow2:!this.data.tipWindow2
  169. })
  170. },
  171. distanceDay:function(){//距离4月23日上市还有XX天
  172. var timestamp = Date.parse(new Date()); //今天的时间戳
  173. var timestamp2 = Date.parse(new Date('2020-04-23')); //上市时间时间戳
  174. if(timestamp2>timestamp){
  175. var slideNum = Math.ceil((timestamp2-timestamp)/60/60/24/1000).toString().split("");
  176. this.setData({
  177. slideDay:slideNum//距离上市时间
  178. })
  179. }
  180. },
  181. cartogramControl:function(){
  182. // var randomNum = Math.floor(Math.random()*4+44);
  183. this.setData({
  184. randomNum:56,
  185. cartogramShow:!this.data.cartogramShow
  186. })
  187. },
  188. submitFirstGuessInfo:function(){//提交竞猜价格
  189. if(this.data.httpState){
  190. return;
  191. }
  192. this.data.httpState = true;
  193. app.wxRequest(app.globalData.urlRoot + "guessPrice/submitSecondGuessInfo", {guess_price:this.data.guessPrice,statistics_scene:app.globalData.sceneSource}, res => {
  194. this.data.httpState = false;
  195. if (res.code == 200) {
  196. app.globalData.getSecondGuessInfo.secondData = {};
  197. app.globalData.getSecondGuessInfo.secondData.guess_price = this.data.guessPrice;
  198. app.globalData.getSecondGuessInfo.secondData.firstData = null;
  199. this.setData({
  200. isGuess:true
  201. })
  202. this.tipWindowControl2();
  203. this.shareWindowControl();
  204. }else{
  205. wx.showToast({
  206. title: res.msg,
  207. icon:"none"
  208. })
  209. }
  210. }, this,"POST");
  211. },
  212. shareWindowControl:function(){//邀请好友弹窗显示控制
  213. this.setData({
  214. shareShow:!this.data.shareShow
  215. })
  216. },
  217. getUserWxMsg:function(e){//通过微信获取用户信息
  218. if (e.detail.errMsg == "getUserInfo:ok") {
  219. this.setData({
  220. isUserInfo:true
  221. })
  222. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  223. this.enterPoster();
  224. }
  225. },
  226. enterPoster:function(){
  227. wx.navigateTo({
  228. url: '/pages/guessPoster/guessPoster',
  229. })
  230. },
  231. lookConfigure: function () {
  232. wx.navigateTo({
  233. url: '/pages/configure/configure',
  234. })
  235. }
  236. })