1.evaluateMultiPopoverScript //在多页面浮动窗口中执行js脚本
uexWindow.evaluateMultiPopoverScript({
windowName:"root",
popName:"content",
pageName:"index",
js:"getGoodsList()"
});
注:需要打包
2.appcan.window.evaluateScript(name,scriptContent,type) //在指定的窗口脚本执行
name:‘dh‘, //要执行脚本的窗口名称
scriptContent:‘appcan.window.close(-1);‘ //要执行的脚本
});
3.更新推送
appcan.ready(function(){
if(typeof(uexUpdate) != "undefined"){
uexUpdate.onWidgetPatchUpdate = function (opId,dataType,data){
var obj = JSON.parse(data);
alert(obj.status);
if(obj.status=="ok")
{
alert("已完成更新,请重新打开应用");
uexWidgetOne.exit(0);
}
}
}
})
4.Ajax
appcan.request.ajax({
url:basrUrl+"",
dataType:"json",
type:"GET",
data:{
},
success:function(data){
console.log(data);
}, error:function(data) {
alert("服务器访问出错");
}
});
----------------------------------------
var phtml = $(‘#pHtml‘).html();
appcan.request.ajax({
url:basrUrl+"",
dataType:"json",
type:"GET",
data:{
},
success:function(data){
console.log(data);
var p = ‘‘
for (var i in data) {
p += pHtml.replace(/\[(\w*)\]/igm, function(node, key) {
return {
‘name‘:data[i].name,
‘id‘:data[i].id
}[key]
})
};
$("#p").html(p)
}, error:function(data) {
alert("服务器访问出错");
}
});
5.appcan.window.open(name,data,aniId,type,dataType,width,height,animDuration,extraInfo) //打开一个新的窗口
appcan.window.open({
name:"dh",
data:‘dh.html‘,
aniId:2,
dataType:0,
type:0
});
6.appcan.window.close(aniId,animDuration) //关闭当前窗口
<a class="return" id="close"></a>
<script>
$(function(){
appcan.button("#close","ani-act",function(){
appcan.window.close(-1);
});
})
</script>
7.底部导航
var tabview_Tab;
(function($) {
tabview_Tab = appcan.tab({
selector: $("#Tab"),
hasIcon: true,
hasAnim: false,
hasLabel: true,
hasBadge: false,
index: 0,
data: [{
"label": "首页",
"icon": "fa-home"
},
{
"label": "购物车",
"icon": "fa-shopping-cart"
},
{
"label": "我的",
"icon": "fa-user"
}]
});
tabview_Tab.on("click",function(obj, index){
//设置多页面浮动窗口跳转到的子页面窗口的索引
appcan.frame.selectMulti(‘content‘,index)
})
//console.log(parseInt($(‘#footer‘).css(‘height‘).split(‘px‘)[0])+‘px‘ );
$(‘#content‘).css(‘height‘,window.outerHeight - parseInt($(‘#Footer‘).css(‘height‘).split(‘px‘)[0])+‘px‘);
appcan.ready(function(){
appcan.frame.open({
id : "content",
url : [{
"inPageName" : "index",
"inUrl" : "index.html",
}, {
"inPageName" : "new",
"inUrl" : "new.html",
}, {
"inPageName" : "yhzx",
"inUrl" : "yhzx.html",
}],
top : 0,
left : 0,
index : 0,
change:function(index,res){
/*浮动窗口推拽变更时回调,可控制tab进行同步变更*/
tabview_Tab.moveTo(res.multiPopSelectedIndex);
}
})
window.onorientationchange = window.onresize = function() {
//var h = $(‘#content‘).offset().height;
//appcan.window.setMultiPopoverFrame("content",0,0,0,h)
}
})
})($);
8.appcan.locStorage.getVal(key) //获取key保存在localStorage中对应的值
//获取保存的
color appcan.locStorage.getVal(‘color‘);//返回保存的颜色值
9.appcan.locStorage.setVal(key,Val) //要设置的键值对
//设置一个color到本地存储中
appcan.locStorage.setVal(‘color‘,‘red‘);