merchant_goods.js
12.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'merchant_goods/index' + location.search,
add_url: 'merchant_goods/add',
edit_url: 'merchant_goods/edit',
del_url: 'merchant_goods/del',
multi_url: 'merchant_goods/multi',
table: 'goods',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
// {field: 'admin_id', title: __('Admin_id')},
{field: 'type', title: __('广告类型'), searchList: {"3":__('图文'),"2":__('音频'),"1":__('视频')}, formatter: Table.api.formatter.label},
{field: 'goods_name', title: __('Goods_name')},
// {field: 'video', title: __('Video')},
// {field: 'voice', title: __('Voice')},
// {field: 'view_time', title: __('View_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'start_time', title: __('Start_time'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime,datetimeFormat:"YYYY-MM-DD",},
{field: 'end_time', title: __('End_time'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime,datetimeFormat:"YYYY-MM-DD",},
// {field: 'sex', title: __('Sex'), searchList: {"2":__('Sex 2'),"1":__('Sex 1'),"0":__('Sex 0')}, formatter: Table.api.formatter.normal},
// {field: 'min_age', title: __('Min_age')},
// {field: 'max_age', title: __('Max_age')},
// {field: 'province', title: __('Province')},
// {field: 'city', title: __('City')},
// {field: 'county', title: __('County')},
// {field: 'address', title: __('Address')},
// {field: 'longitude', title: __('Longitude')},
// {field: 'latitude', title: __('Latitude')},
// {field: 'distance', title: __('Distance'), operate:'BETWEEN'},
// {field: 'url', title: __('Url'), formatter: Table.api.formatter.url},
{field: 'exp', title: __('Exp'), operate:false},
// {field: 'view', title: __('View')},
// {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images},
// {field: 'admin_is_up', title: __('Admin_is_up'), searchList: {"1":__('Admin_is_up 1'),"0":__('Admin_is_up 0')}, formatter: Table.api.formatter.normal},
// {field: 'user_deletetime', title: __('User_deletetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
// {field: 'admin_deletetime', title: __('Admin_deletetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'user_is_up', title: __('上架状态'), searchList: {"1":__('已上架'),"0":__('已下架')}, formatter: Table.api.formatter.normal},
{field: 'status', title: __('审核状态'), searchList: {"3":__('审核失败'),"2":__('审核通过'),"1":__('审核中')}, formatter: Table.api.formatter.status},
/*{field: 'admin.id', title: __('Admin.id')},
{field: 'admin.username', title: __('Admin.username')},
{field: 'admin.nickname', title: __('Admin.nickname')},
{field: 'admin.password', title: __('Admin.password')},
{field: 'admin.salt', title: __('Admin.salt')},
{field: 'admin.avatar', title: __('Admin.avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'admin.email', title: __('Admin.email')},
{field: 'admin.loginfailure', title: __('Admin.loginfailure')},
{field: 'admin.logintime', title: __('Admin.logintime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'admin.createtime', title: __('Admin.createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'admin.updatetime', title: __('Admin.updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'admin.token', title: __('Admin.token')},
{field: 'admin.status', title: __('Admin.status'), formatter: Table.api.formatter.status},
{field: 'admin.user_id', title: __('Admin.user_id')},
{field: 'admin.money', title: __('Admin.money')},
{field: 'admin.merchant_title', title: __('Admin.merchant_title')},
{field: 'admin.merchant_name', title: __('Admin.merchant_name')},
{field: 'admin.merchant_mobile', title: __('Admin.merchant_mobile')},
{field: 'admin.area', title: __('Admin.area')},
{field: 'admin.brief', title: __('Admin.brief')},
{field: 'admin.business_images', title: __('Admin.business_images'), events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'admin.other_images', title: __('Admin.other_images'), events: Table.api.events.image, formatter: Table.api.formatter.images},*/
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
/*// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'question/index' + location.search,
add_url: 'question/add',
edit_url: 'question/edit',
del_url: 'question/del',
multi_url: 'question/multi',
table: 'question',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
search:false,
showToggle: false,
showColumns: false,
showExport: false,
commonSearch: false,
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
columns: [
[
{field: 'id', title: __('Id'), operate:false, visible:false},
{field: 'goods_id', title: __('Goods_id'), operate:false, visible:false},
{field: 'question_type', title: __('问题类型'), searchList: {"2":__('选择题'),"1":__('填空题')}, formatter: Table.api.formatter.label},
{field: 'question_name', title: __('问题')},
{field: 'question_answer', title: __('正确答案')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange',visible:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange',visible:false, formatter: Table.api.formatter.datetime},
{field: 'weigh', title: __('Weigh'), operate: false, visible: false},
{field: 'option', title: __('选项'), operate: false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);*/
type_init();
$('.type').click(function(){
type_init();
});
function type_init(){
var val=$('input:radio[name="row[type]"]:checked').val();
if(val == 1){
//视频
$('.video').show();
$('.voice').hide();
$('.content2').hide();
$('.view_time').hide();
}else if(val == 2){
//音频
$('.video').hide();
$('.voice').show();
$('.content2').hide();
$('.view_time').hide();
}else if(val == 3){
//图文
$('.video').hide();
$('.voice').hide();
$('.content2').show();
$('.view_time').show();
}
}
Controller.api.bindevent();
},
edit: function () {
type_init();
$('.type').click(function(){
type_init();
});
function type_init(){
var val=$('input:radio[name="row[type]"]:checked').val();
if(val == 1){
//视频
$('.video').show();
$('.voice').hide();
$('.content2').hide();
$('.view_time').hide();
}else if(val == 2){
//音频
$('.video').hide();
$('.voice').show();
$('.content2').hide();
$('.view_time').hide();
}else if(val == 3){
//图文
$('.video').hide();
$('.voice').hide();
$('.content2').show();
$('.view_time').show();
}
}
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
},
add_type_init:function () {
type_init();
function type_init(){
var val=$('input:radio[name="row[type]"]:checked').val();
console.log(val);
if(val == 1){
//视频
$('.video').show();
$('.voice').hide();
$('.content').hide();
$('.view_time').hide();
}else if(val == 2){
//音频
$('.video').hide();
$('.voice').show();
$('.content').hide();
$('.view_time').hide();
}else if(val == 3){
//图文
$('.video').hide();
$('.voice').hide();
$('.content').show();
$('.view_time').hide();
}
}
}
}
};
return Controller;
});