const app = getApp() const util = require('../../utils/util.js') Page({ data: { pushCont: { wc_content: '' }, isSetstatus: false, isvip: true, arr: [], indicatorDots: true, wv_grade: '', wv_account_number: '', wv_account_name: '', loaddisplay: true, dcshow: false, wv_register_count: '', wv_contract_count: '', wv_finish_count: '', wv_extract_count: '', wv_qrcode: '', phoneauth: false, autoplay: true, interval: 5000, duration: 2000, usertype: '', userInfo: {}, nickName: '登录', avatarUrl: 'https://api.zhumi.tech/MiniProgram/image/head.png', hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo') }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, init() { const _this = this; // 判断用户是否设置过孕期 util.getData('/getWXUser', { xu_openid: app.globalData.openid }) .then(res => { // console.log(res); if (res.xu_content_type && res.xu_content_date) { _this.setData({ isSetstatus: true }) // 育儿或孕周内容查询 util.postData('/queryUserContent', { openid: app.globalData.openid }) .then(res => { // console.log(res) _this.setData({ pushCont: res }) }) .catch(err => { console.log(err); }) } }) .catch(err => { console.log(err); }) //获取用户等级 console.log(app.globalData); if (app.globalData.usertype == 2) { this.setData({ nickName: app.globalData.userInfo.nickName, avatarUrl: app.globalData.userInfo.avatarUrl }) } else { this.setData({ // nickName: app.globalData.nickName, avatarUrl: 'https://yuesuo.yueguanjia.com/MiniProgram/images/head.png' }) } //判断是否为介绍人 if (app.globalData.userphone != null && app.globalData.userphone != 'undefined' && app.globalData.userphone != ' ' && app.globalData.userphone != '') { util.getData('/checkDcIntroducers', { wv_phone: app.globalData.userphone }).then(res => { if (res != "") { _this.setData({ dcshow: true, phoneauth: true, wv_register_count: res.wv_register_count, wv_contract_count: res.wv_contract_count, wv_finish_count: res.wv_finish_count, wv_extract_count: res.wv_extract_count, wv_grade: res.wv_gradeid, wv_qrcode: res.wv_qrcode, wv_account_number: res.wv_account_number, wv_account_name: res.wv_account_name }) } else { _this.setData({ dcshow: false, phoneauth: true }) } }) } else { this.setData({ dcshow: false, phoneauth: false }) } }, onLoad: function() { this.setData({ navH: app.globalData.navHeight }) }, onShow: function() { const _this = this; wx.checkSession({ success(res) { app.setUserInfo().then(res => { _this.init() }); }, fail() { // session_key 已经失效,需要重新执行登录流程 console.log('checkfail,') } }) }, getUserInfo: function(e) { app.globalData.userInfo = e.detail.userInfo this.setData({ userInfo: e.detail.userInfo, hasUserInfo: true }) }, hrefEq: function(e) { app.checkSession().then(res => { wx.navigateTo({ url: '/pages/mine/myeq/myeq' }) }); }, hrefAboutus: function(e) { wx.navigateTo({ url: '/pages/mine/aboutus/aboutus' }) }, hrefAdd: function(e) { app.checkSession().then(res => { wx.navigateTo({ url: '/pages/mine/myaddress/myaddress' }) }); }, hrefCp: function(e) { app.checkSession().then(res => { if (app.globalData.userphone == null || app.globalData.userphone == '') { app.ifAuthorization(); } else { wx.navigateTo({ url: '/pages/mine/mycoupon/mycoupon' }) } }); }, //去授权,不用检测,就是要去那个页面 hrefAuthPhone: function(e) { wx.navigateTo({ url: '/pages/getphone/getphone?back=mine' }) }, hrefDc: function(e) { wx.navigateTo({ url: '/pages/mine/mydc/mydc' }) }, hrefQrcode: function(e) { wx.navigateTo({ url: '/pages/mine/myqrcode/myqrcode?para=' + this.data.wv_qrcode }) }, hrefOrder: function(e) { if (app.globalData.userphone == null || app.globalData.userphone == '') { app.ifAuthorization(); } else { app.checkSession().then(res => { wx.navigateTo({ url: '/pages/mine/myorder/myorder' }) }); } }, review: function() { wx.navigateTo({ url: '/pages/promotion/promotionhref?para=https://tizhi.zhiyi365.com/default.aspx' }) }, calling: function() { wx.makePhoneCall({ phoneNumber: '400-002-2699', success: function() { }, fail: function() { } }) }, tologin() { app.checkSession() }, // hrefMyInfo: function() { // wx.navigateTo({ // url: '/pages/mine/myinfo/myinfo?accountnumber=' + this.data.wv_account_number + '&wv_account_name=' + this.data // .wv_account_name // }) // }, selectlife() { app.checkSession().then(res => { wx.navigateTo({ url: '/pages/select/select' }) }); }, })