UNPKG

vue-simple

Version:

Use Vue in the simplest and easiest way, contain more than one of plugins and other to do that, i hope you will like it.

47 lines (44 loc) 1.22 kB
var I64BIT_TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.split(''); /** * 根据指定内容生成对应哈希编码 * @param {String} [input] * @return {String} */ function hash(input) { var hv = 0; var src = input; var i = 0; if (src === undefined) { var rnd = Math.random().toString(16); var stamp = new Date().getTime().toString(16); src = rnd + stamp; } if (typeof src !== 'string') src = input.toString(); i = src.length - 1; for (; i > -1; i--) { hv += (hv << 3) + src.charCodeAt(i); } var value = hv & 0x7FFFFFFF; var retValue = ''; do { retValue += I64BIT_TABLE[value & I64BIT_TABLE.length - 1]; } while (value >>= 3); return retValue; } /** * 生成请求时所需唯一标识码(out_request_no) * @returns {string} */ function timehash() { var date = new Date(); var p = { y: date.getFullYear(), m: ('0' + (date.getMonth() + 1)).substr(-2), d: ('0' + date.getDate()).substr(-2), h: ('0' + date.getHours()).substr(-2), i: ('0' + date.getMinutes()).substr(-2), s: ('0' + date.getSeconds()).substr(-2) }; return '' + p.y + p.m + p.d + p.h + p.i + p.s + hash(); } export { hash, timehash };