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

guessSecondPrize.js 6.3KB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 {
  93. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  94. imageUrl: this.data.imgUrl + "/versions/guessShareImg.jpg",
  95. path: "/pages/guess/guess"
  96. }
  97. },
  98. enterLucky:function(){//每日抽奖
  99. wx.navigateTo({
  100. url: '/pages/luckyStar/luckyStar'
  101. })
  102. },
  103. ruleControl:function(){//规则显示控制
  104. this.setData({
  105. ruleShow:!this.data.ruleShow
  106. })
  107. },
  108. focusControl:function(){
  109. this.setData({
  110. focusState:true
  111. })
  112. },
  113. focusControl2:function(){
  114. this.setData({
  115. focusState:false
  116. })
  117. },
  118. getValue:function(e){
  119. this.data.inputValue = e.detail.value;
  120. if(e.detail.value){
  121. this.setData({
  122. tipImgShow:false
  123. })
  124. }else{
  125. this.setData({
  126. tipImgShow:true
  127. })
  128. }
  129. this.setData({
  130. stringValue:e.detail.value
  131. })
  132. },
  133. submitPrice2:function(){
  134. if(this.data.inputValue>150000 || this.data.inputValue<110000){
  135. this.tipWindowControl();
  136. }else{
  137. this.data.guessPrice = this.data.inputValue;
  138. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  139. for(let i=0;i<this.data.guessPriceArr.length;i++){
  140. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  141. }
  142. this.setData({
  143. guessPriceArr:this.data.guessPriceArr
  144. })
  145. console.log(this.data.guessPrice);
  146. console.log(this.data.guessPriceArr);
  147. this.tipWindowControl2();
  148. }
  149. },
  150. tipWindowControl:function(){
  151. this.setData({
  152. tipWindow:!this.data.tipWindow
  153. })
  154. if(!this.data.tipWindow){
  155. this.setData({
  156. stringValue:"",
  157. tipImgShow:true
  158. })
  159. }
  160. },
  161. tipWindowControl2:function(){
  162. this.setData({
  163. tipWindow2:!this.data.tipWindow2
  164. })
  165. },
  166. tipWindowControl3:function(){
  167. this.setData({
  168. stringValue:"",
  169. tipImgShow:true
  170. })
  171. this.setData({
  172. tipWindow2:!this.data.tipWindow2
  173. })
  174. },
  175. distanceDay:function(){//距离4月23日上市还有XX天
  176. var timestamp = Date.parse(new Date()); //今天的时间戳
  177. var timestamp2 = Date.parse(new Date('2020-04-23')); //上市时间时间戳
  178. if(timestamp2>timestamp){
  179. var slideNum = Math.ceil((timestamp2-timestamp)/60/60/24/1000).toString().split("");
  180. this.setData({
  181. slideDay:slideNum//距离上市时间
  182. })
  183. }
  184. },
  185. cartogramControl:function(){
  186. // var randomNum = Math.floor(Math.random()*4+44);
  187. this.setData({
  188. randomNum:56,
  189. cartogramShow:!this.data.cartogramShow
  190. })
  191. },
  192. submitFirstGuessInfo:function(){//提交竞猜价格
  193. if(this.data.httpState){
  194. return;
  195. }
  196. this.data.httpState = true;
  197. app.wxRequest(app.globalData.urlRoot + "guessPrice/submitSecondGuessInfo", {guess_price:this.data.guessPrice,statistics_scene:app.globalData.sceneSource}, res => {
  198. this.data.httpState = false;
  199. if (res.code == 200) {
  200. app.globalData.getSecondGuessInfo.secondData = {};
  201. app.globalData.getSecondGuessInfo.secondData.guess_price = this.data.guessPrice;
  202. app.globalData.getSecondGuessInfo.secondData.firstData = null;
  203. this.setData({
  204. isGuess:true
  205. })
  206. this.tipWindowControl2();
  207. this.shareWindowControl();
  208. }else{
  209. wx.showToast({
  210. title: res.msg,
  211. icon:"none"
  212. })
  213. }
  214. }, this,"POST");
  215. },
  216. shareWindowControl:function(){//邀请好友弹窗显示控制
  217. this.setData({
  218. shareShow:!this.data.shareShow
  219. })
  220. },
  221. getUserWxMsg:function(e){//通过微信获取用户信息
  222. if (e.detail.errMsg == "getUserInfo:ok") {
  223. this.setData({
  224. isUserInfo:true
  225. })
  226. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  227. this.enterPoster();
  228. }
  229. },
  230. enterPoster:function(){
  231. wx.navigateTo({
  232. url: '/pages/guessPoster/guessPoster',
  233. })
  234. },
  235. lookConfigure: function () {
  236. wx.navigateTo({
  237. url: '/pages/configure/configure',
  238. })
  239. }
  240. })