puzhibing
2024-01-03 168d852672f8f671a01d6f0f053349d0d321ec7c
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/**
 * 跨城站点管理管理初始化
 */
var TSite = {
    id: "TSiteTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1,
    picture:"",
    fileUrl:"",
    img:"",
    plan:"",
    goodsPicArray:[],
    validateFields: {
    }
};
/**
 * 初始化表格的列
 */
TSite.initColumn = function () {
    return [
        {field: 'selectItem', checkbox: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '运营商名称', field: 'name', visible: true, align: 'center', valign: 'middle',width:'20%',},
        {title: '管理员姓名', field: 'userName', visible: true, align: 'center', valign: 'middle',
        },
        {title: '管理员手机号', field: 'phone', visible: true, align: 'center', valign: 'middle'},
        {title: '管理区域', field: 'type', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {1:"全国",2:"指定区域"}[data]
            }
        },
        {title: '商户绑定状态', field: 'status', visible: true, align: 'center', valign: 'middle',
            formatter: function (data,row) {
                var btn = "";
                if(data==1) {
                    var str = '<button class="btn btn-outline btn-primary" onclick="TSite.Allocationratio('+row.id+')" >去绑定</button>'
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="" onfocus="TUser.tooltip()">' + str + '</p>']
                }else{
                    var str = '<h3>已绑定</h3>'
                    btn = [str]
                }
                return btn;
            }
        },
        {title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {1:"正常",2:"冻结",3:"删除"}[data]
            }
        },
    ];
};
 
/**
 * 检查是否选中
 */
TSite.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TSite.seItem = selected[0];
        return true;
    }
};
/**
 * 商户号认证
 */
TSite.Allocationratio = function (e) {
 
        var index = layer.open({
            type: 2,
            title: "商户认证",
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/operatorUser'
        });
        this.layerIndex = index;
};
/**
 * 商户号认证页面
 */
TSite.auth = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: "商户认证",
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/operator/proportionAuth/' + TSite.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 商户号认证页面回显
 */
TSite.auth1 = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: "商户认证详情",
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/operator/proportionAuth1/' + TSite.seItem.id
        });
        this.layerIndex = index;
    }
};
/**
 * 分账比例
 */
TSite.proportion = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length >1 ){
        Feng.info("只能选择一个运营商商户设置分账比例!");
    }else {
        if (this.check()) {
            console.log("看看状态")
            console.log(TSite.seItem.status)
            if (TSite.seItem.status==1){
                Feng.error("当前运营商没有绑定商户号,请先绑定商户号!")
                return;
            }
            var index = layer.open({
                type: 2,
                title: "认证",
                area: ['100%', '100%'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/operator/proportion/' + TSite.seItem.id
            });
            this.layerIndex = index;
        }
    }
};
TSite.addSubmit = function(){
    var alipayType = $("input[name='alipayType']:checked").val();
    var wechatType = $("input[name='wechatType']:checked").val();
    var alipayNum  = $("#alipayNum").val();
    var wechatNum  = $("#wechatNum").val();
    var operatorId  = $("#operatorId").val();
    if($("#alipayNum").val()=='' ){
        Feng.info("请输入支付宝商户号")
        return;
    }
    if($("#wechatNum").val()=='' ){
        Feng.info("请输入微信商户号")
        return;
    }
    var ajax = new $ax(Feng.ctxPath + "/operator/auth", function(data){
        Feng.success("认证成功")
        TSite.close();
        TSite.search();
    });
    ajax.set("alipayType",alipayType);
    ajax.set("wechatType",wechatType);
    ajax.set("alipayNum",alipayNum);
    ajax.set("wechatNum",wechatNum);
    ajax.set("operatorId",operatorId);
    ajax.start();
};
TSite.addSubmit1 = function(){
    var alipayProportion  = $("#alipayProportion").val();
    var wechatProportion  = $("#wechatProportion").val();
    var operatorIdOne  = $("#operatorIdOne").val();
    if($("#alipayNum").val()=='' ){
        Feng.info("请输入支付宝分账比例")
        return;
    }
    if($("#wechatNum").val()=='' ){
        Feng.info("请输入微信分账比例")
        return;
    }
    if (Number(alipayProportion)+Number(wechatProportion)!=100){
        Feng.info("总比例应该是100%,当前比例:"+Number(Number(alipayProportion)+Number(wechatProportion)));
        return;
    }
    var ajax = new $ax(Feng.ctxPath + "/operator/proportion", function(data){
        Feng.success("分账比例设置成功")
        window.parent.TSite.table.refresh();
        TSite.close();
        TSite.search();
    });
    ajax.set("alipayProportion",alipayProportion);
    ajax.set("wechatProportion",wechatProportion);
    ajax.set("operatorIdOne",operatorIdOne);
    ajax.start();
};
/**
 * 上架
 */
