123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- // parents/pages/me/me.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
- import { CheckRole } from '../../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData, hasLibraryService, hasVipService, saveUserInfo, getWxloginCode} = getApp()
- const { baseImgUrl, qrcodeInvalidToastText } = globalData
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- baseImgUrl,
- isLoaded: 0,
- isShowVipModal: 0,
- positionArray: ['馆长', '家长'],
- positionIndex: 0,
- canIUseGetUserInfo: wx.canIUse('button.open-type.getUserInfo'),
- vip: {
- position: ''
- },
- routerOne: [
- {
- icon: '../../../assets/vip.png',
- text: '会员服务',
- time: '',
- paras: {},
- url: '',
- zindex: 3
- },
- ],
- routerTwo: [
- {
- icon: '../../../assets/personal_info.png',
- text: '调书申请记录',
- time: '',
- paras: {
- type: 1
- },
- url: 'president/pages/allocate_books_record/allocate_books_record',
- zindex: 3
- },
- {
- icon: '../../../assets/apply_pages.png',
- text: '申请新书记录',
- time: '',
- paras: {},
- url: 'president/pages/newbooks_apply_record/newbooks_apply_record',
- zindex: 3
- },
- ],
-
- footerData: {
- actIndex: 2,
- list: [
- {
- text: '日常事务',
- icon: '../../../assets/lock_gary.png',
- actIcon: '../../../assets/lock_blue.png',
- url: 'president/pages/home/home',
- zindex: 3,
- },
- {
- text: '人员管理',
- icon: '../../../assets/people_manager_gary.png',
- actIcon: '../../../assets/people_manager_blue.png',
- url: 'president/pages/Personnel_management/Personnel_management',
- zindex: 3,
- },
- {
- text: '我的',
- icon: '../../../assets/me_gray.png',
- actIcon: '../../../assets/me_blue.png',
- url: 'president/pages/me/me',
- zindex: 3,
- }
- ]
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const userId = getGlobalVal('userId')
- options.library = getGlobalVal('library')
- options.vipList = getGlobalVal('vipList', `vipList_${userId}`)
- options.vipIndex = getGlobalVal('vipIndex', `vipIndex_${userId}`)
- options.vipId = getGlobalVal('vipId', `vipId_${userId}`)
- options.vip = getGlobalVal('vip', `vip_${userId}`)
- options.userId = userId
- options.userInfo = getGlobalVal('userInfo')
- options.list = getGlobalVal('list')
- console.log(options)
- this.setData({ options, isLoaded: 1 })
- getWxloginCode(code => {
- this.setData({ code })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- const obj = { navigateTo, redirectTo, navigateBack, viewImage }
- for (const i in obj) {
- this[i] = obj[i]
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- testclick: function () {
- navigateTo({
- url: 'president/pages/newbooks_apply_record/newbooks_apply_record?id=113f76b8-8d84-4b18-b882-c4098d515067',
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
- /**
- * 选择跳转进入页
- */
- selectRouteCtl: function (e) {
- const { index } = e.currentTarget.dataset
- const { routerTwo } = this.data
- const { url, zindex } = routerTwo[index]
- // if (index==2){
- navigateTo({ url, zindex })
- // }else{
- // if (!hasVipService()) return
- // navigateTo({ url, zindex })
- // }
-
- },
- /**
- * 身份切换
- */
- pickerpositionCtl: function (e) {
- const { value } = e.detail
- const { positionArray, positionIndex } = this.data
- this.setData({ 'vip.position': ~~value + 1, positionIndex: value })
- if (value ==0) {
- wx.showToast({
- title: '您目前的身份已经是馆长啦',
- icon: 'none'
- })
- return
- }
- else{
- this.toggleSubmit()
- }
- },
- /**
- * 身份切换家长
- */
- toggleSubmit: function () {
- const continuousFn = { fn: this.delCtl, param: { ...arguments } }
- CheckRole({ data: { }, continuousFn }).then(res => {
- wx.showToast({
- title: res.msg
- })
- if (res.code ==999){
- redirectTo({ url: 'parents/pages/main/main', paras: { isDirector: 1 } })
- }
- })
- },
- /**
- * 显示学员切换框
- */
- toggleSelectVipCtl: function () {
- const { vipList } = this.data.options
- // if (!vipList || vipList.length < 2) return
- this.setData({ isShowVipModal: !this.data.isShowVipModal })
- },
- /**
- * 添加孩子跳转
- */
- addchildPage: function () {
- const { routerTwo } = this.data
- const { url, zindex } = routerTwo[0]
- if (!hasVipService()) return
- navigateTo({ url, zindex })
- },
- /**
- * 学员切换
- */
- selectVipCtl: function (e) {
- const { index } = e.currentTarget.dataset
- const { options } = this.data
- const { vipIndex, vipList, userId } = options
- if (index == vipIndex) {
- return
- }
- const { vip_id } = vipList[index]
- if (vip_id) {
- options.vip = vipList[index]
- getApp().globalData['vip'] = vipList[index]
- wx.setStorageSync(`vip_${userId}`, vipList[index])
- options.vipIndex = index
- getApp().globalData['vipIndex'] = index
- wx.setStorageSync(`vipIndex_${userId}`, index)
- options.vipId = vip_id
- getApp().globalData['vipId'] = vip_id
- wx.setStorageSync(`vipId_${userId}`, vip_id)
- wx.removeStorageSync('library')
- }
- this.setData({ options, isShowVipModal: 0 })
- },
- /**
- * 获取微信用户信息
- */
- getUserInfoCtl: function (e) {
- const { detail } = e
- const { userInfo, errMsg = '触发获取微信用户信息失败' } = detail
- if (userInfo) {
- if (isFn(saveUserInfo)) saveUserInfo(detail, this.data.code)
- } else {
- wx.showToast({
- title: '触发微信授权失败',
- icon: 'none'
- })
- }
- }
- })
|