|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- // 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,//星探状态
- },
- /**
- * 显示规则页
- */
- 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/getCertificationInfo", {}, res => {
- this.data.starInfo = res.code;
- if (res.code == 200) {
- 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.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;
- }
- 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) {
- 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();
- },
- cutSelect:function(e){
- var index = e.currentTarget.dataset.type;
- this.data.selectGroup[index] = !this.data.selectGroup[index];
- this.setData({
- selectGroup:this.data.selectGroup
- })
- }
- })
|