apicloud地图、即时通讯、人脸识别登录、以及平时踩过得坑

apicloud技术浅谈

导语

apicloud 的学习也有一段时间了,这是我个人的一些经验,和踩过的坑,希望对大家能有一些帮助。

apicloud的知识准备

apicloud 是一个用原生的思想搭建包含window、frame、widget 的框架,内容用html、css去布局,js进行数据交互;所以首先要熟悉web三件套,html+css+js;因为是移动端,建议大家采用rem布局或者是flex布局进行屏幕适应。

css布局(简单介绍rem和flex)

  • rem是根据html的font-size大小来变化,正是基于这个出发,我们可以在每一个设备下根据设备的宽度设置对应的html字号,从而实现了自适应布局,其中主流的实现方案是通过媒体查询,以下是我在金叶彩虹demo中用到的以750的设计图实现的方案:
@media only screen and (min- 320px) {
	html {
		font-size: 17.0666667px !important;
	}
}
@media only screen and (min- 375px) {
	html {
		font-size: 20px !important;
	}
}
@media only screen and (min- 400px) {
	html {
		font-size: 21.33333333px !important;
	}
}
@media only screen and (min- 414px) {
	html {
		font-size: 21px !important;
	}
}
@media only screen and (min- 480px) {
	html {
		font-size: 25.6px !important;
	}
}
  • Flex是Flexible Box的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性。阿里前端阮一峰有一篇关于flex博客的教程特别详细,点击

apicloud的开发工具遇到过的问题

apicloud官方提供开发工具有apicloud studio, 提供了sublime和webstorm的插件; 调试工具:appLoader和自定义loader

  • 建议大家可以使用自己熟悉的编译器编写,使用apicloud studio进行wifi同步或者usb真机同步
  • 没有加入第三方模块时可以使用apploader进行调试;加入第三方模块apploader不可用,必须使用自定义loader。
  • 当调试时代码改变界面不变时,可能出现手机缓存问题,建议重装loader.
  • 打包时报错svn没有同步到widget; 有可能是svn没有传上去,建议用单独的svn再次上传

金叶彩虹demo的几个模块代码

即时通讯

采用的是融云模块,链接;

  1. 初始化融云模块
// 定义全局变量
var istoken = false; 
 var rong,userId;
rong = api.require('rongCloud2');
rong.init(function (ret, err) {
            if (ret.status == 'error') {
                api.toast({msg: err.code});
            } else {
                alert("初始化成功")
//                alert(JSON.stringify(ret));
            }
        });
  1. token的准备(做的时候没有后台,要模拟token)
