12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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
- })
- }
- }
- })
|