member.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. $(function(){
  2. /* 全选 */
  3. $('.checkall').click(function(){
  4. var _self = this;
  5. $('.checkitem').each(function(){
  6. if (!this.disabled)
  7. {
  8. $(this).attr('checked', _self.checked);
  9. }
  10. });
  11. $('.checkall').attr('checked', this.checked);
  12. });
  13. /* 批量操作按钮 */
  14. $('a[nc_type="batchbutton"]').click(function(){
  15. /* 是否有选择 */
  16. if($('.checkitem:checked').length == 0){ //没有选择
  17. showDialog('请选择需要操作的记录');
  18. return false;
  19. }
  20. var _uri = $(this).attr('uri');
  21. var _name = $(this).attr('name');
  22. var handleResult = function(uri,name) {
  23. /* 获取选中的项 */
  24. var items = '';
  25. $('.checkitem:checked').each(function(){
  26. items += this.value + ',';
  27. });
  28. items = items.substr(0, (items.length - 1));
  29. /* 将选中的项通过GET方式提交给指定的URI */
  30. // window.location.href=uri + '&' + name + '=' + items;
  31. ajaxget(uri + '&' + name + '=' + items);
  32. return false;
  33. }
  34. if($(this).attr('confirm')){
  35. showDialog($(this).attr('confirm'), 'confirm', '', function(){handleResult(_uri,_name)});
  36. return false;
  37. }
  38. handleResult(_uri,_name);
  39. });
  40. /* 缩小大图片 */
  41. $('.makesmall').each(function(){
  42. makesmall(this, $(this).attr('max_width'), $(this).attr('max_height'));
  43. });
  44. $('.su_btn').click(function(){
  45. if($(this).hasClass('close')){
  46. $(this).parent().next('.su_block').css('display', '');
  47. $(this).removeClass('close');
  48. }
  49. else{
  50. $(this).addClass('close');
  51. $(this).parent().next('.su_block').css('display', 'none');
  52. }
  53. });
  54. $('*[nc_type="dialog"]').click(function(){
  55. var id = $(this).attr('dialog_id');
  56. var title = $(this).attr('dialog_title') ? $(this).attr('dialog_title') : '';
  57. var url = $(this).attr('uri');
  58. var width = $(this).attr('dialog_width');
  59. CUR_DIALOG = ajax_form(id, title, url, width,0);
  60. return false;
  61. });
  62. $('*[nc_type="gselector"]').focus(function(){
  63. var id = $(this).attr('gs_id');
  64. var name = $(this).attr('gs_name');
  65. var callback = $(this).attr('gs_callback');
  66. var op = $(this).attr('gs_op');
  67. var store_id = $(this).attr('gs_store_id');
  68. var title = $(this).attr('gs_title') ? $(this).attr('gs_title') : '';
  69. var width = $(this).attr('gs_width');
  70. ajax_form(id, title, SITEURL + '/index.php?act=store_groupbuy&op=' + op + '&dialog=1&title=' + title + '&store_id=' + store_id+ '&id=' + id + '&name=' + name + '&callback=' + callback, width);
  71. return false;
  72. });
  73. var url = window.location.search;
  74. var params = url.substr(1).split('&');
  75. var act = '';
  76. //找出排序的列和排序的方式及app控制器
  77. var sort = '';
  78. var order = '';
  79. for(var j=0; j < params.length; j++)
  80. {
  81. var param = params[j];
  82. var arr = param.split('=');
  83. if(arr[0] == 'act')
  84. {
  85. act = arr[1];
  86. }
  87. if(arr[0] == 'sort')
  88. {
  89. sort = arr[1];
  90. }
  91. if(arr[0] == 'order')
  92. {
  93. order = arr[1];
  94. }
  95. }
  96. $('span[nc_type="order_by"]').each(function(){
  97. if($(this).parent().attr('column') == sort)
  98. {
  99. if(order == 'asc')
  100. {
  101. $(this).removeClass();
  102. $(this).addClass("sort_asc");
  103. }
  104. else if (order == 'desc')
  105. {
  106. $(this).removeClass();
  107. $(this).addClass("sort_desc");
  108. }
  109. }
  110. });
  111. $('span[nc_type="order_by"]').click(function(){
  112. var s_name = $(this).parent().attr('column');
  113. var found = false;
  114. for(var i = 0;i < params.length;i++)
  115. {
  116. var param = params[i];
  117. var arr = param.split('=');
  118. if('page' == arr[0])
  119. {
  120. params[i] = 'page=1';
  121. }
  122. else if('sort' == arr[0])
  123. {
  124. params[i] = 'sort'+'='+ s_name;
  125. found = true;
  126. }
  127. else if('order' == arr[0])
  128. {
  129. params[i] = 'order'+'='+(arr[1] =='asc' ? 'desc' : 'asc');
  130. }
  131. }
  132. if(!found)
  133. {
  134. params.push('sort'+'='+ s_name);
  135. params.push('order=asc');
  136. }
  137. if(location.pathname.indexOf('/admin/')>-1)
  138. {
  139. location.assign(SITEURL + '/admin/index.php?' + params.join('&'));
  140. return;
  141. }
  142. location.assign(SITEURL + '/index.php?' + params.join('&'));
  143. });
  144. // 初始化上传
  145. trigger_uploader();
  146. });
  147. function set_zindex(parents, index){
  148. $.each(parents,function(i,n){
  149. if($(n).css('position') == 'relative'){//alert('relative');
  150. //alert($(n).css('z-index'));
  151. $(n).css('z-index',index);
  152. }
  153. });
  154. }
  155. function check_number(v)
  156. {
  157. if(isNaN(v))
  158. {
  159. alert("必须是数字");//lang.only_number
  160. return false;
  161. }
  162. if(v.indexOf('-') > -1)
  163. {
  164. alert("必须是数字");//lang.only_number
  165. return false;
  166. }
  167. return true;
  168. }
  169. function check_required(v)
  170. {
  171. if(v == '')
  172. {
  173. alert("不能为空");//lang.not_empty
  174. return false;
  175. }
  176. return true;
  177. }
  178. function check_pint(v)
  179. {
  180. var regu = /^[0-9]{1,}$/;
  181. if(!regu.test(v))
  182. {
  183. alert("必须是整数");//lang.only_int
  184. return false;
  185. }
  186. return true;
  187. }
  188. function check_max(v)
  189. {
  190. var regu = /^[0-9]{1,}$/;
  191. if(!regu.test(v))
  192. {
  193. alert("必须是整数");//lang.only_int
  194. return false;
  195. }
  196. var max = 255;
  197. if(parseInt(v) > parseInt(max))
  198. {
  199. alert("范围是0~"+max);//lang.small
  200. return false;
  201. }
  202. return true;
  203. }
  204. function trigger_uploader(){
  205. // 打开商品图片上传器
  206. $('#open_uploader').unbind('click');
  207. $('#open_uploader').click(function(){
  208. if($('#uploader').css('display') == 'none'){
  209. $('#uploader').show();
  210. $(this).find('.hide').attr('class','show');
  211. }else{
  212. $('#uploader').hide();
  213. $(this).find('.show').attr('class','hide');
  214. }
  215. });
  216. /* 悬停解释 */
  217. $('*[ecm_title]').hover(function(){
  218. $('*[nc_type="explain_layer"]').remove();
  219. $(this).parent().parent().append('<div class="titles" nc_type="explain_layer" style="display:none; z-index:999">' + $(this).attr('ecm_title') + '<div class="line"></div></div>');
  220. $('*[nc_type="explain_layer"]').fadeIn();
  221. },
  222. function(){
  223. $('*[nc_type="explain_layer"]').fadeOut();
  224. }
  225. );
  226. }