101 lines
4.1 KiB
JavaScript
101 lines
4.1 KiB
JavaScript
/**
|
|
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const navigation = require('../../utils/navigation')
|
|
/**
|
|
* Purpose: permission supports index.js by holding or executing the permission page or API role.
|
|
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
const permission = require('../../utils/permission')
|
|
|
|
Page({
|
|
/**
|
|
* Purpose: data supports index.js by holding or executing the data page or API role.
|
|
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
data: {
|
|
/**
|
|
* Purpose: userInfo supports index.js by holding or executing the user info page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
userInfo: null,
|
|
/**
|
|
* Purpose: currentShop supports index.js by holding or executing the current shop page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
currentShop: null,
|
|
/**
|
|
* Purpose: modules supports index.js by holding or executing the modules page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
modules: []
|
|
},
|
|
|
|
/**
|
|
* Purpose: onShow supports index.js by holding or executing the on show page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
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,
|
|
/**
|
|
* Purpose: modules supports index.js by holding or executing the modules page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
modules: permission.getManageModules(userInfo, permissionCodes, currentShop)
|
|
})
|
|
},
|
|
|
|
handleOpenWorkbench() {
|
|
navigation.switchTab('/pages/workbench/index').catch(() => undefined)
|
|
},
|
|
|
|
handleOpenOrders() {
|
|
navigation.switchTab('/pages/orders/index').catch(() => undefined)
|
|
},
|
|
|
|
handleOpenProfile() {
|
|
navigation.switchTab('/pages/profile/index').catch(() => undefined)
|
|
},
|
|
|
|
/**
|
|
* Purpose: handleOpenModule supports index.js by holding or executing the handle open module page or API role.
|
|
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
handleOpenModule(event) {
|
|
const module = event.currentTarget.dataset.module
|
|
if (!module) {
|
|
return
|
|
}
|
|
|
|
if (!module.allowed) {
|
|
wx.showToast({
|
|
/**
|
|
* Purpose: title supports index.js by holding or executing the title page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
title: module.disabledReason || '当前账号没有进入该模块的权限',
|
|
/**
|
|
* Purpose: icon supports index.js by holding or executing the icon page or API role.
|
|
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
|
|
*/
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
|
|
navigation.navigate(module.path).catch(() => undefined)
|
|
}
|
|
})
|