功能:收口小程序前后台安全与防重复提交
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user