|
@@ -5,7 +5,14 @@ const loadTypeMaps = new Map()
|
|
|
loadTypeMaps.set(enums.LoadType.onLoad, onLoad)
|
|
loadTypeMaps.set(enums.LoadType.onLoad, onLoad)
|
|
|
loadTypeMaps.set(enums.LoadType.onShow, onShow)
|
|
loadTypeMaps.set(enums.LoadType.onShow, onShow)
|
|
|
loadTypeMaps.set(enums.LoadType.onReady, onReady)
|
|
loadTypeMaps.set(enums.LoadType.onReady, onReady)
|
|
|
-const staticData = {}
|
|
|
|
|
|
|
+type goPageExt = {
|
|
|
|
|
+ /** 默认navigateTo */
|
|
|
|
|
+ goPageType?: GoPageTypeKeys
|
|
|
|
|
+ params?: AnyObject
|
|
|
|
|
+}
|
|
|
|
|
+const staticData = {
|
|
|
|
|
+ goPageExt: {} as goPageExt,
|
|
|
|
|
+}
|
|
|
type ExtType<T> = Record<keyof T, { showLoading?: boolean }>
|
|
type ExtType<T> = Record<keyof T, { showLoading?: boolean }>
|
|
|
export default {
|
|
export default {
|
|
|
/** 初始化对象内的方法,自动为对象内所有方法增加防重提功能(同步方法、异步方法执行中再次触发不执行) */
|
|
/** 初始化对象内的方法,自动为对象内所有方法增加防重提功能(同步方法、异步方法执行中再次触发不执行) */
|
|
@@ -49,32 +56,36 @@ export default {
|
|
|
goHome() {
|
|
goHome() {
|
|
|
ay.goPage(config.pages.index_index, { goPageType: enums.GoPageType.reLaunch })
|
|
ay.goPage(config.pages.index_index, { goPageType: enums.GoPageType.reLaunch })
|
|
|
},
|
|
},
|
|
|
- goLogin() {
|
|
|
|
|
- ay.goPage(config.pages.login_index, { goPageType: enums.GoPageType.reLaunch }) // { params: { backPage: curPage } })
|
|
|
|
|
|
|
+ /** 跳登录
|
|
|
|
|
+ * @params type 0:手机号快捷 1:账号、密码
|
|
|
|
|
+ */
|
|
|
|
|
+ goLogin(type = 0) {
|
|
|
|
|
+ if (type === 0) ay.goPage(config.pages.login_index, { goPageType: enums.GoPageType.reLaunch }) // { params: { backPage: curPage } })
|
|
|
// func.face.showToast({
|
|
// func.face.showToast({
|
|
|
// title: '请登录',
|
|
// title: '请登录',
|
|
|
// icon: 'error',
|
|
// icon: 'error',
|
|
|
// })
|
|
// })
|
|
|
|
|
+ if (type === 1) {
|
|
|
|
|
+ ay.goPage(config.pages.webview_login, { goPageType: enums.GoPageType.reLaunch })
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
/** 关闭当前页面,返回上一页面或多级页面 */
|
|
/** 关闭当前页面,返回上一页面或多级页面 */
|
|
|
async navigateBack({
|
|
async navigateBack({
|
|
|
args,
|
|
args,
|
|
|
aceas,
|
|
aceas,
|
|
|
- }: { args?: UniApp.NavigateBackOptions; aceas?: AyContainerEntryArgs } = {}) {
|
|
|
|
|
|
|
+ }: {
|
|
|
|
|
+ /** uni.navigateBack透传参数 */
|
|
|
|
|
+ args?: UniApp.NavigateBackOptions
|
|
|
|
|
+ /** 有值时,返回页面时执行AyEntranceCallBack-只执行一次 */
|
|
|
|
|
+ aceas?: AyContainerEntryArgs
|
|
|
|
|
+ } = {}) {
|
|
|
store.curPage.pageConfig.prePage.onceBackReloadArgs = aceas
|
|
store.curPage.pageConfig.prePage.onceBackReloadArgs = aceas
|
|
|
await uni.navigateBack(args)
|
|
await uni.navigateBack(args)
|
|
|
},
|
|
},
|
|
|
/** 页面跳转
|
|
/** 页面跳转
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- async goPage(
|
|
|
|
|
- page?: ayPage,
|
|
|
|
|
- ext?: {
|
|
|
|
|
- /** 默认navigateTo */
|
|
|
|
|
- goPageType?: GoPageTypeKeys
|
|
|
|
|
- params?: AnyObject
|
|
|
|
|
- },
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ async goPage(page?: ayPage, ext?: goPageExt) {
|
|
|
let goPageFunc = uni.navigateTo
|
|
let goPageFunc = uni.navigateTo
|
|
|
if (page._type === enums.PageType.tabPage) {
|
|
if (page._type === enums.PageType.tabPage) {
|
|
|
goPageFunc = uni.switchTab
|
|
goPageFunc = uni.switchTab
|
|
@@ -82,13 +93,15 @@ export default {
|
|
|
if (ext?.goPageType) {
|
|
if (ext?.goPageType) {
|
|
|
goPageFunc = uni[ext.goPageType]
|
|
goPageFunc = uni[ext.goPageType]
|
|
|
}
|
|
}
|
|
|
- if (ext?.params) {
|
|
|
|
|
- store.curPage.initPageInfo({ page, params: ext.params })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ staticData.goPageExt = ext
|
|
|
|
|
+
|
|
|
// 防止重复跳转
|
|
// 防止重复跳转
|
|
|
func.antiShake({
|
|
func.antiShake({
|
|
|
- func: () => {
|
|
|
|
|
- goPageFunc({ url: page._url })
|
|
|
|
|
|
|
+ func: async () => {
|
|
|
|
|
+ await goPageFunc({ url: page._url })
|
|
|
|
|
+ // if (ext?.params) {
|
|
|
|
|
+ // store.curPage.initPageInfo({ page, params: ext.params })
|
|
|
|
|
+ // }
|
|
|
},
|
|
},
|
|
|
immediately: true,
|
|
immediately: true,
|
|
|
mark: page._url,
|
|
mark: page._url,
|
|
@@ -96,7 +109,7 @@ export default {
|
|
|
// await goPageFunc({ url: page._url })
|
|
// await goPageFunc({ url: page._url })
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
- 页面生命周期入口,默认拦截enums.LoadType.onLoad、enums.LoadType.refresh, 可配置ext扩展参数
|
|
|
|
|
|
|
+ 页面生命周期入口,初始化页面,默认拦截enums.LoadType.onLoad、enums.LoadType.refresh, 可配置ext扩展参数
|
|
|
*/
|
|
*/
|
|
|
entrance(
|
|
entrance(
|
|
|
/** 页面生命周期入口的回调函数 */
|
|
/** 页面生命周期入口的回调函数 */
|
|
@@ -113,7 +126,7 @@ export default {
|
|
|
cras: config.common.defAyContainerRefreshArgs,
|
|
cras: config.common.defAyContainerRefreshArgs,
|
|
|
}
|
|
}
|
|
|
const init = () => {
|
|
const init = () => {
|
|
|
- store.curPage.initPageInfo()
|
|
|
|
|
|
|
+ store.curPage.initPageInfo({ params: staticData.goPageExt?.params })
|
|
|
let isLogined = true
|
|
let isLogined = true
|
|
|
|
|
|
|
|
const curPage = store.curPage.pageConfig
|
|
const curPage = store.curPage.pageConfig
|
|
@@ -131,14 +144,13 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onUnload(() => {
|
|
onUnload(() => {
|
|
|
- // redirectTo跳转时会清理跳转的页面
|
|
|
|
|
- // store.curPage.removeCurPagerInfo()
|
|
|
|
|
|
|
+ store.curPage.removeCurPagerInfo()
|
|
|
})
|
|
})
|
|
|
onLoad((options) => {
|
|
onLoad((options) => {
|
|
|
if (!func.antiShake({ func: init, immediately: true, mark: tempid })) {
|
|
if (!func.antiShake({ func: init, immediately: true, mark: tempid })) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (store.curPage.pageConfig.isPager) {
|
|
|
|
|
|
|
+ if (store.curPage?.pageConfig?.isPager) {
|
|
|
store.curPage.pageConfig.curCallBack = (cras: AyContainerRefreshArgs) => {
|
|
store.curPage.pageConfig.curCallBack = (cras: AyContainerRefreshArgs) => {
|
|
|
args.cras = {
|
|
args.cras = {
|
|
|
...args.cras,
|
|
...args.cras,
|
|
@@ -182,9 +194,15 @@ export default {
|
|
|
ext.addLoadTypes.forEach((f) => {
|
|
ext.addLoadTypes.forEach((f) => {
|
|
|
const curLt = loadTypeMaps.get(f)
|
|
const curLt = loadTypeMaps.get(f)
|
|
|
if (curLt) {
|
|
if (curLt) {
|
|
|
- args.loadType = f
|
|
|
|
|
curLt(() => {
|
|
curLt(() => {
|
|
|
- callBack(args)
|
|
|
|
|
|
|
+ if (f === enums.LoadType.onShow && !store.curPage.pageConfig.onShowed) {
|
|
|
|
|
+ store.curPage.pageConfig.onShowed = true
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ callBack({
|
|
|
|
|
+ ...args,
|
|
|
|
|
+ loadType: f,
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -201,7 +219,7 @@ export default {
|
|
|
* 通知容器数据加载完毕
|
|
* 通知容器数据加载完毕
|
|
|
*/
|
|
*/
|
|
|
containerLoaded(args?: AyContainerMethodsLoadedArgs) {
|
|
containerLoaded(args?: AyContainerMethodsLoadedArgs) {
|
|
|
- if (store.curPage.pageConfig.isPager) {
|
|
|
|
|
|
|
+ if (store.curPage?.pageConfig?.isPager) {
|
|
|
store.curPage.pagerMethods.loaded({
|
|
store.curPage.pagerMethods.loaded({
|
|
|
...store.curPage.pageConfig.pagerInfo,
|
|
...store.curPage.pageConfig.pagerInfo,
|
|
|
...args,
|
|
...args,
|