member.js 7.1 KB

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