let mmg; var QLG = QLG || {}; let authActionUrl=''; QLG.init=function (typeNum){ if(1 == typeNum){ authActionUrl = 'personalAction'; }else if(2 == typeNum){ authActionUrl = 'companyAction'; }else if(3 == typeNum){ authActionUrl = 'setUserUpdate'; } } function showMsg(title,html){ layer.open({ type: 1, title: title, closeBtn: 1, shadeClose: true, area: '50%', btn: ['确定'], btnAlign: 'c', //按钮居中 // skin: '', content: html }); } $("body").on("click",'.showShopImg',function(){ let imgs = $(this).attr('data-imgs'); let imgsArr = imgs.split(','); let html=''; $.each(imgsArr,function(i,v){ html+='<img src="'+WST.conf.IMGURL+'/'+v+'"><br>'; }) showMsg('商铺图片组',html) }); //亲人认证 $("body").on("click",'.family_personal',function(){ let userId = $(this).attr('data-userId'); $.post(WST.U('admin/Users/authFamilyList'),{'isPersonal':1,'userId':userId},function(data) { let json = WST.toAdminJson(data); if(1 == json.status){ if('undefined' == typeof(json.data)){ WST.msg('没有相关数据', {icon: 2,time:3000}); return; } let auth_html = '<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"></fieldset> ' + '<table class="layui-table" lay-even="" lay-skin="row">' + ' <thead>' + ' <tr>' + ' <th>本人ID</th>' + ' <th>亲人ID</th>' + ' <th>亲人姓名</th>' + ' <th>亲人身份证</th>' + ' <th>关系</th>' + ' <th>关系证明照</th>' + ' <th>身份证正面</th>' + ' <th>身份证反面</th>' + ' </tr> ' + ' </thead>' + ' <tbody>'; let tdStr=''; $.each(json.data,function(){ tdStr+='<tr><td>'+this.userId+'</td>'; tdStr+='<td>'+this.familyId+'</td>'; tdStr+='<td>'+this.familyName+'</td>'; tdStr+='<td>'+this.familyIdCard+'</td>'; tdStr+='<td>'+this.familyRelations+'</td>'; tdStr+='<td>'+"<img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+this.familyRelationsImg+'\' /></td>'; tdStr+='<td>'+"<img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+this.idCardFrontImg+'\' /></td>'; tdStr+='<td>'+"<img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+this.idCardBackImg+'\' /></td></tr>'; }); auth_html+=tdStr+'</tbody>' + '</table> '; showMsg('亲人认证列表',auth_html) return; } WST.msg('数据读取出错,请重试', {icon: 2,time:3000}); return; }); }); //亲人报备 $("body").on("click",'.family_report',function(){ let userId = $(this).attr('data-userId'); $.post(WST.U('admin/Users/authFamilyList'),{'isPersonal':0,'userId':userId},function(data) { let json = WST.toAdminJson(data); if(1 == json.status){ if('undefined' == typeof(json.data)){ WST.msg('没有相关数据', {icon: 2,time:3000}); return; } let auth_html = '<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"></fieldset> ' + '<table class="layui-table" lay-even="" lay-skin="row">' + ' <thead>' + ' <tr>' + ' <th>本人ID</th>' + ' <th>报备姓名</th>' + ' <th>报备身份证</th>' + ' <th>关系</th>' + ' <th>关系证明照</th>' + ' </tr> ' + ' </thead>' + ' <tbody>'; let tdStr=''; $.each(json.data,function(){ tdStr+='<tr><td>'+this.userId+'</td>'; tdStr+='<td>'+this.familyName+'</td>'; tdStr+='<td>'+this.familyIdCard+'</td>'; tdStr+='<td>'+this.familyRelations+'</td>'; tdStr+='<td>'+"<img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+this.familyRelationsImg+'\' /></td></tr>'; }); auth_html+=tdStr+'</tbody>' + '</table> '; showMsg('亲人报备列表',auth_html) return; } WST.msg('数据读取出错,请重试', {icon: 2,time:3000}); return; }); }); //合作认证 $("body").on("click",'.company_partner',function(){ let userId = $(this).attr('data-userId'); $.post(WST.U('admin/Users/authCompanyList'),{'userId':userId},function(data) { let json = WST.toAdminJson(data); if(1 == json.status){ if('undefined' == typeof(json.data)){ WST.msg('没有相关数据', {icon: 2,time:3000}); return; } let auth_html = '<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"></fieldset> ' + '<table class="layui-table" lay-even="" lay-skin="row">' + ' <thead>' + ' <tr>' + ' <th>本人ID</th>' + ' <th>合伙人ID</th>' + ' <th>合伙人姓名</th>' + ' <th>身份证</th>' + ' <th>职位</th>' + ' <th>持股比例</th>' + ' <th>手持营业执照照片</th>' + ' <th>身份证正面</th>' + ' <th>身份证反面</th>' + ' </tr> ' + ' </thead>' + ' <tbody>'; let tdStr=''; $.each(json.data,function(){ tdStr+='<tr><td>'+this.userId+'</td>'; tdStr+='<td>'+this.partnerId+'</td>'; tdStr+='<td>'+this.uName+'</td>'; tdStr+='<td>'+this.idCard+'</td>'; tdStr+='<td>'+this.positionName+'</td>'; tdStr+='<td>'+this.stake+'</td>'; tdStr+='<td>'+"<img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+this.businessImg+'\' /></td>'; tdStr+='<td>'+"<img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+this.idCardFrontImg+'\' /></td>'; tdStr+='<td>'+"<img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+this.idCardBackImg+'\' /></td> </tr>'; }); auth_html+=tdStr+'/tbody>' + '</table> '; showMsg('合作人认证列表',auth_html) return; } WST.msg('数据读取出错,请重试', {icon: 2,time:3000}); return; }); }); //银行卡列表 $("body").on("click",'.company_bank',function(){ let userId = $(this).attr('data-userId'); $.post(WST.U('admin/Users/authCompanyBank'),{'userId':userId},function(data) { let json = WST.toAdminJson(data); if(1 == json.status){ if('undefined' == typeof(json.data)){ WST.msg('没有相关数据', {icon: 2,time:3000}); return; } let auth_html = '<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;"></fieldset> ' + '<table class="layui-table" lay-even="" lay-skin="row">' + ' <thead>' + ' <tr>' + ' <th>本人ID</th>' + ' <th>银行名</th>' + ' <th>开户名</th>' + ' <th>卡号</th>' + ' </tr> ' + ' </thead>' + ' <tbody>'; let tdStr=''; $.each(json.data,function(){ tdStr+='<tr><td>'+this.userId+'</td>'; tdStr+='<td>'+this.bankName+'</td>'; tdStr+='<td>'+this.accountName+'</td>'; tdStr+='<td>'+this.bankNo+'</td></tr>'; }); auth_html+=tdStr+'</tbody>' + '</table> '; showMsg('合作人银行卡列表',auth_html) return; } WST.msg('数据读取出错,请重试', {icon: 2,time:3000}); return; }); }); $("body").on("click",'.authAction',function(){ let id = $(this).attr('data-id'); layer.open({ type: 1, title: '审核操作', closeBtn: 1, shadeClose: true, area: '50%', btn: ['确定'], btnAlign: 'c', //按钮居中 // skin: '', content: '<div style="text-align:center;margin-top:1rem;padding-top:1rem;">审核处理:<label><input type="radio" class="status" value="1" name="status" onclick="javascript:WST.showHide(0,"#trApplyDesc");" title="通过">通过' + ' </label> ' + '<label><input type="radio" class="status" value="2" name="status" onclick="javascript:WST.showHide(1,"#trApplyDesc");" title="不通过">拒绝' + '</label>' + '<div id="trApplyDesc" style="display:none">' + '<th>不通过原因<font color="red">*</font>:</th>' + '<td><textarea id="applyDesc" class="ipt" style="width:300px;height:100px;" maxlength="100" data-rule="不通过原因:required(#status-1:checked);"></textarea></td>' + '</div></div>', yes: function(index){ let obj = $("input[name='status']:checked"); let status =obj.val(); if(!status){ WST.msg('请选择通过或不通过', {icon: 2,time:3000}); return; } let applyDesc = $('#applyDesc').val(); if(2 == status && '' == applyDesc ){ WST.msg('请输入拒绝理由', {icon: 2,time:3000}); $('#applyDesc').focus(); return; } let msgArr = ['通过','拒绝']; let msg = "您确定要"+msgArr[status-1]+"此用户的申请信息?"; let box = WST.confirm({content:msg,yes:function(){ let loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000}); $.post(WST.U('admin/Users/'+authActionUrl),{id:id,status:status,'reasonsForRefusal':applyDesc},function(data,textStatus){ layer.close(loading); let json = WST.toAdminJson(data); if(json.status=='1'){ WST.msg("操作成功",{icon:1}); layer.close(box); layer.close(index); userQuery(); }else{ WST.msg(json.msg,{icon:2}); } }); }}); } }); }); $("body").on("click",'.uploadImg',function(){ layer.open({ type: 1, title: false, closeBtn: 0, area: '90%', skin: 'layui-layer-nobg', //没有背景色 shadeClose: true, content: '<div ><img src="'+$(this).attr('src')+'"></div>' }); }); function initPersonalGrid(){ let h = WST.pageHeight(); let cols = [ {title:'账号', name:'loginName', width: 130,sortable:true}, {title:'手机号码', name:'userPhone' ,width:100,sortable:true}, {title:'户主姓名', name:'householdName' ,width:100,sortable:true}, {title:'身份证', name:'householdIdCard' ,width:100,sortable:true}, {title:'居住地址', name:'houseAddress' ,width:100,sortable:true}, {title:'手持户口本照片', name:'accountBookImg' ,width:100,sortable:true ,renderer:function(val,item,rowIndex) { return"<span><img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+val+"'</span>"; }}, {title:'认证信息', name:'' ,width:150, align:'center', renderer: function(val,item,rowIndex) { let h = ""; h += "<a data-userId='"+item.userId+"'class='family_personal'>亲人认证</a> "; h += "<a data-userId='"+item.userId+"'class='family_report'> 亲人报备</a> "; return h; }}, {title:'申请时间', name:'createTime' ,width:120,sortable:true,renderer:function(val,item,rowIndex) { return getLocalTime(val); }}, {title:'状态/操作', name:'status' ,width:60,sortable:true, renderer:function(val,item,rowIndex) { let h = ""; if(val==1){ h += "<span class='statu-yes'><i class='fa fa-check-circle'></i> 已通过 </span>"; if (WST.GRANT.GTRZSH_01) { h += "<a data-id='" + item.id + "'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>修改</a> "; } }else if(val==2){ h += "<span class='statu-no'><i class='fa fa-ban'></i> 已拒绝 </span>"; if (WST.GRANT.GTRZSH_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>修改</a> "; } }else { h += "<span class='statu-wait'><i class='fa fa-clock-o'></i> 待审核 </span>"; if (WST.GRANT.GTRZSH_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>审核</a> "; } } return h; } }]; mmg = $('.mmg').mmGrid({height: h-173,indexCol: true,indexColWidth:50, cols: cols,method:'POST', url: WST.U('admin/Users/getPersonalReview'), fullWidthRows: true, autoLoad: true,remoteSort: true,sortName:'createTime',sortStatus:'desc', plugins: [ $('#pg').mmPaginator({}) ] }); $('#headTip').WSTTips({width:90,height:35,callback:function(v){ if(v){ mmg.resize({height:h-173}); }else{ mmg.resize({height:h-128}); } }}); } function initCompanyGrid(){ let h = WST.pageHeight(); let cols = [ {title:'账号', name:'loginName', width: 130,sortable:true}, {title:'手机号码', name:'userPhone' ,width:100,sortable:true}, {title:'合作名', name:'companyName' ,width:100,sortable:true}, {title:'直营人姓名', name:'trueName' ,width:100,sortable:true}, {title:'身份证', name:'idCard' ,width:100,sortable:true}, {title:'公司地址', name:'companyAddress' ,width:100,sortable:true}, // {title:'手持户口本照片', name:'accountBookImg' ,width:100,sortable:true ,renderer:function(val,item,rowIndex) { // return"<span><img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+val+"'</span>"; // }}, {title:'认证信息', name:'' ,width:150, align:'center', renderer: function(val,item,rowIndex) { let h = ""; h += "<a data-userId='"+item.userId+"'class='company_partner'>合作人员</a> "; h += "<a data-userId='"+item.userId+"'class='company_bank'> 银行卡列表</a> "; return h; }}, {title:'申请时间', name:'createTime' ,width:120,sortable:true,renderer:function(val,item,rowIndex) { return getLocalTime(val); }}, {title:'状态/操作', name:'status' ,width:60,sortable:true, renderer:function(val,item,rowIndex) { let h = ""; if(val==1){ h += "<span class='statu-yes'><i class='fa fa-check-circle'></i> 已通过 </span>"; if (WST.GRANT.HZRZSH_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>修改</a> "; } }else if(val==2){ h += "<span class='statu-no'><i class='fa fa-ban'></i> 已拒绝 </span>"; if (WST.GRANT.HZRZSH_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>修改</a> "; } }else { h += "<span class='statu-wait'><i class='fa fa-clock-o'></i> 待审核 </span>"; if (WST.GRANT.HZRZSH_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>审核</a> "; } } return h; }} ]; mmg = $('.mmg').mmGrid({height: h-173,indexCol: true,indexColWidth:50, cols: cols,method:'POST', url: WST.U('admin/Users/getCompanyReview'), fullWidthRows: true, autoLoad: true,remoteSort: true,sortName:'createTime',sortStatus:'desc', plugins: [ $('#pg').mmPaginator({}) ] }); $('#headTip').WSTTips({width:90,height:35,callback:function(v){ if(v){ mmg.resize({height:h-173}); }else{ mmg.resize({height:h-128}); } }}); } function toEdit(id){ location.href=WST.U('admin/users/toEdit','id='+id); } function toRecharge(id){ location.href=WST.U('admin/users/toRecharge','id='+id); } function toExport(){ let params = {}; params = WST.getParams('.query'); let box = WST.confirm({content:"您确定要导出订单吗?",yes:function(){ layer.close(box); location.href=WST.U('admin/users/toExport',params); }}); } function toDel(id,userType){ let msg = (userType==1)?"您要删除的用户是商家用户,您确定要删除吗?":"您确定要删除该用户吗?"; let box = WST.confirm({content:msg,yes:function(){ let loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000}); $.post(WST.U('admin/Users/del'),{id:id},function(data,textStatus){ layer.close(loading); let json = WST.toAdminJson(data); if(json.status=='1'){ WST.msg("操作成功",{icon:1}); layer.close(box); userQuery(); }else{ WST.msg(json.msg,{icon:2}); } }); }}); } function userQuery(){ let query = WST.getParams('.query'); query.page = 1; mmg.load(query); } function initApplyGrid(){ var h = WST.pageHeight(); var cols = [ {title:'账号', name:'loginName', width: 130,sortable:true}, {title:'用户名', name:'trueName' ,width:100,sortable:true}, {title:'手机号码', name:'userPhone' ,width:100,sortable:true}, {title:'店铺名', name:'shopName' ,width:100,sortable:true}, {title:'直营人', name:'userName' ,width:100,sortable:true}, {title:'店铺电话', name:'phone' ,width:100,sortable:true}, {title:'申请级别', name:'applyLevel' ,width:60,sortable:true, renderer:function(val,item,rowIndex){ var str = ''; switch(val){ case '2': str = '商超'; break; case '3': str = '商厦'; break; case '4': str = '商都'; break; } return str; }}, {title:'确认书', name:'confirmImg' ,width:100,sortable:true ,renderer:function(val,item,rowIndex) { return"<span><img class='uploadImg' style='width:80px;height:80px;' src='"+WST.conf.IMGURL+'/'+val+"'</span>"; }}, {title:'店铺图片组', name:'shopImg' ,width:100,sortable:true ,renderer:function(val,item,rowIndex) { return"<span data-imgs='"+val+"' class='showShopImg'>查看</span>"; }}, {title:'申请区域', name:'province' ,width:100,sortable:true ,renderer:function(val,item,rowIndex) { var html='<span>'+item.province.areaName+'-'+item.city.areaName+'-'; switch(item.applyLevel){ case '4': html +='<a style="color:red;">'+item.county.areaName+'</a>'; // html +=item.town.areaName+'-'+item.village.areaName; break; case '3': html +=item.county.areaName+'-'; html +='<a style="color:red;">'+item.town.areaName+'</a>'; // html +=item.village.areaName; break; case '2': html +=item.county.areaName+'-'+item.town.areaName+'-'; html +='<a style="color:red;">'+item.village.areaName+'</a>'; break; } html+='</span>'; return html; }}, {title:'申请时间', name:'createTime' ,width:120,sortable:true,renderer:function(val,item,rowIndex) { return getLocalTime(val); }}, {title:'状态/操作', name:'status' ,width:60,sortable:true, renderer:function(val,item,rowIndex) { let h = ""; if(val==1){ h += "<span class='statu-yes'><i class='fa fa-check-circle'></i> 已通过 </span>"; if (WST.GRANT.SQSJ_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>修改</a> "; } }else if(val==2){ h += "<span class='statu-no'><i class='fa fa-ban'></i> 已拒绝 </span>"; if (WST.GRANT.SQSJ_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>修改</a> "; } }else { h += "<span class='statu-wait'><i class='fa fa-clock-o'></i> 待审核 </span>"; if (WST.GRANT.SQSJ_01) { h += "<a data-id='"+item.id+"'class='btn btn-blue authAction'> <i class='fa fa-pencil'></i>审核</a> "; } } return h; } }]; mmg = $('.mmg').mmGrid({height: h-173,indexCol: true,indexColWidth:50, cols: cols,method:'POST', url: WST.U('admin/Users/getUserUpdateList'), fullWidthRows: true, autoLoad: true,remoteSort: true,sortName:'createTime',sortStatus:'desc', plugins: [ $('#pg').mmPaginator({}) ] }); $('#headTip').WSTTips({width:90,height:35,callback:function(v){ if(v){ mmg.resize({height:h-173}); }else{ mmg.resize({height:h-128}); } }}); } function editInit(){ /* 表单验证 */ $('#userForm').validator({ dataFilter: function(data) { if (data.ok === '该登录账号可用' ) return ""; else return "已被注册"; }, rules: { loginName: function(element) { return /\w{5,}/.test(element.value) || '账号应为5-16字母、数字或下划线'; }, myRemote: function(element){ return $.post(WST.U('admin/users/checkLoginKey'),{'loginName':element.value,'userId':$('#userId').val()},function(data,textStatus){}); } }, fields: { loginName: { rule:"required;loginName;myRemote", msg:{required:"请输入会员账号"}, tip:"请输入会员账号", ok:"", }, userPhone: { rule:"mobile;myRemote", ok:"", }, userEmail: { rule:"email;myRemote", ok:"", }, userScore: { rule:"integer[+0]", msg:{integer:"当前积分只能是正整数"}, tip:"当前积分只能是正整数", ok:"", }, userTotalScore: { rule:"match[gte, userScore];integer[+0];", msg:{integer:"当前积分只能是正整数",match:'会员历史积分必须不小于会员积分'}, tip:"当前积分只能是正整数", ok:"", }, userQQ: { rule:"integer[+]", msg:{integer:"QQ只能是数字"}, tip:"QQ只能是数字", ok:"", }, }, valid: function(form){ let params = WST.getParams('.ipt'); let loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000}); $.post(WST.U('admin/Users/'+((params.userId==0)?"add":"edit")),params,function(data,textStatus){ layer.close(loading); let json = WST.toAdminJson(data); if(json.status=='1'){ WST.msg("操作成功",{icon:1}); location.href=WST.U('Admin/Users/index'); }else{ WST.msg(json.msg,{icon:2}); } }); } }); //上传头像 WST.upload({ pick:'#adFilePicker', formData: {dir:'users'}, accept: {extensions: 'gif,jpg,jpeg,png',mimeTypes: 'image/jpg,image/jpeg,image/png,image/gif'}, callback:function(f){ let json = WST.toAdminJson(f); if(json.status==1){ $('#uploadMsg').empty().hide(); //将上传的图片路径赋给全局变量 $('#userPhoto').val(json.savePath+json.name); $('#preview').html('<img src="'+WST.conf.IMGURL+'/'+json.savePath+json.thumb+'" height="152" />'); }else{ WST.msg(json.msg,{icon:2}); } }, progress:function(rate){ $('#uploadMsg').show().html('已上传'+rate+"%"); } }); } /** * 时间戳格式化函数 */ function getLocalTime(nS) { return new Date(parseInt(nS) * 1000).toLocaleString().substr(0,19); }