// pages/guessPrize/guessPrize.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { imgUrl: app.globalData.urlStatic,//图片路径 ruleShow:false,//是否显示规则 yuyueShow:false,//是否显示预约 firstPrice:false,//是否有首轮竞猜价格 httpState:false,//是否正在进行http请求 guessPrice:123456,//竞猜价格 guessPriceArr:['1','2','3','4','5','6'], shareShow:false,//是否显示分享弹窗 slideState:false,//滑动状态 slideNum:0,//滑动距离 slideDay:['0','0'],//距离上市时间 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { app.globalData.nowPage = 3; // this.distanceDay(); if (app.globalData.openid) { this.loadFun(); } else { app.globalData.openidSuccessFuc = this.loadFun; } }, loadFun:function(){ if (!app.globalData.addPageEnterState.guessPrize) { app.addPageEnter("7C8AAA38F8D85EFC48C2995FB6EBAC19"); app.globalData.addPageEnterState.guessPrize = true; } this.getFirstGuessInfo(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: '召唤预言帝!快来和我一起猜启辰星售价,赢升舱大奖!', imageUrl: this.data.imgUrl + "/versions/guessShareImg.jpg", path: "/pages/guess/guess" } }, ruleControl:function(){//规则显示控制 this.setData({ ruleShow:!this.data.ruleShow }) }, shareWindowControl:function(){//邀请好友弹窗显示控制 this.setData({ shareShow:!this.data.shareShow }) }, lookConfigure:function(){//查看车型详细参数 wx.navigateTo({ url: '/pages/configure/configure', }) }, enterLucky:function(){//每日抽奖 wx.navigateTo({ url: '/pages/luckyStar/luckyStar' }) }, yuyueControl:function(){//预约 this.setData({ yuyueShow: !this.data.yuyueShow }) }, getFirstGuessInfo:function(){//获取首轮竞猜价格信息 app.wxRequest(app.globalData.urlRoot + "guessPrice/getFirstGuessInfo", {}, res => { // res.data = null; if (res.code == 200 && res.data) { this.data.guessPriceArr = res.data.guess_price.toString().split(""); for(let i=0;i { this.data.httpState = false; if (res.code == 200) { this.setData({ firstPrice:true }) this.shareWindowControl(); }else{ wx.showToast({ title: res.msg, icon:"none" }) } }, this,"POST"); }, stratMove:function(e){ var index = e.currentTarget.dataset.index; if(index == 0){ return; } this.setData({ slideState:true }) console.log(e); this.data.slideNum = e.changedTouches[0].pageY; }, endMove:function(e){ var index = e.currentTarget.dataset.index; if(index == 0){ return; } this.setData({ slideState:false }) if(e.changedTouches[0].pageY-this.data.slideNum>=10){ console.log("往下滑"); if(index==1){ this.data.guessPrice-=10000; }else if(index==2){ this.data.guessPrice-=1000; }else if(index==3){ this.data.guessPrice-=100; }else if(index==4){ this.data.guessPrice-=10; }else if(index==5){ this.data.guessPrice-=1; } if(this.data.guessPrice<110000){ this.data.guessPrice = 110000; } this.data.guessPriceArr = this.data.guessPrice.toString().split(""); for(let i=0;i150000){ this.data.guessPrice = 150000; } this.data.guessPriceArr = this.data.guessPrice.toString().split(""); for(let i=0;itimestamp){ var slideNum = Math.ceil((timestamp2-timestamp)/60/60/24/1000).toString().split(""); this.setData({ slideDay:slideNum//距离上市时间 }) } } })