user.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var timestamp = new Date().getTime()/1000;
  3. var condition = '';
  4. var nowTime = 0;
  5. var Controller = {
  6. index: function () {
  7. // 初始化表格参数配置
  8. Table.api.init({
  9. extend: {
  10. index_url: Config.urlPath,
  11. table: 'user',
  12. },
  13. });
  14. $('#editKandian').click(function(){
  15. Fast.api.open('/admin/auth/user/kandian','批量修改书币');
  16. });
  17. // 初始化表格
  18. var table = $("#table");
  19. if(Config.group>2 && Config.group!=5){
  20. table.bootstrapTable({
  21. url: $.fn.bootstrapTable.defaults.extend.index_url,
  22. pk: 'id',
  23. sortName: 'id',
  24. showToggle:false,
  25. searchFormVisible:true,
  26. search:false,
  27. columns: [
  28. [
  29. {field: 'avatar', title: __('头像'), formatter: Table.api.formatter.image, operate: false},
  30. {field: 'id', title: __('Id')},
  31. {field: 'nickname', title: __('Nickname'),operate:false,formatter: Controller.api.formatter.nickname},
  32. {field: 'province', title: __('省/市'),operate:false,formatter: Controller.api.formatter.province},
  33. {field: 'is_pay', title: __('充值状态'), searchList: {'0': '未充值', '1':'已充值'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_pay},
  34. {field: 'vip_endtime', title: __('VIP状态'),operate:false,style: 'min-width:100px;',formatter: Controller.api.formatter.vip_endtime },
  35. {field: 'vip_endtime', title: __('vip结束时间'),formatter: Table.api.formatter.datetime,operate:false},
  36. {field: 'sex', title: __('性别'),searchList: {'0': '未知', '1':'男','2':'女'}, style: 'min-width:100px;', formatter: Controller.api.formatter.sex},
  37. {field: 'is_subscribe', title: __('服务号关注状态'), searchList: {'0': '未关注', '1':'已关注'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_subscribe},
  38. {field: 'subscription_extend', title: __('导粉号关注状态'),style: 'min-width:100px;',formatter: Controller.api.formatter.subscription_extend},
  39. {field: 'operate_time', title: __('服务号交互时间'),formatter: Table.api.formatter.datetime,operate:false},
  40. {field: 'state_text', title: __('状态'), operate:false},
  41. {field: 'createtime', title: __('注册时间'),formatter: Table.api.formatter.datetime,operate:false},
  42. {field: 'id', title: __('操作'), table: table, buttons: [
  43. {name: 'detail', text: '查看详情', title: '详情', icon: 'fa fa-flash', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/user/detail'}
  44. ], operate:false, formatter: Table.api.formatter.buttons}
  45. ]
  46. ]
  47. });
  48. }else{
  49. table.bootstrapTable({
  50. url: $.fn.bootstrapTable.defaults.extend.index_url,
  51. pk: 'id',
  52. sortName: 'id',
  53. showToggle:false,
  54. searchFormVisible:true,
  55. search:false,
  56. columns: [
  57. [
  58. {field: 'avatar', title: __('头像'), formatter: Table.api.formatter.image, operate: false},
  59. {field: 'id', title: __('Id')},
  60. {field: 'nickname', title: __('Nickname'),operate:false,formatter: Controller.api.formatter.nickname},
  61. {field: 'province', title: __('省/市'),operate:false,formatter: Controller.api.formatter.province},
  62. {field: 'is_pay', title: __('充值状态'), searchList: {'0': '未充值', '1':'已充值'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_pay},
  63. {field: 'vip_endtime', title: __('VIP状态'),operate:false,style: 'min-width:100px;',formatter: Controller.api.formatter.vip_endtime },
  64. {field: 'vip_endtime', title: __('vip结束时间'),formatter: Table.api.formatter.datetime,operate:false},
  65. {field: 'sex', title: __('性别'),searchList: {'0': '未知', '1':'男','2':'女'}, style: 'min-width:100px;', formatter: Controller.api.formatter.sex},
  66. {field: 'is_subscribe', title: __('服务号关注状态'), searchList: {'0': '未关注', '1':'已关注'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_subscribe},
  67. {field: 'subscription_extend', title: __('导粉号关注状态'),style: 'min-width:100px;',formatter: Controller.api.formatter.subscription_extend},
  68. {field: 'operate_time', title: __('服务号交互时间'),formatter: Table.api.formatter.datetime,operate:false},
  69. {field: 'kandian', title: __('永久书币'),operate:false},
  70. {field: 'state_text', title: __('状态'), operate:false},
  71. {field: 'createtime', title: __('注册时间'),formatter: Table.api.formatter.datetime,operate:false},
  72. {field: 'id', title: __('操作'), table: table, buttons: [
  73. {name: 'detail', text: '修改书币', title: '修改书币',icon: 'fa fa-list', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/user/kandian', callback:function(data){}},
  74. {name: 'detail', text: '查看详情', title: '详情', icon: 'fa fa-flash', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/user/detail'}
  75. ], operate:false, formatter: Table.api.formatter.buttons}
  76. ]
  77. ]
  78. });
  79. }
  80. // 为表格绑定事件
  81. Table.api.bindevent(table);
  82. Controller.api.bindevent();
  83. //自定义搜索VIP状态
  84. $(document).on("change", ".selectVipStatus", function () {
  85. var options = table.bootstrapTable('getOptions');
  86. if($(this).val()==0){ //显示全部
  87. condition = '>=';
  88. nowTime = 0;
  89. }else if ($(this).val()==1){ //只显示vip
  90. condition = '>';
  91. nowTime = timestamp;
  92. }else if ($(this).val()==2){ //只显示非vip
  93. condition = '<';
  94. nowTime = timestamp;
  95. }
  96. options.pageNumber = 1;
  97. options.queryParams = function (params) {
  98. return {
  99. search: params.search,
  100. sort: params.sort,
  101. order: params.order,
  102. filter: JSON.stringify({vip_endtime: nowTime}),
  103. op: JSON.stringify({vip_endtime: condition}),
  104. offset: params.offset,
  105. limit: params.limit,
  106. };
  107. };
  108. table.bootstrapTable('refresh', {});
  109. return false;
  110. });
  111. },
  112. add: function () {
  113. Controller.api.bindevent();
  114. },
  115. edit: function () {
  116. Controller.api.bindevent();
  117. },
  118. kandian:function () {
  119. Controller.api.bindevent();
  120. },
  121. disable:function(){
  122. Form.api.bindevent($("form[role=form]"), function (data) {
  123. parent.location.reload();
  124. });
  125. },
  126. batchisdisabled:function(){
  127. Form.api.bindevent($("form[role=form]"), function (data) {
  128. parent.location.reload();
  129. },null,function(){
  130. let ids = $("textarea[name='row[id]'").val();
  131. $("textarea[name='row[id]'").val(ids.replace(/[\r\n]/g, ","));
  132. return true;
  133. });
  134. },
  135. api: {
  136. bindevent: function () {
  137. Form.api.bindevent($("form[role=form]"));
  138. },formatter:{
  139. sex:function (value,row,index) {
  140. return row.sex_text;
  141. },
  142. is_pay:function (value,row,index) {
  143. return row.is_pay_text;
  144. },
  145. is_subscribe:function (value,row,index) {
  146. return row.is_subscribe_text;
  147. },
  148. subscription_extend:function (value,row,index) {
  149. if(value==1){
  150. return '已关注';
  151. }else{
  152. return '未关注';
  153. }
  154. },
  155. vip_endtime:function(value,row,index){
  156. if (value >= timestamp){
  157. row.vip_endtime_text = '<span style="color:red;">VIP</span>';
  158. }else{
  159. row.vip_endtime_text = '否';
  160. }
  161. return row.vip_endtime_text;
  162. },
  163. nickname:function(value,row,index){
  164. return row.nickname+'&nbsp;&nbsp;<i title="点击复制openid" alt="点击复制openid" onclick="copyOpenid(\''+row.openid+'\')" class="fa fa-copy" ></i>';
  165. },
  166. province:function(value,row,index){
  167. return row.province+'/'+ row.city;
  168. }
  169. }
  170. }
  171. };
  172. return Controller;
  173. });