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

250 line
6.2KB

  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:true,//是否竞猜过价格
  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. this.setData({
  45. isGuess:true,
  46. guessPriceArr:this.data.guessPriceArr
  47. })
  48. }
  49. if(app.globalData.userInfoData && app.globalData.userInfoData.nickName){
  50. this.setData({
  51. isUserInfo:true
  52. })
  53. }
  54. },
  55. loadFun:function(){
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面隐藏
  69. */
  70. onHide: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面卸载
  74. */
  75. onUnload: function () {
  76. },
  77. /**
  78. * 页面相关事件处理函数--监听用户下拉动作
  79. */
  80. onPullDownRefresh: function () {
  81. },
  82. /**
  83. * 页面上拉触底事件的处理函数
  84. */
  85. onReachBottom: function () {
  86. },
  87. /**
  88. * 用户点击右上角分享
  89. */
  90. onShareAppMessage: function () {
  91. return {
  92. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  93. imageUrl: this.data.imgUrl + "/versions/guessShareImg.jpg",
  94. path: "/pages/guess/guess"
  95. }
  96. },
  97. enterLucky:function(){//每日抽奖
  98. wx.navigateTo({
  99. url: '/pages/luckyStar/luckyStar'
  100. })
  101. },
  102. ruleControl:function(){//规则显示控制
  103. this.setData({
  104. ruleShow:!this.data.ruleShow
  105. })
  106. },
  107. focusControl:function(){
  108. this.setData({
  109. focusState:true
  110. })
  111. },
  112. focusControl2:function(){
  113. this.setData({
  114. focusState:false
  115. })
  116. },
  117. getValue:function(e){
  118. this.data.inputValue = e.detail.value;
  119. if(e.detail.value){
  120. this.setData({
  121. tipImgShow:false
  122. })
  123. }else{
  124. this.setData({
  125. tipImgShow:true
  126. })
  127. }
  128. this.setData({
  129. stringValue:e.detail.value
  130. })
  131. },
  132. submitPrice2:function(){
  133. if(this.data.inputValue>150000 || this.data.inputValue<110000){
  134. this.tipWindowControl();
  135. }else{
  136. this.data.guessPrice = this.data.inputValue;
  137. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  138. for(let i=0;i<this.data.guessPriceArr.length;i++){
  139. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  140. }
  141. this.setData({
  142. guessPriceArr:this.data.guessPriceArr
  143. })
  144. console.log(this.data.guessPrice);
  145. console.log(this.data.guessPriceArr);
  146. this.tipWindowControl2();
  147. }
  148. },
  149. tipWindowControl:function(){
  150. this.setData({
  151. tipWindow:!this.data.tipWindow
  152. })
  153. if(!this.data.tipWindow){
  154. this.setData({
  155. stringValue:"",
  156. tipImgShow:true
  157. })
  158. }
  159. },
  160. tipWindowControl2:function(){
  161. this.setData({
  162. tipWindow2:!this.data.tipWindow2
  163. })
  164. },
  165. tipWindowControl3:function(){
  166. this.setData({
  167. stringValue:"",
  168. tipImgShow:true
  169. })
  170. this.setData({
  171. tipWindow2:!this.data.tipWindow2
  172. })
  173. },
  174. distanceDay:function(){//距离4月23日上市还有XX天
  175. var timestamp = Date.parse(new Date()); //今天的时间戳
  176. var timestamp2 = Date.parse(new Date('2020-04-23')); //上市时间时间戳
  177. if(timestamp2>timestamp){
  178. var slideNum = Math.ceil((timestamp2-timestamp)/60/60/24/1000).toString().split("");
  179. this.setData({
  180. slideDay:slideNum//距离上市时间
  181. })
  182. }
  183. },
  184. cartogramControl:function(){
  185. // var randomNum = Math.floor(Math.random()*4+44);
  186. this.setData({
  187. randomNum:56,
  188. cartogramShow:!this.data.cartogramShow
  189. })
  190. },
  191. submitFirstGuessInfo:function(){//提交竞猜价格
  192. if(this.data.httpState){
  193. return;
  194. }
  195. this.data.httpState = true;
  196. app.wxRequest(app.globalData.urlRoot + "guessPrice/submitSecondGuessInfo", {guess_price:this.data.guessPrice,statistics_scene:app.globalData.sceneSource}, res => {
  197. this.data.httpState = false;
  198. if (res.code == 200) {
  199. app.globalData.getSecondGuessInfo.secondData = {};
  200. app.globalData.getSecondGuessInfo.secondData.guess_price = this.data.guessPrice;
  201. app.globalData.getSecondGuessInfo.secondData.firstData = null;
  202. this.setData({
  203. isGuess:true
  204. })
  205. this.tipWindowControl2();
  206. this.shareWindowControl();
  207. }else{
  208. wx.showToast({
  209. title: res.msg,
  210. icon:"none"
  211. })
  212. }
  213. }, this,"POST");
  214. },
  215. shareWindowControl:function(){//邀请好友弹窗显示控制
  216. this.setData({
  217. shareShow:!this.data.shareShow
  218. })
  219. },
  220. getUserWxMsg:function(e){//通过微信获取用户信息
  221. if (e.detail.errMsg == "getUserInfo:ok") {
  222. this.setData({
  223. isUserInfo:true
  224. })
  225. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  226. this.enterPoster();
  227. }
  228. },
  229. enterPoster:function(){
  230. wx.navigateTo({
  231. url: '/pages/guessPoster/guessPoster',
  232. })
  233. }
  234. })