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,CAAA;AAxJoB,MAAM;IAD1B,WAAW,EAAE;GACO,MAAM,CAwJ1B;eAxJoB,MAAM","file":"navbar.js","sourcesContent":["import { SuperComponent, wxComponent } from '../common/src/index';\nimport config from '../common/config';\nimport props from './props';\n\nconst { prefix } = config;\nconst name = `${prefix}-navbar`;\n\n@wxComponent()\nexport default class Navbar extends SuperComponent {\n externalClasses = [\n 't-class',\n 't-class-title',\n 't-class-left',\n 't-class-center',\n 't-class-left-icon',\n 't-class-home-icon',\n 't-class-capsule',\n 't-class-nav-btn',\n ];\n\n timer = null;\n\n options = {\n addGlobalClass: true,\n multipleSlots: true,\n };\n\n properties = props;\n\n observers = {\n visible(this: Navbar, visible) {\n const { animation } = this.properties;\n const visibleClass = `${name}${visible ? '--visible' : '--hide'}`;\n this.setData({\n visibleClass: `${visibleClass}${animation ? '-animation' : ''}`,\n });\n if (this.timer) {\n clearTimeout(this.timer);\n }\n if (animation) {\n this.timer = setTimeout(() => {\n this.setData({\n visibleClass,\n });\n }, 300);\n }\n },\n fixed(this: Navbar, fixed) {\n this.setData({\n fixedClass: fixed ? `${name}--fixed` : '',\n });\n },\n background(this: Navbar, background) {\n const list = [];\n if (background) list.push(`background: ${background}`);\n this.setData({\n contentStyle: list.join(';'),\n });\n },\n 'homeIcon, leftIcon'(this: Navbar) {\n this.calcLeftBtn();\n },\n 'title,titleMaxLength'(this: any) {\n const { title } = this.properties;\n const titleMaxLength = this.properties.titleMaxLength || Number.MAX_SAFE_INTEGER;\n let temp = title.slice(0, titleMaxLength);\n if (titleMaxLength < title.length) temp += '...';\n this.setData({\n showTitle: temp,\n });\n },\n };\n\n data = {\n hasHomeIcon: false,\n hasBackIcon: false,\n\n classPrefix: name,\n fixedClass: `${name}--fixed`,\n\n contentStyle: '',\n boxStyle: '',\n\n opacity: 0.1,\n ios: false,\n delta: 1,\n showTitle: '',\n };\n\n attached() {\n this.calcLeftBtn(); // 根据页面栈来决定展示返回按钮还是home按钮\n // 场景值为1177(视频号直播间)和1175 (视频号profile页)时,小程序禁用了 wx.getMenuButtonBoundingClientRect\n let rect = null;\n if (wx.getMenuButtonBoundingClientRect) {\n rect = wx.getMenuButtonBoundingClientRect();\n }\n wx.getSystemInfo({\n success: (res) => {\n const ios = !!(res.system.toLowerCase().search('ios') + 1);\n const navbarHeight = ios ? 44 : 48;\n const boxStyleList = [];\n boxStyleList.push(\n `--narbar-padding-top:${(rect.bottom + rect.top) / 2 - navbarHeight / 2}px;`,\n );\n if (rect && res?.windowWidth) {\n boxStyleList.push(`--navbar-right:${res.windowWidth - rect.left}px;`); // 导航栏右侧小程序胶囊按钮宽度\n }\n boxStyleList.push(`--capsule-height:${rect.height}px;`); // 胶囊高度\n boxStyleList.push(`--capsule-wight:${rect.width}px;`); // 胶囊宽度\n boxStyleList.push(`--navbar-height:${navbarHeight}px;`); // navbar高度\n this.setData({\n ios,\n boxStyle: boxStyleList.join(';'),\n });\n },\n fail: (err) => {\n console.error('navbar 获取系统信息失败', err);\n },\n });\n }\n\n calcLeftBtn() {\n const { homeIcon, leftIcon } = this.properties as any;\n\n let home = false;\n let back = false;\n\n if (homeIcon) home = true;\n\n if (leftIcon) back = true;\n this.setData({\n hasHomeIcon: home,\n hasBackIcon: back,\n });\n }\n\n goHome() {\n this.triggerEvent('go-home');\n }\n\n goBack() {\n const { delta } = this.data;\n // eslint-disable-next-line\n const that = this;\n this.triggerEvent('go-back');\n if (delta > 0) {\n wx.navigateBack({\n delta,\n fail(e) {\n that.triggerEvent('fail', e);\n },\n complete(e) {\n that.triggerEvent('complete', e);\n },\n success(e) {\n that.triggerEvent('success', e);\n },\n });\n }\n }\n}\n"]}