企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 第三课常用js解读 ### foxui是人人商城微信端样式 文本框 ``` <pre class="calibre14">``` <span class="token"><</span>div class<span class="token">=</span><span class="token4">"fui-cell bank-group"</span> <span class="token2">{</span><span class="token5">if</span> <span class="token1">empty</span><span class="token2">(</span>$type_array<span class="token2">[</span><span class="token3">3</span><span class="token2">]</span><span class="token2">[</span><span class="token4">'checked'</span><span class="token2">]</span><span class="token2">)</span><span class="token2">}</span>style<span class="token">=</span><span class="token4">"display: none;"</span><span class="token2">{</span><span class="token">/</span><span class="token5">if</span><span class="token2">}</span><span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"fui-cell-label"</span> style<span class="token">=</span><span class="token4">"width: 120px;"</span><span class="token">></span>银行开户行<span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"fui-cell-info"</span><span class="token">></span><span class="token"><</span>input type<span class="token">=</span><span class="token4">"text"</span> id<span class="token">=</span><span class="token4">"bankaddress"</span> name<span class="token">=</span><span class="token4">"bankaddress"</span> class<span class="token">=</span><span class="token4">'fui-input'</span> value<span class="token">=</span><span class="token4">"{$last_data['bankaddress']}"</span> <span class="token">/</span><span class="token">></span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` 上传 ``` <pre class="calibre14">``` <span class="token"><</span>div class<span class="token">=</span><span class="token4">'fui-cell'</span><span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">'fui-cell-label'</span><span class="token">></span>上传身份证<span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">'fui-cell-info'</span><span class="token">></span> <span class="token"><</span>ul class<span class="token">=</span><span class="token4">"fui-images fui-images-sm"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>ul<span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"fui-uploader fui-uploader-sm"</span> data<span class="token">-</span>max<span class="token">=</span><span class="token4">"5"</span> data<span class="token">-</span>count<span class="token">=</span><span class="token4">"0"</span><span class="token">></span> <span class="token"><</span>input type<span class="token">=</span><span class="token4">"file"</span> name<span class="token">=</span><span class="token4">'cid'</span> id<span class="token">=</span><span class="token4">'cid'</span> multiple<span class="token">=</span><span class="token4">""</span> accept<span class="token">=</span><span class="token4">"image/*"</span> <span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> ``` ``` html模板中使用js模板 - html代码 ``` <pre class="calibre14">``` <span class="token"><</span>div class<span class="token">=</span><span class="token4">"fui-list-group"</span> id<span class="token">=</span><span class="token4">"qq"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>script type<span class="token">=</span><span class="token4">"text/html"</span> id<span class="token">=</span><span class="token4">"tpl_list"</span><span class="token">></span> <span class="token"><</span><span class="token">%</span>each list as item<span class="token">%</span><span class="token">></span> <span class="token"><</span>a class<span class="token">=</span><span class="token4">"fui-list"</span> href<span class="token">=</span><span class="token4">"{php echo mobileUrl('qa/detail')}&id=<%item.id%>"</span><span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"fui-list-inner"</span><span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"title"</span><span class="token">></span><span class="token"><</span><span class="token">%</span>item<span class="token2">.</span>title<span class="token">%</span><span class="token">></span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"fui-list-angle"</span><span class="token">></span> <span class="token"><</span>div class<span class="token">=</span><span class="token4">"angle"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>div<span class="token">></span> <span class="token"><</span><span class="token">/</span>a<span class="token">></span> <span class="token"><</span><span class="token">%</span><span class="token">/</span>each<span class="token">%</span><span class="token">></span> <span class="token"><</span><span class="token">/</span>script<span class="token">></span> ``` ``` - 模板加载 ``` <pre class="calibre14">``` <span class="token"><</span>script<span class="token">></span> var result <span class="token">=</span> <span class="token2">{</span>list<span class="token2">:</span> <span class="token2">[</span> <span class="token2">{</span> title<span class="token2">:</span> <span class="token4">'<油价>调整周期缩至10个工作日 无4%幅度限制'</span><span class="token2">,</span> url<span class="token2">:</span> <span class="token4">'http://finance.qq.com/zt2013/2013yj/index.htm'</span> <span class="token2">}</span><span class="token2">,</span> <span class="token2">{</span> title<span class="token2">:</span> <span class="token4">'明起汽油价格每吨下调310元 单价回归7元时代'</span><span class="token2">,</span> url<span class="token2">:</span> <span class="token4">'http://finance.qq.com/a/20130326/007060.htm'</span> <span class="token2">}</span><span class="token2">,</span> <span class="token2">{</span> title<span class="token2">:</span> <span class="token4">'广东副县长疑因抛弃情妇遭6女子围殴 纪检调查'</span><span class="token2">,</span> url<span class="token2">:</span> <span class="token4">'http://news.qq.com/a/20130326/001254.htm'</span> <span class="token2">}</span><span class="token2">,</span> <span class="token2">{</span> title<span class="token2">:</span> <span class="token4">'湖南27岁副县长回应质疑:父亲已不是领导'</span><span class="token2">,</span> url<span class="token2">:</span> <span class="token4">'http://news.qq.com/a/20130326/000959.htm'</span> <span class="token2">}</span><span class="token2">,</span> <span class="token2">{</span> title<span class="token2">:</span> <span class="token4">'朝军进入战斗工作状态 称随时准备导弹攻击美国'</span><span class="token2">,</span> url<span class="token2">:</span> <span class="token4">'http://news.qq.com/a/20130326/001307.htm'</span> <span class="token2">}</span> <span class="token2">]</span><span class="token2">}</span><span class="token2">;</span> core<span class="token2">.</span><span class="token1">tpl</span><span class="token2">(</span><span class="token4">'#qq'</span><span class="token2">,</span> <span class="token4">'tpl_list'</span><span class="token2">,</span> result<span class="token2">)</span><span class="token2">;</span> <span class="token"><</span><span class="token">/</span>script<span class="token">></span> ``` ``` - 其他语法 ``` <pre class="calibre14">``` <span class="token"><</span><span class="token">%</span>content<span class="token">%</span><span class="token">></span> 输出内容 <span class="token"><</span><span class="token">%</span>#content<span class="token">%</span><span class="token">></span> 不输出 条件语句 <span class="token"><</span><span class="token">%</span><span class="token5">if</span> k<span class="token">></span><span class="token3">0</span><span class="token">%</span><span class="token">></span> <span class="token"><</span><span class="token">%</span><span class="token5">else</span> <span class="token5">if</span> k<span class="token"><</span><span class="token3">0</span><span class="token">%</span><span class="token">></span> <span class="token"><</span><span class="token">%</span><span class="token5">else</span><span class="token">%</span><span class="token">></span> <span class="token"><</span><span class="token">%</span><span class="token">/</span><span class="token5">if</span><span class="token">%</span><span class="token">></span> 循环数组或对象 <span class="token"><</span><span class="token">%</span>each list as k v<span class="token">%</span><span class="token">></span> <span class="token"><</span><span class="token">%</span>k<span class="token">%</span><span class="token">></span><span class="token">-</span><span class="token"><</span><span class="token">%</span>v<span class="token2">.</span>user<span class="token">%</span><span class="token">></span> <span class="token"><</span><span class="token">%</span><span class="token">/</span>each<span class="token">%</span><span class="token">></span> 子模板 <span class="token"><</span><span class="token">%</span>include <span class="token4">'temp_name'</span><span class="token">%</span><span class="token">></span> 辅助方法 ``` ``` FoxUI方法 ``` <pre class="calibre14">``` FoxUI<span class="token2">.</span>loader<span class="token2">.</span><span class="token1">show</span><span class="token2">(</span><span class="token4">'mini'</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//loading</span> FoxUI<span class="token2">.</span>loader<span class="token2">.</span><span class="token1">hide</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span> FoxUI<span class="token2">.</span>toast<span class="token2">.</span><span class="token1">show</span><span class="token2">(</span><span class="token4">'取消支付'</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//自动消失</span> FoxUI<span class="token2">.</span><span class="token1">alert</span><span class="token2">(</span><span class="token4">'下单失败'</span><span class="token2">)</span><span class="token2">;</span> FoxUI<span class="token2">.</span><span class="token1">confirm</span><span class="token2">(</span><span class="token4">'内容'</span><span class="token2">,</span><span class="token4">'标题'</span><span class="token2">,</span><span class="token5">function</span><span class="token2">(</span><span class="token2">)</span><span class="token2">{</span> console<span class="token2">.</span><span class="token1">log</span><span class="token2">(</span><span class="token4">"确定"</span><span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span><span class="token2">,</span><span class="token5">function</span><span class="token2">(</span><span class="token2">)</span><span class="token2">{</span> console<span class="token2">.</span><span class="token1">log</span><span class="token2">(</span><span class="token4">"取消"</span><span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> FoxUI<span class="token2">.</span>message<span class="token2">.</span><span class="token1">show</span><span class="token2">(</span><span class="token2">{</span> title<span class="token2">:</span> <span class="token4">"很遗憾,您没有中奖!"</span><span class="token2">,</span> icon<span class="token2">:</span> <span class="token4">'icon icon-wrong'</span><span class="token2">,</span> content<span class="token2">:</span> <span class="token4">''</span><span class="token2">,</span> buttons<span class="token2">:</span> <span class="token2">[</span><span class="token2">{</span> text<span class="token2">:</span> <span class="token4">'确定'</span><span class="token2">,</span> extraClass<span class="token2">:</span> <span class="token4">'btn-danger'</span><span class="token2">,</span> onclick<span class="token2">:</span> <span class="token5">function</span> <span class="token2">(</span><span class="token2">)</span> <span class="token2">{</span> console<span class="token2">.</span><span class="token1">log</span><span class="token2">(</span><span class="token3">11</span><span class="token2">)</span> <span class="token2">}</span> <span class="token2">}</span><span class="token2">]</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> ``` ``` 调用clipboard.min.js不使用flash复制插件 ``` <pre class="calibre16">``` <span class="token1">require</span><span class="token2">(</span><span class="token2">[</span>myconfig<span class="token2">.</span>path<span class="token">+</span><span class="token4">'dist/clipboard.min.js'</span><span class="token2">]</span><span class="token2">,</span> <span class="token5">function</span><span class="token2">(</span>Clipboard<span class="token2">)</span><span class="token2">{</span> var clipboard <span class="token">=</span> <span class="token5">new</span> <span class="token1">Clipboard</span><span class="token2">(</span><span class="token4">'.jsclip'</span><span class="token2">,</span> <span class="token2">{</span> text<span class="token2">:</span> <span class="token5">function</span><span class="token2">(</span>e<span class="token2">)</span> <span class="token2">{</span> <span class="token5">return</span> $<span class="token2">(</span>e<span class="token2">)</span><span class="token2">.</span><span class="token1">data</span><span class="token2">(</span><span class="token4">'url'</span><span class="token2">)</span><span class="token">||</span>$<span class="token2">(</span>e<span class="token2">)</span><span class="token2">.</span><span class="token1">data</span><span class="token2">(</span><span class="token4">'href'</span><span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> clipboard<span class="token2">.</span><span class="token1">on</span><span class="token2">(</span><span class="token4">'success'</span><span class="token2">,</span> <span class="token5">function</span><span class="token2">(</span>e<span class="token2">)</span> <span class="token2">{</span> tip<span class="token2">.</span>msgbox<span class="token2">.</span><span class="token1">suc</span><span class="token2">(</span><span class="token4">'复制成功'</span><span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span><span class="token2">)</span><span class="token2">;</span> <span class="token2">}</span><span class="token2">)</span> ``` ```