//appBusinessHandle.js
const doSomeThing = ()=>{...}
/*小程序启动时需要处理的个性逻辑*/
const onLaunchHandle = {}
/*小程序显示时需要处理的个性逻辑*/
const onShowHandle = {
// 某某平台小程序个性逻辑
platform_169: () => {
doSomeThing.call(this)
}
}
/*小程序隐藏时需要处理的个性逻辑*/
const onHideHandle = {}
/*App.vue 生命周期相关业务处理*/
const appBusinessFactory = () => {
// 平台编号从配置处获取 这里简单写个示例
const platform = { platform_id:167}
const platformId = platform.platform_id
const key = ['platform', platformId].join('_')
const appBusinessFun = {
// App.vue: 小程序启动时需要处理的个性逻辑
onLaunch: () => {
if (key in onLaunchHandle) {
onLaunchHandle[key].call(this)
}
},
// App.vue: 小程序显示时需要处理的个性逻辑
onShow: () => {
if (key in onShowHandle) {
onShowHandle[key].call(this)
}
},
// App.vue: 小程序隐藏时需要处理的个性逻辑
onHide: () => {
if (key in onHideHandle) {
onHideHandle[key].call(this)
}
}
}
return appBusinessFun
}
export default appBusinessFactory()
// 在App.vue处执行示例
import businessHandle from './businessHandle/appBusinessHandle.js'
businessHandle.onShow.call(this)