123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var component_1 = require("../common/component");
- var utils_1 = require("../common/utils");
- (0, component_1.VantComponent)({
- classes: ['title-class'],
- props: {
- title: String,
- fixed: {
- type: Boolean,
- observer: 'setHeight',
- },
- placeholder: {
- type: Boolean,
- observer: 'setHeight',
- },
- leftText: String,
- rightText: String,
- customStyle: String,
- leftArrow: Boolean,
- border: {
- type: Boolean,
- value: true,
- },
- zIndex: {
- type: Number,
- value: 1,
- },
- safeAreaInsetTop: {
- type: Boolean,
- value: true,
- },
- // 新增参数
- background: {
- type: String,
- value: ''
- },
- color: {
- type: String,
- value: ''
- },
- iconColor: {
- type: String,
- value: 'rgba(0,0,0,0.9)'
- },
- borderColor: {
- type: String,
- value: '#d9d9dc'
- },
- back: {
- type: Boolean,
- value: true
- },
- tab: {
- type: String,
- value: ''
- },
- url: {
- type: String,
- value: ''
- },
- homeButton: {
- type: Boolean,
- value: false,
- },
- // back为true的时候,返回的页面深度
- delta: {
- type: Number,
- value: 1
- },
- },
- data: {
- height: 46,
- },
- created: function () {
- var statusBarHeight = (0, utils_1.getSystemInfoSync)().statusBarHeight;
- var menu = wx.getMenuButtonBoundingClientRect()
- this.setData({
- statusBarHeight: statusBarHeight,
- height: 46 + statusBarHeight,
- menuHeight:menu.height,
- menuTop:menu.top - statusBarHeight
- });
- },
- mounted: function () {
- this.setHeight();
- },
- methods: {
- back() {
- const data = this.data
- if (data.delta) {
- wx.navigateBack({
- delta: data.delta
- })
- }
- this.triggerEvent('back', { delta: data.delta }, {})
- },
- //回到首页点击事件
- home() {
- const data = this.data
- if (data.tab) {
- wx.switchTab({
- url: data.url,
- })
- } else {
- wx.navigateTo({
- url: data.url,
- })
- }
- //this.triggerEvent('home', { tab: data.tab, url: data.url }, {})
- },
- onClickLeft: function () {
- this.$emit('click-left');
- },
- onClickRight: function () {
- this.$emit('click-right');
- },
- setHeight: function () {
- var _this = this;
- if (!this.data.fixed || !this.data.placeholder) {
- return;
- }
- wx.nextTick(function () {
- (0, utils_1.getRect)(_this, '.van-nav-bar').then(function (res) {
- if (res && 'height' in res) {
- _this.setData({
- height: res.height
- });
- }
- });
- });
- },
- },
- });
|