You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.0 KiB
TypeScript
69 lines
1.0 KiB
TypeScript
|
4 years ago
|
import { Component, Vue } from "vue-property-decorator";
|
||
|
|
import { page } from "@/utils/page";
|
||
|
|
import { session } from "@/store/modules/session";
|
||
|
|
import { image } from "@/utils/image";
|
||
|
|
@Component
|
||
|
|
export class BasePage extends Vue {
|
||
|
|
/**
|
||
|
|
* 全局uni变量
|
||
|
|
*/
|
||
|
|
uni = uni;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 当前会话信息
|
||
|
|
*/
|
||
|
|
session = session;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面索引
|
||
|
|
*/
|
||
|
|
page = page;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 图片
|
||
|
|
*/
|
||
|
|
image = image;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面滚动高度
|
||
|
|
*/
|
||
|
|
scrollTop = 0;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 未登录是否可以访问本页面
|
||
|
|
*/
|
||
|
|
get guest(): boolean {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 每次显示页面时调用
|
||
|
|
*/
|
||
|
|
onShow() {
|
||
|
|
// 检查登录状态
|
||
|
|
if (!this.guest && !session.isUserLoggedIn) {
|
||
|
|
uni.reLaunch({
|
||
|
|
url: page.login.login,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面跳转
|
||
|
|
* @param url
|
||
|
|
*/
|
||
|
|
toPage(url: string) {
|
||
|
|
uni.navigateTo({ url });
|
||
|
|
}
|
||
|
|
redirectTo(url: string) {
|
||
|
|
uni.redirectTo({ url });
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 页面滚动
|
||
|
|
* @param e
|
||
|
|
*/
|
||
|
|
onPageScroll(e: any) {
|
||
|
|
this.scrollTop = e.scrollTop;
|
||
|
|
}
|
||
|
|
}
|