const { isEmpty } = require("../utils/util") // components/topbar.js Component({ externalClasses: ['topbar-class', 'topbar-title-class', 'back-color-class'], /** * 组件的属性列表 */ properties: { title: { type: String, value: '' }, backColor: { type: String, value: '' }, titleColor: { type: String, value: '' } }, /** * 组件的初始数据 */ data: { }, attached: function() { let dwObj = wx.getMenuButtonBoundingClientRect() let navHeight_ = (dwObj.top + dwObj.height) let capsuleTop_ = dwObj.top let windowHeight = wx.getSystemInfoSync().windowHeight const data = { navHeight: navHeight_, capsuleTop:capsuleTop_, capHeight: dwObj.height, bodyHeight: windowHeight - navHeight_, } if (!isEmpty(this.data.backColor)) { data.backStyle = "color:" + this.data.backColor + ";"; } if (!isEmpty(this.data.titleColor)) { data.titleStyle = "color:" + this.data.titleColor + ";" } this.setData(data); }, /** * 组件的方法列表 */ methods: { handleBack() { let routeLen = getCurrentPages().length; if (routeLen == 1) { wx.reLaunch({ url: '/pages/welfareMall/index/index', }) return } wx.navigateBack({ delta: -1 }) } } })