appcan实用技术总结(二)

2018-08-06  本文已影响0人  蕾520

系统采用bootstrap构建静态页面,非appcan原本开发,因此下拉刷新等均未采用appcan自带方法解决。

一.第一次安装完成,进入app的提示,仅出现一次

     

     appcan.ready(function() {    

         var newVisitor = isNewVisitor();// 如果是新访客       

         if(newVisitor === true)        {       // 动画弹出消息框      

                   //标记:已经向该访客弹出过消息。30天之内不要再弹       

               appcan.window.open({

                        name: 'link_page',

                        data: 'linkpage.html',

                        aniId: 5

                    });

setCookie("gznotes-visited","true",5);        }     });      

              function isNewVisitor() {      // 从cookie读取“已经向访客提示过消息”的标    

                   varflg = getCookie("gznotes-visited");        

                   if (flg === "") {        

                       return true;        

                       }else {         

                           return false;        

                           }      }   // 写cookie     

        function setCookie(cname,cvalue, exdays) {       

            var d = new Date();       

            d.setTime(d.getTime()+ (exdays*24*60*60*1000));       

            var expires = "expires="+d.toUTCString();       

            document.cookie = cname + "="+ cvalue + "; "+ expires +";path=/";     

            }       // 读cookie     

            functiongetCookie(cname){       

                var name = cname + "=";       

                var ca = document.cookie.split(';');       

                for(var i=0; i

                    var c = ca[i];          

                    while (c.charAt(0)==' ')c=c.substring(1);          

            if (c.indexOf(name) == 0)

                    return c.substring(name.length,c.length);        

                    }        

                    return "";     

                    } 

二.上拉刷新

function refresh(){

   $(window).scroll(function(){

     var scrollTop = $(this).scrollTop();//滚动条距离顶部的高度

     var scrollHeight = $(document).height();//当前页面的总高度

     var windowHeight = $(this).height();//当前可视的页面高度

if(scrollTop+ windowHeight >= scrollHeight){

          $('#myModal').modal('hide');

          appcan.frame.setBounce({

            bounceType:'1',

            startPullCall:function(){},

         upEndCall:function(){

              up();

              uexWindow.setBounce(0);

            },

              color:'#F0F0F0',

             imgSettings:{

              "textColor":"#530606",

              "pullToReloadText":"拖动刷新",

              "releaseToReloadText":"释放刷新",

              "loadingText":"加载中,请稍等"

                }

          });

              uexWindow.setBounce(1);              

             }else if(scrollTop<=0){//滚动条距离顶部的高度小于等于0

               //  alert("下拉刷新,要在这调用啥方法?");

             }

         });

       }

三.打开指定页面并执行指定的js

uexWindow.evaluatePopoverScript({

              windowName:"",

              popName:"query-project_content",

              js:"isearch();"

        });

四.退出登录,关闭所有打开过的页面,避免页面显示混乱

myPages.push(getstorage("myPages")+","+"login");

            setstorage("myPages",myPages);

var pns=myPages[0].split(",");

                      var s=[];

                      for(var i = 0;i

                          if(s.indexOf(pns[i])==-1){

                              s.push(pns[i]);

                          }

                      } 

                for (var i = 1; i < s.length; i++) {

                        appcan.window.evaluateScript({

                            name: s[i],

scriptContent :"appcan.window.close();"

                         });       

             }

上一篇下一篇

猜你喜欢

热点阅读