123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- // pages/childList/childList.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- thumbnail: app.globalData.thumbnail,
- baseImgUrl: app.globalData.baseImgUrl,
- hiddenModel: false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData(options);
- console.log(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 () {
- this.getChildInfo();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 底部导航跳转
- */
- redirectCtl: app.redirectCtl,
- /**
- * 路由跳转
- */
- // navigateCtl: app.navigateCtl,
- navigateCtl: function (e) {
- const { add } = e.currentTarget.dataset
- console.log(e)
- if (add==1) {
- wx.removeStorageSync('list')
- app.navigateCtl(e);
- }else{
- app.navigateCtl(e);
- }
-
- },
- /**
- * 我的信息
- */
- getMyInfo: function () {
- const userId = app.globalData.userId || wx.getStorageSync('userId')
- if (userId) {
- console.log('123')
- const parentInfo = app.globalData.parentInfo || wx.getStorageSync(`parentInfo-${userId}`)
- const parentVipList = wx.getStorageSync(`parentVipList-${userId}`) || []
- 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: '' };
- this.setData({ userId, parentInfo, parentVipList, parentVipLiIdx, parentVipId, parentImg, childImg: imgUrl })
- // console.log(parentVipList);
- }
- },
- // 获取孩子信息
- getChildInfo:function(){
- wx.showLoading({
- title: '加载中',
- })
- const { userId}=this.data;
- if (userId) {
- const parentVipLiIdx = app.globalData.parentVipLiIdx || wx.getStorageSync(`parentVipLiIdx-${userId}`) || 0;
- this.setData({ parentVipLiIdx })
- }
- const postData = { fn: this.getChildInfo, param: { ...arguments } }
- app.post('/api/parents/parents/V2/getMyInfo', {}, 0, postData).then(res => {
- wx.hideLoading();
- const { childList}=res.data;
- this.setData({ parentVipList: childList})
- })
- },
- /**
- * 提示框隐藏
- */
- allShowModel: function () {
- this.setData({ hiddenModel: false })
- },
- /**
- * 切换孩子信息
- */
- modalInfo: function (e) {
- const { index } = e.currentTarget.dataset;
- this.setData({ hiddenModel: true, childIndex: index })
- },
- checkActChildCtl: function (res) {
- const { childIndex } = this.data;
- const { parentVipLiIdx, parentVipList, userId } = this.data;
- this.setData({
- parentVipLiIdx: childIndex,
- parentVipId: parentVipList[childIndex]['vipId'],
- hiddenModel: false
- })
- getApp().globalData.parentVipLiIdx = childIndex
- getApp().globalData.parentVipId = parentVipList[childIndex]['vipId']
- wx.setStorageSync(`parentVipLiIdx-${userId}`, childIndex)
- wx.setStorageSync(`parentVipId-${userId}`, parentVipList[childIndex]['vipId'])
- this.setData({ pageNo: 1 })
- // this.getChildInfo();
- },
- })
|