123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var timestamp = new Date().getTime()/1000;
- var condition = '';
- var nowTime = 0;
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: Config.urlPath,
- table: 'user',
- },
- });
- $('#editKandian').click(function(){
- Fast.api.open('/admin/auth/user/kandian','批量修改书币');
- });
- // 初始化表格
- var table = $("#table");
- if(Config.group>2 && Config.group!=5){
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- showToggle:false,
- searchFormVisible:true,
- search:false,
- columns: [
- [
- {field: 'avatar', title: __('头像'), formatter: Table.api.formatter.image, operate: false},
- {field: 'id', title: __('Id')},
- {field: 'nickname', title: __('Nickname'),operate:false,formatter: Controller.api.formatter.nickname},
- {field: 'province', title: __('省/市'),operate:false,formatter: Controller.api.formatter.province},
- {field: 'is_pay', title: __('充值状态'), searchList: {'0': '未充值', '1':'已充值'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_pay},
- {field: 'vip_endtime', title: __('VIP状态'),operate:false,style: 'min-width:100px;',formatter: Controller.api.formatter.vip_endtime },
- {field: 'vip_endtime', title: __('vip结束时间'),formatter: Table.api.formatter.datetime,operate:false},
- {field: 'sex', title: __('性别'),searchList: {'0': '未知', '1':'男','2':'女'}, style: 'min-width:100px;', formatter: Controller.api.formatter.sex},
- {field: 'is_subscribe', title: __('服务号关注状态'), searchList: {'0': '未关注', '1':'已关注'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_subscribe},
- {field: 'subscription_extend', title: __('导粉号关注状态'),style: 'min-width:100px;',formatter: Controller.api.formatter.subscription_extend},
- {field: 'operate_time', title: __('服务号交互时间'),formatter: Table.api.formatter.datetime,operate:false},
- {field: 'state_text', title: __('状态'), operate:false},
- {field: 'createtime', title: __('注册时间'),formatter: Table.api.formatter.datetime,operate:false},
- {field: 'id', title: __('操作'), table: table, buttons: [
- {name: 'detail', text: '查看详情', title: '详情', icon: 'fa fa-flash', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/user/detail'}
- ], operate:false, formatter: Table.api.formatter.buttons}
- ]
- ]
- });
- }else{
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- showToggle:false,
- searchFormVisible:true,
- search:false,
- columns: [
- [
- {field: 'avatar', title: __('头像'), formatter: Table.api.formatter.image, operate: false},
- {field: 'id', title: __('Id')},
- {field: 'nickname', title: __('Nickname'),operate:false,formatter: Controller.api.formatter.nickname},
- {field: 'province', title: __('省/市'),operate:false,formatter: Controller.api.formatter.province},
- {field: 'is_pay', title: __('充值状态'), searchList: {'0': '未充值', '1':'已充值'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_pay},
- {field: 'vip_endtime', title: __('VIP状态'),operate:false,style: 'min-width:100px;',formatter: Controller.api.formatter.vip_endtime },
- {field: 'vip_endtime', title: __('vip结束时间'),formatter: Table.api.formatter.datetime,operate:false},
- {field: 'sex', title: __('性别'),searchList: {'0': '未知', '1':'男','2':'女'}, style: 'min-width:100px;', formatter: Controller.api.formatter.sex},
- {field: 'is_subscribe', title: __('服务号关注状态'), searchList: {'0': '未关注', '1':'已关注'}, style: 'min-width:100px;',formatter: Controller.api.formatter.is_subscribe},
- {field: 'subscription_extend', title: __('导粉号关注状态'),style: 'min-width:100px;',formatter: Controller.api.formatter.subscription_extend},
- {field: 'operate_time', title: __('服务号交互时间'),formatter: Table.api.formatter.datetime,operate:false},
- {field: 'kandian', title: __('永久书币'),operate:false},
- {field: 'state_text', title: __('状态'), operate:false},
- {field: 'createtime', title: __('注册时间'),formatter: Table.api.formatter.datetime,operate:false},
- {field: 'id', title: __('操作'), table: table, buttons: [
- {name: 'detail', text: '修改书币', title: '修改书币',icon: 'fa fa-list', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/user/kandian', callback:function(data){}},
- {name: 'detail', text: '查看详情', title: '详情', icon: 'fa fa-flash', classname: 'btn btn-xs btn-primary btn-dialog', url: '/admin/auth/user/detail'}
- ], operate:false, formatter: Table.api.formatter.buttons}
- ]
- ]
- });
- }
- // 为表格绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- //自定义搜索VIP状态
- $(document).on("change", ".selectVipStatus", function () {
- var options = table.bootstrapTable('getOptions');
- if($(this).val()==0){ //显示全部
- condition = '>=';
- nowTime = 0;
- }else if ($(this).val()==1){ //只显示vip
- condition = '>';
- nowTime = timestamp;
- }else if ($(this).val()==2){ //只显示非vip
- condition = '<';
- nowTime = timestamp;
- }
- options.pageNumber = 1;
- options.queryParams = function (params) {
- return {
- search: params.search,
- sort: params.sort,
- order: params.order,
- filter: JSON.stringify({vip_endtime: nowTime}),
- op: JSON.stringify({vip_endtime: condition}),
- offset: params.offset,
- limit: params.limit,
- };
- };
- table.bootstrapTable('refresh', {});
- return false;
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- kandian:function () {
- Controller.api.bindevent();
- },
- disable:function(){
- Form.api.bindevent($("form[role=form]"), function (data) {
- parent.location.reload();
- });
- },
- batchisdisabled:function(){
- Form.api.bindevent($("form[role=form]"), function (data) {
- parent.location.reload();
- },null,function(){
- let ids = $("textarea[name='row[id]'").val();
- $("textarea[name='row[id]'").val(ids.replace(/[\r\n]/g, ","));
- return true;
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },formatter:{
- sex:function (value,row,index) {
- return row.sex_text;
- },
- is_pay:function (value,row,index) {
- return row.is_pay_text;
- },
- is_subscribe:function (value,row,index) {
- return row.is_subscribe_text;
- },
- subscription_extend:function (value,row,index) {
- if(value==1){
- return '已关注';
- }else{
- return '未关注';
- }
- },
- vip_endtime:function(value,row,index){
- if (value >= timestamp){
- row.vip_endtime_text = '<span style="color:red;">VIP</span>';
- }else{
- row.vip_endtime_text = '否';
- }
- return row.vip_endtime_text;
- },
- nickname:function(value,row,index){
- return row.nickname+' <i title="点击复制openid" alt="点击复制openid" onclick="copyOpenid(\''+row.openid+'\')" class="fa fa-copy" ></i>';
- },
- province:function(value,row,index){
- return row.province+'/'+ row.city;
- }
- }
- }
- };
- return Controller;
- });
|