/*自定义 和融云通信的 ajax 方法.  */
    function ajaxToRongCloud(appKey, appSecret, userId, name, portraitUri, callback) {
        (function () {
            var n;

            function e(n) {
                var e, t, r = "", o = -1, f;
                if (n && n.length) {
                    f = n.length;
                    while ((o += 1) < f) {
                        e = n.charCodeAt(o);
                        t = o + 1 < f ? n.charCodeAt(o + 1) : 0;
                        if (55296 <= e && e <= 56319 && 56320 <= t && t <= 57343) {
                            e = 65536 + ((e & 1023) << 10) + (t & 1023);
                            o += 1
                        }
                        if (e <= 127) {
                            r += String.fromCharCode(e)
                        } else if (e <= 2047) {
                            r += String.fromCharCode(192 | e >>> 6 & 31, 128 | e & 63)
                        } else if (e <= 65535) {
                            r += String.fromCharCode(224 | e >>> 12 & 15, 128 | e >>> 6 & 63, 128 | e & 63)
                        } else if (e <= 2097151) {
                            r += String.fromCharCode(240 | e >>> 18 & 7, 128 | e >>> 12 & 63, 128 | e >>> 6 & 63, 128 | e & 63)
                        }
                    }
                }
                return r
            }

            function t(n) {
                var e, t, r, o, f, i = [], h;
                e = t = r = o = f = 0;
                if (n && n.length) {
                    h = n.length;
                    n += "";
                    while (e < h) {
                        r = n.charCodeAt(e);
                        t += 1;
                        if (r < 128) {
                            i[t] = String.fromCharCode(r);
                            e += 1
                        } else if (r > 191 && r < 224) {
                            o = n.charCodeAt(e + 1);
                            i[t] = String.fromCharCode((r & 31) << 6 | o & 63);
                            e += 2
                        } else {
                            o = n.charCodeAt(e + 1);
                            f = n.charCodeAt(e + 2);
                            i[t] = String.fromCharCode((r & 15) << 12 | (o & 63) << 6 | f & 63);
                            e += 3
                        }
                    }
                }
                return i.join("")
            }

            function r(n, e) {
                var t = (n & 65535) + (e & 65535), r = (n >> 16) + (e >> 16) + (t >> 16);
                return r << 16 | t & 65535
            }

            function o(n, e) {
                return n << e | n >>> 32 - e
            }

            function f(n, e) {
                var t = e ? "0123456789ABCDEF" : "0123456789abcdef", r = "", o, f = 0, i = n.length;
                for (; f < i; f += 1) {
                    o = n.charCodeAt(f);
                    r += t.charAt(o >>> 4 & 15) + t.charAt(o & 15)
                }
                return r
            }

            function i(n) {
                var e, t = n.length, r = "";
                for (e = 0; e < t; e += 1) {
                    r += String.fromCharCode(n.charCodeAt(e) & 255, n.charCodeAt(e) >>> 8 & 255)
                }
                return r
            }

            function h(n) {
                var e, t = n.length, r = "";
                for (e = 0; e < t; e += 1) {
                    r += String.fromCharCode(n.charCodeAt(e) >>> 8 & 255, n.charCodeAt(e) & 255)
                }
                return r
            }

            function u(n) {
                var e, t = n.length * 32, r = "";
                for (e = 0; e < t; e += 8) {
                    r += String.fromCharCode(n[e >> 5] >>> 24 - e % 32 & 255)
                }
                return r
            }

            function a(n) {
                var e, t = n.length * 32, r = "";
                for (e = 0; e < t; e += 8) {
                    r += String.fromCharCode(n[e >> 5] >>> e % 32 & 255)
                }
                return r
            }

            function c(n) {
                var e, t = n.length * 8, r = Array(n.length >> 2), o = r.length;
                for (e = 0; e < o; e += 1) {
                    r[e] = 0
                }
                for (e = 0; e < t; e += 8) {
                    r[e >> 5] |= (n.charCodeAt(e / 8) & 255) << e % 32
                }
                return r
            }

            function l(n) {
                var e, t = n.length * 8, r = Array(n.length >> 2), o = r.length;
                for (e = 0; e < o; e += 1) {
                    r[e] = 0
                }
                for (e = 0; e < t; e += 8) {
                    r[e >> 5] |= (n.charCodeAt(e / 8) & 255) << 24 - e % 32
                }
                return r
            }

            function D(n, e) {
                var t = e.length, r = Array(), o, f, i, h, u, a, c, l;
                a = Array(Math.ceil(n.length / 2));
                h = a.length;
                for (o = 0; o < h; o += 1) {
                    a[o] = n.charCodeAt(o * 2) << 8 | n.charCodeAt(o * 2 + 1)
                }
                while (a.length > 0) {
                    u = Array();
                    i = 0;
                    for (o = 0; o < a.length; o += 1) {
                        i = (i << 16) + a[o];
                        f = Math.floor(i / t);
                        i -= f * t;
                        if (u.length > 0 || f > 0) {
                            u[u.length] = f
                        }
                    }
                    r[r.length] = i;
                    a = u
                }
                c = "";
                for (o = r.length - 1; o >= 0; o--) {
                    c += e.charAt(r[o])
                }
                l = Math.ceil(n.length * 8 / (Math.log(e.length) / Math.log(2)));
                for (o = c.length; o < l; o += 1) {
                    c = e[0] + c
                }
                return c
            }

            function B(n, e) {
                var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", r = "", o = n.length, f, i, h;
                e = e || "=";
                for (f = 0; f < o; f += 3) {
                    h = n.charCodeAt(f) << 16 | (f + 1 < o ? n.charCodeAt(f + 1) << 8 : 0) | (f + 2 < o ? n.charCodeAt(f + 2) : 0);
                    for (i = 0; i < 4; i += 1) {
                        if (f * 8 + i * 6 > n.length * 8) {
                            r += e
                        } else {
                            r += t.charAt(h >>> 6 * (3 - i) & 63)
                        }
                    }
                }
                return r
            }

            n = {
                VERSION: "1.0.5", Base64: function () {
                    var n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", r = "=", o = false, f = true;
                    this.encode = function (t) {
                        var o, i, h, u = "", a = t.length;
                        r = r || "=";
                        t = f ? e(t) : t;
                        for (o = 0; o < a; o += 3) {
                            h = t.charCodeAt(o) << 16 | (o + 1 < a ? t.charCodeAt(o + 1) << 8 : 0) | (o + 2 < a ? t.charCodeAt(o + 2) : 0);
                            for (i = 0; i < 4; i += 1) {
                                if (o * 8 + i * 6 > a * 8) {
                                    u += r
                                } else {
                                    u += n.charAt(h >>> 6 * (3 - i) & 63)
                                }
                            }
                        }
                        return u
                    };
                    this.decode = function (e) {
                        var o, i, h, u, a, c, l, D, B, C, A = "", s = [];
                        if (!e) {
                            return e
                        }
                        o = C = 0;
                        e = e.replace(new RegExp("\" + r, "gi"), "");
                        do {
                            a = n.indexOf(e.charAt(o += 1));
                            c = n.indexOf(e.charAt(o += 1));
                            l = n.indexOf(e.charAt(o += 1));
                            D = n.indexOf(e.charAt(o += 1));
                            B = a << 18 | c << 12 | l << 6 | D;
                            i = B >> 16 & 255;
                            h = B >> 8 & 255;
                            u = B & 255;
                            C += 1;
                            if (l === 64) {
                                s[C] = String.fromCharCode(i)
                            } else if (D === 64) {
                                s[C] = String.fromCharCode(i, h)
                            } else {
                                s[C] = String.fromCharCode(i, h, u)
                            }
                        } while (o < e.length);
                        A = s.join("");
                        A = f ? t(A) : A;
                        return A
                    };
                    this.setPad = function (n) {
                        r = n || r;
                        return this
                    };
                    this.setTab = function (e) {
                        n = e || n;
                        return this
                    };
                    this.setUTF8 = function (n) {
                        if (typeof n === "boolean") {
                            f = n
                        }
                        return this
                    }
                }, CRC32: function (n) {
                    var t = 0, r = 0, o = 0, f, i, h;
                    n = e(n);
                    f = ["00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ", "79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ", "84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F ", "63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD ", "A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC ", "51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 ", "B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 ", "06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 ", "E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 ", "12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 ", "D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 ", "33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 ", "CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 ", "9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E ", "7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D ", "806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 ", "60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ", "AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ", "5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ", "B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ", "05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 ", "F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA ", "11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 ", "D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F ", "30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E ", "C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D"].join("");
                    t = t ^ -1;
                    for (i = 0, h = n.length; i < h; i += 1) {
                        o = (t ^ n.charCodeAt(i)) & 255;
                        r = "0x" + f.substr(o * 9, 8);
                        t = t >>> 8 ^ r
                    }
                    return (t ^ -1) >>> 0
                }, MD5: function (n) {
                    var t = n && typeof n.uppercase === "boolean" ? n.uppercase : false, i = n && typeof n.pad === "string" ? n.pda : "=", h = n && typeof n.utf8 === "boolean" ? n.utf8 : true;
                    this.hex = function (n) {
                        return f(u(n, h), t)
                    };
                    this.b64 = function (n) {
                        return B(u(n), i)
                    };
                    this.any = function (n, e) {
                        return D(u(n, h), e)
                    };
                    this.raw = function (n) {
                        return u(n, h)
                    };
                    this.hex_hmac = function (n, e) {
                        return f(l(n, e), t)
                    };
                    this.b64_hmac = function (n, e) {
                        return B(l(n, e), i)
                    };
                    this.any_hmac = function (n, e, t) {
                        return D(l(n, e), t)
                    };
                    this.vm_test = function () {
                        return hex("abc").toLowerCase() === "900150983cd24fb0d6963f7d28e17f72"
                    };
                    this.setUpperCase = function (n) {
                        if (typeof n === "boolean") {
                            t = n
                        }
                        return this
                    };
                    this.setPad = function (n) {
                        i = n || i;
                        return this
                    };
                    this.setUTF8 = function (n) {
                        if (typeof n === "boolean") {
                            h = n
                        }
                        return this
                    };
                    function u(n) {
                        n = h ? e(n) : n;
                        return a(C(c(n), n.length * 8))
                    }

                    function l(n, t) {
                        var r, o, f, i, u;
                        n = h ? e(n) : n;
                        t = h ? e(t) : t;
                        r = c(n);
                        if (r.length > 16) {
                            r = C(r, n.length * 8)
                        }
                        o = Array(16), f = Array(16);
                        for (u = 0; u < 16; u += 1) {
                            o[u] = r[u] ^ 909522486;
                            f[u] = r[u] ^ 1549556828
                        }
                        i = C(o.concat(c(t)), 512 + t.length * 8);
                        return a(C(f.concat(i), 512 + 128))
                    }

                    function C(n, e) {
                        var t, o, f, i, h, u = 1732584193, a = -271733879, c = -1732584194, l = 271733878;
                        n[e >> 5] |= 128 << e % 32;
                        n[(e + 64 >>> 9 << 4) + 14] = e;
                        for (t = 0; t < n.length; t += 16) {
                            o = u;
                            f = a;
                            i = c;
                            h = l;
                            u = s(u, a, c, l, n[t + 0], 7, -680876936);
                            l = s(l, u, a, c, n[t + 1], 12, -389564586);
                            c = s(c, l, u, a, n[t + 2], 17, 606105819);
                            a = s(a, c, l, u, n[t + 3], 22, -1044525330);
                            u = s(u, a, c, l, n[t + 4], 7, -176418897);
                            l = s(l, u, a, c, n[t + 5], 12, 1200080426);
                            c = s(c, l, u, a, n[t + 6], 17, -1473231341);
                            a = s(a, c, l, u, n[t + 7], 22, -45705983);
                            u = s(u, a, c, l, n[t + 8], 7, 1770035416);
                            l = s(l, u, a, c, n[t + 9], 12, -1958414417);
                            c = s(c, l, u, a, n[t + 10], 17, -42063);
                            a = s(a, c, l, u, n[t + 11], 22, -1990404162);
                            u = s(u, a, c, l, n[t + 12], 7, 1804603682);
                            l = s(l, u, a, c, n[t + 13], 12, -40341101);
                            c = s(c, l, u, a, n[t + 14], 17, -1502002290);
                            a = s(a, c, l, u, n[t + 15], 22, 1236535329);
                            u = w(u, a, c, l, n[t + 1], 5, -165796510);
                            l = w(l, u, a, c, n[t + 6], 9, -1069501632);
                            c = w(c, l, u, a, n[t + 11], 14, 643717713);
                            a = w(a, c, l, u, n[t + 0], 20, -373897302);
                            u = w(u, a, c, l, n[t + 5], 5, -701558691);
                            l = w(l, u, a, c, n[t + 10], 9, 38016083);
                            c = w(c, l, u, a, n[t + 15], 14, -660478335);
                            a = w(a, c, l, u, n[t + 4], 20, -405537848);
                            u = w(u, a, c, l, n[t + 9], 5, 568446438);
                            l = w(l, u, a, c, n[t + 14], 9, -1019803690);
                            c = w(c, l, u, a, n[t + 3], 14, -187363961);
                            a = w(a, c, l, u, n[t + 8], 20, 1163531501);
                            u = w(u, a, c, l, n[t + 13], 5, -1444681467);
                            l = w(l, u, a, c, n[t + 2], 9, -51403784);
                            c = w(c, l, u, a, n[t + 7], 14, 1735328473);
                            a = w(a, c, l, u, n[t + 12], 20, -1926607734);
                            u = F(u, a, c, l, n[t + 5], 4, -378558);
                            l = F(l, u, a, c, n[t + 8], 11, -2022574463);
                            c = F(c, l, u, a, n[t + 11], 16, 1839030562);
                            a = F(a, c, l, u, n[t + 14], 23, -35309556);
                            u = F(u, a, c, l, n[t + 1], 4, -1530992060);
                            l = F(l, u, a, c, n[t + 4], 11, 1272893353);
                            c = F(c, l, u, a, n[t + 7], 16, -155497632);
                            a = F(a, c, l, u, n[t + 10], 23, -1094730640);
                            u = F(u, a, c, l, n[t + 13], 4, 681279174);
                            l = F(l, u, a, c, n[t + 0], 11, -358537222);
                            c = F(c, l, u, a, n[t + 3], 16, -722521979);
                            a = F(a, c, l, u, n[t + 6], 23, 76029189);
                            u = F(u, a, c, l, n[t + 9], 4, -640364487);
                            l = F(l, u, a, c, n[t + 12], 11, -421815835);
                            c = F(c, l, u, a, n[t + 15], 16, 530742520);
                            a = F(a, c, l, u, n[t + 2], 23, -995338651);
                            u = E(u, a, c, l, n[t + 0], 6, -198630844);
                            l = E(l, u, a, c, n[t + 7], 10, 1126891415);
                            c = E(c, l, u, a, n[t + 14], 15, -1416354905);
                            a = E(a, c, l, u, n[t + 5], 21, -57434055);
                            u = E(u, a, c, l, n[t + 12], 6, 1700485571);
                            l = E(l, u, a, c, n[t + 3], 10, -1894986606);
                            c = E(c, l, u, a, n[t + 10], 15, -1051523);
                            a = E(a, c, l, u, n[t + 1], 21, -2054922799);
                            u = E(u, a, c, l, n[t + 8], 6, 1873313359);
                            l = E(l, u, a, c, n[t + 15], 10, -30611744);
                            c = E(c, l, u, a, n[t + 6], 15, -1560198380);
                            a = E(a, c, l, u, n[t + 13], 21, 1309151649);
                            u = E(u, a, c, l, n[t + 4], 6, -145523070);
                            l = E(l, u, a, c, n[t + 11], 10, -1120210379);
                            c = E(c, l, u, a, n[t + 2], 15, 718787259);
                            a = E(a, c, l, u, n[t + 9], 21, -343485551);
                            u = r(u, o);
                            a = r(a, f);
                            c = r(c, i);
                            l = r(l, h)
                        }
                        return Array(u, a, c, l)
                    }

                    function A(n, e, t, f, i, h) {
                        return r(o(r(r(e, n), r(f, h)), i), t)
                    }

                    function s(n, e, t, r, o, f, i) {
                        return A(e & t | ~e & r, n, e, o, f, i)
                    }

                    function w(n, e, t, r, o, f, i) {
                        return A(e & r | t & ~r, n, e, o, f, i)
                    }

                    function F(n, e, t, r, o, f, i) {
                        return A(e ^ t ^ r, n, e, o, f, i)
                    }

                    function E(n, e, t, r, o, f, i) {
                        return A(t ^ (e | ~r), n, e, o, f, i)
                    }
                }, SHA1: function (n) {
                    var t = n && typeof n.uppercase === "boolean" ? n.uppercase : false, i = n && typeof n.pad === "string" ? n.pda : "=", h = n && typeof n.utf8 === "boolean" ? n.utf8 : true;
                    this.hex = function (n) {
                        return f(a(n, h), t)
                    };
                    this.b64 = function (n) {
                        return B(a(n, h), i)
                    };
                    this.any = function (n, e) {
                        return D(a(n, h), e)
                    };
                    this.raw = function (n) {
                        return a(n, h)
                    };
                    this.hex_hmac = function (n, e) {
                        return f(c(n, e))
                    };
                    this.b64_hmac = function (n, e) {
                        return B(c(n, e), i)
                    };
                    this.any_hmac = function (n, e, t) {
                        return D(c(n, e), t)
                    };
                    this.vm_test = function () {
                        return hex("abc").toLowerCase() === "900150983cd24fb0d6963f7d28e17f72"
                    };
                    this.setUpperCase = function (n) {
                        if (typeof n === "boolean") {
                            t = n
                        }
                        return this
                    };
                    this.setPad = function (n) {
                        i = n || i;
                        return this
                    };
                    this.setUTF8 = function (n) {
                        if (typeof n === "boolean") {
                            h = n
                        }
                        return this
                    };
                    function a(n) {
                        n = h ? e(n) : n;
                        return u(C(l(n), n.length * 8))
                    }

                    function c(n, t) {
                        var r, o, f, i, a;
                        n = h ? e(n) : n;
                        t = h ? e(t) : t;
                        r = l(n);
                        if (r.length > 16) {
                            r = C(r, n.length * 8)
                        }
                        o = Array(16), f = Array(16);
                        for (i = 0; i < 16; i += 1) {
                            o[i] = r[i] ^ 909522486;
                            f[i] = r[i] ^ 1549556828
                        }
                        a = C(o.concat(l(t)), 512 + t.length * 8);
                        return u(C(f.concat(a), 512 + 160))
                    }

                    function C(n, e) {
                        var t, f, i, h, u, a, c, l, D = Array(80), B = 1732584193, C = -271733879, w = -1732584194, F = 271733878, E = -1009589776;
                        n[e >> 5] |= 128 << 24 - e % 32;
                        n[(e + 64 >> 9 << 4) + 15] = e;
                        for (t = 0; t < n.length; t += 16) {
                            h = B, u = C;
                            a = w;
                            c = F;
                            l = E;
                            for (f = 0; f < 80; f += 1) {
                                if (f < 16) {
                                    D[f] = n[t + f]
                                } else {
                                    D[f] = o(D[f - 3] ^ D[f - 8] ^ D[f - 14] ^ D[f - 16], 1)
                                }
                                i = r(r(o(B, 5), A(f, C, w, F)), r(r(E, D[f]), s(f)));
                                E = F;
                                F = w;
                                w = o(C, 30);
                                C = B;
                                B = i
                            }
                            B = r(B, h);
                            C = r(C, u);
                            w = r(w, a);
                            F = r(F, c);
                            E = r(E, l)
                        }
                        return Array(B, C, w, F, E)
                    }

                    function A(n, e, t, r) {
                        if (n < 20) {
                            return e & t | ~e & r
                        }
                        if (n < 40) {
                            return e ^ t ^ r
                        }
                        if (n < 60) {
                            return e & t | e & r | t & r
                        }
                        return e ^ t ^ r
                    }

                    function s(n) {
                        return n < 20 ? 1518500249 : n < 40 ? 1859775393 : n < 60 ? -1894007588 : -899497514
                    }
                }, SHA256: function (n) {
                    var t = n && typeof n.uppercase === "boolean" ? n.uppercase : false, o = n && typeof n.pad === "string" ? n.pda : "=", i = n && typeof n.utf8 === "boolean" ? n.utf8 : true, h;
                    this.hex = function (n) {
                        return f(a(n, i))
                    };
                    this.b64 = function (n) {
                        return B(a(n, i), o)
                    };
                    this.any = function (n, e) {
                        return D(a(n, i), e)
                    };
                    this.raw = function (n) {
                        return a(n, i)
                    };
                    this.hex_hmac = function (n, e) {
                        return f(c(n, e))
                    };
                    this.b64_hmac = function (n, e) {
                        return B(c(n, e), o)
                    };
                    this.any_hmac = function (n, e, t) {
                        return D(c(n, e), t)
                    };
                    this.vm_test = function () {
                        return hex("abc").toLowerCase() === "900150983cd24fb0d6963f7d28e17f72"
                    };
                    this.setUpperCase = function (n) {
                        if (typeof n === "boolean") {
                            t = n
                        }
                        return this
                    };
                    this.setPad = function (n) {
                        o = n || o;
                        return this
                    };
                    this.setUTF8 = function (n) {
                        if (typeof n === "boolean") {
                            i = n
                        }
                        return this
                    };
                    function a(n, t) {
                        n = t ? e(n) : n;
                        return u(m(l(n), n.length * 8))
                    }

                    function c(n, t) {
                        n = i ? e(n) : n;
                        t = i ? e(t) : t;
                        var r, o = 0, f = l(n), h = Array(16), a = Array(16);
                        if (f.length > 16) {
                            f = m(f, n.length * 8)
                        }
                        for (; o < 16; o += 1) {
                            h[o] = f[o] ^ 909522486;
                            a[o] = f[o] ^ 1549556828
                        }
                        r = m(h.concat(l(t)), 512 + t.length * 8);
                        return u(m(a.concat(r), 512 + 256))
                    }

                    function C(n, e) {
                        return n >>> e | n << 32 - e
                    }

                    function A(n, e) {
                        return n >>> e
                    }

                    function s(n, e, t) {
                        return n & e ^ ~n & t
                    }

                    function w(n, e, t) {
                        return n & e ^ n & t ^ e & t
                    }

                    function F(n) {
                        return C(n, 2) ^ C(n, 13) ^ C(n, 22)
                    }

                    function E(n) {
                        return C(n, 6) ^ C(n, 11) ^ C(n, 25)
                    }

                    function d(n) {
                        return C(n, 7) ^ C(n, 18) ^ A(n, 3)
                    }

                    function g(n) {
                        return C(n, 17) ^ C(n, 19) ^ A(n, 10)
                    }

                    function p(n) {
                        return C(n, 28) ^ C(n, 34) ^ C(n, 39)
                    }

                    function y(n) {
                        return C(n, 14) ^ C(n, 18) ^ C(n, 41)
                    }

                    function b(n) {
                        return C(n, 1) ^ C(n, 8) ^ A(n, 7)
                    }

                    function v(n) {
                        return C(n, 19) ^ C(n, 61) ^ A(n, 6)
                    }

                    h = [1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998];
                    function m(n, e) {
                        var t = [1779033703, -1150833019, 1013904242, -1521486534, 1359893119, -1694144372, 528734635, 1541459225];
                        var o = new Array(64);
                        var f, i, u, a, c, l, D, B;
                        var C, A, p, y;
                        n[e >> 5] |= 128 << 24 - e % 32;
                        n[(e + 64 >> 9 << 4) + 15] = e;
                        for (C = 0; C < n.length; C += 16) {
                            f = t[0];
                            i = t[1];
                            u = t[2];
                            a = t[3];
                            c = t[4];
                            l = t[5];
                            D = t[6];
                            B = t[7];
                            for (A = 0; A < 64; A += 1) {
                                if (A < 16) {
                                    o[A] = n[A + C]
                                } else {
                                    o[A] = r(r(r(g(o[A - 2]), o[A - 7]), d(o[A - 15])), o[A - 16])
                                }
                                p = r(r(r(r(B, E(c)), s(c, l, D)), h[A]), o[A]);
                                y = r(F(f), w(f, i, u));
                                B = D;
                                D = l;
                                l = c;
                                c = r(a, p);
                                a = u;
                                u = i;
                                i = f;
                                f = r(p, y)
                            }
                            t[0] = r(f, t[0]);
                            t[1] = r(i, t[1]);
                            t[2] = r(u, t[2]);
                            t[3] = r(a, t[3]);
                            t[4] = r(c, t[4]);
                            t[5] = r(l, t[5]);
                            t[6] = r(D, t[6]);
                            t[7] = r(B, t[7])
                        }
                        return t
                    }
                }, SHA512: function (n) {
                    var t = n && typeof n.uppercase === "boolean" ? n.uppercase : false, r = n && typeof n.pad === "string" ? n.pda : "=", o = n && typeof n.utf8 === "boolean" ? n.utf8 : true, i;
                    this.hex = function (n) {
                        return f(h(n))
                    };
                    this.b64 = function (n) {
                        return B(h(n), r)
                    };
                    this.any = function (n, e) {
                        return D(h(n), e)
                    };
                    this.raw = function (n) {
                        return h(n, o)
                    };
                    this.hex_hmac = function (n, e) {
                        return f(a(n, e))
                    };
                    this.b64_hmac = function (n, e) {
                        return B(a(n, e), r)
                    };
                    this.any_hmac = function (n, e, t) {
                        return D(a(n, e), t)
                    };
                    this.vm_test = function () {
                        return hex("abc").toLowerCase() === "900150983cd24fb0d6963f7d28e17f72"
                    };
                    this.setUpperCase = function (n) {
                        if (typeof n === "boolean") {
                            t = n
                        }
                        return this
                    };
                    this.setPad = function (n) {
                        r = n || r;
                        return this
                    };
                    this.setUTF8 = function (n) {
                        if (typeof n === "boolean") {
                            o = n
                        }
                        return this
                    };
                    function h(n) {
                        n = o ? e(n) : n;
                        return u(c(l(n), n.length * 8))
                    }

                    function a(n, t) {
                        n = o ? e(n) : n;
                        t = o ? e(t) : t;
                        var r, f = 0, i = l(n), h = Array(32), a = Array(32);
                        if (i.length > 32) {
                            i = c(i, n.length * 8)
                        }
                        for (; f < 32; f += 1) {
                            h[f] = i[f] ^ 909522486;
                            a[f] = i[f] ^ 1549556828
                        }
                        r = c(h.concat(l(t)), 1024 + t.length * 8);
                        return u(c(a.concat(r), 1024 + 512))
                    }

                    function c(n, e) {
                        var t, r, o, f = new Array(80), h = new Array(16), u = [new C(1779033703, -205731576), new C(-1150833019, -2067093701), new C(1013904242, -23791573), new C(-1521486534, 1595750129), new C(1359893119, -1377402159), new C(-1694144372, 725511199), new C(528734635, -79577749), new C(1541459225, 327033209)], a = new C(0, 0), c = new C(0, 0), l = new C(0, 0), D = new C(0, 0), B = new C(0, 0), p = new C(0, 0), y = new C(0, 0), b = new C(0, 0), v = new C(0, 0), m = new C(0, 0), x = new C(0, 0), _ = new C(0, 0), S = new C(0, 0), U = new C(0, 0), j = new C(0, 0), M = new C(0, 0), T = new C(0, 0);
                        if (i === undefined) {
                            i = [new C(1116352408, -685199838), new C(1899447441, 602891725), new C(-1245643825, -330482897), new C(-373957723, -2121671748), new C(961987163, -213338824), new C(1508970993, -1241133031), new C(-1841331548, -1357295717), new C(-1424204075, -630357736), new C(-670586216, -1560083902), new C(310598401, 1164996542), new C(607225278, 1323610764), new C(1426881987, -704662302), new C(1925078388, -226784913), new C(-2132889090, 991336113), new C(-1680079193, 633803317), new C(-1046744716, -815192428), new C(-459576895, -1628353838), new C(-272742522, 944711139), new C(264347078, -1953704523), new C(604807628, 2007800933), new C(770255983, 1495990901), new C(1249150122, 1856431235), new C(1555081692, -1119749164), new C(1996064986, -2096016459), new C(-1740746414, -295247957), new C(-1473132947, 766784016), new C(-1341970488, -1728372417), new C(-1084653625, -1091629340), new C(-958395405, 1034457026), new C(-710438585, -1828018395), new C(113926993, -536640913), new C(338241895, 168717936), new C(666307205, 1188179964), new C(773529912, 1546045734), new C(1294757372, 1522805485), new C(1396182291, -1651133473), new C(1695183700, -1951439906), new C(1986661051, 1014477480), new C(-2117940946, 1206759142), new C(-1838011259, 344077627), new C(-1564481375, 1290863460), new C(-1474664885, -1136513023), new C(-1035236496, -789014639), new C(-949202525, 106217008), new C(-778901479, -688958952), new C(-694614492, 1432725776), new C(-200395387, 1467031594), new C(275423344, 851169720), new C(430227734, -1194143544), new C(506948616, 1363258195), new C(659060556, -544281703), new C(883997877, -509917016), new C(958139571, -976659869), new C(1322822218, -482243893), new C(1537002063, 2003034995), new C(1747873779, -692930397), new C(1955562222, 1575990012), new C(2024104815, 1125592928), new C(-2067236844, -1578062990), new C(-1933114872, 442776044), new C(-1866530822, 593698344), new C(-1538233109, -561857047), new C(-1090935817, -1295615723), new C(-965641998, -479046869), new C(-903397682, -366583396), new C(-779700025, 566280711), new C(-354779690, -840897762), new C(-176337025, -294727304), new C(116418474, 1914138554), new C(174292421, -1563912026), new C(289380356, -1090974290), new C(460393269, 320620315), new C(685471733, 587496836), new C(852142971, 1086792851), new C(1017036298, 365543100), new C(1126000580, -1676669620), new C(1288033470, -885112138), new C(1501505948, -60457430), new C(1607167915, 987167468), new C(1816402316, 1246189591)]
                        }
                        for (r = 0; r < 80; r += 1) {
                            f[r] = new C(0, 0)
                        }
                        n[e >> 5] |= 128 << 24 - (e & 31);
                        n[(e + 128 >> 10 << 5) + 31] = e;
                        o = n.length;
                        for (r = 0; r < o; r += 32) {
                            A(l, u[0]);
                            A(D, u[1]);
                            A(B, u[2]);
                            A(p, u[3]);
                            A(y, u[4]);
                            A(b, u[5]);
                            A(v, u[6]);
                            A(m, u[7]);
                            for (t = 0; t < 16; t += 1) {
                                f[t].h = n[r + 2 * t];
                                f[t].l = n[r + 2 * t + 1]
                            }
                            for (t = 16; t < 80; t += 1) {
                                s(j, f[t - 2], 19);
                                w(M, f[t - 2], 29);
                                F(T, f[t - 2], 6);
                                _.l = j.l ^ M.l ^ T.l;
                                _.h = j.h ^ M.h ^ T.h;
                                s(j, f[t - 15], 1);
                                s(M, f[t - 15], 8);
                                F(T, f[t - 15], 7);
                                x.l = j.l ^ M.l ^ T.l;
                                x.h = j.h ^ M.h ^ T.h;
                                d(f[t], _, f[t - 7], x, f[t - 16])
                            }
                            for (t = 0; t < 80; t += 1) {
                                S.l = y.l & b.l ^ ~y.l & v.l;
                                S.h = y.h & b.h ^ ~y.h & v.h;
                                s(j, y, 14);
                                s(M, y, 18);
                                w(T, y, 9);
                                _.l = j.l ^ M.l ^ T.l;
                                _.h = j.h ^ M.h ^ T.h;
                                s(j, l, 28);
                                w(M, l, 2);
                                w(T, l, 7);
                                x.l = j.l ^ M.l ^ T.l;
                                x.h = j.h ^ M.h ^ T.h;
                                U.l = l.l & D.l ^ l.l & B.l ^ D.l & B.l;
                                U.h = l.h & D.h ^ l.h & B.h ^ D.h & B.h;
                                g(a, m, _, S, i[t], f[t]);
                                E(c, x, U);
                                A(m, v);
                                A(v, b);
                                A(b, y);
                                E(y, p, a);
                                A(p, B);
                                A(B, D);
                                A(D, l);
                                E(l, a, c)
                            }
                            E(u[0], u[0], l);
                            E(u[1], u[1], D);
                            E(u[2], u[2], B);
                            E(u[3], u[3], p);
                            E(u[4], u[4], y);
                            E(u[5], u[5], b);
                            E(u[6], u[6], v);
                            E(u[7], u[7], m)
                        }
                        for (r = 0; r < 8; r += 1) {
                            h[2 * r] = u[r].h;
                            h[2 * r + 1] = u[r].l
                        }
                        return h
                    }

                    function C(n, e) {
                        this.h = n;
                        this.l = e
                    }

                    function A(n, e) {
                        n.h = e.h;
                        n.l = e.l
                    }

                    function s(n, e, t) {
                        n.l = e.l >>> t | e.h << 32 - t;
                        n.h = e.h >>> t | e.l << 32 - t
                    }

                    function w(n, e, t) {
                        n.l = e.h >>> t | e.l << 32 - t;
                        n.h = e.l >>> t | e.h << 32 - t
                    }

                    function F(n, e, t) {
                        n.l = e.l >>> t | e.h << 32 - t;
                        n.h = e.h >>> t
                    }

                    function E(n, e, t) {
                        var r = (e.l & 65535) + (t.l & 65535);
                        var o = (e.l >>> 16) + (t.l >>> 16) + (r >>> 16);
                        var f = (e.h & 65535) + (t.h & 65535) + (o >>> 16);
                        var i = (e.h >>> 16) + (t.h >>> 16) + (f >>> 16);
                        n.l = r & 65535 | o << 16;
                        n.h = f & 65535 | i << 16
                    }

                    function d(n, e, t, r, o) {
                        var f = (e.l & 65535) + (t.l & 65535) + (r.l & 65535) + (o.l & 65535);
                        var i = (e.l >>> 16) + (t.l >>> 16) + (r.l >>> 16) + (o.l >>> 16) + (f >>> 16);
                        var h = (e.h & 65535) + (t.h & 65535) + (r.h & 65535) + (o.h & 65535) + (i >>> 16);
                        var u = (e.h >>> 16) + (t.h >>> 16) + (r.h >>> 16) + (o.h >>> 16) + (h >>> 16);
                        n.l = f & 65535 | i << 16;
                        n.h = h & 65535 | u << 16
                    }

                    function g(n, e, t, r, o, f) {
                        var i = (e.l & 65535) + (t.l & 65535) + (r.l & 65535) + (o.l & 65535) + (f.l & 65535), h = (e.l >>> 16) + (t.l >>> 16) + (r.l >>> 16) + (o.l >>> 16) + (f.l >>> 16) + (i >>> 16), u = (e.h & 65535) + (t.h & 65535) + (r.h & 65535) + (o.h & 65535) + (f.h & 65535) + (h >>> 16), a = (e.h >>> 16) + (t.h >>> 16) + (r.h >>> 16) + (o.h >>> 16) + (f.h >>> 16) + (u >>> 16);
                        n.l = i & 65535 | h << 16;
                        n.h = u & 65535 | a << 16
                    }
                }, RMD160: function (n) {
                    var t = n && typeof n.uppercase === "boolean" ? n.uppercase : false, i = n && typeof n.pad === "string" ? n.pda : "=", h = n && typeof n.utf8 === "boolean" ? n.utf8 : true, u = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13], a = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11], l = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6], C = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11];
                    this.hex = function (n) {
                        return f(A(n, h))
                    };
                    this.b64 = function (n) {
                        return B(A(n, h), i)
                    };
                    this.any = function (n, e) {
                        return D(A(n, h), e)
                    };
                    this.raw = function (n) {
                        return A(n, h)
                    };
                    this.hex_hmac = function (n, e) {
                        return f(s(n, e))
                    };
                    this.b64_hmac = function (n, e) {
                        return B(s(n, e), i)
                    };
                    this.any_hmac = function (n, e, t) {
                        return D(s(n, e), t)
                    };
                    this.vm_test = function () {
                        return hex("abc").toLowerCase() === "900150983cd24fb0d6963f7d28e17f72"
                    };
                    this.setUpperCase = function (n) {
                        if (typeof n === "boolean") {
                            t = n
                        }
                        return this
                    };
                    this.setPad = function (n) {
                        if (typeof n !== "undefined") {
                            i = n
                        }
                        return this
                    };
                    this.setUTF8 = function (n) {
                        if (typeof n === "boolean") {
                            h = n
                        }
                        return this
                    };
                    function A(n) {
                        n = h ? e(n) : n;
                        return w(F(c(n), n.length * 8))
                    }

                    function s(n, t) {
                        n = h ? e(n) : n;
                        t = h ? e(t) : t;
                        var r, o, f = c(n), i = Array(16), u = Array(16);
                        if (f.length > 16) {
                            f = F(f, n.length * 8)
                        }
                        for (r = 0; r < 16; r += 1) {
                            i[r] = f[r] ^ 909522486;
                            u[r] = f[r] ^ 1549556828
                        }
                        o = F(i.concat(c(t)), 512 + t.length * 8);
                        return w(F(u.concat(o), 512 + 160))
                    }

                    function w(n) {
                        var e, t = "", r = n.length * 32;
                        for (e = 0; e < r; e += 8) {
                            t += String.fromCharCode(n[e >> 5] >>> e % 32 & 255)
                        }
                        return t
                    }

                    function F(n, e) {
                        var t, f, i, h, c = 1732584193, D = 4023233417, B = 2562383102, A = 271733878, s = 3285377520, w, F, p, y, b, v, m, x, _, S;
                        n[e >> 5] |= 128 << e % 32;
                        n[(e + 64 >>> 9 << 4) + 14] = e;
                        h = n.length;
                        for (i = 0; i < h; i += 16) {
                            w = v = c;
                            F = m = D;
                            p = x = B;
                            y = _ = A;
                            b = S = s;
                            for (f = 0; f <= 79; f += 1) {
                                t = r(w, E(f, F, p, y));
                                t = r(t, n[i + u[f]]);
                                t = r(t, d(f));
                                t = r(o(t, l[f]), b);
                                w = b;
                                b = y;
                                y = o(p, 10);
                                p = F;
                                F = t;
                                t = r(v, E(79 - f, m, x, _));
                                t = r(t, n[i + a[f]]);
                                t = r(t, g(f));
                                t = r(o(t, C[f]), S);
                                v = S;
                                S = _;
                                _ = o(x, 10);
                                x = m;
                                m = t
                            }
                            t = r(D, r(p, _));
                            D = r(B, r(y, S));
                            B = r(A, r(b, v));
                            A = r(s, r(w, m));
                            s = r(c, r(F, x));
                            c = t
                        }
                        return [c, D, B, A, s]
                    }

                    function E(n, e, t, r) {
                        return 0 <= n && n <= 15 ? e ^ t ^ r : 16 <= n && n <= 31 ? e & t | ~e & r : 32 <= n && n <= 47 ? (e | ~t) ^ r : 48 <= n && n <= 63 ? e & r | t & ~r : 64 <= n && n <= 79 ? e ^ (t | ~r) : "rmd160_f: j out of range"
                    }

                    function d(n) {
                        return 0 <= n && n <= 15 ? 0 : 16 <= n && n <= 31 ? 1518500249 : 32 <= n && n <= 47 ? 1859775393 : 48 <= n && n <= 63 ? 2400959708 : 64 <= n && n <= 79 ? 2840853838 : "rmd160_K1: j out of range"
                    }

                    function g(n) {
                        return 0 <= n && n <= 15 ? 1352829926 : 16 <= n && n <= 31 ? 1548603684 : 32 <= n && n <= 47 ? 1836072691 : 48 <= n && n <= 63 ? 2053994217 : 64 <= n && n <= 79 ? 0 : "rmd160_K2: j out of range"
                    }
                }
            };
            (function (e, t) {
                var r = false;
                if (typeof exports === "object") {
                    r = exports;
                    if (exports && typeof global === "object" && global && global === global.global) {
                        e = global
                    }
                }
                if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
                    define(function () {
                        return n
                    })
                } else if (r) {
                    if (typeof module === "object" && module && module.exports === r) {
                        module.exports = n
                    } else {
                        r.Hashes = n
                    }
                } else {
                    e.Hashes = n
                }
            })(this)
        })();
        function sha1(str) {
            var sha1Val = new Hashes.SHA1().hex(str);
            return sha1Val;
        }

        var appKey = appKey;
        var appSecret = appSecret;
        var nonce = Math.floor(Math.random() * 1000000);
        var timestamp = Date.now();
        var signature = sha1("" + appSecret + nonce + timestamp);
         userId = userId;
        var name = name;
        var portraitUri = portraitUri;
        var url = "https://api.cn.rong.io/user/getToken.json";
        api.ajax({
            url: url,
            method: "post",
            headers: {
                "RC-App-Key": appKey,
                "RC-Nonce": "" + nonce,
                "RC-Timestamp": "" + timestamp,
                "RC-Signature": "" + signature,
                "Content-Type": "application/x-www-form-urlencoded"
            },
            data: {
                values: {
                    userId: userId,
                    name: name,
                    portraitUri: portraitUri
                }
            }
        }, function (ret, err) {
            if ("function" == typeof callback) {
                callback(ret, err)
            }
        });
    }
  1. 获取token
  function getToken() {
        var appKey = "x18ywvqfxlf5c"; // 融云的appkey
        var appSecret = "IKVkrndJkaBTu"; // 融云的appSecret
         userId = userId;  // 在登陆时自定义一个userId存在Storage中了,用getStorage获取的
        var name = 'wj';
        var portraitUri = "widget://image/jych/fr.jpg"; // 聊天头像 
        var callback = function (ret, err) {
            istoken = true;
            api.toast({
                msg: "连接成功"
            });

            rong.connect({   // 时时保持融云连接状态
                token: ret.token
            }, function (ret, err) {

            });
        };
        ajaxToRongCloud(appKey, appSecret, userId, name, portraitUri, callback); 
    }
  1. 一个工具方法: 可以获取 所有表情图片的名称和真实url地址, 以JSON对像形式返回;
    其中以表情文本为 属性名, 以图片真实路径为属性值. 用来发送表情的
    function getImgsPaths(sourcePathOfChatBox, callback) {
        var jsonPath = sourcePathOfChatBox;
        api.readFile({
            path: jsonPath
        }, function (ret, err) {
            if (ret.status) {
                var emotionArray = JSON.parse(ret.data);
                var emotion = {};
                for (var idx in emotionArray) {
                    var emotionItem = emotionArray[idx];
                    var emotionText = emotionItem["text"];
                    var emotionUrl = "../../iconimages/emotion/" + emotionItem["name"] + ".png";
                    emotion[emotionText] = emotionUrl;
                }
                /* 把 emotion对象 回调出去. */
                if ("function" === typeof (callback)) {
                    callback(emotion);
                }
            }
        });
    }
  1. 将文字中的表情符号翻译成图片,并可自定义图片尺寸.
            function transText(text, imgWidth, imgHeight) {
                var imgWidth = imgWidth || 10;
                var imgHeight = imgHeight || 10;
                var regx = /[(.*?)]/gm
                var textTransed = text.replace(regx, function (match) {
                    var imgSrc = emotionData[match];
                    if (!imgSrc) {
                        return match;
                    }
                    var img = imgSrc;
                    img = "<img width=imgWidth height=imgHeight src="+img+">";
                    return img;
            });

                return textTransed;
            };
  1. 发送消息的方法
