|
|
|
|
import { getCurrentPageUrl } from '@/utils/util'
|
|
|
|
|
const app = getApp()
|
|
|
|
|
|
|
|
|
|
Component({
|
|
|
|
|
properties: {},
|
|
|
|
|
data: {
|
|
|
|
|
imageUrl: app.globalData.imageUrl,
|
|
|
|
|
isChild: 0,
|
|
|
|
|
active: 0,
|
|
|
|
|
list: [
|
|
|
|
|
{
|
|
|
|
|
pagePath: '/pages/index/index',
|
|
|
|
|
text: '首页',
|
|
|
|
|
icon: 'home',
|
|
|
|
|
iconActive: 'home-active',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
pagePath: '/pages/repository/index',
|
|
|
|
|
text: '知识',
|
|
|
|
|
icon: 'story',
|
|
|
|
|
iconActive: 'story-active',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
pagePath: '/pages/live/index',
|
|
|
|
|
text: '活动',
|
|
|
|
|
icon: 'gift',
|
|
|
|
|
iconActive: 'gift-active',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
pagePath: '/pages/my/index',
|
|
|
|
|
text: '我的',
|
|
|
|
|
icon: 'my',
|
|
|
|
|
iconActive: 'my-active',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
userInfo: {},
|
|
|
|
|
showRed: false,
|
|
|
|
|
anyWhere: false,
|
|
|
|
|
|
|
|
|
|
config: {} as any,
|
|
|
|
|
},
|
|
|
|
|
observers: {},
|
|
|
|
|
lifetimes: {
|
|
|
|
|
ready() {
|
|
|
|
|
app.getTheme().then((res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
theme: res,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const pagePath = getCurrentPageUrl()
|
|
|
|
|
const active = this.data.list.findIndex((item) => item.pagePath === pagePath)
|
|
|
|
|
this.setData({
|
|
|
|
|
active,
|
|
|
|
|
anyWhere: app.globalData.anyWhere,
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
showRed: app.globalData.showRed,
|
|
|
|
|
})
|
|
|
|
|
getApp().registerListener(() => {
|
|
|
|
|
this.setData({
|
|
|
|
|
anyWhere: app.globalData.anyWhere,
|
|
|
|
|
})
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '?r=zd/common/get-config',
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
this.setData({
|
|
|
|
|
config: res,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
onChange() {},
|
|
|
|
|
handleNav(e) {
|
|
|
|
|
const { index } = e.currentTarget.dataset
|
|
|
|
|
const { list } = this.data
|
|
|
|
|
const pagePath = list[index].pagePath
|
|
|
|
|
app.globalData.BeginnerCardId = ''
|
|
|
|
|
this.setData({
|
|
|
|
|
anyWhere: app.globalData.anyWhere,
|
|
|
|
|
})
|
|
|
|
|
if (pagePath == '/pages/my/index') {
|
|
|
|
|
app.permissionVerification(2, 0, `/pages/index/index`).then(() => {
|
|
|
|
|
wx.switchTab({
|
|
|
|
|
url: pagePath,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
wx.switchTab({
|
|
|
|
|
url: pagePath,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|