45 lines
988 B
JavaScript
45 lines
988 B
JavaScript
const navigation = require('../../utils/navigation')
|
|
const permission = require('../../utils/permission')
|
|
|
|
Page({
|
|
data: {
|
|
userInfo: null,
|
|
currentShop: null,
|
|
modules: []
|
|
},
|
|
|
|
onShow() {
|
|
if (!navigation.ensureLogin('进入经营模块')) {
|
|
return
|
|
}
|
|
|
|
const app = getApp()
|
|
const userInfo = app.globalData.userInfo
|
|
const currentShop = app.globalData.currentShop
|
|
const permissionCodes = app.globalData.permissionCodes || []
|
|
|
|
this.setData({
|
|
userInfo,
|
|
currentShop,
|
|
modules: permission.getManageModules(userInfo, permissionCodes, currentShop)
|
|
})
|
|
},
|
|
|
|
handleOpenModule(event) {
|
|
const module = event.currentTarget.dataset.module
|
|
if (!module) {
|
|
return
|
|
}
|
|
|
|
if (!module.allowed) {
|
|
wx.showToast({
|
|
title: module.disabledReason || '当前账号没有进入该模块的权限',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
navigation.navigate(module.path).catch(() => undefined)
|
|
}
|
|
})
|