鹤壁电销版 自用

function.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. //*HySoft.VIPSystem后台管理页JS函数,Jquery扩展
  2. //*作者:一些事情
  3. //*时间:2012年02月20日
  4. //=============================切换验证码======================================
  5. function ToggleCode(obj, codeurl) {
  6. $(obj).attr("src", codeurl + "?time=" + Math.random());
  7. }
  8. //表格隔行变色
  9. $(function () {
  10. $(".msgtable tr:nth-child(odd)").addClass("tr_odd_bg"); //隔行变色
  11. $(".msgtable tr").hover(
  12. function () {
  13. $(this).addClass("tr_hover_col");
  14. },
  15. function () {
  16. $(this).removeClass("tr_hover_col");
  17. }
  18. );
  19. });
  20. //==========================页面加载时JS函数结束===============================
  21. //===========================系统管理JS函数开始================================
  22. //Tab控制函数
  23. function tabs(tabId, tabNum) {
  24. //设置点击后的切换样式
  25. $(tabId + " .tab_nav li").removeClass("selected");
  26. $(tabId + " .tab_nav li").eq(tabNum).addClass("selected");
  27. //根据参数决定显示内容
  28. $(tabId + " .tab_con").hide();
  29. $(tabId + " .tab_con").eq(tabNum).show();
  30. }
  31. //可以自动关闭的提示
  32. function jsprint(msgtitle, url, msgcss, callback) {
  33. $("#msgprint").remove();
  34. var cssname = "";
  35. switch (msgcss) {
  36. case "Success":
  37. cssname = "pcent success";
  38. break;
  39. case "Error":
  40. cssname = "pcent error";
  41. break;
  42. default:
  43. cssname = "pcent warning";
  44. break;
  45. }
  46. var str = "<div id=\"msgprint\" class=\"" + cssname + "\">" + msgtitle + "</div>";
  47. $("body").append(str);
  48. $("#msgprint").show();
  49. var itemiframe = "#framecenter .l-tab-content .l-tab-content-item";
  50. var curriframe = "";
  51. $(itemiframe).each(function () {
  52. if ($(this).css("display") != "none") {
  53. curriframe = $(itemiframe).index($(this));
  54. return false;
  55. }
  56. });
  57. if (url == "back" && curriframe != "") {
  58. frames[curriframe].history.back(-1);
  59. } else if (url != "" && curriframe != "") {
  60. frames[curriframe].location.href = url;
  61. }
  62. //3秒后清除提示
  63. setTimeout(function () {
  64. $("#msgprint").fadeOut(500);
  65. //如果动画结束则删除节点
  66. if (!$("#msgprint").is(":animated")) {
  67. $("#msgprint").remove();
  68. }
  69. }, 3000);
  70. //执行回调函数
  71. if (typeof (callback) == "function") callback();
  72. }
  73. //全选取消按钮函数,调用样式如:
  74. function checkAll(chkobj){
  75. if($(chkobj).find("span b").text()=="全选")
  76. {
  77. $(chkobj).find("span b").text("取消");
  78. $(".checkall input").attr("checked", true);
  79. }else{
  80. $(chkobj).find("span b").text("全选");
  81. $(".checkall input").attr("checked", false);
  82. }
  83. }
  84. //全选取消按钮函数,调用样式如:
  85. function checkAllByName(chkobj) {
  86. if ($(chkobj).find("span b").text() == "全选") {
  87. $(chkobj).find("span b").text("取消");
  88. $("input[name=checkall]").attr("checked", true);
  89. } else {
  90. $(chkobj).find("span b").text("全选");
  91. $("input[name=checkall]").attr("checked", false);
  92. }
  93. }
  94. //执行回传函数
  95. function ExePostBack(objId, objmsg) {
  96. if ($(".checkall input:checked").size() < 1) {
  97. $.ligerDialog.warn("对不起,请选中您要操作的记录!");
  98. return false;
  99. }
  100. var msg = "删除记录后不可恢复,您确定吗?";
  101. if (arguments.length == 2) {
  102. msg = objmsg;
  103. }
  104. $.ligerDialog.confirm(msg, "提示信息", function (result) {
  105. if (result) {
  106. __doPostBack(objId, '');
  107. }
  108. });
  109. return false;
  110. }
  111. //关闭提示窗口
  112. function CloseTip(objId) {
  113. $("#" + objId).hide();
  114. }
  115. //打开Dialog窗口
  116. function openDialog(tit, sendUrl, w, h) {
  117. if (arguments.length == 3) {
  118. $.ligerDialog.open({ title: tit, url: sendUrl, width: w, isResize: true });
  119. } else if (arguments.length == 4) {
  120. $.ligerDialog.open({ title: tit, url: sendUrl, width: w, height: h, isResize: true });
  121. } else {
  122. $.ligerDialog.open({ title: tit, url: sendUrl, isResize: true });
  123. }
  124. }
  125. //只允许输入数字
  126. function checkNumber(e) {
  127. if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) { //FF
  128. if (!((e.which >= 48 && e.which <= 57) || (e.which >= 96 && e.which <= 105) || (e.which == 8) || (e.which == 46)))
  129. return false;
  130. } else {
  131. if (!((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode == 8) || (event.keyCode == 46)))
  132. event.returnValue = false;
  133. }
  134. }
  135. //===========================系统管理JS函数结束================================
  136. //================上传文件JS函数开始,需和jquery.form.js一起使用===============
  137. //文件上传
  138. function Upload(action, repath, uppath, iswater, isthumbnail, filepath) {
  139. var sendUrl = "../../tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath;
  140. //判断是否打水印
  141. if(arguments.length == 4){
  142. sendUrl = "../../tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath + "&IsWater=" + iswater;
  143. }
  144. //判断是否生成宿略图
  145. if (arguments.length == 5) {
  146. sendUrl = "../../tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath + "&IsWater=" + iswater + "&IsThumbnail=" + isthumbnail;
  147. }
  148. //自定义上传路径
  149. if (arguments.length == 6) {
  150. sendUrl = filepath + "tools/upload_ajax.ashx?action=" + action + "&ReFilePath=" + repath + "&UpFilePath=" + uppath + "&IsWater=" + iswater + "&IsThumbnail=" + isthumbnail;
  151. }
  152. //开始提交
  153. $("#form1").ajaxSubmit({
  154. beforeSubmit: function(formData, jqForm, options){
  155. //隐藏上传按钮
  156. $("#"+repath).nextAll(".files").eq(0).hide();
  157. //显示LOADING图片
  158. $("#"+repath).nextAll(".uploading").eq(0).show();
  159. },
  160. success: function(data, textStatus) {
  161. if (data.msg == 1) {
  162. $("#"+repath).val(data.msgbox);
  163. } else {
  164. $.ligerDialog.alert(data.msgbox, '提示', "warm");
  165. }
  166. $("#"+repath).nextAll(".files").eq(0).show();
  167. $("#"+repath).nextAll(".uploading").eq(0).hide();
  168. },
  169. error: function(data, status, e) {
  170. $.ligerDialog.alert("上传失败,错误信息:" + e, '提示', "error");
  171. $("#"+repath).nextAll(".files").eq(0).show();
  172. $("#"+repath).nextAll(".uploading").eq(0).hide();
  173. },
  174. url: sendUrl,
  175. type: "post",
  176. dataType: "json",
  177. timeout: 600000
  178. });
  179. };
  180. //附件上传
  181. function AttachUpload(repath, uppath) {
  182. var submitUrl = "../../tools/upload_ajax.ashx?action=AttachFile&UpFilePath=" + uppath;
  183. //开始提交
  184. $("#form1").ajaxSubmit({
  185. beforeSubmit: function (formData, jqForm, options) {
  186. //隐藏上传按钮
  187. $("#" + uppath).parent().hide();
  188. //显示LOADING图片
  189. $("#" + uppath).parent().nextAll(".uploading").eq(0).show();
  190. },
  191. success: function (data, textStatus) {
  192. if (data.msg == 1) {
  193. var listBox = $("#" + repath + " ul");
  194. var newLi = '<li>'
  195. + '<input name="hidFileName" type="hidden" value="0|' + data.mstitle + "|" + data.msgbox + '" />'
  196. + '<b class="close" title="删除" onclick="DelAttachLi(this);"></b>'
  197. + '<span class="right">&nbsp;&nbsp;&nbsp;</span><a href="javascript:;" class="upfile right"><input type="file" name="FileUpdate" onchange="AttachUpdate(\'hidFileName\',this);" /></a>'
  198. + '<span class="right" >标题:<input name="txtFileTitle" type="text" style="width:120px;" class="input2" value="标题" /></span>'
  199. + '<span class="title">附件:' + data.mstitle + '</span>'
  200. + '<span style="display:none;">人气:0</span>'
  201. + '<span class="uploading">正在更新...</span>'
  202. + '</li>';
  203. listBox.append(newLi);
  204. } else {
  205. alert(data.msgbox);
  206. }
  207. $("#" + uppath).parent().show();
  208. $("#" + uppath).parent().nextAll(".uploading").eq(0).hide();
  209. },
  210. error: function (data, status, e) {
  211. alert("上传失败,错误信息:" + e);
  212. $("#" + uppath).parent().show();
  213. $("#" + uppath).parent().nextAll(".uploading").eq(0).hide();
  214. },
  215. url: submitUrl,
  216. type: "post",
  217. dataType: "json",
  218. timeout: 600000
  219. });
  220. };
  221. //更新附件上传
  222. function AttachUpdate(repath, uppath) {
  223. var btnOldName = $(uppath).attr("name");
  224. var btnNewName = "NewFileUpdate";
  225. $(uppath).attr("name", btnNewName);
  226. var submitUrl = "../../tools/upload_ajax.ashx?action=AttachFile&UpFilePath=" + btnNewName;
  227. //开始提交
  228. $("#form1").ajaxSubmit({
  229. beforeSubmit: function (formData, jqForm, options) {
  230. //隐藏上传按钮
  231. $(uppath).parent().hide();
  232. //显示LOADING图片
  233. $(uppath).parent().nextAll(".uploading").eq(0).show();
  234. },
  235. success: function (data, textStatus) {
  236. if (data.msg == 1) {
  237. var ArrFileName = $(uppath).parent().prevAll("input[name='" + repath + "']").val().split("|");
  238. $(uppath).parent().prevAll("input[name='" + repath + "']").val(ArrFileName[0] + "|" + data.mstitle + "|" + data.msgbox);
  239. $(uppath).parent().nextAll(".title").html("附件:" + data.mstitle);
  240. } else {
  241. alert(data.msgbox);
  242. }
  243. $(uppath).parent().show();
  244. $(uppath).parent().nextAll(".uploading").eq(0).hide();
  245. $(uppath).attr("name", btnOldName);
  246. },
  247. error: function (data, status, e) {
  248. alert("上传失败,错误信息:" + e);
  249. $(uppath).parent().show();
  250. $(uppath).parent().nextAll(".uploading").eq(0).hide();
  251. $(uppath).attr("name", btnOldName);
  252. },
  253. url: submitUrl,
  254. type: "post",
  255. dataType: "json",
  256. timeout: 600000
  257. });
  258. };
  259. //===========================上传文件JS函数结束================================
  260. //#region 获取url参数
  261. function GetUrlQuerying() {
  262. var args = new Object();
  263. var query = location.search.substring(1); // Get query string
  264. var pairs = query.split("&"); // Break at ampersand
  265. for (var i = 0; i < pairs.length; i++) {
  266. var pos = pairs[i].indexOf('='); // Look for "name=value"
  267. if (pos == -1) continue; // If not found, skip
  268. var argname = pairs[i].substring(0, pos); // Extract the name
  269. var value = pairs[i].substring(pos + 1); // Extract the value
  270. try {
  271. value = decodeURIComponent(value); // Decode it, if needed
  272. }
  273. catch (e) {
  274. value = unescape(value);
  275. }
  276. args[argname] = value; // Store as a property
  277. }
  278. return args; // Return the object
  279. }
  280. //#endregion