// pages/star/star.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { imgUrl: app.globalData.urlStatic,//图片路径 maskShow: false, ruleShow: false, phonebol: false,//是否有手机号 getNumber: null,//数字跳跃 starNumber: 0,//开始人数 stopNumber: 0,//结束人数 numList: [], isbtn: true,//防重复点击 }, /** * 显示规则页 */ showRule: function () { // this.setData({ // maskShow:true, // ruleShow:true // }) if (app.globalData.entered) { this.everyDay(); } else { wx.navigateTo({ url: '/pages/fragmentRule/fragmentRule' }) } }, /** * 关闭规则页 */ hiddenRule: function () { this.setData({ maskShow: false, ruleShow: false }) }, /** * 每日任务 */ everyDay: function () { if (this.data.isbtn) { this.setData({ isbtn: false }) } else { return; } wx.navigateTo({ url: '../everyday/everyday' }) }, /** * 星探任务 */ scout: function () { if (this.data.isbtn) { this.setData({ isbtn: false }) } else { return; } this.phonebolb(); }, phonebolb: function (_phone) { app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationInfo", {}, res => { if (res.code == 200) { app.globalData.authenticationStatus = res.data; if (!app.globalData.certificationInfo) { app.globalData.certificationInfo = true; wx.setStorageSync("certificationInfo", true); } app.globalData.certificationState = res.data.certificationState; wx.navigateTo({ url: '/pages/scout/scout' }) } else if (res.code == -307) { wx.navigateTo({ url: '/pages/mobileVerification/mobileVerification' }) } else if (res.code == -308) { wx.navigateTo({ url: '/pages/scout/register/register' }) } else { this.setData({ isbtn: true }) } }, this); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { app.globalData.nowPage = 2; // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/getCertificationNoCarList", { // adminState: 0, page:1,count:10 // }, res => { // console.log(res) // }, this); // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditRefuse", { id:4 }, res => { // console.log(res) // }, this,"POST"); // app.wxRequest(app.globalData.urlRoot + "/admin/certificationNoCar/auditPass", { id:4 }, res => { // console.log(res) // }, this,"POST"); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { this.setData({ starNumber: 0 }) if (app.globalData.openid) { this.loadFun(); } else { app.globalData.openidSuccessFuc = this.loadFun; } }, loadFun() { if (!app.globalData.addPageEnterState.star) { app.addPageEnter("61D8FFCBF9D58A1DFB3F660294CE006A"); app.globalData.addPageEnterState.star = true; } this.gettime(); }, gettime() { app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationCount", {}, res => { console.log(res) if (res.code == 200) { if (res.data) { this.data.starNumber = res.data.total - 1000 < 0 ? 0 : res.data.total - 1000; this.setData({ stopNumber: res.data.total ? res.data.total : '0' }) } else { this.setData({ stopNumber: '0' }) } // if (this.data.stopNumber < 10000) { // this.setData({ // numList: [4, 0, 0, 0] // }) // } else { // this.setData({ // numList: [0, 4, 0, 0, 0] // }) // } this.getNumber = setInterval(this.vCodeDownTime, 20); } }, this); }, vCodeDownTime() { var numb = this.data.starNumber; // numb=Math.floor(this.data.starNumber+(this.data.stopNumber-4000)/80); numb = Math.floor(this.data.starNumber + this.data.stopNumber / 80); if (numb >= this.data.stopNumber) { numb = this.data.stopNumber; clearInterval(this.getNumber); } this.setData({ starNumber: numb, numList: numb.toString().split("") }) }, getPhone(e) { console.log(e.detail) if (e.detail.errMsg == 'getPhoneNumber:ok') { if (this.data.isbtn) { this.setData({ isbtn: false }) } else { return; } app.getMobile(e.detail.encryptedData, e.detail.iv, res => { if (res.code == 200) { if (res.data.result == 0) { this.phonebolb(res.data.decodeData.phoneNumber); app.globalData.userMobile = res.data.decodeData.phoneNumber; } else { this.setData({ isbtn: true }) wx.showToast({ title: '获取失败', icon: "none" }) } } else { this.setData({ isbtn: true }) wx.showToast({ title: res.msg, icon: "none" }) } }, this) } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { if (app.globalData.userMobile == null) { this.setData({ phonebol: true }) } else { this.setData({ phonebol: false }) } this.setData({ isbtn: true }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return app.sharePack(); } })