const tl_rtc_app_module_sidebar_tool = { props : { tools : { type : Array, default : [] }, isLogin: { type: Boolean, default: false }, isMobile: { type: Boolean, default: false }, user: { type: Object, default: function(){ return { id: '', name: '', avatar: '' } } }, leftModule: { type: String, default: '' }, rightModule: { type: String, default: '' } }, watch: { isMobile: { handler: function(){ this.initSwiper() }, immediate: true }, tools: { handler: function(val){ this.initSwiper() }, deep: true, immediate: true }, leftModule: function (val) { }, rightModule: function (val) { } }, computed: { propsTools(){ return this.tools; }, propsIsLogin(){ return this.isLogin; }, propsIsMobile(){ return this.isMobile; }, propsUser(){ return this.user; }, openMessageDot(){ return this.user.messageSetting.messageDot }, showToolCount(){ return this.propsTools.filter(item => item.show).length }, propsLeftModule() { return this.leftModule; }, propsRightModule() { return this.rightModule; }, }, methods: { /** * 事件触发,向上传递 * @param {*} event */ leftModuleChange: function(event){ this.$emit('left-module-change', event) }, /** * 事件触发,向上传递 * @param {*} event */ rightModuleChange: function(event){ this.$emit('right-module-change', event) }, /** * 点击工具栏 * @param {*} tool */ activeTool : function(tool){ // 如果是更多按钮,不改变active状态,直接调用handler if(tool.name === 'more') { tool.handler && tool.handler.call(this); return; } this.tools.map(item => { item.active = false; }) tool.active = true; tool.handler && tool.handler.call(this); }, mouseEnter: function(event, item){ if(this.propsIsMobile){ return } if(item.hover){ item.hover() return } tl_rtc_app_comm.mouseEnterTips({ id: event.target.id, text: item.title, position: 'right' }); }, mouseLeave: function(){ if(this.propsIsMobile){ return } tl_rtc_app_comm.mouseLeaveTips(); }, /** * 渲染swiper * @returns */ initSwiper: function(){ let that = this if(!this.propsIsMobile){ return } new Swiper('#sidebarToolListMobileSwiper', { slidesPerView: that.showToolCount > 4 ? 4 : that.showToolCount, direction: 'horizontal', loop: false, observer: true, mousewheel: false, // 鼠标滚轮控制 forceToAxis: true, // 滚动条只能在一个方向上拖动 spaceBetween: 0, freeMode: { momentumRatio: 1, // 惯性动量比 momentumBounceRatio: 0, // 滑动反弹 minimumVelocity: 0, // 最小滑动速度 } }); } }, data : function(){ return { swiper: null } }, mounted() { this.initSwiper() }, template: `