function diyChat(sendMsg) {
                if (istoken) {
                    rong.sendTextMessage({
                        conversationType: 'PRIVATE',
                        targetId: '123',
                        text: sendMsg,
                        extra: ''
                    }, function (ret, err) {
                        if (ret.status == 'prepare') {
                            //准备发送
                            var mess = $api.byId('messageList');
                            $api.append(mess, '<div class="sender clearfix"><div class="sender-avatar clearfix"><img src="../../image/jych/fr.jpg"></div><div class="sender-cont"><div class="right_triangle"></div><span>' + ret.result.message.content.text + '</span><div id="status_' + ret.result.message.messageId + '" class="status">等待发送</div></div></div>');
                        } else if (ret.status == 'success')
                        //发送成功后移除loading
                            var load = $api.byId('status_' + ret.result.message.messageId);
                        $api.remove(load);
                    });
                } else {
                    api.toast({
                        msg: "发送失败,正在连接"
                    });
                    getToken();
                }
            }
  1. 接受消息的方法
  rong.setOnReceiveMessageListener(function (ret, err) {
                $api.append($api.byId('messageList'), '<div class="receiver"><div class="receiver-avatar"><img src="../../image/jych/fr.jpg"></div><div class="receiver-cont"><div class="left_triangle"></div><span>' + ret.result.message.content.text + '</span></div></div>');


        });

