//新建相册
function album_open(){
  xtip.open({
    type: 'html',
    width: '400px',
    height: '305px',
    content: '<div class="layui-form-pane" style="padding:15px 15px;"><input type="text" id="album_name" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" placeholder="相册名称"><input type="text" id="album_img" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" placeholder="相册封面"><input type="text" id="album_pw" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" placeholder="相册密码"><select id="album_hide" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;"><option value="1">公开显示</option><option value="2">私密相册</option></select><button type="button" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" onclick="album_new()">确认创建</button></div>',
    title: '新建相册',
    lock: true,
	over: false,
  });
}
//发送请求
function album_new() {
    var url = quanjuurl+'inc/huiyuan.php?album=tianjia';
    $.ajax({
        url: url,
        type: "post",
        data: {name:$("#album_name").val(), img:$("#album_img").val(), pw:$("#album_pw").val(), hide:$("#album_hide").val()},
        dataType: "TEXT",
        success: function(result) {
            xtip.msg(result);
			setTimeout(function(){
				location.reload();
			},1000)
        }
    });
}
function album_xunwshanchu(id){
	xtip.confirm('确认删除该相册吗？删除不可恢复！',function(){
		album_shanchu(id)
	});
}
function album_shanchu(id) {
    var url = quanjuurl+'inc/huiyuan.php?album=shanchu';
    $.ajax({
        url: url,
        type: "post",
        data: {pid:id},
        dataType: "TEXT",
        success: function(result) {
            xtip.msg(result);
			setTimeout(function(){
				location.reload();
			},1000)
        }
    });
}
function album_open1(){
  xtip.open({
    type: 'html',
    width: '400px',
    height: '260px',
    content: '<div class="layui-form-pane" style="padding:15px 15px;"><input type="text" id="album_name" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" placeholder="照片标题"><input type="text" id="album_img" style="width:82%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px 0 0 5px;margin-bottom:10px;" placeholder="图片地址"><button type="button" class="layui-btn" style="border-radius:0 5px 5px 0;" onclick="fmtsc()">上传</button><select id="album_hide" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;"><option value="1">公开显示</option><option value="2">私密照片</option></select><button type="button" class="layui-btn layui-btn-fluid" onclick="album_new1()">确认创建</button></div>',
    title: '新建相册',
    lock: true,
  });
}
//发送请求
function album_new1() {
    var url = quanjuurl+'inc/huiyuan.php?picture=tianjia';
    $.ajax({
        url: url,
        type: "post",
        data: {name:$("#album_name").val(), img:$("#album_img").val(), album_hide:$("#album_hide").val(), sortid:<?php echo $_GET["pid"];?>},
        dataType: "TEXT",
        success: function(result) {
            xtip.msg(result);
			// setTimeout(function(){
				// location.reload();
			// },1000)
        }
    });
}
function fmtsc(){
        $("#fmtscup").click();
}
function myFfmt() {
    var fd = new FormData();
    fd.append("upload", 1);
    fd.append("upfile", $("#fmtscup").get(0).files[0]);
	fd.append("name", $("#fmtscup").get(0).files[0].name);
    $.ajax({
      url: quanjuurl+"inc/huiyuan.php?action=wenzhangcr",
      type: "POST",
      processData: false,
      contentType: false,
      data: fd,
	  success: function(result) {
		$('#album_img').val(result);
	  }
    });
}
