123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869 |
- /*
- * APICloud JavaScript Library
- * Copyright (c) 2014 apicloud.com
- */
- (function(window) {
- var u = {};
- var isAndroid = (/android/gi).test(navigator.appVersion);
- var uzStorage = function() {
- var ls = window.localStorage;
- if (isAndroid) {
- ls = os.localStorage();
- }
- return ls;
- };
- function parseArguments(url, data, fnSuc, dataType) {
- if (typeof(data) == 'function') {
- dataType = fnSuc;
- fnSuc = data;
- data = undefined;
- }
- if (typeof(fnSuc) != 'function') {
- dataType = fnSuc;
- fnSuc = undefined;
- }
- return {
- url: url,
- data: data,
- fnSuc: fnSuc,
- dataType: dataType
- };
- }
- u.trim = function(str) {
- if (String.prototype.trim) {
- return str == null ? "" : String.prototype.trim.call(str);
- } else {
- return str.replace(/(^\s*)|(\s*$)/g, "");
- }
- };
- u.trimAll = function(str) {
- return str.replace(/\s*/g, '');
- };
- u.isElement = function(obj) {
- return !!(obj && obj.nodeType == 1);
- };
- u.isArray = function(obj) {
- if (Array.isArray) {
- return Array.isArray(obj);
- } else {
- return obj instanceof Array;
- }
- };
- u.isEmptyObject = function(obj) {
- if (JSON.stringify(obj) === '{}') {
- return true;
- }
- return false;
- };
- u.addEvt = function(el, name, fn, useCapture) {
- if (!u.isElement(el)) {
- console.warn('$api.addEvt Function need el param, el param must be DOM Element');
- return;
- }
- useCapture = useCapture || false;
- if (el.addEventListener) {
- el.addEventListener(name, fn, useCapture);
- }
- };
- u.rmEvt = function(el, name, fn, useCapture) {
- if (!u.isElement(el)) {
- console.warn('$api.rmEvt Function need el param, el param must be DOM Element');
- return;
- }
- useCapture = useCapture || false;
- if (el.removeEventListener) {
- el.removeEventListener(name, fn, useCapture);
- }
- };
- u.one = function(el, name, fn, useCapture) {
- if (!u.isElement(el)) {
- console.warn('$api.one Function need el param, el param must be DOM Element');
- return;
- }
- useCapture = useCapture || false;
- var that = this;
- var cb = function() {
- fn && fn();
- that.rmEvt(el, name, cb, useCapture);
- };
- that.addEvt(el, name, cb, useCapture);
- };
- u.dom = function(el, selector) {
- if (arguments.length === 1 && typeof arguments[0] == 'string') {
- if (document.querySelector) {
- return document.querySelector(arguments[0]);
- }
- } else if (arguments.length === 2) {
- if (el.querySelector) {
- return el.querySelector(selector);
- }
- }
- };
- u.domAll = function(el, selector) {
- if (arguments.length === 1 && typeof arguments[0] == 'string') {
- if (document.querySelectorAll) {
- return document.querySelectorAll(arguments[0]);
- }
- } else if (arguments.length === 2) {
- if (el.querySelectorAll) {
- return el.querySelectorAll(selector);
- }
- }
- };
- u.byId = function(id) {
- return document.getElementById(id);
- };
- u.first = function(el, selector) {
- if (arguments.length === 1) {
- if (!u.isElement(el)) {
- console.warn('$api.first Function need el param, el param must be DOM Element');
- return;
- }
- return el.children[0];
- }
- if (arguments.length === 2) {
- return this.dom(el, selector + ':first-child');
- }
- };
- u.last = function(el, selector) {
- if (arguments.length === 1) {
- if (!u.isElement(el)) {
- console.warn('$api.last Function need el param, el param must be DOM Element');
- return;
- }
- var children = el.children;
- return children[children.length - 1];
- }
- if (arguments.length === 2) {
- return this.dom(el, selector + ':last-child');
- }
- };
- u.eq = function(el, index) {
- return this.dom(el, ':nth-child(' + index + ')');
- };
- u.not = function(el, selector) {
- return this.domAll(el, ':not(' + selector + ')');
- };
- u.prev = function(el) {
- if (!u.isElement(el)) {
- console.warn('$api.prev Function need el param, el param must be DOM Element');
- return;
- }
- var node = el.previousSibling;
- if (node.nodeType && node.nodeType === 3) {
- node = node.previousSibling;
- return node;
- }
- };
- u.next = function(el) {
- if (!u.isElement(el)) {
- console.warn('$api.next Function need el param, el param must be DOM Element');
- return;
- }
- var node = el.nextSibling;
- if (node.nodeType && node.nodeType === 3) {
- node = node.nextSibling;
- return node;
- }
- };
- u.closest = function(el, selector) {
- if (!u.isElement(el)) {
- console.warn('$api.closest Function need el param, el param must be DOM Element');
- return;
- }
- var doms, targetDom;
- var isSame = function(doms, el) {
- var i = 0,
- len = doms.length;
- for (i; i < len; i++) {
- if (doms[i].isEqualNode(el)) {
- return doms[i];
- }
- }
- return false;
- };
- var traversal = function(el, selector) {
- doms = u.domAll(el.parentNode, selector);
- targetDom = isSame(doms, el);
- while (!targetDom) {
- el = el.parentNode;
- if (el != null && el.nodeType == el.DOCUMENT_NODE) {
- return false;
- }
- traversal(el, selector);
- }
- return targetDom;
- };
- return traversal(el, selector);
- };
- u.contains = function(parent, el) {
- var mark = false;
- if (el === parent) {
- mark = true;
- return mark;
- } else {
- do {
- el = el.parentNode;
- if (el === parent) {
- mark = true;
- return mark;
- }
- } while (el === document.body || el === document.documentElement);
- return mark;
- }
- };
- u.remove = function(el) {
- if (el && el.parentNode) {
- el.parentNode.removeChild(el);
- }
- };
- u.attr = function(el, name, value) {
- if (!u.isElement(el)) {
- console.warn('$api.attr Function need el param, el param must be DOM Element');
- return;
- }
- if (arguments.length == 2) {
- return el.getAttribute(name);
- } else if (arguments.length == 3) {
- el.setAttribute(name, value);
- return el;
- }
- };
- u.removeAttr = function(el, name) {
- if (!u.isElement(el)) {
- console.warn('$api.removeAttr Function need el param, el param must be DOM Element');
- return;
- }
- if (arguments.length === 2) {
- el.removeAttribute(name);
- }
- };
- u.hasCls = function(el, cls) {
- if (!u.isElement(el)) {
- console.warn('$api.hasCls Function need el param, el param must be DOM Element');
- return;
- }
- if (el.className.indexOf(cls) > -1) {
- return true;
- } else {
- return false;
- }
- };
- u.addCls = function(el, cls) {
- if (!u.isElement(el)) {
- console.warn('$api.addCls Function need el param, el param must be DOM Element');
- return;
- }
- if ('classList' in el) {
- el.classList.add(cls);
- } else {
- var preCls = el.className;
- var newCls = preCls + ' ' + cls;
- el.className = newCls;
- }
- return el;
- };
- u.removeCls = function(el, cls) {
- if (!u.isElement(el)) {
- console.warn('$api.removeCls Function need el param, el param must be DOM Element');
- return;
- }
- if ('classList' in el) {
- el.classList.remove(cls);
- } else {
- var preCls = el.className;
- var newCls = preCls.replace(cls, '');
- el.className = newCls;
- }
- return el;
- };
- u.toggleCls = function(el, cls) {
- if (!u.isElement(el)) {
- console.warn('$api.toggleCls Function need el param, el param must be DOM Element');
- return;
- }
- if ('classList' in el) {
- el.classList.toggle(cls);
- } else {
- if (u.hasCls(el, cls)) {
- u.removeCls(el, cls);
- } else {
- u.addCls(el, cls);
- }
- }
- return el;
- };
- u.val = function(el, val) {
- if (!u.isElement(el)) {
- console.warn('$api.val Function need el param, el param must be DOM Element');
- return;
- }
- if (arguments.length === 1) {
- switch (el.tagName) {
- case 'SELECT':
- var value = el.options[el.selectedIndex].value;
- return value;
- break;
- case 'INPUT':
- return el.value;
- break;
- case 'TEXTAREA':
- return el.value;
- break;
- }
- }
- if (arguments.length === 2) {
- switch (el.tagName) {
- case 'SELECT':
- el.options[el.selectedIndex].value = val;
- return el;
- break;
- case 'INPUT':
- el.value = val;
- return el;
- break;
- case 'TEXTAREA':
- el.value = val;
- return el;
- break;
- }
- }
- };
- u.prepend = function(el, html) {
- if (!u.isElement(el)) {
- console.warn('$api.prepend Function need el param, el param must be DOM Element');
- return;
- }
- el.insertAdjacentHTML('afterbegin', html);
- return el;
- };
- u.append = function(el, html) {
- if (!u.isElement(el)) {
- console.warn('$api.append Function need el param, el param must be DOM Element');
- return;
- }
- el.insertAdjacentHTML('beforeend', html);
- return el;
- };
- u.before = function(el, html) {
- if (!u.isElement(el)) {
- console.warn('$api.before Function need el param, el param must be DOM Element');
- return;
- }
- el.insertAdjacentHTML('beforebegin', html);
- return el;
- };
- u.after = function(el, html) {
- if (!u.isElement(el)) {
- console.warn('$api.after Function need el param, el param must be DOM Element');
- return;
- }
- el.insertAdjacentHTML('afterend', html);
- return el;
- };
- u.html = function(el, html) {
- if (!u.isElement(el)) {
- console.warn('$api.html Function need el param, el param must be DOM Element');
- return;
- }
- if (arguments.length === 1) {
- return el.innerHTML;
- } else if (arguments.length === 2) {
- el.innerHTML = html;
- return el;
- }
- };
- u.text = function(el, txt) {
- if (!u.isElement(el)) {
- console.warn('$api.text Function need el param, el param must be DOM Element');
- return;
- }
- if (arguments.length === 1) {
- return el.textContent;
- } else if (arguments.length === 2) {
- el.textContent = txt;
- return el;
- }
- };
- u.offset = function(el) {
- if (!u.isElement(el)) {
- console.warn('$api.offset Function need el param, el param must be DOM Element');
- return;
- }
- var sl = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
- var st = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
- var rect = el.getBoundingClientRect();
- return {
- l: rect.left + sl,
- t: rect.top + st,
- w: el.offsetWidth,
- h: el.offsetHeight
- };
- };
- u.css = function(el, css) {
- if (!u.isElement(el)) {
- console.warn('$api.css Function need el param, el param must be DOM Element');
- return;
- }
- if (typeof css == 'string' && css.indexOf(':') > 0) {
- el.style && (el.style.cssText += ';' + css);
- }
- };
- u.cssVal = function(el, prop) {
- if (!u.isElement(el)) {
- console.warn('$api.cssVal Function need el param, el param must be DOM Element');
- return;
- }
- if (arguments.length === 2) {
- var computedStyle = window.getComputedStyle(el, null);
- return computedStyle.getPropertyValue(prop);
- }
- };
- u.jsonToStr = function(json) {
- if (typeof json === 'object') {
- return JSON && JSON.stringify(json);
- }
- };
- u.strToJson = function(str) {
- if (typeof str === 'string') {
- return JSON && JSON.parse(str);
- }
- };
- u.setStorage = function(key, value) {
- if (arguments.length === 2) {
- var v = value;
- if (typeof v == 'object') {
- v = JSON.stringify(v);
- v = 'obj-' + v;
- } else {
- v = 'str-' + v;
- }
- var ls = uzStorage();
- if (ls) {
- ls.setItem(key, v);
- }
- }
- };
- u.getStorage = function(key) {
- var ls = uzStorage();
- if (ls) {
- var v = ls.getItem(key);
- if (!v) { return; }
- if (v.indexOf('obj-') === 0) {
- v = v.slice(4);
- return JSON.parse(v);
- } else if (v.indexOf('str-') === 0) {
- return v.slice(4);
- }
- }
- };
- u.rmStorage = function(key) {
- var ls = uzStorage();
- if (ls && key) {
- ls.removeItem(key);
- }
- };
- u.clearStorage = function() {
- var ls = uzStorage();
- if (ls) {
- ls.clear();
- }
- };
- /*by king*/
- u.fixIos7Bar = function(el){
- return u.fixStatusBar(el);
- };
- u.fixStatusBar = function(el){
- if(!u.isElement(el)){
- console.warn('$api.fixStatusBar Function need el param, el param must be DOM Element');
- return 0;
- }
- el.style.paddingTop = api.safeArea.top + 'px';
- return el.offsetHeight;
- };
- u.fixTabBar = function(el){
- if(!u.isElement(el)){
- console.warn('$api.fixTabBar Function need el param, el param must be DOM Element');
- return 0;
- }
- el.style.paddingBottom = api.safeArea.bottom + 'px';
- return el.offsetHeight;
- };
- u.toast = function(title, text, time) {
- var opts = {};
- var show = function(opts, time) {
- api.showProgress(opts);
- setTimeout(function() {
- api.hideProgress();
- }, time);
- };
- if (arguments.length === 1) {
- var time = time || 500;
- if (typeof title === 'number') {
- time = title;
- } else {
- opts.title = title + '';
- }
- show(opts, time);
- } else if (arguments.length === 2) {
- var time = time || 500;
- var text = text;
- if (typeof text === "number") {
- var tmp = text;
- time = tmp;
- text = null;
- }
- if (title) {
- opts.title = title;
- }
- if (text) {
- opts.text = text;
- }
- show(opts, time);
- }
- if (title) {
- opts.title = title;
- }
- if (text) {
- opts.text = text;
- }
- time = time || 500;
- show(opts, time);
- };
- u.post = function( /*url,data,fnSuc,dataType*/ ) {
- var argsToJson = parseArguments.apply(null, arguments);
- var json = {};
- var fnSuc = argsToJson.fnSuc;
- argsToJson.url && (json.url = argsToJson.url);
- argsToJson.data && (json.data = argsToJson.data);
- if (argsToJson.dataType) {
- var type = argsToJson.dataType.toLowerCase();
- if (type == 'text' || type == 'json') {
- json.dataType = type;
- }
- } else {
- json.dataType = 'json';
- }
- json.method = 'post';
- api.ajax(json,
- function(ret, err) {
- if (ret) {
- fnSuc && fnSuc(ret);
- }
- }
- );
- };
- u.get = function( /*url,fnSuc,dataType*/ ) {
- var argsToJson = parseArguments.apply(null, arguments);
- var json = {};
- var fnSuc = argsToJson.fnSuc;
- argsToJson.url && (json.url = argsToJson.url);
- //argsToJson.data && (json.data = argsToJson.data);
- if (argsToJson.dataType) {
- vartype = argsToJson.dataType.toLowerCase();
- if (type == 'text' || type == 'json') {
- json.dataType = type;
- }
- } else {
- json.dataType = 'text';
- }
- json.method = 'get';
- api.ajax(json,
- function(ret, err) {
- if (ret) {
- fnSuc && fnSuc(ret);
- }
- }
- );
- };
- /*end*/
- window.$api = u;
- setFixStatusBar = function() {
- var systemType = api.systemType;
- var systemVersion = api.systemVersion;
- var h = api.safeArea.top + 'px';
- if (systemType == 'ios') {
- $api.fixStatusBar($api.dom('body'));
- $('.topbar').css("height", h);
- $('.page').css("margin-top", h);
- $('body').css("margin-top", "-0.05rem");
- } else {
- $api.fixStatusBar($api.dom('body'));
- $('.topbar').css("height", h);
- $('.page').css("margin-top", h);
- $('body').css("margin-top", "-0.05rem");
- }
- }
- setIosTopBar = function() {
- var systemType = api.systemType;
- var systemVersion = api.systemVersion;
- var h = api.safeArea.top + 'px';
- if (systemType == 'ios') {
- $api.fixStatusBar($api.dom('body'));
- $('.topbar').css("height", h);
- $('.page').css("margin-top", h);
- $('body').css("margin-top", "-0.05rem");
- } else {
- $api.fixStatusBar($api.dom('body'));
- $('.topbar').css("height", h);
- $('.page').css("margin-top", h);
- $('body').css("margin-top", "-0.05rem");
- }
- }
- setBackDisable = function() {
- var systemType = api.systemType;
- if (systemType == 'ios') {
- api.setWinAttr({
- slidBackEnabled: false
- });
- } else {
- var backSecond = 0;
- api.addEventListener({
- name: 'keyback'
- }, function(ret, err) {
- var curSecond = (new Date().getTime()) / 1000;
- if (Math.abs(curSecond - backSecond) > 2) {
- backSecond = curSecond;
- api.toast({
- msg: '再按一次退出',
- duration: 2000,
- location: 'bottom'
- });
- } else {
- api.closeWidget({
- id: 'A6007457911931',
- retData: { name: 'closeWidget' },
- silent: true
- });
- }
- });
- }
- }
- setTimeCloseWin = function(winname) {
- setTimeout(function() { api.closeWin({ name: winname }); }, 800);
- }
- limitNumber = function(txt, num) {
- var str = txt;
- str = str.substr(0, num) + '...';
- return str;
- }
- statInputNum = function (textArea, numItem) {
- // body...
- var max = numItem.text(), curLength;
- textArea[0].setAttribute("maxlength", max);
- curLength = textArea.val().length;
- numItem.text(max - curLength);
- textArea.on('input propertychange', function() {
- numItem.text(max - $(this).val().length);
- })
- }
- errcode = function (res, code) {
- // console.log(code)
- switch (code) {
- case 2000:
- $api.rmStorage("storeid");
- $api.rmStorage("memberid");
- $api.rmStorage("agent_id");
- $api.rmStorage("accesstoken");
- api.openWin({
- name: 'login',
- url: 'widget://login.html',
- bounces: false,
- pageParam: {
- keyid: true
- }
- })
- // api.closeWin({ name: 'index' });
- // api.closeWin({ name: 'hotelindex' });
- // api.closeWin({ name: 'agentindex' });
- // api.closeWin();
- // console.log(res)
- break;
- case 1001:
- api.toast({ msg: res.msg })
- break;
- case 3000:
- console.log(res)
- api.toast({ msg: '系统开小差了' })
- break;
- case 999:
- console.log(res)
- api.toast({ msg: res.msg })
- break;
- default:
- console.log(res)
- api.toast({ msg: '发生了不知名的错误'+code })
- break;
- }
- }
- gallery_qz = function (img) {
- img = img.replace('thumb/', '');
- var _html = '<div class="weui-gallery" data-imgurl="'+img+'" style="display: block;">';
- _html += '<span class="weui-gallery__img" style="background-image: url(' + img + ');"></span>';
- _html += '<div class="weui-gallery__opr">';
- _html += '<a href="javascript:$(\'.weui-gallery\').remove()" class="weui-gallery__del">';
- _html += '<i class="weui-icon-cancel" style="font-size: 1rem;"></i></a></div></div>';
- $("body").prepend(_html);
- }
- gallery_adv = function (img, function_name, id, oid) {
- // body...
- var _html = '<div class="weui-gallery" style="display: block;background-color: rgba(0, 0, 0, 0.18);">';
- _html += '<a href="javascript:'+function_name+'('+id+', '+oid+')"><span class="weui-gallery__img" style="background-image: url('+img+');"></span></a>';
- _html += '<div class="weui-gallery__opr" style="background-color: rgba(0, 0, 0, 0);">';
- _html += '<a href="javascript:color()" class="weui-gallery__del">';
- _html += '<i class="weui-icon-cancel" style="font-size: 1rem;"></i></a></div></div>';
- $("body").prepend(_html);
- }
- toast_weui = function (e) {
- // body...
- var _html = '<div class="js_dialog" id="iosDialog2_qz" style="display: block;">';
- _html += '<div class="weui-mask"></div>';
- _html += '<div class="weui-dialog">';
- _html += '<div class="weui-dialog__bd">购物前请确认<h2 style="margin: 8px 0;color: #d9251c;">'+e+'</h2>是否是您入住的酒店</div>';
- _html += '<div class="weui-dialog__ft">';
- _html += '<a href="javascript:api.closeWin();" class="weui-dialog__btn m-bottom back-btn weui-dialog__btn_default" style="background: #777;">返回确认</a>';
- _html += '<a href="javascript:$(\'#iosDialog2_qz\').remove();" class="weui-dialog__btn m-bottom weui-dialog__btn_primary">确认无误</a></div></div></div>';
- $("body").prepend(_html);
- }
- toast_loding_show = function (e) {
- var _html = '<div id="loadingToast_k" class="loadingToast_k">';
- _html += '<div class="weui-mask_transparent"></div>';
- _html += '<div class="weui-toast">';
- _html += '<i class="weui-loading weui-icon_toast"></i>';
- _html += '<p class="weui-toast__content">数据加载中</p></div></div>';
- $("body").prepend(_html);
- }
- toast_loding_hide = function () {
- $(".loadingToast_k").remove();
- }
- hasPermission = function (one_per) {
- var perms = new Array();
- if(one_per){
- perms.push(one_per);
- } else {
- api.toast({ msg: '系统开小差了' });
- return;
- }
- var rets = api.hasPermission({
- list: perms
- });
- if(!one_per){
- api.toast({ msg: '判断结果:' + JSON.stringify(rets) });
- return;
- }
- return rets;
- }
- reqPermission = function (one_per, callback){
- var perms = new Array();
- if(one_per){
- perms.push(one_per);
- } else {
- api.toast({ msg: '系统开小差了' });
- return;
- }
- api.requestPermission({
- list: perms,
- code: 100001
- }, function(ret, err){
- if(callback){
- callback(ret);
- return;
- }
- console.log(JSON.stringify(ret));
- })
- }
- function_name = function () {
- $('body').imagesLoaded()
- .always( function( instance ) {
- // console.log('all images loaded');
- })
- .done( function( instance ) {
- // console.log('all images successfully loaded');
- })
- .fail( function() {
- // console.log('all images loaded, at least one is broken');
- })
- .progress( function( instance, image ) {
- // var result = image.isLoaded ? 'loaded' : 'broken';
- // console.log( 'image is ' + result + ' for ' + image.img.src );
- // console.log(image)
- // image.img.parentNode.className = image.isLoaded ? '' : 'is-broken';
- if ( !image.isLoaded ) {
- // image.img.className = 'is-broken';
- image.img.src = 'http://www2.qzaiwang.com/static/home/images/logo2.png'
- }
- });
- }
- qz_update = function () {
- var mam = api.require('mam');
- mam.checkUpdate(function(ret, err){
- if (ret) {
- var result = ret.result;
- if (result.update == true && result.closed == false) {
- var str = '新版本号:' + result.version +';更新提示语:'+result.updateTip;
- api.confirm({
- title: '有新的版本,是否下载并安装',
- msg: str,
- buttons: ['确定', '取消']
- }, function(ret, err) {
- var index = ret.buttonIndex;
- if ( api.systemType == "android" ) {
- api.download({
- url: result.source,
- report: true
- }, function(ret, err) {
- if (ret && 0 == ret.state) {
- api.toast({
- msg: "正在下载"+ ret.percent + "%",
- duration: 2000
- })
- }
- })
- }
- })
- } else {
- api.toast({
- msg: "已经是最新版本"
- })
- }
- } else {
- alert(JSON.stringify(err));
- }
- })
- }
- })(window);
- // var siteurl = 'http://www2.qzaiwang.com/';
- var siteurl = 'https://www.qzaiwang.com/';
- // var rooturl = 'http://www2.qzaiwang.com/api/index.php';
- var rooturl = 'https://www.qzaiwang.com/api/index.php';
- var version = '1.01';
|