地图模块(用的shibMap模块)

  var map;
        var lonSelft, latSelf;
        // alert(api.systemType)
        map = api.require('bMap');
        var bMap = api.require('bMap'); // 初始化地图模块

        if (api.systemType == "ios") {  // 判断是不是ios设备,因为Android不需要init
            alert("ditu")
            map.initMapSDK(function (ret,err) {
                if (ret.status) {
                    alert('地图初始化成功,可以从百度地图服务器检索信息了!');
                }else {
                    alert(JSON.stringify(err));
                }
            });
        }

        // 获取定位
        bMap.getLocation({
            accuracy: '100m',
            autoStop: true,
            filter: 1
        }, function (ret, err) {
            if (ret.status) {
                lonSelft = ret.lon;
                latSelf = ret.lat;
//                alert(JSON.stringify(ret));
//                alert('lonSelft1', lonSelft)
//                alert('latSelf1', latSelf)
                mapOpen();
            } else {
                alert("请把手机定位打开");
            }
        });
        function mapOpen() {
            map.open({
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                center: {
                    lon: 116.297,
                    lat: 40.109
//                    lon: lonSelft,
//                    lat: latSelf
                },
                zoomLevel: 15,
                showUserLocation: true,
                fixedOn: "fraMap",
                fixed: true
            }, function (ret) {
                if (ret.status) {
                    alert('地图打开成功');
                    addAn();
                    addBillboard();
                }
            });
        }

