1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- // commpents/mobile-frame/mobile-main.js
- const app = getApp()
- Component({
- /**
- * 组件的属性列表
- */
- options: { multipleSlots: true },
- properties: {
- frameStyle: { type: Object }
- },
- /**
- * 组件的初始数据
- */
- data: {
- infoHeight: ''
- },
- // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
- attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
- ready: function () { },
- pageLifetimes: {
- // 组件所在页面的生命周期函数
- show: function () { this.searchHeight() },
- hide: function () { },
- resize: function () { },
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 返回上一级
- back() {
- this.triggerEvent('back', '1')
- },
- tabPath(e) {
- this.triggerEvent('tabPath', e)
- },
- searchHeight() {
- let frameStyle = this.data.frameStyle;
- let client = app.globalData.client;
- let infoHeight = client.windowHeight;
- // 减去状态栏
- if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
- // 减去菜单栏
- if (frameStyle.useBar) infoHeight = infoHeight - 50;
- this.setData({ infoHeight: infoHeight })
- }
- }
- })
|