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

guessPrize.js 6.1KB

5 yıl önce
5 yıl önce
5 yıl önce
5 yıl önce
5 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. // pages/guessPrize/guessPrize.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. ruleShow:false,//是否显示规则
  10. yuyueShow:false,//是否显示预约
  11. firstPrice:false,//是否有首轮竞猜价格
  12. httpState:false,//是否正在进行http请求
  13. guessPrice:123456,//竞猜价格
  14. guessPriceArr:['1','2','3','4','5','6'],
  15. shareShow:false,//是否显示分享弹窗
  16. slideState:false,//滑动状态
  17. slideNum:0,//滑动距离
  18. slideDay:['0','0'],//距离上市时间
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. app.globalData.nowPage = 3;
  25. // this.distanceDay();
  26. if (app.globalData.openid) {
  27. this.loadFun();
  28. } else {
  29. app.globalData.openidSuccessFuc = this.loadFun;
  30. }
  31. },
  32. loadFun:function(){
  33. if (!app.globalData.addPageEnterState.guessPrize) {
  34. app.addPageEnter("7C8AAA38F8D85EFC48C2995FB6EBAC19");
  35. app.globalData.addPageEnterState.guessPrize = true;
  36. }
  37. this.getFirstGuessInfo();
  38. },
  39. /**
  40. * 生命周期函数--监听页面初次渲染完成
  41. */
  42. onReady: function () {
  43. },
  44. /**
  45. * 生命周期函数--监听页面显示
  46. */
  47. onShow: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面隐藏
  51. */
  52. onHide: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面卸载
  56. */
  57. onUnload: function () {
  58. },
  59. /**
  60. * 页面相关事件处理函数--监听用户下拉动作
  61. */
  62. onPullDownRefresh: function () {
  63. },
  64. /**
  65. * 页面上拉触底事件的处理函数
  66. */
  67. onReachBottom: function () {
  68. },
  69. /**
  70. * 用户点击右上角分享
  71. */
  72. onShareAppMessage: function () {
  73. return {
  74. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  75. imageUrl: this.data.imgUrl + "/versions/guessShareImg.jpg",
  76. path: "/pages/guess/guess"
  77. }
  78. },
  79. ruleControl:function(){//规则显示控制
  80. this.setData({
  81. ruleShow:!this.data.ruleShow
  82. })
  83. },
  84. shareWindowControl:function(){//邀请好友弹窗显示控制
  85. this.setData({
  86. shareShow:!this.data.shareShow
  87. })
  88. },
  89. lookConfigure:function(){//查看车型详细参数
  90. wx.navigateTo({
  91. url: '/pages/configure/configure',
  92. })
  93. },
  94. enterLucky:function(){//每日抽奖
  95. wx.navigateTo({
  96. url: '/pages/luckyStar/luckyStar'
  97. })
  98. },
  99. yuyueControl:function(){//预约
  100. this.setData({
  101. yuyueShow: !this.data.yuyueShow
  102. })
  103. },
  104. getFirstGuessInfo:function(){//获取首轮竞猜价格信息
  105. app.wxRequest(app.globalData.urlRoot + "guessPrice/getFirstGuessInfo", {}, res => {
  106. // res.data = null;
  107. if (res.code == 200 && res.data) {
  108. this.data.guessPriceArr = res.data.guess_price.toString().split("");
  109. for(let i=0;i<this.data.guessPriceArr.length;i++){
  110. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  111. }
  112. this.setData({
  113. firstPrice:true,
  114. guessPriceArr:this.data.guessPriceArr
  115. })
  116. }
  117. }, this);
  118. },
  119. submitPrice:function(){
  120. if(this.data.firstPrice){
  121. this.shareWindowControl();
  122. }else{
  123. this.submitFirstGuessInfo();
  124. }
  125. },
  126. submitFirstGuessInfo:function(){//提交首轮竞猜价格
  127. if(this.data.httpState){
  128. return;
  129. }
  130. this.data.httpState = true;
  131. app.wxRequest(app.globalData.urlRoot + "guessPrice/submitFirstGuessInfo", {guess_price:this.data.guessPrice,statistics_scene:app.globalData.sceneSource}, res => {
  132. this.data.httpState = false;
  133. if (res.code == 200) {
  134. this.setData({
  135. firstPrice:true
  136. })
  137. this.shareWindowControl();
  138. }else{
  139. wx.showToast({
  140. title: res.msg,
  141. icon:"none"
  142. })
  143. }
  144. }, this,"POST");
  145. },
  146. stratMove:function(e){
  147. var index = e.currentTarget.dataset.index;
  148. if(index == 0){
  149. return;
  150. }
  151. this.setData({
  152. slideState:true
  153. })
  154. console.log(e);
  155. this.data.slideNum = e.changedTouches[0].pageY;
  156. },
  157. endMove:function(e){
  158. var index = e.currentTarget.dataset.index;
  159. if(index == 0){
  160. return;
  161. }
  162. this.setData({
  163. slideState:false
  164. })
  165. if(e.changedTouches[0].pageY-this.data.slideNum>=10){
  166. console.log("往下滑");
  167. if(index==1){
  168. this.data.guessPrice-=10000;
  169. }else if(index==2){
  170. this.data.guessPrice-=1000;
  171. }else if(index==3){
  172. this.data.guessPrice-=100;
  173. }else if(index==4){
  174. this.data.guessPrice-=10;
  175. }else if(index==5){
  176. this.data.guessPrice-=1;
  177. }
  178. if(this.data.guessPrice<110000){
  179. this.data.guessPrice = 110000;
  180. }
  181. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  182. for(let i=0;i<this.data.guessPriceArr.length;i++){
  183. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  184. }
  185. this.setData({
  186. guessPriceArr:this.data.guessPriceArr
  187. })
  188. }else if(e.changedTouches[0].pageY+10<=this.data.slideNum){
  189. console.log("往上滑");
  190. if(index==1){
  191. this.data.guessPrice+=10000;
  192. }else if(index==2){
  193. this.data.guessPrice+=1000;
  194. }else if(index==3){
  195. this.data.guessPrice+=100;
  196. }else if(index==4){
  197. this.data.guessPrice+=10;
  198. }else if(index==5){
  199. this.data.guessPrice+=1;
  200. }
  201. if(this.data.guessPrice>150000){
  202. this.data.guessPrice = 150000;
  203. }
  204. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  205. for(let i=0;i<this.data.guessPriceArr.length;i++){
  206. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  207. }
  208. this.setData({
  209. guessPriceArr:this.data.guessPriceArr
  210. })
  211. }
  212. },
  213. distanceDay:function(){//距离4月23日上市还有XX天
  214. var timestamp = Date.parse(new Date()); //今天的时间戳
  215. var timestamp2 = Date.parse(new Date('2020-04-23')); //上市时间时间戳
  216. if(timestamp2>timestamp){
  217. var slideNum = Math.ceil((timestamp2-timestamp)/60/60/24/1000).toString().split("");
  218. this.setData({
  219. slideDay:slideNum//距离上市时间
  220. })
  221. }
  222. }
  223. })