// pages/me/me.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { thumbnail: app.globalData.thumbnail, baseImgUrl: app.globalData.baseImgUrl, userInfo: null, pageNo: 1, pageSize: 5, list:[], childImg:'', hiddenModel:false, isAll:false, isShell: 1, footerData: { actIndex: 2, list: [ { text: '首页', url: '../../image/shou_ye_hui.png', actUrl: '../../image/shou_ye.png', src: 'homework_list', id: 'homework_list' }, { text: '学习成长报告', url: '../../image/xue_qing_hui.png', actUrl: '../../image/xue_qing.png', src: 'learning_report', id: 'learning_report' }, { text: '我的', url: '../../image/wo_de_hui.png', actUrl: '../../image/wo_de.png', src: 'me', id: 'me' } ], }, user: { headIcon: '../../assets/shu_gong@3x.png', nickName: '维尼尊者' }, actChildIndex: 0, vip: { // nickName: '', // headIcon: '', // totalCapacity: 52, // capacity: 26, // userId:'' }, listOne: [ { icon: '../../assets/xiao_xi@3x.png', text: '消息', src: 'chat_detail', method: null }, { icon: '../../assets/hai_zi_zhang_hao@3x.png', text: '孩子账号', src: 'children', method: null }, { icon: '../../assets/yu_yue_dao_guan@3x.png', text: '预约到馆', src: '', //appointment method: null }, { icon: '../../assets/hui_yuan_xu_fei@3x.png', text: '会员续费', src: '', // membership method: null }, { icon: '../../assets/yong_hu_zhi_nan@3x.png', text: '用户使用指南', src: '', // guide method: null }, { icon: '../../assets/yong_hu_xie_yi@3x.png', text: '用户协议', src: 'agreement', method: null } ], listTwo: [ { icon: '../../assets/she_zhi@3x.png', text: '设置', src: 'settings', method: null } ] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { app.getWxloginCode(code => { this.setData({ code }) }) const userInfo = app.globalData.userInfo || wx.getStorageSync('userInfo') || null if (userInfo) { this.setData({ userInfo }) } this.setData({ options }); if (!options.vipId) { const userId = app.globalData.userId || wx.getStorageSync('userId') const vipId = app.globalData.parentVipId || wx.getStorageSync(`parentVipId-${userId}`) options.vipId = vipId options.userId = userId this.setData({ options }); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { const userInfo = wx.getStorageSync('userInfo') const { vipId } = this.data.options if (!userInfo) { this.setData({ isOne: true }) } else if (userInfo) { this.getMyInfo() } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { // const { isAll } = this.data // if (isAll) { // return // } // const userId = app.globalData.userId || wx.getStorageSync('userId') // if (userId) { // const { pageNo}=this.data; // const parentVipId = app.globalData.parentVipId || wx.getStorageSync(`parentVipId-${userId}`) || ''; // this.setData({ parentVipId, pageNo: pageNo+1}) // } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, /** * 底部导航跳转 */ redirectCtl: app.redirectCtl, /** * 路由跳转 */ navigateCtl:function(e) { const { userInfo } = this.data if (userInfo) { app.navigateCtl(e); } else { wx.showToast({ title: '请授权登录后再试', icon: 'none' }) } }, /** * 孩子名片 */ businessCard: function (e) { const { vipId, childIndex, userInfo } = this.data if (childIndex>=0) { this.setData({ parentVipLiIdx: childIndex }); } if (vipId) { app.navigateCtl(e); } else if (!userInfo) { wx.showToast({ title: '请授权登录后再试', icon: 'none' }) }else{ wx.showToast({ title: '请添加孩子后再试', icon: 'none' }) } }, // 会员中心 memberCtrl:function(){ wx.showToast({ title: '暂未开放', icon: 'none' }) }, //查看图片 viewImageCtl:app.viewImageCtl, /** * 我的信息 */ getMyInfo: function () { var that=this; const userId = app.globalData.userId || wx.getStorageSync('userId'); const postData = { fn: this.getChildInfo, param: { ...arguments } } app.post('/api/parents/parents/V2/getMyInfo', {}, 0, postData).then(res => { const { childList,phone} = res.data; if (phone=="") { that.redirectCtl({ url:'phone', method: { isFrist: 1} }, true) } if (userId) { const parentInfo = app.globalData.parentInfo || wx.getStorageSync(`parentInfo-${userId}`) // const parentVipList = wx.getStorageSync(`parentVipList-${userId}`) || [] var parentVipList=childList const parentVipLiIdx = app.globalData.parentVipLiIdx || wx.getStorageSync(`parentVipLiIdx-${userId}`) || 0 const parentVipId = app.globalData.parentVipId || wx.getStorageSync(`parentVipId-${userId}`) || '' const parentImg = parentInfo.imgUrl || ''; const { imgUrl } = parentVipList[parentVipLiIdx] ? parentVipList[parentVipLiIdx] : { imgUrl: '' }; const { childName, derver, vipId, isZybService, zybEndDate, childType, qrCodeImg} = parentVipList[parentVipLiIdx]; this.setData({ userId, parentVipList,parentInfo, parentVipLiIdx, parentVipId, parentImg,imgUrl, childName, derver, vipId, isZybService, zybEndDate, childType, qrCodeImg}) } }) }, /** * 提示框隐藏 */ allShowModel: function () { this.setData({hiddenModel: false }) }, /** * 切换孩子信息 */ modalInfo:function(e){ const { index } = e.currentTarget.dataset; // console.log(index) this.setData({ hiddenModel: true, childIndex: index}) this.setData({ parentVipLiIdx: index }) }, sureCheckChildren:function(){ const { childIndex}=this.data; this.setData({ hiddenModel: false}); this.checkActChildCtl(childIndex); }, checkActChildCtl: function (res) { const index = res; const { parentVipLiIdx, parentVipList, userId } = this.data this.setData({ parentVipLiIdx: index, parentVipId: parentVipList[index]['vipId'] }) getApp().globalData.parentVipLiIdx = index getApp().globalData.parentVipId = parentVipList[index]['vipId'] wx.setStorageSync(`parentVipLiIdx-${userId}`, index) wx.setStorageSync(`parentVipId-${userId}`, parentVipList[index]['vipId']) this.setData({pageNo: 1}) this.getMyInfo(); }, // /** // * 获取定位经纬度 // */ // getLocation: function () { // app.getWxUserLocationSetting(res => { // wx.showLoading({ // title: '定位中' // }) // wx.getLocation({ // type: 'wgs84', // success: res => { // this.setData({ // longitude: res.longitude, // '113.36403' || // latitude: res.latitude // '23.14203' || // }) // }, // fail: res => { // setTimeout(() => { // wx.showToast({ // title: '定位失败', // icon: 'none' // }) // }, 10) // setTimeout(() => { // wx.navigateBack({ // delta: 1 // }) // }, 1000) // }, // complete: res => { // wx.hideLoading() // } // }) // }) // }, /** * 添加学员 */ addChildCtl: function () { const postData = { fn: this.addChildCtl, param: { ...arguments } } const {vipId}=this.data.options; const { longitude, latitude}=this.data; // console.log(longitude, latitude) wx.scanCode({ onlyFromCamera: true, success: (e) => { if (e.result.indexOf('https://t.sharingschool.com')!=-1){ app.post('/api/parents/parents/swipeQrCode', { vipId, longitude, latitude, qrCode: e.result }, 0, postData).then(res => { wx.showToast({ title: '扫码成功', icon: 'success', duration: 1000 }) }) }else{ wx.showToast({ title: '二维码不正确', icon: 'none', duration: 1000 }) } } }) }, /** * 微信授权 */ bindGetUserInfo: function (e) { const {code } = this.data; if (e.detail.userInfo) { app.saveUserInfo(e.detail, code) } else { wx.showToast({ title: '微信授权失败', icon: 'none' }) } } })