// pages/recruit/index.js Page({ /** * 页面的初始数据 */ data: { recruitData : '', type : 'flowPath', //flowPath 参与流程 clockIn 打卡 followState : false, loginCode : '', calendarData : [], //日历表 canSign : '', //是否可以签到 selectMonth : '', //当前月 lastMonth : '', //选择下个月 nextMonth : '', //选择上个月 signDayNumber : '', //累计打卡天数 signDayCount : '', //总打卡天数 signWaterNumber: '', //总打卡给水滴 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log(options) if(options.invite != undefined) { getApp().globalData.inviteText = options.invite } if(options.is_experience != undefined) { getApp().globalData.isExperience = options.is_experience } if(options.experience_area_id != undefined) { getApp().globalData.experienceAreaId = options.experience_area_id } }, /** * 生命周期函数--监听页面显示 */ onShow() { wx.login({ success: res => { this.setData({ loginCode: res.code }) } }) // 获取体验官首页 this.recruitInfo(); }, /** * 体验官首页 */ recruitInfo() { wx.$api.recruit.index({ invite : getApp().globalData.inviteText || '', is_experience : getApp().globalData.isExperience || '' }).then(res => { this.setData({ recruitData: res.data }) // 0可以申请 1需要面检测 5签收-查看物流 6打卡 7第二次面 if(res.data.can.status == 6) { // 获取日历 this.signInfo(); // 显示打卡数据 this.setData({ type : 'clockIn' }) } // if(res.data.can.status == 7) { // // 获取两次报告对比 // this.skinInfo(); // } // 获取两次报告对比 this.skinInfo(); }).catch(err => {}) }, /** * 申请 */ applyGo() { if(wx.getStorageSync("token") != ''){ // 0可以申请 1需要面检测 5签收-查看物流 6打卡 7第二次面 if(this.data.recruitData.can.status == 0) { // 申请体验官 wx.navigateTo({ url: './referto/referto?id=' + this.data.recruitData.experience_id }) } else if(this.data.recruitData.can.status == 5) { var data = JSON.stringify(this.data.recruitData.express) // 查看物流 wx.navigateTo({ url: `/pages/order/logistic/logistic?newData=` + encodeURIComponent(data) }) } else if(this.data.recruitData.can.status == 6) { // 日历打卡 } else { // 面部检测 wx.navigateTo({ url: '/pages/index/assess/assess?type=1' }) } return } // 去登录 wx.navigateTo({ url: "/pages/login/index" }) }, rejectGo() { wx.showModal({ title: '驳回原因提示', showCancel: false, content: this.data.recruitData.can.remark, success: res => {} }) }, /** * 获取code */ followCode() { wx.getUserProfile({ desc : "获取你的昵称、头像、地区及性别", success : e => { if(e.errMsg == "getUserProfile:ok"){ wx.$api.recruit.wechatMini({ code :this.data.loginCode, iv : e.iv, encryptedData: e.encryptedData }).then(res => { // subscribe == 0未关注公众号 if (res.data.subscribe == 0) { this.setData({ followState: true }) return } // 获取首页数据 subscribe == 1已 关注公众号 this.mallData(); }).catch(err => {}) } }, fail: err => { return; } }) }, /** * 日历 */ signInfo() { wx.$api.recruit.signCalendar({ date : this.data.selectMonth, experience_id: this.data.recruitData.experience_id }).then(res => { this.setData({ calendarData : res.data.calendar, lastMonth : res.data.lastMonth, nextMonth : res.data.nextMonth, selectMonth : res.data.nowMonth, canSign : res.data.canSign, signDayNumber: res.data.signDayNumber, signDayCount : res.data.signDayCount, signWaterNumber : res.data.signWaterNumber }) }).catch(err => {}) }, /** * 日历数量加减 */ couponNumber(e){ let val = e.currentTarget.dataset.type if (val == 'plus'){ this.setData({ selectMonth: this.data.lastMonth }) }else{ this.setData({ selectMonth: this.data.nextMonth }) } // 获取日历 this.signInfo(); }, /** * 签到弹出 */ tapPop() { if(!this.data.canSign) { wx.navigateTo({ url: './signWrite/signWrite?experienceId=' + this.data.recruitData.experience_id + '&signDayNumber=' + this.data.signDayNumber }) } }, /** * 两次报告对比 */ skinInfo() { wx.$api.recruit.skinDiff().then(res => { console.log(res) }).catch(err => {}) }, /** * 公众号弹出 */ followHide() { this.setData({ followState: !this.data.followState }) } })