You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
2.0 KiB
JavaScript
1 line
2.0 KiB
JavaScript
|
2 years ago
|
"use strict";function t(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Component({data:{ctrl:{}},properties:{childs:Array,opts:Array},attached:function(){this.triggerEvent("add",this,{bubbles:!0,composed:!0})},methods:{noop:function(){},getNode:function(t){for(var e=t.split("_"),r=this.data.childs[e[0]],i=1;i<e.length;i++)r=r.children[e[i]];return r},play:function(t){if(this.root.triggerEvent("play"),this.root.data.pauseVideo){for(var e=!1,r=t.target.id,i=this.root._videos.length;i--;)this.root._videos[i].id===r?e=!0:this.root._videos[i].pause();if(!e){var o=wx.createVideoContext(r,this);o.id=r,this.root._videos.push(o)}}},imgTap:function(t){var e=this.getNode(t.target.dataset.i);if(e.a)return this.linkTap(e.a);if(!e.attrs.ignore&&(this.root.triggerEvent("imgtap",e.attrs),this.root.data.previewImg)){var r=this.root.imgList[e.i];wx.previewImage({showmenu:this.root.data.showImgMenu,current:r,urls:this.root.imgList})}},imgLoad:function(e){var r,i=e.target.dataset.i,o=this.getNode(i);o.w?(this.data.opts[1]&&!this.data.ctrl[i]||-1===this.data.ctrl[i])&&(r=1):r=e.detail.width,r&&this.setData(t({},"ctrl."+i,r))},linkTap:function(t){var e=t.currentTarget?this.getNode(t.currentTarget.dataset.i):{},r=e.attrs||t,i=r.href;this.root.triggerEvent("linktap",Object.assign({innerText:this.root.getText(e.children||[])},r)),i&&("#"===i[0]?this.root.navigateTo(i.substring(1)).catch(function(){}):i.split("?")[0].includes("://")?this.root.data.copyLink&&wx.setClipboardData({data:i,success:function(){return wx.showToast({title:"链接已复制"})}}):wx.navigateTo({url:i,fail:function(){wx.switchTab({url:i,fail:function(){}})}}))},mediaError:function(e){var r=e.target.dataset.i,i=this.getNode(r);if("video"===i.name||"audio"===i.name){var o=(this.data.ctrl[r]||0)+1;if(o>i.src.length&&(o=0),o<i.src.length)return this.setData(t({},"ctrl."+r,o))}else"img"===i.name&&this.data.opts[2]&&this.setData(t({},"ctrl."+r,-1));this.root&&this.root.triggerEvent("error",{source:i.name,attrs:i.attrs,errMsg:e.detail.errMsg})}}});
|