diff --git a/bin/tsw/util/h5-test/del.js b/bin/tsw/util/h5-test/del.js index b08be8af..64a76e60 100644 --- a/bin/tsw/util/h5-test/del.js +++ b/bin/tsw/util/h5-test/del.js @@ -47,8 +47,7 @@ const returnJson = json => { }; module.exports.deleteTestUser = uin => { - uin = Array.isArray(uin) ? uin : [uin]; - return module.exports.deleteTestUsers([uin]); + return module.exports.deleteTestUsers(uin.split(',')); }; /** diff --git a/bin/tsw/util/h5-test/page/src/new.tmpl.html b/bin/tsw/util/h5-test/page/src/new.tmpl.html index fd83d748..4a034717 100644 --- a/bin/tsw/util/h5-test/page/src/new.tmpl.html +++ b/bin/tsw/util/h5-test/page/src/new.tmpl.html @@ -170,7 +170,7 @@ $('#remove-submit2').click(function(e){ var val = $('#join-textarea').val(); api.delTestUser({ - uin : handlerNums(val) + uin : handlerNums(val).join(',') }).done(function(){ alert("H5测试环境删除成功"); }).fail(function(errMsg){ diff --git a/bin/tsw/util/h5-test/page/tmpl.js b/bin/tsw/util/h5-test/page/tmpl.js index cb51e4a7..2b5df525 100644 --- a/bin/tsw/util/h5-test/page/tmpl.js +++ b/bin/tsw/util/h5-test/page/tmpl.js @@ -92,7 +92,7 @@ define(function(require, exports, module) { _p(data.appid); __p.push('\',\n uid: getCookie(\'uid\'),\n token: getCookie(\'token\')\n };\n var _api = {};\n /*\n * 添加白名单\n * */\n _api.addTestUser = function(params){\n var defer =$.Deferred();\n $.ajax({\n url: \'/api/h5test/add\',\n data:$.extend({},commomData,{\n uin: params.uin,\n val: params.val\n }),\n success: function(data){\n if(data && data.code === 0 ) {\n defer.resolve(data);\n }else {\n var message = (data && data.msg && data.msg != "") ? data.msg : "系统繁忙,请稍后再试";\n defer.reject( message);\n }\n },\n fail: function(err){\n var message = "系统繁忙,请稍后再试";\n if(err && err.msg) {\n message = err.msg;\n }\n defer.reject( message);\n }\n });\n\n return defer;\n };\n _api.addTestUsers = function(params){\n var defer =$.Deferred();\n $.ajax({\n url: \'/api/h5test/add\',\n type: \'POST\',\n contentType : "application/json",\n dataType : "json",\n data: JSON.stringify($.extend({},commomData,{\n uinval: params\n })),\n success: function(data){\n if(data && data.code === 0 ) {\n defer.resolve(data);\n }else {\n defer.reject( data && data.msg || "系统繁忙,请稍后再试");\n }\n },\n fail: function(err){\n defer.reject( err && err.msg || "系统繁忙,请稍后再试");\n }\n });\n\n return defer;\n };\n\n /*\n * 删除白名单\n */\n _api.delTestUser = function(params){\n var defer =$.Deferred();\n $.ajax({\n url: \'/api/h5test/del\',\n data:$.extend({},commomData,{\n uin: params.uin\n }),\n success: function(data){\n if(data && data.code === 0 ) {\n defer.resolve(data);\n }else {\n var message = (data && data.msg && data.msg != "") ? data.msg : "系统繁忙,请稍后再试";\n defer.reject( message);\n }\n },\n fail: function(err){\n var message = "系统繁忙,请稍后再试";\n if(err && err.msg) {\n message = err.msg;\n }\n defer.reject( message);\n }\n });\n\n return defer;\n };\n _api.getTestUser = function(params){\n var defer =$.Deferred();\n\n $.ajax({\n url: \'/api/h5test/get\',\n data:$.extend({},commomData),\n success: function(data){\n if(data && data.code === 0 ) {\n defer.resolve(data);\n }else {\n var message = (data && data.msg && data.msg != "") ? data.msg : "系统繁忙,请稍后再试";\n defer.reject( message);\n }\n },\n fail: function(err){\n var message = "系统繁忙,请稍后再试";\n if(err && err.msg) {\n message = err.msg;\n }\n defer.reject( message);\n }\n });\n\n return defer;\n };\n return _api;\n })()\n \n \n (function() {\n var handlerNums = function(val){\n var arr = [];\n val.replace(/(\\b[0-9a-zA-Z_\\-]{1,64}\\b)/g, function(uin){arr.push(uin); return uin;});\n return arr;\n };\n $(\'#join-submit2\').click(function(e){\n var val = $(\'#join-textarea\').val();\n var arr = handlerNums(val);\n var param = {};\n var selectVal = $(\'.selected\')[0].value;\n for(var i = 0; i < arr.length; i++) {\n param[arr[i]] = selectVal;\n }\n api.addTestUsers(param).done(function(){\n alert("你的号码,现已加入H5测试环境");\n }).fail(function(errMsg){\n alert(errMsg || "出了点小问题,请联系系统管理员处理");\n });\n return false;\n });\n $(\'#remove-submit2\').click(function(e){\n var val = $(\'#join-textarea\').val();\n api.delTestUser({\n uin : handlerNums(val)\n }).done(function(){\n alert("H5测试环境删除成功");\n }).fail(function(errMsg){\n alert(errMsg || "出了点小问题,请联系系统管理员处理");\n });\n return false;\n });\n $(\'#number-get\').click(function(event){\n var self = this;\n if($(self).is(\'.expended\')){\n $(self).removeClass(\'expended\').text(\'查看H5测试号码列表\');\n $(\'#number-list\').html(\'\');\n return;\n }\n var request = api.getTestUser();\n request.done(function(data) {\n var html = "";\n var num = 0;\n for (var i in data.data) {\n num++;\n var val = data.data[i];\n html += \'

\' + i + \'\' + \':\' + val + \'

\';\n }\n if (num == 0) {\n html = "还没有测试号码~"\n }\n $(\'#number-list\').html(html);\n $(self).addClass(\'expended\').text(\'收起H5测试号码列表\');\n }).fail(function(errMsg) {\n errMsg = errMsg || "出了点小问题,请联系系统管理员处理";\n alert(errMsg);\n });\n return false;\n });\n\n $(document).on(\'click\', \'.js-select-btn\', function(event){\n var target = $(this);\n $(\'.js-select-btn\').removeClass(\'btn-primary positive\');\n $(\'.js-select-btn\').removeClass(\'selected positive\');\n target.addClass(\'btn-primary positive\');\n target.addClass(\'selected\');\n if (history.replaceState) {\n var server = target.attr(\'value\');\n var newUrl = location.protocol + \'//\' + location.host + location.pathname + \'?server=\' + encodeURIComponent(server);\n history.replaceState({server: server}, \'\', newUrl);\n }\n });\n var server = getUrlParam(\'server\');\n if (server) {\n $(\'.js-select-btn\').each(function(i, el) {\n var $el = $(el);\n if ($el.attr(\'value\') === server) {\n var $box = $el.closest(\'.column>div\');\n $box.scrollTop(el.offsetTop - 140);\n $el.trigger(\'click\');\n return false;\n }\n });\n }\n })();\n
\n (function() {\n var handlerNums = function(val){\n var arr = [];\n val.replace(/(\\b[0-9a-zA-Z_\\-]{1,64}\\b)/g, function(uin){arr.push(uin); return uin;});\n return arr;\n };\n $(\'#join-submit2\').click(function(e){\n var val = $(\'#join-textarea\').val();\n var arr = handlerNums(val);\n var param = {};\n var selectVal = $(\'.selected\')[0].value;\n for(var i = 0; i < arr.length; i++) {\n param[arr[i]] = selectVal;\n }\n api.addTestUsers(param).done(function(){\n alert("你的号码,现已加入H5测试环境");\n }).fail(function(errMsg){\n alert(errMsg || "出了点小问题,请联系系统管理员处理");\n });\n return false;\n });\n $(\'#remove-submit2\').click(function(e){\n var val = $(\'#join-textarea\').val();\n api.delTestUser({\n uin : handlerNums(val).join(\',\')\n }).done(function(){\n alert("H5测试环境删除成功");\n }).fail(function(errMsg){\n alert(errMsg || "出了点小问题,请联系系统管理员处理");\n });\n return false;\n });\n $(\'#number-get\').click(function(event){\n var self = this;\n if($(self).is(\'.expended\')){\n $(self).removeClass(\'expended\').text(\'查看H5测试号码列表\');\n $(\'#number-list\').html(\'\');\n return;\n }\n var request = api.getTestUser();\n request.done(function(data) {\n var html = "";\n var num = 0;\n for (var i in data.data) {\n num++;\n var val = data.data[i];\n html += \'

\' + i + \'\' + \':\' + val + \'

\';\n }\n if (num == 0) {\n html = "还没有测试号码~"\n }\n $(\'#number-list\').html(html);\n $(self).addClass(\'expended\').text(\'收起H5测试号码列表\');\n }).fail(function(errMsg) {\n errMsg = errMsg || "出了点小问题,请联系系统管理员处理";\n alert(errMsg);\n });\n return false;\n });\n\n $(document).on(\'click\', \'.js-select-btn\', function(event){\n var target = $(this);\n $(\'.js-select-btn\').removeClass(\'btn-primary positive\');\n $(\'.js-select-btn\').removeClass(\'selected positive\');\n target.addClass(\'btn-primary positive\');\n target.addClass(\'selected\');\n if (history.replaceState) {\n var server = target.attr(\'value\');\n var newUrl = location.protocol + \'//\' + location.host + location.pathname + \'?server=\' + encodeURIComponent(server);\n history.replaceState({server: server}, \'\', newUrl);\n }\n });\n var server = getUrlParam(\'server\');\n if (server) {\n $(\'.js-select-btn\').each(function(i, el) {\n var $el = $(el);\n if ($el.attr(\'value\') === server) {\n var $box = $el.closest(\'.column>div\');\n $box.scrollTop(el.offsetTop - 140);\n $el.trigger(\'click\');\n return false;\n }\n });\n }\n })();\n '); return __p.join('');