123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- // 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'
- })
- }
- }
-
- })
|