东风启辰小程序端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

guessPrize.js 7.5KB

il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
il y a 5 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. submitBefore:true,//提交预测价格之前
  20. inputValue:"",//输入的价格
  21. stringValue:"",
  22. tipWindow:false,//是否显示价格超出的提示弹窗
  23. tipWindow2:false,
  24. focusState:false
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. app.globalData.nowPage = 3;
  31. // this.distanceDay();
  32. if (app.globalData.openid) {
  33. this.loadFun();
  34. } else {
  35. app.globalData.openidSuccessFuc = this.loadFun;
  36. }
  37. },
  38. loadFun:function(){
  39. if (!app.globalData.addPageEnterState.guessPrize) {
  40. app.addPageEnter("7C8AAA38F8D85EFC48C2995FB6EBAC19");
  41. app.globalData.addPageEnterState.guessPrize = true;
  42. }
  43. this.getFirstGuessInfo();
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload: function () {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function () {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom: function () {
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage: function () {
  79. return {
  80. title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!',
  81. imageUrl: this.data.imgUrl + "/versions/guessShareImg.jpg",
  82. path: "/pages/guess/guess"
  83. }
  84. },
  85. ruleControl:function(){//规则显示控制
  86. this.setData({
  87. ruleShow:!this.data.ruleShow
  88. })
  89. },
  90. shareWindowControl:function(){//邀请好友弹窗显示控制
  91. this.setData({
  92. shareShow:!this.data.shareShow
  93. })
  94. },
  95. lookConfigure:function(){//查看车型详细参数
  96. wx.navigateTo({
  97. url: '/pages/configure/configure',
  98. })
  99. },
  100. enterLucky:function(){//每日抽奖
  101. wx.navigateTo({
  102. url: '/pages/luckyStar/luckyStar'
  103. })
  104. },
  105. yuyueControl:function(){//预约
  106. this.setData({
  107. yuyueShow: !this.data.yuyueShow
  108. })
  109. },
  110. getFirstGuessInfo:function(){//获取首轮竞猜价格信息
  111. app.wxRequest(app.globalData.urlRoot + "guessPrice/getFirstGuessInfo", {}, res => {
  112. // res.data = null;
  113. if (res.code == 200 && res.data) {
  114. this.data.guessPriceArr = res.data.guess_price.toString().split("");
  115. for(let i=0;i<this.data.guessPriceArr.length;i++){
  116. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  117. }
  118. this.setData({
  119. submitBefore:false,
  120. firstPrice:true,
  121. guessPriceArr:this.data.guessPriceArr
  122. })
  123. }
  124. }, this);
  125. },
  126. submitPrice:function(){
  127. if(this.data.firstPrice){
  128. this.shareWindowControl();
  129. }else{
  130. this.submitFirstGuessInfo();
  131. }
  132. },
  133. submitFirstGuessInfo:function(){//提交首轮竞猜价格
  134. if(this.data.httpState){
  135. return;
  136. }
  137. this.data.httpState = true;
  138. app.wxRequest(app.globalData.urlRoot + "guessPrice/submitFirstGuessInfo", {guess_price:this.data.guessPrice,statistics_scene:app.globalData.sceneSource}, res => {
  139. this.data.httpState = false;
  140. if (res.code == 200) {
  141. this.setData({
  142. submitBefore:false,
  143. firstPrice:true
  144. })
  145. this.tipWindowControl2();
  146. this.shareWindowControl();
  147. }else{
  148. wx.showToast({
  149. title: res.msg,
  150. icon:"none"
  151. })
  152. }
  153. }, this,"POST");
  154. },
  155. stratMove:function(e){
  156. var index = e.currentTarget.dataset.index;
  157. if(index == 0){
  158. return;
  159. }
  160. this.setData({
  161. slideState:true
  162. })
  163. console.log(e);
  164. this.data.slideNum = e.changedTouches[0].pageY;
  165. },
  166. endMove:function(e){
  167. var index = e.currentTarget.dataset.index;
  168. if(index == 0){
  169. return;
  170. }
  171. this.setData({
  172. slideState:false
  173. })
  174. if(e.changedTouches[0].pageY-this.data.slideNum>=10){
  175. console.log("往下滑");
  176. if(index==1){
  177. this.data.guessPrice-=10000;
  178. }else if(index==2){
  179. this.data.guessPrice-=1000;
  180. }else if(index==3){
  181. this.data.guessPrice-=100;
  182. }else if(index==4){
  183. this.data.guessPrice-=10;
  184. }else if(index==5){
  185. this.data.guessPrice-=1;
  186. }
  187. if(this.data.guessPrice<110000){
  188. this.data.guessPrice = 110000;
  189. }
  190. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  191. for(let i=0;i<this.data.guessPriceArr.length;i++){
  192. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  193. }
  194. this.setData({
  195. guessPriceArr:this.data.guessPriceArr
  196. })
  197. }else if(e.changedTouches[0].pageY+10<=this.data.slideNum){
  198. console.log("往上滑");
  199. if(index==1){
  200. this.data.guessPrice+=10000;
  201. }else if(index==2){
  202. this.data.guessPrice+=1000;
  203. }else if(index==3){
  204. this.data.guessPrice+=100;
  205. }else if(index==4){
  206. this.data.guessPrice+=10;
  207. }else if(index==5){
  208. this.data.guessPrice+=1;
  209. }
  210. if(this.data.guessPrice>150000){
  211. this.data.guessPrice = 150000;
  212. }
  213. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  214. for(let i=0;i<this.data.guessPriceArr.length;i++){
  215. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  216. }
  217. this.setData({
  218. guessPriceArr:this.data.guessPriceArr
  219. })
  220. }
  221. },
  222. distanceDay:function(){//距离4月23日上市还有XX天
  223. var timestamp = Date.parse(new Date()); //今天的时间戳
  224. var timestamp2 = Date.parse(new Date('2020-04-23')); //上市时间时间戳
  225. if(timestamp2>timestamp){
  226. var slideNum = Math.ceil((timestamp2-timestamp)/60/60/24/1000).toString().split("");
  227. this.setData({
  228. slideDay:slideNum//距离上市时间
  229. })
  230. }
  231. },
  232. getValue:function(e){
  233. this.data.inputValue = e.detail.value;
  234. this.setData({
  235. stringValue:e.detail.value
  236. })
  237. },
  238. submitPrice2:function(){
  239. if(this.data.inputValue>150000 || this.data.inputValue<110000){
  240. this.tipWindowControl();
  241. }else{
  242. this.data.guessPrice = this.data.inputValue;
  243. this.data.guessPriceArr = this.data.guessPrice.toString().split("");
  244. for(let i=0;i<this.data.guessPriceArr.length;i++){
  245. this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
  246. }
  247. this.setData({
  248. guessPriceArr:this.data.guessPriceArr
  249. })
  250. console.log(this.data.guessPrice);
  251. console.log(this.data.guessPriceArr);
  252. this.tipWindowControl2();
  253. }
  254. // this.submitFirstGuessInfo();
  255. },
  256. tipWindowControl:function(){
  257. this.setData({
  258. tipWindow:!this.data.tipWindow
  259. })
  260. },
  261. tipWindowControl2:function(){
  262. this.setData({
  263. tipWindow2:!this.data.tipWindow2
  264. })
  265. },
  266. focusControl:function(){
  267. this.setData({
  268. focusState:true
  269. })
  270. },
  271. focusControl2:function(){
  272. this.setData({
  273. focusState:false
  274. })
  275. }
  276. })