// pages/star/star.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { imgUrl: app.globalData.urlStatic,//图片路径 maskShow: false, phonebol: false,//是否有手机号 getNumber: null,//数字跳跃 starNumber: 0,//开始人数 stopNumber: 0,//结束人数 numList: [], isbtn: true,//防重复点击 selectGroup:[false,false,false], addressShow:false, isAddress:false,//是否有地址 starInfo:null,//星探状态 getUserInfoBtn:false,//是否显示获取个人信息的按钮 btnType:1, }, /** * 显示规则页 */ showRule: function () { if (app.globalData.entered) { this.everyDay(); } else { wx.navigateTo({ url: '/pages/fragmentRule/fragmentRule' }) } }, showMask:function(){ this.setData({ maskShow: true }) }, hiddenMask: function () { this.setData({ maskShow: false }) }, /** * 每日任务 */ everyDay: function () { if (this.data.isbtn) { this.setData({ isbtn: false }) } else { return; } wx.navigateTo({ url: '../everyday/everyday' }) }, /** * 星探任务 */ scout: function () { if(this.data.starInfo==200 || app.globalData.isStar){ wx.navigateTo({ url: '/pages/scout/scout' }) }else if(this.data.starInfo==-307){ wx.navigateTo({ url: '/pages/mobileVerification/mobileVerification' }) }else if(this.data.starInfo==-308){ wx.navigateTo({ url: '/pages/scout/register/register' }) } }, phonebolb: function (_phone) { app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationInfoV2", {}, res => { this.data.starInfo = res.code; if (res.code == 200) { this.setData({ btnType:2 }) app.globalData.isStar = res.data; wx.setStorageSync('isStar', res.data); 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"); }, addressControl: function () {//跳转到地址管理 this.setData({ addressShow: !this.data.addressShow }) if (this.data.addressShow) { app.globalData.skipType = 'mycenter'; } }, getAddress: function () {//获取地址 app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => { if (res.code == 200) { if (res.data) { this.setData({ isAddress:true }) } } }, this) }, /** * 生命周期函数--监听页面初次渲染完成 */ 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; } if(!app.globalData.isStar){ this.phonebolb(); }else{ this.setData({ btnType:2 }) this.getAddress(); this.getFriendStoreAward(); app.globalData.authenticationStatus = app.globalData.isStar; if (!app.globalData.certificationInfo) { app.globalData.certificationInfo = true; wx.setStorageSync("certificationInfo", true); } app.globalData.certificationState = app.globalData.isStar.certificationState; var enterScout = wx.getStorageSync('enterScout'); if(app.globalData.isStar.agentDetail && enterScout){ if(!app.globalData.userInfoData || !app.globalData.userInfoData.avatarUrl){ this.setData({ getUserInfoBtn:true }) } } } this.gettime(); }, getFriendStoreAward(){//是否需要显示弹窗 app.wxRequest(app.globalData.urlRoot + "userInfo/getFriendStoreAward", {}, res => { if (res.code == 200 && res.data && res.data.showState==1) { this.showMask(); } }, this); }, gettime() { app.wxRequest(app.globalData.urlRoot + "userInfo/getCertificationCount", {}, 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) { 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 }) if(app.globalData.isStar){ this.setData({ btnType:2 }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return app.sharePack(); }, cutSelect:function(e){ var index = e.currentTarget.dataset.type; this.data.selectGroup[index] = !this.data.selectGroup[index]; this.setData({ selectGroup:this.data.selectGroup }) }, skipPoster(){ var enterScout = wx.getStorageSync('enterScout'); if(app.globalData.isStar && app.globalData.isStar.agentDetail && enterScout){ if(app.globalData.userInfoData && app.globalData.userInfoData.avatarUrl){ wx.navigateTo({ url:'../poster/poster' }) } }else{ wx.navigateTo({ url:'../scout/scout' }) } }, getUserWxMsg:function(e){//通过微信获取用户信息 if (e.detail.errMsg == "getUserInfo:ok") { if(app.globalData.userInfoData){ app.globalData.userInfoData.avatarUrl = e.detail.userInfo.avatarUrl; app.globalData.userInfoData.nickName = e.detail.userInfo.nickName; } this.setData({ getUserInfoBtn:false }) app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName); wx.navigateTo({ url:'../poster/poster' }) } } })