//根据长度生成随机码 app.randCode = function (len) { var charset = ‘abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ0123456789‘; var charsetLen = charset.length - 1; var code = ‘‘; for (var i = 0; i < len; i++) { code += charset[parseInt(charsetLen * Math.random())]; } return code; };