Commit 08db4d37 by 杨北旺

首页

1 parent 27ec1eeb
"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}/*!
* mp-html v2.2.2
* https://github.com/jin-yufeng/mp-html
*
* Released under the MIT license
* Author: Jin Yufeng
*/
var t=require("./parser"),n=[];Component({data:{nodes:[]},properties:{containerStyle:String,content:{type:String,value:"",observer:function(e){this.setContent(e)}},copyLink:{type:Boolean,value:!0},domain:String,errorImg:String,lazyLoad:Boolean,loadingImg:String,pauseVideo:{type:Boolean,value:!0},previewImg:{type:Boolean,value:!0},scrollTable:Boolean,selectable:null,setTitle:{type:Boolean,value:!0},showImgMenu:{type:Boolean,value:!0},tagStyle:Object,useAnchor:null},created:function(){this.plugins=[];for(var e=n.length;e--;)this.plugins.push(new n[e](this))},detached:function(){clearInterval(this._timer),this._hook("onDetached")},methods:{in:function(e,t,n){e&&t&&n&&(this._in={page:e,selector:t,scrollTop:n})},navigateTo:function(t,n){var o=this;return new Promise(function(i,r){if(!o.data.useAnchor)return void r(Error("Anchor is disabled"));var a=wx.createSelectorQuery().in(o._in?o._in.page:o).select((o._in?o._in.selector:"._root")+(t?"".concat(">>>","#").concat(t):"")).boundingClientRect();o._in?a.select(o._in.selector).scrollOffset().select(o._in.selector).boundingClientRect():a.selectViewport().scrollOffset(),a.exec(function(t){if(!t[0])return void r(Error("Label not found"));var a=t[1].scrollTop+t[0].top-(t[2]?t[2].top:0)+(n||parseInt(o.data.useAnchor)||0);o._in?o._in.page.setData(e({},o._in.scrollTop,a)):wx.pageScrollTo({scrollTop:a,duration:300}),i()})})},getText:function(e){var t="";return function e(n){for(var o=0;o<n.length;o++){var i=n[o];if("text"===i.type)t+=i.text.replace(/&amp;/g,"&");else if("br"===i.name)t+="\n";else{var r="p"===i.name||"div"===i.name||"tr"===i.name||"li"===i.name||"h"===i.name[0]&&i.name[1]>"0"&&i.name[1]<"7";r&&t&&"\n"!==t[t.length-1]&&(t+="\n"),i.children&&e(i.children),r&&"\n"!==t[t.length-1]?t+="\n":"td"!==i.name&&"th"!==i.name||(t+="\t")}}}(e||this.data.nodes),t},getRect:function(){var e=this;return new Promise(function(t,n){wx.createSelectorQuery().in(e).select("._root").boundingClientRect().exec(function(e){return e[0]?t(e[0]):n(Error("Root label not found"))})})},pauseMedia:function(){for(var e=(this._videos||[]).length;e--;)this._videos[e].pause()},setContent:function(e,n){var o=this;this.imgList&&n||(this.imgList=[]),this._videos=[];var i={},r=new t(this).parse(e);if(n)for(var a=this.data.nodes.length,l=r.length;l--;)i["nodes[".concat(a+l,"]")]=r[l];else i.nodes=r;this.setData(i,function(){o._hook("onLoad"),o.triggerEvent("load")});var s;clearInterval(this._timer),this._timer=setInterval(function(){o.getRect().then(function(e){e.height===s&&(o.triggerEvent("ready",e),clearInterval(o._timer)),s=e.height}).catch(function(){})},350)},_hook:function(e){for(var t=n.length;t--;)this.plugins[t][e]&&this.plugins[t][e]()},_add:function(e){e.detail.root=this}}});
\ No newline at end of file \ No newline at end of file
{"component":true,"usingComponents":{"node":"./node/node"}}
\ No newline at end of file \ No newline at end of file
<view class="_root {{selectable?'_select':''}}" style="{{containerStyle}}"><slot wx:if="{{!nodes[0]}}"/><node id="_root" childs="{{nodes}}" opts="{{[lazyLoad,loadingImg,errorImg]}}" catchadd="_add"/></view>
\ No newline at end of file \ No newline at end of file
._root{padding:1px 0;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}._select{-webkit-user-select:text;user-select:text}
\ No newline at end of file \ No newline at end of file
"use strict";function t(t,i,e){return i in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,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 i=t.split("_"),e=this.data.childs[i[0]],r=1;r<i.length;r++)e=e.children[i[r]];return e},play:function(t){if(this.root.data.pauseVideo){for(var i=!1,e=t.target.id,r=this.root._videos.length;r--;)this.root._videos[r].id===e?i=!0:this.root._videos[r].pause();if(!i){var s=wx.createVideoContext(e,this);s.id=e,this.root._videos.push(s)}}},imgTap:function(t){var i=this.getNode(t.target.dataset.i);if(i.a)return this.linkTap(i.a);if(!i.attrs.ignore&&(this.root.triggerEvent("imgtap",i.attrs),this.root.data.previewImg)){var e=this.root.imgList[i.i];wx.previewImage({current:e,urls:this.root.imgList})}},imgLoad:function(i){var e,r=i.target.dataset.i,s=this.getNode(r);s.w?(this.data.opts[1]&&!this.data.ctrl[r]||-1===this.data.ctrl[r])&&(e=1):e=i.detail.width,e&&this.setData(t({},"ctrl."+r,e))},linkTap:function(t){var i=t.currentTarget?this.getNode(t.currentTarget.dataset.i):{},e=i.attrs||t,r=e.href;this.root.triggerEvent("linktap",Object.assign({innerText:this.root.getText(i.children||[])},e)),r&&("#"===r[0]?this.root.navigateTo(r.substring(1)).catch(function(){}):r.split("?")[0].includes("://")?this.root.data.copyLink&&wx.setClipboardData({data:r,success:function(){return wx.showToast({title:"链接已复制"})}}):wx.navigateTo({url:r,fail:function(){wx.switchTab({url:r,fail:function(){}})}}))},mediaError:function(i){var e=i.target.dataset.i,r=this.getNode(e);if("video"===r.name||"audio"===r.name){var s=(this.data.ctrl[e]||0)+1;if(s>r.src.length&&(s=0),s<r.src.length)return this.setData(t({},"ctrl."+e,s))}else"img"===r.name&&this.data.opts[2]&&this.setData(t({},"ctrl."+e,-1));this.root&&this.root.triggerEvent("error",{source:r.name,attrs:r.attrs,errMsg:i.detail.errMsg})}}});
\ No newline at end of file \ No newline at end of file
{"component":true,"usingComponents":{"node":"./node"}}
\ No newline at end of file \ No newline at end of file
<wxs module="use">var e={abbr:!0,b:!0,big:!0,code:!0,del:!0,em:!0,i:!0,ins:!0,label:!0,q:!0,small:!0,span:!0,strong:!0,sub:!0,sup:!0};module.exports=function(n){return!n.c&&(!n.children||"a"===n.name||!e[n.name]&&-1===(n.attrs.style||"").indexOf("inline"))};</wxs><template name="el"><block wx:if="{{n.name==='img'}}"><image wx:if="{{(opts[1]&&!ctrl[i])||ctrl[i]<0}}" class="_img" style="{{n.attrs.style}}" src="{{ctrl[i]<0?opts[2]:opts[1]}}" mode="widthFix"/><image id="{{n.attrs.id}}" class="_img {{n.attrs.class}}" style="{{ctrl[i]===-1?'display:none;':''}}width:{{ctrl[i]||1}}px;height:1px;{{n.attrs.style}}" src="{{n.attrs.src}}" mode="{{n.h?'':'widthFix'}}" lazy-load="{{opts[0]}}" webp="{{n.webp}}" show-menu-by-longpress="{{opts[3]&&!n.attrs.ignore}}" data-i="{{i}}" bindload="imgLoad" binderror="mediaError" catchtap="{{opts[4] ? 'imgTap' : ''}}" bindlongpress="noop"/></block><text wx:elif="{{n.text}}" user-select="{{n.us}}" decode>{{n.text}}</text><text wx:elif="{{n.name==='br'}}">\n</text><view wx:elif="{{n.name==='a'}}" id="{{n.attrs.id}}" class="{{n.attrs.href?'_a ':''}}{{n.attrs.class}}" hover-class="_hover" style="display:inline;{{n.attrs.style}}" data-i="{{i}}" catchtap="linkTap"><node childs="{{n.children}}" opts="{{opts}}" style="display:inherit"/></view><video wx:elif="{{n.name==='video'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" autoplay="{{n.attrs.autoplay}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" muted="{{n.attrs.muted}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" bindplay="play" binderror="mediaError"/><audio wx:elif="{{n.name==='audio'}}" id="{{n.attrs.id}}" class="{{n.attrs.class}}" style="{{n.attrs.style}}" author="{{n.attrs.author}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" name="{{n.attrs.name}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" bindplay="play" binderror="mediaError"/><rich-text wx:else id="{{n.attrs.id}}" style="{{n.f}}" nodes="{{[n]}}"/></template><block wx:for="{{childs}}" wx:for-item="n1" wx:for-index="i1" wx:key="i1"><template wx:if="{{use(n1)}}" is="el" data="{{n:n1,i:''+i1,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n1.attrs.id}}" class="_{{n1.name}} {{n1.attrs.class}}" style="{{n1.attrs.style}}"><block wx:for="{{n1.children}}" wx:for-item="n2" wx:for-index="i2" wx:key="i2"><template wx:if="{{use(n2)}}" is="el" data="{{n:n2,i:i1+'_'+i2,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n2.attrs.id}}" class="_{{n2.name}} {{n2.attrs.class}}" style="{{n2.attrs.style}}"><block wx:for="{{n2.children}}" wx:for-item="n3" wx:for-index="i3" wx:key="i3"><template wx:if="{{use(n3)}}" is="el" data="{{n:n3,i:i1+'_'+i2+'_'+i3,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n3.attrs.id}}" class="_{{n3.name}} {{n3.attrs.class}}" style="{{n3.attrs.style}}"><block wx:for="{{n3.children}}" wx:for-item="n4" wx:for-index="i4" wx:key="i4"><template wx:if="{{use(n4)}}" is="el" data="{{n:n4,i:i1+'_'+i2+'_'+i3+'_'+i4,opts:opts,ctrl:ctrl}}"/><view wx:else id="{{n4.attrs.id}}" class="_{{n4.name}} {{n4.attrs.class}}" style="{{n4.attrs.style}}"><block wx:for="{{n4.children}}" wx:for-item="n5" wx:for-index="i5" wx:key="i5"><template wx:if="{{use(n5)}}" is="el" data="{{n:n5,i:i1+'_'+i2+'_'+i3+'_'+i4+'_'+i5,opts:opts,ctrl:ctrl}}"/><node wx:else id="{{n5.attrs.id}}" class="_{{n5.name}} {{n5.attrs.class}}" style="{{n5.attrs.style}}" childs="{{n5.children}}" opts="{{opts}}"/></block></view></block></view></block></view></block></view></block>
\ No newline at end of file \ No newline at end of file
._a{padding:1.5px 0 1.5px 0;color:#366092;word-break:break-all}._hover{text-decoration:underline;opacity:.7}._img{max-width:100%;-webkit-touch-callout:none}._b,._strong{font-weight:700}._code{font-family:monospace}._del{text-decoration:line-through}._em,._i{font-style:italic}._h1{font-size:2em}._h2{font-size:1.5em}._h3{font-size:1.17em}._h5{font-size:.83em}._h6{font-size:.67em}._h1,._h2,._h3,._h4,._h5,._h6{display:block;font-weight:700}._ins{text-decoration:underline}._li{display:list-item}._ol{list-style-type:decimal}._ol,._ul{display:block;padding-left:40px;margin:1em 0}._q::before{content:'"'}._q::after{content:'"'}._sub{font-size:smaller;vertical-align:sub}._sup{font-size:smaller;vertical-align:super}._tbody,._tfoot,._thead{display:table-row-group}._tr{display:table-row}._td,._th{display:table-cell;vertical-align:middle}._th{font-weight:700;text-align:center}._ul{list-style-type:disc}._ul ._ul{margin:0;list-style-type:circle}._ul ._ul ._ul{list-style-type:square}._abbr,._b,._code,._del,._em,._i,._ins,._label,._q,._span,._strong,._sub,._sup{display:inline}._blockquote,._div,._p{display:block}
\ No newline at end of file \ No newline at end of file
"use strict";function t(t){for(var i=Object.create(null),e=t.split(","),s=e.length;s--;)i[e[s]]=!0;return i}function i(t,i){for(var e=t.indexOf("&");-1!==e;){var s=t.indexOf(";",e+3),n=void 0;if(-1===s)break;"#"===t[e+1]?(n=parseInt(("x"===t[e+2]?"0":"")+t.substring(e+2,s)),isNaN(n)||(t=t.substr(0,e)+String.fromCharCode(n)+t.substr(s+1))):(n=t.substring(e+1,s),(a.entities[n]||"amp"===n&&i)&&(t=t.substr(0,e)+(a.entities[n]||"&")+t.substr(s+1))),e=t.indexOf("&",e+1)}return t}function e(t){this.options=t.data||{},this.tagStyle=Object.assign({},a.tagStyle,this.options.tagStyle),this.imgList=t.imgList||[],this.plugins=t.plugins||[],this.attrs=Object.create(null),this.stack=[],this.nodes=[],this.pre=(this.options.containerStyle||"").includes("white-space")&&this.options.containerStyle.includes("pre")?2:0}function s(t){this.handler=t}var a={trustTags:t("a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,ruby,rt,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video"),blockTags:t("address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section"),ignoreTags:t("area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr"),voidTags:t("area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr"),entities:{lt:"<",gt:">",quot:'"',apos:"'",ensp:" ",emsp:" ",nbsp:" ",semi:";",ndash:"–",mdash:"—",middot:"·",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",bull:"•",hellip:"…"},tagStyle:{address:"font-style:italic",big:"display:inline;font-size:1.2em",caption:"display:table-caption;text-align:center",center:"text-align:center",cite:"font-style:italic",dd:"margin-left:40px",mark:"background-color:yellow",pre:"font-family:monospace;white-space:pre",s:"text-decoration:line-through",small:"display:inline;font-size:0.8em",strike:"text-decoration:line-through",u:"text-decoration:underline"},svgDict:{animatetransform:"animateTransform",lineargradient:"linearGradient",viewbox:"viewBox",attributename:"attributeName",repeatcount:"repeatCount",repeatdur:"repeatDur"}},n={},r=wx.getSystemInfoSync(),o=r.windowWidth,h=r.system,l=t(" ,\r,\n,\t,\f"),c=0;e.prototype.parse=function(t){for(var i=this.plugins.length;i--;)this.plugins[i].onUpdate&&(t=this.plugins[i].onUpdate(t,a)||t);for(new s(this).parse(t);this.stack.length;)this.popNode();return this.nodes},e.prototype.expose=function(){for(var t=this.stack.length;t--;){var i=this.stack[t];if(i.c||"a"===i.name||"video"===i.name||"audio"===i.name)return;i.c=1}},e.prototype.hook=function(t){for(var i=this.plugins.length;i--;)if(this.plugins[i].onParse&&!1===this.plugins[i].onParse(t,this))return!1;return!0},e.prototype.getUrl=function(t){var i=this.options.domain;return"/"===t[0]?"/"===t[1]?t=(i?i.split("://")[0]:"http")+":"+t:i&&(t=i+t):!i||t.includes("data:")||t.includes("://")||(t=i+"/"+t),t},e.prototype.parseStyle=function(t){var i=t.attrs,e=(this.tagStyle[t.name]||"").split(";").concat((i.style||"").split(";")),s={},a="";i.id&&!this.xml&&(this.options.useAnchor?this.expose():"img"!==t.name&&"a"!==t.name&&"video"!==t.name&&"audio"!==t.name&&(i.id=void 0)),i.width&&(s.width=parseFloat(i.width)+(i.width.includes("%")?"%":"px"),i.width=void 0),i.height&&(s.height=parseFloat(i.height)+(i.height.includes("%")?"%":"px"),i.height=void 0);for(var n=0,r=e.length;n<r;n++){var h=e[n].split(":");if(!(h.length<2)){var c=h.shift().trim().toLowerCase(),d=h.join(":").trim();if("-"===d[0]&&d.lastIndexOf("-")>0||d.includes("safe"))a+=";".concat(c,":").concat(d);else if(!s[c]||d.includes("import")||!s[c].includes("import")){if(d.includes("url")){var p=d.indexOf("(")+1;if(p){for(;'"'===d[p]||"'"===d[p]||l[d[p]];)p++;d=d.substr(0,p)+this.getUrl(d.substr(p))}}else d.includes("rpx")&&(d=d.replace(/[0-9.]+\s*rpx/g,function(t){return parseFloat(t)*o/750+"px"}));s[c]=d}}}return t.attrs.style=a,s},e.prototype.onTagName=function(t){this.tagName=this.xml?t:t.toLowerCase(),"svg"===this.tagName&&(this.xml=(this.xml||0)+1)},e.prototype.onAttrName=function(t){t=this.xml?t:t.toLowerCase(),"data-"===t.substr(0,5)?"data-src"!==t||this.attrs.src?"img"===this.tagName||"a"===this.tagName?this.attrName=t:this.attrName=void 0:this.attrName="src":(this.attrName=t,this.attrs[t]="T")},e.prototype.onAttrVal=function(t){var e=this.attrName||"";"style"===e||"href"===e?this.attrs[e]=i(t,!0):e.includes("src")?this.attrs[e]=this.getUrl(i(t,!0)):e&&(this.attrs[e]=t)},e.prototype.onOpenTag=function(t){var i=Object.create(null);i.name=this.tagName,i.attrs=this.attrs,this.attrs=Object.create(null);var e=i.attrs,s=this.stack[this.stack.length-1],r=s?s.children:this.nodes,h=this.xml?t:a.voidTags[i.name];if(n[i.name]&&(e.class=n[i.name]+(e.class?" "+e.class:"")),"embed"===i.name){var l=e.src||"";l.includes(".mp4")||l.includes(".3gp")||l.includes(".m3u8")||(e.type||"").includes("video")?i.name="video":(l.includes(".mp3")||l.includes(".wav")||l.includes(".aac")||l.includes(".m4a")||(e.type||"").includes("audio"))&&(i.name="audio"),e.autostart&&(e.autoplay="T"),e.controls="T"}if("video"!==i.name&&"audio"!==i.name||("video"!==i.name||e.id||(e.id="v"+c++),e.controls||e.autoplay||(e.controls="T"),i.src=[],e.src&&(i.src.push(e.src),e.src=void 0),this.expose()),h){if(!this.hook(i)||a.ignoreTags[i.name])return void("base"!==i.name||this.options.domain?"source"===i.name&&s&&("video"===s.name||"audio"===s.name)&&e.src&&s.src.push(e.src):this.options.domain=e.href);var d=this.parseStyle(i);if("img"===i.name){if(e.src&&(e.src.includes("webp")&&(i.webp="T"),e.src.includes("data:")&&!e["original-src"]&&(e.ignore="T"),!e.ignore||i.webp||e.src.includes("cloud://"))){for(var p=this.stack.length;p--;){var u=this.stack[p];if("a"===u.name){i.a=u.attrs;break}var g=u.attrs.style||"";if(!g.includes("flex:")||g.includes("flex:0")||g.includes("flex: 0")||d.width&&d.width.includes("%"))if(g.includes("flex")&&"100%"===d.width)for(var f=p+1;f<this.stack.length;f++){var m=this.stack[f].attrs.style||"";if(!m.includes(";width")&&!m.includes(" width")&&0!==m.indexOf("width")){d.width="";break}}else g.includes("inline-block")&&(d.width&&"%"===d.width[d.width.length-1]?(u.attrs.style+=";max-width:"+d.width,d.width=""):u.attrs.style+=";max-width:100%");else{d.width="100% !important",d.height="";for(var v=p+1;v<this.stack.length;v++)this.stack[v].attrs.style=(this.stack[v].attrs.style||"").replace("inline-","")}u.c=1}i.i=this.imgList.length;var y=e["original-src"]||e.src;if(this.imgList.includes(y)){var x=y.indexOf("://");if(-1!==x){x+=3;for(var b=y.substr(0,x);x<y.length&&"/"!==y[x];x++)b+=Math.random()>.5?y[x].toUpperCase():y[x];b+=y.substr(x),y=b}}this.imgList.push(y)}"inline"===d.display&&(d.display=""),e.ignore&&(d["max-width"]=d["max-width"]||"100%",e.style+=";-webkit-touch-callout:none"),parseInt(d.width)>o&&(d.height=void 0),d.width&&(d.width.includes("auto")?d.width="":(i.w="T",!isNaN(parseInt(d.height))&&(!d.height.includes("%")||s&&(s.attrs.style||"").includes("height"))&&(i.h="T")))}else if("svg"===i.name)return r.push(i),this.stack.push(i),void this.popNode();for(var w in d)d[w]&&(e.style+=";".concat(w,":").concat(d[w].replace(" !important","")));e.style=e.style.substr(1)||void 0}else("pre"===i.name||(e.style||"").includes("white-space")&&e.style.includes("pre"))&&2!==this.pre&&(this.pre=i.pre=1),i.children=[],this.stack.push(i);r.push(i)},e.prototype.onCloseTag=function(t){t=this.xml?t:t.toLowerCase();var i;for(i=this.stack.length;i--&&this.stack[i].name!==t;);if(-1!==i)for(;this.stack.length>i;)this.popNode();else if("p"===t||"br"===t){var e=this.stack.length?this.stack[this.stack.length-1].children:this.nodes;e.push({name:t,attrs:{class:n[t],style:this.tagStyle[t]}})}},e.prototype.popNode=function(){var t=this.stack.pop(),i=t.attrs,e=t.children,s=this.stack[this.stack.length-1],n=s?s.children:this.nodes;if(!this.hook(t)||a.ignoreTags[t.name])return"title"===t.name&&e.length&&"text"===e[0].type&&this.options.setTitle&&wx.setNavigationBarTitle({title:e[0].text}),void n.pop();if(t.pre&&2!==this.pre){this.pre=t.pre=void 0;for(var r=this.stack.length;r--;)this.stack[r].pre&&(this.pre=1)}if("svg"===t.name){if(this.xml>1)return void this.xml--;var h="",l=i.style;return i.style="",i.xmlns="http://www.w3.org/2000/svg",function t(i){if("text"===i.type)return void(h+=i.text);var e=a.svgDict[i.name]||i.name;h+="<"+e;for(var s in i.attrs){var n=i.attrs[s];n&&(h+=" ".concat(a.svgDict[s]||s,'="').concat(n,'"'))}if(i.children){h+=">";for(var r=0;r<i.children.length;r++)t(i.children[r]);h+="</"+e+">"}else h+="/>"}(t),t.name="img",t.attrs={src:"data:image/svg+xml;utf8,"+h.replace(/#/g,"%23"),style:l,ignore:"T"},t.children=void 0,void(this.xml=!1)}var c={};if(i.align&&("table"===t.name?"center"===i.align?c["margin-inline-start"]=c["margin-inline-end"]="auto":c.float=i.align:c["text-align"]=i.align,i.align=void 0),i.dir&&(c.direction=i.dir,i.dir=void 0),"font"===t.name&&(i.color&&(c.color=i.color,i.color=void 0),i.face&&(c["font-family"]=i.face,i.face=void 0),i.size)){var d=parseInt(i.size);isNaN(d)||(d<1?d=1:d>7&&(d=7),c["font-size"]=["x-small","small","medium","large","x-large","xx-large","xxx-large"][d-1]),i.size=void 0}if((i.class||"").includes("align-center")&&(c["text-align"]="center"),Object.assign(c,this.parseStyle(t)),"table"!==t.name&&parseInt(c.width)>o&&(c["max-width"]="100%",c["box-sizing"]="border-box"),a.blockTags[t.name])t.name="div";else if(a.trustTags[t.name]||this.xml)if("a"===t.name||"ad"===t.name)this.expose();else if("video"===t.name||"audio"===t.name)t.children=void 0;else if("ul"!==t.name&&"ol"!==t.name||!t.c){if("table"===t.name){var p=parseFloat(i.cellpadding),u=parseFloat(i.cellspacing),g=parseFloat(i.border);if(t.c&&(isNaN(p)&&(p=2),isNaN(u)&&(u=2)),g&&(i.style+=";border:"+g+"px solid gray"),t.flag&&t.c){t.flag=void 0,c.display="grid",u?(c["grid-gap"]=u+"px",c.padding=u+"px"):g&&(i.style+=";border-left:0;border-top:0");var f=[],m=[],v=[],y={};!function t(i){for(var e=0;e<i.length;e++)"tr"===i[e].name?m.push(i[e]):t(i[e].children||[])}(e);for(var x=1;x<=m.length;x++){for(var b=1,w=0;w<m[x-1].children.length;w++,b++){var k=m[x-1].children[w];if("td"===k.name||"th"===k.name){for(;y[x+"."+b];)b++;k.c=1;var N=k.attrs.style||"",T=N.indexOf("width")?N.indexOf(";width"):0;if(-1!==T){var O=N.indexOf(";",T+6);-1===O&&(O=N.length),k.attrs.colspan||(f[b]=N.substring(T?T+7:6,O)),N=N.substr(0,T)+N.substr(O)}if(N+=(g?";border:".concat(g,"px solid gray")+(u?"":";border-right:0;border-bottom:0"):"")+(p?";padding:".concat(p,"px"):""),k.attrs.colspan&&(N+=";grid-column-start:".concat(b,";grid-column-end:").concat(b+parseInt(k.attrs.colspan)),k.attrs.rowspan||(N+=";grid-row-start:".concat(x,";grid-row-end:").concat(x+1)),b+=parseInt(k.attrs.colspan)-1),k.attrs.rowspan){N+=";grid-row-start:".concat(x,";grid-row-end:").concat(x+parseInt(k.attrs.rowspan)),k.attrs.colspan||(N+=";grid-column-start:".concat(b,";grid-column-end:").concat(b+1));for(var C=1;C<k.attrs.rowspan;C++)for(var S=0;S<(k.attrs.colspan||1);S++)y[x+C+"."+(b-S)]=1}N&&(k.attrs.style=N),v.push(k)}}if(1===x){for(var A="",I=1;I<b;I++)A+=(f[I]?f[I]:"auto")+" ";c["grid-template-columns"]=A}}t.children=v}else t.c&&(c.display="table"),isNaN(u)||(c["border-spacing"]=u+"px"),(g||p||t.c)&&function i(e){for(var s=0;s<e.length;s++){var a=e[s];t.c&&(a.c=1),"th"===a.name||"td"===a.name?(g&&(a.attrs.style="border:".concat(g,"px solid gray;").concat(a.attrs.style||"")),p&&(a.attrs.style="padding:".concat(p,"px;").concat(a.attrs.style||""))):a.children&&i(a.children)}}(e);if(this.options.scrollTable&&!(i.style||"").includes("inline")){var z=Object.assign({},t);t.name="div",t.attrs={style:"overflow-x:auto;padding:1px"},t.children=[z],i=z.attrs}}else if("td"!==t.name&&"th"!==t.name||!i.colspan&&!i.rowspan){if("ruby"===t.name){t.name="span";for(var j=0;j<e.length-1;j++)"text"===e[j].type&&"rt"===e[j+1].name&&(e[j]={name:"span",attrs:{style:"display:inline-block;text-align:center"},children:[{name:"div",attrs:{style:"font-size:50%;"+(e[j+1].attrs.style||"")},children:e[j+1].children},e[j]]},e.splice(j+1,1))}}else for(var L=this.stack.length;L--;)if("table"===this.stack[L].name){this.stack[L].flag=1;break}}else{var q={a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};q[i.type]&&(i.style+=";list-style-type:"+q[i.type],i.type=void 0),t.c=1;for(var F=e.length;F--;)"li"===e[F].name&&(e[F].c=1)}else t.name="span";if((c.display||"").includes("flex")&&!t.c)for(var U=e.length;U--;){var V=e[U];V.f&&(V.attrs.style=(V.attrs.style||"")+V.f,V.f=void 0)}var D=s&&(s.attrs.style||"").includes("flex")&&!t.c&&!(c.display||"").includes("inline");if(D&&(t.f=";max-width:100%"),e.length>=50&&t.c&&!(c.display||"").includes("flex"))for(var B=e.length-1,P=B;P>=-1;P--)(-1===P||e[P].c||!e[P].name||"div"!==e[P].name&&"p"!==e[P].name&&"h"!==e[P].name[0]||(e[P].attrs.style||"").includes("inline"))&&(B-P>=5&&e.splice(P+1,B-P,{name:"div",attrs:{},children:t.children.slice(P+1,B+1)}),B=P-1);for(var Z in c)if(c[Z]){var G=";".concat(Z,":").concat(c[Z].replace(" !important",""));D&&(Z.includes("flex")&&"flex-direction"!==Z||"align-self"===Z||"-"===c[Z][0]||"width"===Z&&G.includes("%"))?(t.f+=G,"width"===Z&&(i.style+=";width:100%")):i.style+=G}i.style=i.style.substr(1)||void 0},e.prototype.onText=function(t){if(!this.pre){for(var e,s="",a=0,n=t.length;a<n;a++)l[t[a]]?(" "!==s[s.length-1]&&(s+=" "),"\n"!==t[a]||e||(e=!0)):s+=t[a];if(" "===s&&e)return;t=s}var r=Object.create(null);if(r.type="text",r.text=i(t),this.hook(r)){"force"===this.options.selectable&&h.includes("iOS")&&(this.expose(),r.us="T");(this.stack.length?this.stack[this.stack.length-1].children:this.nodes).push(r)}},s.prototype.parse=function(t){this.content=t||"",this.i=0,this.start=0,this.state=this.text;for(var i=this.content.length;-1!==this.i&&this.i<i;)this.state()},s.prototype.checkClose=function(t){var i="/"===this.content[this.i];return!!(">"===this.content[this.i]||i&&">"===this.content[this.i+1])&&(t&&this.handler[t](this.content.substring(this.start,this.i)),this.i+=i?2:1,this.start=this.i,this.handler.onOpenTag(i),"script"===this.handler.tagName?(this.i=this.content.indexOf("</",this.i),-1!==this.i&&(this.i+=2,this.start=this.i),this.state=this.endTag):this.state=this.text,!0)},s.prototype.text=function(){if(this.i=this.content.indexOf("<",this.i),-1===this.i)return void(this.start<this.content.length&&this.handler.onText(this.content.substring(this.start,this.content.length)));var t=this.content[this.i+1];if(t>="a"&&t<="z"||t>="A"&&t<="Z")this.start!==this.i&&this.handler.onText(this.content.substring(this.start,this.i)),this.start=++this.i,this.state=this.tagName;else if("/"===t||"!"===t||"?"===t){this.start!==this.i&&this.handler.onText(this.content.substring(this.start,this.i));var i=this.content[this.i+2];if("/"===t&&(i>="a"&&i<="z"||i>="A"&&i<="Z"))return this.i+=2,this.start=this.i,void(this.state=this.endTag);var e="--\x3e";"!"===t&&"-"===this.content[this.i+2]&&"-"===this.content[this.i+3]||(e=">"),this.i=this.content.indexOf(e,this.i),-1!==this.i&&(this.i+=e.length,this.start=this.i)}else this.i++},s.prototype.tagName=function(){if(l[this.content[this.i]]){for(this.handler.onTagName(this.content.substring(this.start,this.i));l[this.content[++this.i]];);this.i<this.content.length&&!this.checkClose()&&(this.start=this.i,this.state=this.attrName)}else this.checkClose("onTagName")||this.i++},s.prototype.attrName=function(){var t=this.content[this.i];if(l[t]||"="===t){this.handler.onAttrName(this.content.substring(this.start,this.i));for(var i="="===t,e=this.content.length;++this.i<e;)if(t=this.content[this.i],!l[t]){if(this.checkClose())return;if(i)return this.start=this.i,void(this.state=this.attrVal);if("="!==this.content[this.i])return this.start=this.i,void(this.state=this.attrName);i=!0}}else this.checkClose("onAttrName")||this.i++},s.prototype.attrVal=function(){var t=this.content[this.i],i=this.content.length;if('"'===t||"'"===t){if(this.start=++this.i,this.i=this.content.indexOf(t,this.i),-1===this.i)return;this.handler.onAttrVal(this.content.substring(this.start,this.i))}else for(;this.i<i;this.i++){if(l[this.content[this.i]]){this.handler.onAttrVal(this.content.substring(this.start,this.i));break}if(this.checkClose("onAttrVal"))return}for(;l[this.content[++this.i]];);this.i<i&&!this.checkClose()&&(this.start=this.i,this.state=this.attrName)},s.prototype.endTag=function(){var t=this.content[this.i];if(l[t]||">"===t||"/"===t){if(this.handler.onCloseTag(this.content.substring(this.start,this.i)),">"!==t&&(this.i=this.content.indexOf(">",this.i),-1===this.i))return;this.start=++this.i,this.state=this.text}else this.i++},module.exports=e;
\ No newline at end of file \ No newline at end of file
// components/banner/banner.js
Component({
/**
* 组件的属性列表
*/
properties: {
bannerList: {
type: Array,
value: []
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
jumpGoods(e) {
let {
id,
url,
equity,
item
} = e.currentTarget.dataset
if (id) {
wx.$router.go('/packageShopmall/packageMall/pages/detail/detail', {
id,
isActivity: false,
notIntercept: true
})
} else if (equity) {
wx.$router.go('/packageShopmall/packageEquity/pages/allEquity/allEquity')
} else {
if (url) wx.$router.go('/packageShopmall/packageIndex/pages/bannerJumpPage/bannerJumpPage', item)
}
},
changePage(e) {
let {
bannerList
} = this.data
bannerList.map(i => i.active = false)
let {
current
} = e.detail
bannerList[current].active = true
this.setData({
bannerList
})
},
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {
},
"component": true
}
\ No newline at end of file \ No newline at end of file
<block>
<view class="banner">
<swiper class="swiper" bindchange="changePage" autoplay interval="5000">
<block wx:for="{{bannerList}}" wx:key="index">
<swiper-item>
<block>
<image webp src="{{item.bannerImg}}" class="banner-img" bindtap="jumpGoods" data-item="{{item}}" data-bannerType="{{item.bannerType}}" data-id="{{item.goods.id}}" data-url="{{item.linkUrl}}" data-equity="{{item.equity}}"></image>
</block>
</swiper-item>
</block>
</swiper>
<block wx:if="{{bannerList.length > 1}}">
<view class="banner-dots">
<block wx:for="{{bannerList}}" wx:key="index">
<view class="dots {{item.active?'active':''}}"></view>
</block>
</view>
</block>
</view>
</block>
.banner {
padding: 0rpx 30rpx 30rpx;
position: relative;
height: 268rpx;
overflow: hidden;
position: relative;
border-radius: 16rpx;
}
.banner .swiper {
height: 100%;
border-radius: 16rpx;
overflow: hidden;
position: relative;
transform: translateY(0);
}
.banner .swiper.border {
border: 16rpx solid #fff;
box-sizing: border-box;
background: #D6D6D6;
}
.banner .swiper .logo {
left: 50%;
}
.banner .swiper-item,
.banner .banner-img {
border-radius: 16rpx;
overflow: hidden;
}
.banner .banner-dots {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
width: 100%;
bottom: 52rpx;
left: 0;
}
.banner .banner-dots .dots {
width: 12rpx;
height: 4rpx;
margin: 0 6rpx;
border-radius: 3rpx;
background-color: rgba(0, 0, 0, .5);
transition: all .5s;
}
.banner .banner-dots .dots.active {
background-color: #2A69FF;
}
\ No newline at end of file \ No newline at end of file
// components/marquee/marquee.js
let timer = null
Component({
/**
* 组件的属性列表
*/
properties: {
data: {
type: String,
observer: function (n) {
if (n) this.begin()
}
},
delay: {
type: Number,
value: 1000
},
fontSize: {
type: Number,
value: 11
},
speed: {
type: Number,
value: 5000
}
},
/**
* 组件的初始数据
*/
data: {
flag: true,
show: true,
IMGURL: wx.$imgUrl
},
/**
* 组件的方法列表
*/
methods: {
/**
* 获取宽度
*/
begin() {
let boxWidth = 0
let valueWidth = 0
wx.p.wxApi.getViewInfo(
'#marquee',
res => {
boxWidth = res.width
this.setData({
boxWidth
})
wx.p.wxApi.getViewInfo(
'#content',
contentInfo => {
valueWidth = contentInfo.width
if (boxWidth - 20 <= valueWidth) {
this.setData({
valueWidth,
isRun: true
})
this.run()
}
},
this
)
},
this
)
},
run() {
clearTimeout(timer)
wx.p.util
.promise(resolve => {
let {
speed,
delay,
valueWidth
} = this.data
let animation = wx
.createAnimation({
duration: speed,
timingFunction: 'linear',
delay
})
.left(`-${valueWidth}px`)
.step()
this.setData({
animation: animation.export()
})
let time = Number(delay) + Number(speed) + 1000
timer = setTimeout(() => {
resolve()
}, time)
})
.then(() => {
this.setData({
flag: false
})
this.again()
})
},
again() {
clearTimeout(timer)
wx.p.util
.promise(resolve => {
let {
boxWidth
} = this.data
let animation = wx
.createAnimation({
duration: 1,
timingFunction: 'linear'
})
.left(`${boxWidth}px`)
.step()
this.setData({
animation: animation.export()
})
timer = setTimeout(() => {
resolve()
}, 500)
})
.then(() => {
this.setData({
flag: true
})
this.reset()
})
},
reset() {
clearTimeout(timer)
wx.p.util
.promise(resolve => {
let {
valueWidth,
boxWidth,
speed
} = this.data
let animation = wx
.createAnimation({
duration: speed * (boxWidth / valueWidth).toFixed(2),
timingFunction: 'linear'
})
.left('0%')
.step()
this.setData({
animation: animation.export()
})
timer = setTimeout(() => {
resolve()
}, Number(speed) + 1000)
})
.then(() => {
this.run()
})
},
onShow() {
this.setData({
show: true
})
this.begin()
},
onHide() {
if (this.data.isRun) {
this.reset()
clearTimeout(timer)
this.setData({
show: false
})
}
}
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<block wx:if="{{show}}">
<view class="marquee-box" style="font-size:{{fontSize * 2}}rpx">
<view class="notice-title">
<glsx-image class="sprite-icon-c" src="home/notice_icon.png"></glsx-image>
<text>公告</text>
</view>
<view class="box" id="marquee" style="min-height:{{fontSize / 0.55 * 2}}rpx">
<view class="content" id="content" style="opacity:{{flag?1:0}};" animation="{{animation}}">
<block wx:if="{{data}}">{{data}}</block>
<block wx:else>
<slot></slot>
</block>
</view>
</view>
</view>
</block>
\ No newline at end of file \ No newline at end of file
@import '/style/sprite.wxss';
.marquee-box {
margin: 0 30rpx;
padding: 10rpx 0 10rpx 8rpx;
box-sizing: border-box;
display: flex;
align-items: center;
flex-shrink: 0;
background: white;
border-radius: 6rpx;
}
.marquee-box .notice-title {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 76rpx;
height: 36rpx;
border-radius: 8rpx;
font-size: 20rpx;
}
.marquee-box .notice-title .sprite-icon-c {
width: 24rpx;
height: 24rpx;
margin-right: 8rpx;
}
.marquee-box .box {
width: calc(100% - 12rpx);
margin-left: 12rpx;
position: relative;
overflow: hidden;
color: #3F444D;
}
.marquee-box .box .content {
width: auto;
height: 100%;
position: absolute;
top: 50%;
left: 0;
white-space: nowrap;
transform: translateY(-50%);
display: flex;
align-items: center;
}
\ No newline at end of file \ No newline at end of file
const navStyle = "background-color: transparent;";
Page({ Page({
data: { data: {
navStyle,
noticeContent: true,
noticeContent: '卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡卡',
bannerList: [{
bannerImg: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/wuye/home/banner_test.png'
}],
codeList: [{
title: '官方',
desc: '福利群',
tip: '优惠资讯,先人一步',
url: 'fuliq'
}, {
title: '专属',
desc: '福利官',
tip: '超多福利,不容错过',
url: 'fulig'
}],
showModal:false,
urlName:''
},
navbarReady(e) {
let {
height
} = e.detail;
this.setData({
navBarHeight: height,
user_box_style: `padding-top:${height + 20}px`
})
},
// 处理滚动事件
onPageScroll(e) {
const { navBarHeight } = this.data
this.setData({
navStyle: e.scrollTop >= navBarHeight-50 ? '' : navStyle,
})
}, },
onLoad(options) { onLoad(options) {
},
toShowQrCode(e){
const {url} = e.currentTarget.dataset
this.setData({
urlName:url,
showModal:true
})
},
closeModal(){
this.setData({
showModal:false,
urlName:''
})
}, },
}) })
\ No newline at end of file \ No newline at end of file
{ {
"usingComponents": { "usingComponents": {
"money-saving-tips": "../../../components/MoneySavingTips/MoneySavingTips" "notice-bar": "./components/noticeBar/noticeBar",
"banner": "./components/banner/banner",
"MoneySavingTips":"/components/MoneySavingTips/MoneySavingTips"
}, },
"navigationStyle": "custom", "navigationStyle": "custom",
"onReachBottomDistance": 10, "onReachBottomDistance": 10,
......
page{ page {
background:#F8F8F8 background: #F8F8F8
}
.bar-text {
font-weight: bold;
font-size: 36rpx;
color: #333333;
}
.top_bg_wrap {
background-image: linear-gradient(180deg, #E3EFFD 0%, #F8F8F8 100%);
}
.store-wrap {
box-sizing: border-box;
padding: 0 30rpx 30rpx 30rpx;
.inner {
height: 120rpx;
background: #FFFFFF;
border-radius: 8rpx 8rpx 0 0;
box-sizing: border-box;
padding: 20rpx;
position: relative;
.logo {
width: 104rpx;
height: 80rpx;
margin-right: 12rpx;
}
.store_name {
font-weight: 600;
font-size: 32rpx;
color: #333333;
}
.change_box {
position: absolute;
top: 50%;
right: 32rpx;
transform: translateY(-50%);
.icon {
width: 40rpx;
height: 40rpx;
}
}
}
}
.menu_wrap {
margin: 30rpx;
.cover {
width: 336rpx;
height: 150rpx;
}
}
.code_wrap {
margin: 0 30rpx 48rpx;
.code_item {
width: 336rpx;
background: #FFFFFF;
border-radius: 8rpx;
box-sizing: border-box;
padding: 24rpx 20rpx;
.left {
.title {
color: #333333;
font-size: 28rpx;
font-weight: 600;
.spc {
color: #C41B24;
}
}
.tip {
font-weight: 400;
font-size: 20rpx;
color: #999999;
margin-top: 8rpx;
}
}
.code {
width: 88rpx;
height: 88rpx;
}
}
}
.modal_widget {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 998;
.popup-bg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
background-color: rgba(0, 0, 0, .6);
}
.max_cover {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 638rpx;
height: 756rpx;
}
} }
\ No newline at end of file \ No newline at end of file
<money-saving-tips></money-saving-tips>
\ No newline at end of file \ No newline at end of file
<view class="container">
<navigation-bar bindnavbarReady="navbarReady" navStyle="{{navStyle}}" page-title="甄选福利">
<view class="bar-text">甄选福利</view>
</navigation-bar>
<view style="{{user_box_style}}" class="top_bg_wrap">
<view class="store-wrap">
<view class="inner flex_sc">
<glsx-image class="logo" webp src="home/store_logo.png"></glsx-image>
<view class="store_name">深圳中海美居</view>
<view class="change_box">
<glsx-image class="icon" webp src="home/change_store_icon.png"></glsx-image>
</view>
</view>
</view>
</view>
<!-- 公告 -->
<block wx:if="{{noticeContent}}">
<view class="notice-bar">
<notice-bar data="{{noticeContent}}" speed="7500" id="com-1"></notice-bar>
</view>
</block>
<!-- 家生活/车生活 -->
<view class="menu_wrap flex_scb">
<glsx-image class="cover" webp src="home/family_menu_banner.png"></glsx-image>
<glsx-image class="cover" webp src="home/car_menu_banner.png"></glsx-image>
</view>
<!-- 轮播图 -->
<view class="banner-box" wx:if="{{bannerList.length > 0}}">
<banner bannerList="{{bannerList}}"></banner>
</view>
<!-- 福利二维码 -->
<view class="code_wrap flex_scb">
<block wx:for="{{codeList}}" wx:key="index">
<view data-url="{{item.url}}" bind:tap="toShowQrCode" class="code_item flex_scb">
<view class="left">
<view class="title">
<text>{{item.title}}</text>
<text class="spc">{{item.desc}}</text>
</view>
<view class="tip">{{item.tip}}</view>
</view>
<glsx-image class="code" webp src="home/qr_code_logo.png"></glsx-image>
</view>
</block>
</view>
<!-- 省钱攻略 -->
<MoneySavingTips></MoneySavingTips>
</view>
<!-- 弹框 -->
<view wx:if="{{showModal}}" class="modal_widget">
<view bind:tap="closeModal" class="popup-bg"></view>
<glsx-image wx:if="{{urlName}}" class="max_cover" webp src="home/{{urlName}}.png"></glsx-image>
</view>
\ No newline at end of file \ No newline at end of file
...@@ -101,6 +101,11 @@ const parseString = str => { ...@@ -101,6 +101,11 @@ const parseString = str => {
}) })
return obj return obj
} }
const promise = callBack => {
return new Promise((resolve, reject) => {
callBack(resolve, reject)
})
}
const Util = { const Util = {
onReachBottom, onReachBottom,
...@@ -108,5 +113,6 @@ const Util = { ...@@ -108,5 +113,6 @@ const Util = {
throttle, throttle,
isEmptyObj, isEmptyObj,
parseString, parseString,
promise
} }
export default Util export default Util
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!