SearchBox_wev8.js 3.27 KB
define("SearchBox_html",function(){return'<div id="NMEC_${id}" class="wev-comp-${compType}" >    <div class="wev-searchbox wev-search">        {@if leftBtns.length > 0}        <div class="wev-searchbox-btn-wrap">           {@each leftBtns as btn,index}                {@if btn.text && btn.icon}                    <div class="btn" data-index="${btn.index}">                        <div class="btn-inner">                            <img src="${btn.icon}">                            <div>$${btn.text}</div>                        </div>                    </div>                {@else if btn.text}                    <button class="btn" data-index="${btn.index}">$${btn.text}</button>                {@else if btn.icon}                    <img class="btn" data-index="${btn.index}" src="${btn.icon}">                {@/if}           {@/each}        </div>        {@/if}        <div class="wev-search-inner">            <div class="wev-placeholder">                <div class="wev-placeholder-inner wev-ellipsis">                    <span class="wev-small-icon wev-icon-search"></span><span class="wev-placeholder-text">${tip}</span>                </div>            </div>            <div class="wev-clear-btn"></div>        </div>       {@if rightBtns.length > 0}        <div class="wev-searchbox-btn-wrap">           {@each rightBtns as btn,index}                {@if btn.text && btn.icon}                    <div class="btn" data-index="${btn.index}">                        <div class="btn-inner">                            <img src="${btn.icon}">                            <div>$${btn.text}</div>                        </div>                    </div>                {@else if btn.text}                    <button class="btn" data-index="${btn.index}">$${btn.text}</button>                {@else if btn.icon}                    <img class="btn" data-index="${btn.index}" src="${btn.icon}">                {@/if}           {@/each}        </div>        {@/if}    </div></div>'}),define(["mUtil","Component","mService"],function(o,e,t){return e.init(function(i){e.super(this,i),this.type="SearchBox",this.tpl=this.type+"_html",this.css=this.type+"_css";var c=this.viewModel={tip:"",scan:!0,history:!0,btns:[],onSearch:function(){},standalone:!0};this.beforeMount=function(){c.leftBtns=[],c.rightBtns=[],c.btns.forEach(function(i){i.index=o.UUID(),"left"==i.align?c.leftBtns.push(i):"right"==i.align&&c.rightBtns.push(i)})},this.mounted=function(){var s=this,i=this.$el.children(".wev-comp-"+c.compType),e=$(".wev-search",i);require("i18n"),s.$container,i.on("click",".btn",function(){var n=$(this).data("index");c.btns.every(function(i,e){return i.index!=n||(o.eval(i.click,s.pageid),!1)})});var a=function(){o.back()},n=function(i){t.show("searchbox",{preload:i,compid:s.id,tip:c.tip,scan:c.scan,history:c.history,classAnimation:"show_hide_searchbox",closeCallback:function(){a()},onSearch:function(i){if(o.isObject(c.onSearch)){var e=c.onSearch,n=e.query.replace("$KEY$",i);if(o.getPageId(e.pageid)==s.pageid)Mobile_NS.refreshSpecifiedList(e.pageid,e.compoid,n).then(function(){a()});else{var t={onPageLoad:function(){Mobile_NS.refreshList(e.compoid,n)}};$u("/mobilemode/appHomepageView.jsp?appHomepageId="+e.pageid,t)}}else o.eval(c.onSearch,s.pageid,"'"+i+"'")}})};e.on("click.active",".wev-placeholder",function(i){n(!1)}),n(!0)}})});