TSite.onShelf = function () {
    if (this.check()){
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            state:null
        };
        selected.forEach(function(obj) {
            console.log("查看选中")
            console.log(obj)
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 1;
 
        $.ajax({
            url: Feng.ctxPath + "/operator/changeState",
            type: "POST",
            contentType: "application/json", // 设置请求头的 Content-Type
            data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
            success: function(response) {
                Feng.success("解冻成功!");
                TSite.search();
            },
            error: function(xhr, status, error) {
                var errorMessage = xhr.responseText ? xhr.responseText : "解冻失败!";
            }
        });
    }
};
 
/**
 * 下架
 */
TSite.offShelf = function () {
    if (this.check()){
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            state:null
        };
        selected.forEach(function(obj) {
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 2;
        $.ajax({
            url: Feng.ctxPath + "/operator/changeState",
            type: "POST",
            contentType: "application/json", // 设置请求头的 Content-Type
            data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
            success: function(response) {
                Feng.success("冻结成功!");
                TSite.search();
            },
            error: function(xhr, status, error) {
                var errorMessage = xhr.responseText ? xhr.responseText : "冻结失败!";
            }
        });
    }
};
 
 
/**
 * 跳转添加运营商页面
 */
TSite.openAddTSite = function () {
 
    var index = layer.open({
        type: 2,
        title: "添加运营商",
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/operator/add'
    });
    this.layerIndex = index;
};
/**
 * 打开场地管理查看详情
 */
TSite.openInfo = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length >1 ){
        Feng.info("只能选择一个问题进行编辑!");
    }else {
        if (this.check()) {
            var index = layer.open({
                type: 2,
                title: "编辑运营商",
                area: ['100%', '100%'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/operator/update/' + TSite.seItem.id
            });
            this.layerIndex = index;
        }
    }
};
TSite.reload = function () {
    if (this.check()) {
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            password:null
        };
        selected.forEach(function(obj) {
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 2;
        var operation = function() {
            $.ajax({
                url: Feng.ctxPath + "/operator/pwd",
                type: "POST",
                contentType: "application/json", // 设置请求头的 Content-Type
                data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
                success: function (response) {
                    TSite.search();
                },
                error: function (xhr, status, error) {
                    var errorMessage = xhr.responseText ? xhr.responseText : "冻结失败!";
                }
            });
        }
 
        Feng.confirm("确认重置密码?重置后密码为:a123456", operation);
    }
};
/**
 * 关闭此对话框
 */
TSite.close = function() {
    parent.layer.close(window.parent.TSite.layerIndex);
};
 
TSite.search = function () {
    var queryData = {};
    queryData['userName']  = $("#name").val();
    queryData['phone'] =$("#phone").val();
    queryData['type'] =$("#type").val();
    TSite.table.refresh({query: queryData});
};
 
TSite.resetSearch = function () {
    $("#name").val("");
    $("#phone").val("");
    $("#type").val("");
    TSite.search();
};
 
$(function () {
    var defaultColunms = TSite.initColumn();
    var table = new BSTable(TSite.id, "/operator/listAll", defaultColunms);
    table.setPaginationType("server");
    TSite.table = table.init();
});