layui.use(['element','upload','laydate','form'], function(){
var element = layui.element;
var upload = layui.upload;
var laydate = layui.laydate;
var form = layui.form;
//鑾峰彇hash鏉ュ垏鎹㈤€夐」鍗★紝鍋囪褰撳墠鍦板潃鐨刪ash涓簂ay-id瀵瑰簲鐨勫€
var layid = location.hash.replace(/^#tab=/, '');
element.tabChange('tab', layid); //鍋囪褰撳墠鍦板潃涓猴細http://a.com#test1=222锛岄偅涔堥€夐」鍗′細鑷姩鍒囨崲鍒扳€滃彂閫佹秷鎭€濊繖涓€椤
//鐩戝惉Tab鍒囨崲锛屼互鏀瑰彉鍦板潃hash鍊
element.on('tab(tab)', function(){
var clayid=this.getAttribute('lay-id');
if(clayid){
location.hash = 'tab='+ clayid;
$('.page').find('a').each(function(index,element){//閬垮厤tab缈婚〉闂
var url=$(this).attr('href');
if(url.indexOf('tab=')==-1){
$(this).attr('href', url+'#tab='+ clayid);
}else{
$(this).attr('href', url.replace(/tab=[\w]+/, 'tab='+ clayid));
}
});
}
});
//璺宠浆
form.on('select(tourl)', function(data){
window.location.href= data.value;
});
//鎻愮ず
$(".tips").on("mouseover",function(){
layer.tips($(this).data('content'), this);
})
//鐢ㄦ埛鐧诲綍楠岃瘉
form.on('submit(login-submit)', function(data){
var form = $("#dologin");
var url = form.attr('action');
var username = form.find("#username").val();
var password = form.find("#password").val();
var checkcode = form.find("#checkcode").val();
var formcheck = form.find("#formcheck").val();
$.ajax({
type: 'POST',
url: url,
dataType: 'json',
data: {
username: username,
password: password,
checkcode: checkcode,
formcheck: formcheck
},
success: function (response, status) {
if (response.code == 1) {
layer.msg("鐧诲綍鎴愬姛锛?, {icon: 1});
window.location.href = response.data;
} else {
form.find("#checkcode").val("");
$('#codeimg').click();//鏇存柊楠岃瘉鐮
layer.msg("鐧诲綍澶辫触锛? + response.data, {icon: 5});
}
},
error:function(xhr,status,error){
layer.msg("鐧诲綍璇锋眰鍙戠敓閿欒!", {icon: 5});
$('#note').html('鐧诲綍璇锋眰鍙戠敓閿欒锛屾偍鍙寜鐓у涓嬫柟寮忔帓鏌ワ細
1銆佽瘯鐫€鍒犻櫎鏍圭洰褰曚笅runtime鐩綍锛屽埛鏂伴〉闈㈤噸璇旣
2銆佹鏌ョ郴缁熶細璇濇枃浠跺瓨鍌ㄧ洰褰曟槸鍚﹀叿鏈夊啓鍏ユ潈闄愶紱
3銆佹鏌ユ湇鍔″櫒鐜pathinfo鍙婁吉闈欐€佽鍒欓厤缃紱
4銆佸鏋滆繕涓嶈閭e氨鍒颁氦娴佺兢鍑洪挶璇蜂汉澶勭悊鍚э紒');
}
});
return false;
});
var sitedir=$('#sitedir').data('sitedir');
var uploadurl = $("#preurl").data('preurl')+'/index/upload';
//鎵ц鍗曞浘鐗囧疄渚
var uploadInst = upload.render({
elem: '.upload' //缁戝畾鍏冪礌
,url: uploadurl //涓婁紶鎺ュ彛
,field: 'upload' //瀛楁鍚嶇О
,multiple: false //澶氭枃浠朵笂浼
,accept: 'images' //鎺ユ敹鏂囦欢绫诲瀷 images锛堝浘鐗囷級銆乫ile锛堟墍鏈夋枃浠讹級銆乿ideo锛堣棰戯級銆乤udio锛堥煶棰戯級
,acceptMime: 'image/*'
,before: function(obj){
//鍒ゆ柇鏄惁闇€瑕佸姞姘村嵃
if($(this.item).hasClass('watermark')){
uploadInst.config.url=uploadurl+'/watermark/1';//鏀瑰彉URL
}
layer.load(); //涓婁紶loading
}
,done: function(res){
var item = this.item;
var des=$(item).data('des');
layer.closeAll('loading'); //鍏抽棴loading
if(res.code==1){
$('#'+des).val(res.data[0]);
$('#'+des+'_box').html("