|
- // pages/guessSecondPrize/guessSecondPrize.js
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.urlStatic,//图片路径
- ruleShow:false,//是否显示竞猜规则
- inputValue:"",//输入的价格
- stringValue:"",//输入的竞猜价格
- focusState:false,//输入框聚焦状态
- tipImgShow:true,//是否显示输入框提示
- isGuess:true,//是否竞猜过价格
- guessPrice:"",
- guessPriceArr:[1,2,3,4,5,6],
- slideDay:['0','0'],//距离上市时间
- randomNum:44,//随机数
- cartogramShow:false,//是否显示统计图
- getSecondGuessInfo:null,
- httpState:false,//是否正在进行http请求
- isUserInfo:false,//是否有个人信息
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- app.globalData.nowPage = 3;
- this.distanceDay();
- if (app.globalData.openid) {
- this.loadFun();
- } else {
- app.globalData.openidSuccessFuc = this.loadFun;
- }
- this.setData({
- getSecondGuessInfo:app.globalData.getSecondGuessInfo
- })
- var getSecondGuessInfo = app.globalData.getSecondGuessInfo;
- if(getSecondGuessInfo.secondData){
- this.data.guessPriceArr = getSecondGuessInfo.secondData.guess_price.toString().split("");
- for(let i=0;i<this.data.guessPriceArr.length;i++){
- this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
- }
- this.setData({
- isGuess:true,
- guessPriceArr:this.data.guessPriceArr
- })
- }
- if(app.globalData.userInfoData && app.globalData.userInfoData.nickName){
- this.setData({
- isUserInfo:true
- })
- }
- },
- loadFun:function(){
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- 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"
- }
- },
- enterLucky:function(){//每日抽奖
- wx.navigateTo({
- url: '/pages/luckyStar/luckyStar'
- })
- },
- ruleControl:function(){//规则显示控制
- this.setData({
- ruleShow:!this.data.ruleShow
- })
- },
- focusControl:function(){
- this.setData({
- focusState:true
- })
- },
- focusControl2:function(){
- this.setData({
- focusState:false
- })
- },
- getValue:function(e){
- this.data.inputValue = e.detail.value;
- if(e.detail.value){
- this.setData({
- tipImgShow:false
- })
- }else{
- this.setData({
- tipImgShow:true
- })
- }
- this.setData({
- stringValue:e.detail.value
- })
- },
- submitPrice2:function(){
- if(this.data.inputValue>150000 || this.data.inputValue<110000){
- this.tipWindowControl();
- }else{
- this.data.guessPrice = this.data.inputValue;
- this.data.guessPriceArr = this.data.guessPrice.toString().split("");
- for(let i=0;i<this.data.guessPriceArr.length;i++){
- this.data.guessPriceArr[i] = parseInt(this.data.guessPriceArr[i]);
- }
- this.setData({
- guessPriceArr:this.data.guessPriceArr
- })
- console.log(this.data.guessPrice);
- console.log(this.data.guessPriceArr);
- this.tipWindowControl2();
- }
- },
- tipWindowControl:function(){
- this.setData({
- tipWindow:!this.data.tipWindow
- })
- if(!this.data.tipWindow){
- this.setData({
- stringValue:"",
- tipImgShow:true
- })
- }
- },
- tipWindowControl2:function(){
- this.setData({
- tipWindow2:!this.data.tipWindow2
- })
- },
- tipWindowControl3:function(){
- this.setData({
- stringValue:"",
- tipImgShow:true
- })
- this.setData({
- tipWindow2:!this.data.tipWindow2
- })
- },
- distanceDay:function(){//距离4月23日上市还有XX天
- var timestamp = Date.parse(new Date()); //今天的时间戳
- var timestamp2 = Date.parse(new Date('2020-04-23')); //上市时间时间戳
- if(timestamp2>timestamp){
- var slideNum = Math.ceil((timestamp2-timestamp)/60/60/24/1000).toString().split("");
- this.setData({
- slideDay:slideNum//距离上市时间
- })
- }
- },
- cartogramControl:function(){
- // var randomNum = Math.floor(Math.random()*4+44);
- this.setData({
- randomNum:56,
- cartogramShow:!this.data.cartogramShow
- })
- },
- submitFirstGuessInfo:function(){//提交竞猜价格
- if(this.data.httpState){
- return;
- }
- this.data.httpState = true;
- app.wxRequest(app.globalData.urlRoot + "guessPrice/submitSecondGuessInfo", {guess_price:this.data.guessPrice,statistics_scene:app.globalData.sceneSource}, res => {
- this.data.httpState = false;
- if (res.code == 200) {
- app.globalData.getSecondGuessInfo.secondData = {};
- app.globalData.getSecondGuessInfo.secondData.guess_price = this.data.guessPrice;
- app.globalData.getSecondGuessInfo.secondData.firstData = null;
- this.setData({
- isGuess:true
- })
- this.tipWindowControl2();
- this.shareWindowControl();
- }else{
- wx.showToast({
- title: res.msg,
- icon:"none"
- })
- }
- }, this,"POST");
- },
- shareWindowControl:function(){//邀请好友弹窗显示控制
- this.setData({
- shareShow:!this.data.shareShow
- })
- },
- getUserWxMsg:function(e){//通过微信获取用户信息
- if (e.detail.errMsg == "getUserInfo:ok") {
- this.setData({
- isUserInfo:true
- })
- app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
- this.enterPoster();
- }
- },
- enterPoster:function(){
- wx.navigateTo({
- url: '/pages/guessPoster/guessPoster',
- })
- }
- })
|