<?php
$title='快捷登录配置';
include __DIR__ . '/head.php';
?>


<div class="p-4 md:p-6">
    <div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
        <div class="p-4 md:p-6 border-b border-gray-200">
            <h2 class="text-base md:text-lg font-semibold text-gray-800">快捷登录配置</h2>
        </div>
        <div class="p-4 md:p-6">
            <form onsubmit="saveSetting(this);return false;" method="post" class="space-y-6">
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">快捷登录</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="quick_open" default="<?php echo $conf['quick_open']?>">
                            <option value="0">关闭</option>
                            <option value="1">彩虹聚合登录</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">API地址</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="quick_url" value="<?php echo $conf['quick_url']==''?'http://u.0mz.cn/':$conf['quick_url']?>" placeholder="http://qq.com/">
                        <p class="mt-1 text-xs text-gray-500">申请地址：<a href="http://u.0mz.cn/" target="_blank" class="text-blue-600 hover:underline">http://u.0mz.cn/</a>,免费使用</p>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">APPID</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="quick_appid" value="<?php echo $conf['quick_appid']?>">
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">APPKEY</label>
                    <div class="md:col-span-3">
                        <input type="text" class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="quick_appkey" value="<?php echo $conf['quick_appkey']?>">
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">QQ</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="quick_qq" default="<?php echo $conf['quick_qq']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">微信</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="quick_wx" default="<?php echo $conf['quick_wx']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <label class="text-xs md:text-sm font-medium text-gray-700 pt-2">支付宝</label>
                    <div class="md:col-span-3">
                        <select class="w-full px-3 md:px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm" name="quick_alipay" default="<?php echo $conf['quick_alipay']?>">
                            <option value="0">关闭</option>
                            <option value="1">开启</option>
                        </select>
                    </div>
                </div>
                <div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-start">
                    <div class="md:col-start-2 md:col-span-3 space-y-4">
                        <button type="submit" class="inline-flex items-center px-6 py-2.5 bg-blue-500 text-white text-sm font-medium rounded-lg hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
                            <i class="fas fa-save mr-2"></i>保存
                        </button>
                        <div class="p-4 bg-blue-50 border border-blue-200 rounded-lg">
                            <p class="text-sm text-blue-700">
                                <i class="fas fa-info-circle mr-2"></i>快捷登录接口设置好后就不要更换了，否则之前绑定快捷登录的用户都会失效
                            </p>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<?php include 'foot.php'; ?>
<script type="text/javascript">
	function saveSetting(obj){
		showLoading();
		$.ajax({
			type : 'POST',
			url : 'ajax.php?act=set',
			data : $(obj).serialize(),
			dataType : 'json',
			success : function(data) {
				hideLoading();
				showToast(data.msg, 'success');
				location.reload();
			},
			error:function(data){
				hideLoading();
				showToast('服务器错误', 'error');
				return false;
			}
		});
	}
	var items = $("select[default]");
	for (i = 0; i < items.length; i++) {
		$(items[i]).val($(items[i]).attr("default")||0);
	}
</script>