|
- // pages/star/star.js
- const app = getApp()
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.urlStatic,//图片路径
- maskShow: false,
- ruleShow:false,
- phonebol:false,//是否有手机号
- getNumber:null,//数字跳跃
- starNumber:4000,//开始人数
- stopNumber:0,//结束人数
- numList:[4,0,0,0],
- 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) {
- 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:4000
- })
- if (app.globalData.openid) {
- this.gettime();
- } else {
- app.globalData.openidSuccessFuc = this.gettime;
- }
- },
- gettime(){
- app.wxRequest(app.globalData.urlRoot + "certificationInfo/getCertificationNum", {}, res => {
- console.log(res)
- if (res.code == 200) {
- this.setData({
- stopNumber: res.data ? res.data.certificationNum : '0000'
- })
- 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);
- 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();
- }
- })
|