// 添加标注
        function addAn() {
            map.addAnnotations({
                annotations: [{
                    id: 1,
                    lon: 116.297,
                    lat: 40.109
                }],
                icon: 'widget://',
                draggable: true
            }, function (ret) {
                if (ret) {
//                    alert(ret.id);
//                    setBubble();
                    searchRoute();
                }
            });
        }

// 设置布广告
        function addBillboard() {
            map.addBillboard({
                id: 4,
                coords: {
                    lon: 116.297,
                    lat: 40.109
                },
                bgImg: 'widget://image/bMapTest.png',
                content: {
                    title: '鸿运烟酒',
                    subTitle: '灵宝市四平市场东',
                    illus: 'http://ico.ooopic.com/ajax/iconpng/?id=145044.png'
                },
                styles: {
                    titleColor: '#000',
                    titleSize: 16,
                    subTitleColor: '#999',
                    subTitleSize: 12,
                    illusAlign: 'left'
                }
            }, function (ret) {
                if (ret) {
                    searchRoute();
                    map.setRegion({
                        lbLon: 116.297,
                        lbLat: 40.109,
                        rtLon: lonSelft,
                        rtLat: latSelf,
                        animation: true
                    });
                }
            });
        }


// 设置搜素路线
        function searchRoute() {
            map.searchRoute({
                id: 1,
                type: 'drive',
                policy: 'ecar_fee_first',
                start: {
                    lon: lonSelft,
                    lat: latSelf
                },
                end: {
                    lon: 116.297,
                    lat: 40.109
                }
            }, function (ret, err) {
                if (ret.status) {
                    map.drawRoute({
                        id: 1,
                        autoresizing: false,
                        index: 0,
                        styles: {
                            start: {
                                icon: 'widget://image/bmap_start.png'
                            },
                            end: {
                                icon: 'widget://image/bmap_end.png'
                            }
                        }
                    }, function (ret) {

                    });
                } else {
                    api.alert({msg: JSON.stringify(err)});
                }
            });
        }

人脸识别(一登模块)

    function logFace() {
        var superID = api.require('superID');
        superID.registerApp();
        superID.obtainLoginView(function (ret, err) {
            if(ret) {
                $api.setStorage('userId',ret.userInfo.openid);
                var msg = "登录成功:" + ret.userInfo.name;
                alert(msg)
                fnLogin();
            }else {
                alert("请重新扫描")
            }
        });
    }

      function fnLogin() {
        api.openWin({
            name: 'index',
            url: '../../index.html'
        })
    }
原文地址:https://www.cnblogs.com/webwangjin/p/6704792.html