//config的设置是全局的
layui.config({
  base: '/static/js/extend/' //假设这是你存放拓展模块的根目录
}).extend({ //设定模块别名
  common: 'common' //如果 mymod.js 是在根目录，也可以不用设定别名
});


layui.use(['form','table','upload','common'], function() {
    var form = layui.form;
    var common = layui.common;
    var table = layui.table;
    var $ = layui.jquery,upload = layui.upload;
    table.render({
      elem: '#userTable'
      , url: '/user/userEnterpriseList'
      , id: 'id'
      , loading: true
      ,method:"post"
      ,contentType:"application/json;charset=UTF-8"
      , cols: [[
        {field: 'id', title: 'ID', sort: true, checkbox: true, fixed: 'left'}
        , {field: 'userNo', title: '服务编号'}
        , {field: 'enterpriseName', title: '企业名称', sort: true}
        , {field: 'userPhone', title: '用户手机号', sort: true}
        , {field: 'provinceId', title: '维修省份',templet:function (d) {
            return common.ajaxGetRequest("/lbs/getLbsMapById",{id:d.province}).name;
          }}
        , {field: 'cityId', title: '维修市区',templet:function (d) {
            return common.ajaxGetRequest("/lbs/getLbsMapById",{id:d.city}).name;
          }}
        , {field: 'servicesAreaId', title: '维修区域',templet:function (d) {
            return common.ajaxGetRequest("/lbs/getLbsMapById",{id:d.area}).name;
          }}
        ,{field:'licenseImage', title: '图片',templet:function(d){
            return '<img onclick="showImg(\''+d.licenseImage+'\',\'营业执照\')" src='+d.imageUrl+'>';
          }}
        , {field: 'state', title: '审核状态',templet:function (d) {
              if (d.state==0){
                return  "待审核";
              } else if(d.state=="1"){
                return  "审核通过";
              }else if(d.state=="2"){
                return  "审核不通过";
              }
          }}
        ,{field: 'remarks', title: '备注'}
        ,{field: 'createTime', title: '创建时间'}
      ]]
      , page: true
    });

});


function showImg(url,title) {
  layer.photos({
    photos: { "data": [{alt:title,"src": url}] }
  });
}