新增用户信息修改,可以修改昵称和QQ号信息
This commit is contained in:
parent
fab394138f
commit
0f2aa55382
0
admin/index.php
Normal file
0
admin/index.php
Normal file
0
api/auth/changepassword.php
Normal file
0
api/auth/changepassword.php
Normal file
150
api/class/info_change.php
Normal file
150
api/class/info_change.php
Normal file
|
@ -0,0 +1,150 @@
|
|||
<?PHP
|
||||
/*
|
||||
* wxxy_class 项目组
|
||||
* 代码均开源
|
||||
*/
|
||||
|
||||
// 载入头
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/api/header-control.php');
|
||||
|
||||
// 获取参数
|
||||
$post = file_get_contents('php://input');
|
||||
$POST_INFO = json_decode($post,true);
|
||||
|
||||
// 载入用户个人信息
|
||||
$member_url = $setting['API']['Domain'].'/class/person.php?key='.$setting['Key'].'&type=normal&studentID='.$POST_INFO['data']['studentID'];
|
||||
$member_ch = curl_init($member_url);
|
||||
curl_setopt($member_ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt($member_ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$member = curl_exec($member_ch);
|
||||
$member = json_decode($member,true);
|
||||
|
||||
// 构建函数
|
||||
if ($POST_INFO['ssid'] == $member['data']['ssid']) {
|
||||
// 对数据进行转义,避免数据库注入
|
||||
$data_person_displayname = addslashes($POST_INFO['data']['person_displayname']);
|
||||
$data_person_qq = addslashes($POST_INFO['data']['person_qq']);
|
||||
$data_person_city = addslashes($POST_INFO['data']['person_city']);
|
||||
$data_person = addslashes($POST_INFO['data']['studentID']);
|
||||
|
||||
// 检查数据
|
||||
if (!empty($data_person)
|
||||
and !empty($data_person_city)
|
||||
and !empty($data_person_displayname)) {
|
||||
// 检查数据可行性
|
||||
if (preg_match('/[0-9]{8}/',$data_person) and preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{2,20}+$/u',$data_person_displayname)) {
|
||||
// 对部分数据(QQ)进行数据检查
|
||||
if (!empty($data_person_qq)) {
|
||||
if (!preg_match('/[1-9][0-9]{4,}/',$data_person_qq)) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'DATA_QQ',
|
||||
'code'=>403,
|
||||
'info'=>'参数 Json[data.person_qq] 错误'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
||||
}
|
||||
|
||||
// 上传数据(保证数据可以正常上传则锁定数据库)
|
||||
mysqli_query($conn,"LOCK TABLE ".$setting['SQL_DATA']['info']." WHRITE");
|
||||
if (mysqli_query($conn,"UPDATE ".$setting['SQL_DATA']['info']." SET displayname='$data_person_displayname',qq='$data_person_qq',city='$data_person_city' WHERE studentID='$data_person'")) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'SUCCESS',
|
||||
'code'=>200,
|
||||
'info'=>'修改完毕!'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'MYSQL_ERROR',
|
||||
'code'=>403,
|
||||
'info'=>'请重试或联系管理员'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
||||
mysqli_query($conn,"TABLE UNLOCK");
|
||||
} else {
|
||||
if (!preg_match('/[0-9]{8}/',$data_person)) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'DATA_USER',
|
||||
'code'=>403,
|
||||
'info'=>'参数 Json[data.studentID] 错误'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
} elseif (!preg_match('/^[\x{4e00}-\x{9fa5}A-Za-z0-9_]{2,20}+$/u',$data_person_displayname)) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'DATA_DISPLAYNAME',
|
||||
'code'=>403,
|
||||
'info'=>'参数 Json[data.person_displayname] 错误'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (empty($data_person)) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'NONE_USER',
|
||||
'code'=>403,
|
||||
'info'=>'参数 Json[data.studentID] 缺失'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
} elseif ($data_person_displayname) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'NONE_DISPLAYNAME',
|
||||
'code'=>403,
|
||||
'info'=>'参数 Json[data.person_displayname] 缺失'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
} elseif ($data_person_city) {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'NONE_CITY',
|
||||
'code'=>403,
|
||||
'info'=>'参数 Json[data.person_city] 缺失'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
} else {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'NONE_ERROR',
|
||||
'code'=>403,
|
||||
'info'=>'参数 Json[data.__] 缺失,未知错误'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 编译数据
|
||||
$data = array(
|
||||
'output'=>'SSID_ERROR',
|
||||
'code'=>403,
|
||||
'info'=>'密钥错误'
|
||||
);
|
||||
// 输出数据
|
||||
echo json_encode($data,JSON_UNESCAPED_UNICODE);
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
}
|
|
@ -66,6 +66,9 @@ if ($key == $sql_key) {
|
|||
'office'=>$result_person_object->office,
|
||||
'gender'=>$result_person_object->gender,
|
||||
'qq'=>$result_person_object->qq,
|
||||
'displayname'=>$result_person_object->displayname,
|
||||
'ssid'=>$result_person_object->ssid,
|
||||
'city'=>$result_person_object->city,
|
||||
)
|
||||
);
|
||||
// 输出数据
|
||||
|
|
48
index.php
48
index.php
|
@ -57,6 +57,9 @@ $member_all = json_decode($member_all,true);
|
|||
<div class="row">
|
||||
<div class="col-12 fs-5 mb-3"><i class="bi bi-emoji-smile"></i> 欢迎</div>
|
||||
<div class="col-12 px-5 mb-3">不知道写啥,放着吧。这个网站就服务我们二班的东西,顺便也是自己PHP练手的</div>
|
||||
<div class="col-12 text-center">
|
||||
<a class="btn btn-primary" href="/setting.php" role="button">个人设置</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -78,7 +81,7 @@ $member_all = json_decode($member_all,true);
|
|||
<div class="card shadow rounded-3 flex-grow-1">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-1 fs-5 fw-bold"><i class="bi bi-file-earmark-person"></i> 班干部表</div>
|
||||
<div class="col-12 mb-3 fs-5 fw-bold"><i class="bi bi-file-earmark-person"></i> 班干部表</div>
|
||||
<div class="col-12">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
@ -117,7 +120,15 @@ $member_all = json_decode($member_all,true);
|
|||
<div class="card shadow rounded-3 flex-grow-1">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-1 fs-5 fw-bold"><i class="bi bi-file-earmark-person"></i> 班级辅导员</div>
|
||||
<div class="col-12 mb-3 fs-5 fw-bold"><i class="bi bi-file-earmark-person"></i> 班级辅导员</div>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3 text-center">
|
||||
<img src="https://q1.qlogo.cn/g?b=qq&nk=843552555&s=640" style="width:120px;" class="rounded-circle">
|
||||
</div>
|
||||
<div class="col-12 mb-1 text-center fs-5 fw-bold">辅导员 - 缪志刚老师</div>
|
||||
<div class="col-12 text-center">QQ:843552555</div>
|
||||
<div class="col-12 text-center">TEL:15605297830</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -126,36 +137,9 @@ $member_all = json_decode($member_all,true);
|
|||
<div class="card shadow rounded-3 flex-grow-1">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-1 fs-5 fw-bold"><i class="bi bi-file-earmark-person"></i> 校园地图</div>
|
||||
<div class="col-12 container">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">学号</th>
|
||||
<th scope="col">姓名</th>
|
||||
<th scope="col">职位</th>
|
||||
<th scope="col">QQ号</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?PHP
|
||||
$num_add = 1;
|
||||
while (!empty($member_all['data'][$num_add]['studentID'])) {
|
||||
if ($member_all['data'][$num_add]['op'] == '1') {
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><?PHP echo $member_all['data'][$num_add]['studentID'] ?></th>
|
||||
<td><?PHP echo $member_all['data'][$num_add]['name'] ?></td>
|
||||
<td><?PHP echo $member_all['data'][$num_add]['office'] ?></td>
|
||||
<td><?PHP echo $member_all['data'][$num_add]['qq'] ?></td>
|
||||
</tr>
|
||||
<?PHP
|
||||
}
|
||||
$num_add ++;
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="col-12 mb-3 fs-5 fw-bold"><i class="bi bi-file-earmark-person"></i> 校园地图</div>
|
||||
<div class="col-12">
|
||||
<img src="/src/img/map.jpg" class="container">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -27,6 +27,18 @@ function menu_color($menu_num) {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="headingTwo">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#c-Two" aria-expanded="true" aria-controls="collapseTwo"><i class="bi bi-clipboard"></i> 管理</button>
|
||||
</h2>
|
||||
<div id="c-Two" class="accordion-collapse collapse" aria-labelledby="headingOne" data-bs-parent="#acd">
|
||||
<div class="accordion-body">
|
||||
<div class="row px-4">
|
||||
<div class="col-12 mb-1"><a href="/setting.php" class="text-decoration-none <?PHP menu_color(100) ?>"><i class="bi bi-gear"></i> 个人设置</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="headingFour">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#c-Four" aria-expanded="false" aria-controls="collapseFour"><i class="bi bi-share"></i> 外链</button>
|
||||
|
|
136
setting.php
Normal file
136
setting.php
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
// 页面ID
|
||||
$menu_page = 100;
|
||||
$menu_list = 2;
|
||||
// 载入组件
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/module/head-check.php');
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/plugins/function.php');
|
||||
?>
|
||||
<!doctype html>
|
||||
<!--
|
||||
哎呀,原来你看到了呀。
|
||||
欢迎你~
|
||||
如果你想看完整的代码你可以去我的GITHUB看代码,代码地址如下哦:
|
||||
https://github.com/XiaoLFeng/wxxy_class
|
||||
欢迎来201宿舍玩啊~
|
||||
-->
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?PHP echo $normal['data']['web_title']['text']?> - <?PHP echo $normal['data']['web_subtitle']['text']?></title>
|
||||
<link rel="shortcut icon" href="<?PHP echo $normal['data']['web_icon']['text']?>" type="image/x-icon">
|
||||
<meta name="description" content="<?PHP echo $normal['data']['web_desc']['text']?>">
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="<?PHP echo $mirror['data']['info']['bootstrap_css'] ?>">
|
||||
<link rel="stylesheet" href="<?PHP echo $mirror['data']['info']['bootstrap_icon'] ?>">
|
||||
<link rel="stylesheet" href="<?PHP echo $mirror['data']['info']['qweather'] ?>">
|
||||
<link href="/src/css/city-picker.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body style="background-color:#e3f2fd;">
|
||||
<!-- 菜单 -->
|
||||
<header>
|
||||
<?PHP include($_SERVER['DOCUMENT_ROOT'].'/module/header.php') ?>
|
||||
</header>
|
||||
<!-- 内容 -->
|
||||
<div id="loader" class="container placeholder-glow text-center py-4">
|
||||
<div class="spinner-grow text-primary" role="status"><span class="visually-hidden">Loading...</span></div>
|
||||
<div class="spinner-grow text-primary" role="status"><span class="visually-hidden">Loading...</span></div>
|
||||
<div class="spinner-grow text-primary" role="status"><span class="visually-hidden">Loading...</span></div>
|
||||
</div>
|
||||
<div id="main" class="container">
|
||||
<div class="row">
|
||||
<div class="col-12 col-bg-4 col-lg-3 mb-3">
|
||||
<?PHP include('./module/menu.php'); ?>
|
||||
</div>
|
||||
<div class="col-12 col-bg-8 col-lg-9 mt-3 mb-3">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
<div class="card shadow rounded-3">
|
||||
<div class="card-body">
|
||||
<form action="/setting_data_upload.php?type=normal" method="post">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-4 fs-5 fw-bold"><i class="bi bi-list-ul"></i> 基本设置</div>
|
||||
<div class="row px-4">
|
||||
<div class="col-12 col-lg-6 mb-3">
|
||||
<label class="form-label"><i class="bi bi-person"></i> 学号 <font color="red">*</font></label>
|
||||
<input type="text" class="form-control" value="<?PHP echo stripslashes($member['data']['studentID']) ?>" readonly>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 mb-3">
|
||||
<label class="form-label"><i class="bi bi-person"></i> 姓名 <font color="red">*</font></label>
|
||||
<input type="text" class="form-control" value="<?PHP echo stripslashes($member['data']['name']) ?>" readonly>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 mb-3">
|
||||
<label class="form-label"><i class="bi bi-person"></i> 宿舍号 <font color="red">*</font></label>
|
||||
<input type="text" class="form-control" value="<?PHP echo stripslashes($member['data']['dormitory']) ?>" readonly>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 mb-3">
|
||||
<label class="form-label"><i class="bi bi-person"></i> 班级委员 <font color="red">*</font></label>
|
||||
<input type="text" class="form-control" value="<?PHP echo stripslashes($member['data']['office']) ?>" readonly>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 mb-3">
|
||||
<label class="form-label"><i class="bi bi-card-list"></i> 昵称 <font color="red">*</font></label>
|
||||
<input type="text" class="form-control" id="person_displayname" name="person_displayname" value="<?PHP echo stripslashes($member['data']['displayname']) ?>">
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 mb-3">
|
||||
<label class="form-label"><i class="bi bi-chat-dots"></i> QQ <font color="grey" class="fw-light">头像会自动获取QQ头像</font></label>
|
||||
<input type="text" class="form-control" id="person_qq" name="person_qq" value="<?PHP echo stripslashes($member['data']['qq']) ?>">
|
||||
</div>
|
||||
<div class="col-12 mb-3">
|
||||
<label class="form-label"><i class="bi bi-building"></i> 所在设区市 <font color="red">*</font></label>
|
||||
<div id="distpicker" class="container">
|
||||
<div class="form-group">
|
||||
<input id="person_city" name="person_city" class="form-control" readonly type="text" value="<?PHP
|
||||
if (empty($member['data']['city'])) {
|
||||
echo '北京市/北京市/朝阳区';
|
||||
} else {
|
||||
echo stripslashes($member['data']['city']);
|
||||
}
|
||||
?>" data-toggle="city-picker" style="width: auto;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 mb-3 text-end">
|
||||
<button class="btn btn-outline-success" type="submit"><i class="bi bi-check-circle"></i> 提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 mb-3">
|
||||
<div class="card shadow rounded-3">
|
||||
<div class="card-body">
|
||||
<form action="" method="post">
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3 fs-5 fw-bold"><i class="bi bi-key"></i> 修改密码</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 页尾 -->
|
||||
<?PHP include($_SERVER['DOCUMENT_ROOT'].'/module/footer.php') ?>
|
||||
</body>
|
||||
<!-- JavaScript -->
|
||||
<script src="<?PHP echo $mirror['data']['info']['qweather'] ?>"></script>
|
||||
<script src="/src/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="<?PHP echo $mirror['data']['info']['jquery'] ?>"></script>
|
||||
<script src="/src/js/city-picker.data.js"></script>
|
||||
<script src="/src/js/city-picker.js"></script>
|
||||
<script src="/src/js/main.js"></script>
|
||||
<script>
|
||||
// 加载内容
|
||||
$("#main").hide();
|
||||
window.onload=function(){
|
||||
$("#loader").fadeOut(200);
|
||||
$("#main").show(500);
|
||||
}
|
||||
</script>
|
||||
</html>
|
92
setting_data_upload.php
Normal file
92
setting_data_upload.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?PHP
|
||||
/*
|
||||
* 筱锋xiao_lfeng 分享系统(插件)
|
||||
* 信息上传组件
|
||||
*/
|
||||
|
||||
// 定义请求头
|
||||
header("Content-type:text/html;charset=utf-8");
|
||||
// 获取组件
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/setting.inc.php');
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/plugins/sql_conn.php');
|
||||
|
||||
// 载入用户个人信息
|
||||
$member_url = $setting['API']['Domain'].'/class/person.php?key='.$setting['Key'].'&type=normal&studentID='.$_COOKIE['studentID'];
|
||||
$member_ch = curl_init($member_url);
|
||||
curl_setopt($member_ch,CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt($member_ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$member = curl_exec($member_ch);
|
||||
$member = json_decode($member,true);
|
||||
|
||||
// 获取参数
|
||||
$studentID = $_COOKIE['studentID'];
|
||||
$type = htmlspecialchars($_GET['type']);
|
||||
|
||||
// 注册函数
|
||||
// 发送POST
|
||||
function http_post_json($url, $jsonStr) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json; charset=utf-8',
|
||||
'Content-Length: ' . strlen($jsonStr)
|
||||
)
|
||||
);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
// 函数构建
|
||||
if (!empty($studentID)) {
|
||||
// 发送用户信息
|
||||
$url = $setting['API']['Domain']."/class/info_change.php"; //请求地址
|
||||
$arr = array(
|
||||
'output'=>'SUCCESS',
|
||||
'code'=>200,
|
||||
'info'=>'数据已发送',
|
||||
'ssid'=>$member['data']['ssid'],
|
||||
'data'=>array(
|
||||
'studentID'=>$studentID,
|
||||
'person_displayname'=>$_POST['person_displayname'],
|
||||
'person_qq'=>$_POST['person_qq'],
|
||||
'person_city'=>$_POST['person_city'],
|
||||
),
|
||||
); //请求参数(数组)
|
||||
$jsonStr = json_encode($arr); //转换为json格式
|
||||
$result = http_post_json($url, $jsonStr);
|
||||
$result = json_decode($result,true);
|
||||
|
||||
// 反馈结果
|
||||
if ($result['output'] == 'SUCCESS') {
|
||||
echo <<<EOF
|
||||
<script language="javascript">
|
||||
alert( "已完成!" )
|
||||
window.location.href = "/setting.php"
|
||||
</script>
|
||||
EOF;
|
||||
} elseif ($result['output'] == 'SQL_DNEY') {
|
||||
echo <<<EOF
|
||||
<script language="javascript">
|
||||
alert( "操作拒绝!已经有数据了" )
|
||||
window.history.go(-1);
|
||||
</script>
|
||||
EOF;
|
||||
} else {
|
||||
echo <<<EOF
|
||||
<script language="javascript">
|
||||
alert( "缺少密钥" )
|
||||
window.history.go(-1);
|
||||
</script>
|
||||
EOF;
|
||||
}
|
||||
} else {
|
||||
echo <<<EOF
|
||||
<script language="javascript">
|
||||
alert( "已完成!" )
|
||||
window.location.href = "/auth.php?callback=https://ourwxxy.x-lf.com/setting.php"
|
||||
</script>
|
||||
EOF;
|
||||
}
|
161
src/css/city-picker.css
Normal file
161
src/css/city-picker.css
Normal file
|
@ -0,0 +1,161 @@
|
|||
.city-picker-input {
|
||||
opacity: 0 !important;
|
||||
top: -9999px;
|
||||
left: -9999px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.city-picker-span {
|
||||
position: relative;
|
||||
display: block;
|
||||
outline: 0;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
border-bottom: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
color: #ccc;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.city-picker-span > .placeholder {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.city-picker-span > .arrow {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 8px;
|
||||
width: 10px;
|
||||
margin-top: -3px;
|
||||
height: 5px;
|
||||
background: url(../images/drop-arrow.png) -10px -25px no-repeat;
|
||||
}
|
||||
|
||||
.city-picker-span.focus,
|
||||
.city-picker-span.open {
|
||||
border-bottom-color: #46A4FF;
|
||||
}
|
||||
|
||||
.city-picker-span.open > .arrow {
|
||||
background-position: -10px -10px;
|
||||
}
|
||||
|
||||
.city-picker-span > .title > span {
|
||||
color: #333;
|
||||
padding: 5px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.city-picker-span > .title > span:hover {
|
||||
background-color: #f1f8ff;
|
||||
}
|
||||
|
||||
.city-picker-dropdown {
|
||||
position: absolute;
|
||||
width: 315px;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
outline: 0;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
z-index: 999999;
|
||||
display: none;
|
||||
min-width: 330px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.city-select-wrap {
|
||||
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.city-select-tab {
|
||||
border-bottom: 1px solid #ccc;
|
||||
background: #f0f0f0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.city-select-tab > a {
|
||||
display: inline-block;
|
||||
padding: 8px 22px;
|
||||
border-left: 1px solid #ccc;
|
||||
border-bottom: 1px solid transparent;
|
||||
color: #4D4D4D;
|
||||
text-align: center;
|
||||
outline: 0;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.city-select-tab > a.active {
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #fff;
|
||||
color: #46A4FF;
|
||||
}
|
||||
|
||||
.city-select-tab > a:first-child {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
.city-select-tab > a:last-child.active {
|
||||
border-right: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.city-select-content {
|
||||
width: 100%;
|
||||
min-height: 10px;
|
||||
background-color: #fff;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
.city-select {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.city-select dl {
|
||||
line-height: 2;
|
||||
clear: both;
|
||||
padding: 3px 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.city-select dt {
|
||||
position: absolute;
|
||||
width: 2.5em;
|
||||
font-weight: 500;
|
||||
text-align: right;
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
.city-select dd {
|
||||
margin-left: 0;
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
.city-select.province dd {
|
||||
margin-left: 3em;
|
||||
}
|
||||
|
||||
.city-select a {
|
||||
display: inline-block;
|
||||
padding: 0 10px;
|
||||
outline: 0;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
margin-right: 2px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.city-select a:hover,
|
||||
.city-select a:focus {
|
||||
background-color: #f1f8ff;
|
||||
border-radius: 2px;
|
||||
color: #46A4FF;
|
||||
}
|
||||
|
||||
.city-select a.active {
|
||||
background-color: #46A4FF;
|
||||
color: #fff;
|
||||
border-radius: 2px;
|
||||
}
|
BIN
src/img/map.jpg
Normal file
BIN
src/img/map.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 150 KiB |
4066
src/js/city-picker.data.js
Normal file
4066
src/js/city-picker.data.js
Normal file
File diff suppressed because it is too large
Load Diff
580
src/js/city-picker.js
Normal file
580
src/js/city-picker.js
Normal file
|
@ -0,0 +1,580 @@
|
|||
/*!
|
||||
* CityPicker v1.0.2
|
||||
* https://github.com/tshi0912/citypicker
|
||||
*
|
||||
* Copyright (c) 2015-2016 Tao Shi
|
||||
* Released under the MIT license
|
||||
*
|
||||
* Date: 2016-02-29T12:11:36.477Z
|
||||
*/
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as anonymous module.
|
||||
define(['jquery', 'ChineseDistricts'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node / CommonJS
|
||||
factory(require('jquery'), require('ChineseDistricts'));
|
||||
} else {
|
||||
// Browser globals.
|
||||
factory(jQuery, ChineseDistricts);
|
||||
}
|
||||
})(function ($, ChineseDistricts) {
|
||||
|
||||
'use strict';
|
||||
|
||||
if (typeof ChineseDistricts === 'undefined') {
|
||||
throw new Error('The file "city-picker.data.js" must be included first!');
|
||||
}
|
||||
|
||||
var NAMESPACE = 'citypicker';
|
||||
var EVENT_CHANGE = 'change.' + NAMESPACE;
|
||||
var PROVINCE = 'province';
|
||||
var CITY = 'city';
|
||||
var DISTRICT = 'district';
|
||||
|
||||
function CityPicker(element, options) {
|
||||
this.$element = $(element);
|
||||
this.$dropdown = null;
|
||||
this.options = $.extend({}, CityPicker.DEFAULTS, $.isPlainObject(options) && options);
|
||||
this.active = false;
|
||||
this.dems = [];
|
||||
this.needBlur = false;
|
||||
this.init();
|
||||
}
|
||||
|
||||
CityPicker.prototype = {
|
||||
constructor: CityPicker,
|
||||
|
||||
init: function () {
|
||||
|
||||
this.defineDems();
|
||||
|
||||
this.render();
|
||||
|
||||
this.bind();
|
||||
|
||||
this.active = true;
|
||||
},
|
||||
|
||||
render: function () {
|
||||
var p = this.getPosition(),
|
||||
placeholder = this.$element.attr('placeholder') || this.options.placeholder,
|
||||
textspan = '<span class="city-picker-span" style="' +
|
||||
this.getWidthStyle(p.width) + 'height:' +
|
||||
p.height + 'px;line-height:' + (p.height - 1) + 'px;">' +
|
||||
(placeholder ? '<span class="placeholder">' + placeholder + '</span>' : '') +
|
||||
'<span class="title"></span><div class="arrow"></div>' + '</span>',
|
||||
|
||||
dropdown = '<div class="city-picker-dropdown" style="left:0px;top:100%;' +
|
||||
this.getWidthStyle(p.width, true) + '">' +
|
||||
'<div class="city-select-wrap">' +
|
||||
'<div class="city-select-tab">' +
|
||||
'<a class="active" data-count="province">省份</a>' +
|
||||
(this.includeDem('city') ? '<a data-count="city">城市</a>' : '') +
|
||||
(this.includeDem('district') ? '<a data-count="district">区县</a>' : '') + '</div>' +
|
||||
'<div class="city-select-content">' +
|
||||
'<div class="city-select province" data-count="province"></div>' +
|
||||
(this.includeDem('city') ? '<div class="city-select city" data-count="city"></div>' : '') +
|
||||
(this.includeDem('district') ? '<div class="city-select district" data-count="district"></div>' : '') +
|
||||
'</div></div>';
|
||||
|
||||
this.$element.addClass('city-picker-input');
|
||||
this.$textspan = $(textspan).insertAfter(this.$element);
|
||||
this.$dropdown = $(dropdown).insertAfter(this.$textspan);
|
||||
var $select = this.$dropdown.find('.city-select');
|
||||
|
||||
// setup this.$province, this.$city and/or this.$district object
|
||||
$.each(this.dems, $.proxy(function (i, type) {
|
||||
this['$' + type] = $select.filter('.' + type + '');
|
||||
}, this));
|
||||
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
refresh: function (force) {
|
||||
// clean the data-item for each $select
|
||||
var $select = this.$dropdown.find('.city-select');
|
||||
$select.data('item', null);
|
||||
// parse value from value of the target $element
|
||||
var val = this.$element.val() || '';
|
||||
val = val.split('/');
|
||||
$.each(this.dems, $.proxy(function (i, type) {
|
||||
if (val[i] && i < val.length) {
|
||||
this.options[type] = val[i];
|
||||
} else if (force) {
|
||||
this.options[type] = '';
|
||||
}
|
||||
this.output(type);
|
||||
}, this));
|
||||
this.tab(PROVINCE);
|
||||
this.feedText();
|
||||
this.feedVal();
|
||||
},
|
||||
|
||||
defineDems: function () {
|
||||
var stop = false;
|
||||
$.each([PROVINCE, CITY, DISTRICT], $.proxy(function (i, type) {
|
||||
if (!stop) {
|
||||
this.dems.push(type);
|
||||
}
|
||||
if (type === this.options.level) {
|
||||
stop = true;
|
||||
}
|
||||
}, this));
|
||||
},
|
||||
|
||||
includeDem: function (type) {
|
||||
return $.inArray(type, this.dems) !== -1;
|
||||
},
|
||||
|
||||
getPosition: function () {
|
||||
var p, h, w, s, pw;
|
||||
p = this.$element.position();
|
||||
s = this.getSize(this.$element);
|
||||
h = s.height;
|
||||
w = s.width;
|
||||
if (this.options.responsive) {
|
||||
pw = this.$element.offsetParent().width();
|
||||
if (pw) {
|
||||
w = w / pw;
|
||||
if (w > 0.99) {
|
||||
w = 1;
|
||||
}
|
||||
w = w * 100 + '%';
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
top: p.top || 0,
|
||||
left: p.left || 0,
|
||||
height: h,
|
||||
width: w
|
||||
};
|
||||
},
|
||||
|
||||
getSize: function ($dom) {
|
||||
var $wrap, $clone, sizes;
|
||||
if (!$dom.is(':visible')) {
|
||||
$wrap = $("<div />").appendTo($("body"));
|
||||
$wrap.css({
|
||||
"position": "absolute !important",
|
||||
"visibility": "hidden !important",
|
||||
"display": "block !important"
|
||||
});
|
||||
|
||||
$clone = $dom.clone().appendTo($wrap);
|
||||
|
||||
sizes = {
|
||||
width: $clone.outerWidth(),
|
||||
height: $clone.outerHeight()
|
||||
};
|
||||
|
||||
$wrap.remove();
|
||||
} else {
|
||||
sizes = {
|
||||
width: $dom.outerWidth(),
|
||||
height: $dom.outerHeight()
|
||||
};
|
||||
}
|
||||
|
||||
return sizes;
|
||||
},
|
||||
|
||||
getWidthStyle: function (w, dropdown) {
|
||||
if (this.options.responsive && !$.isNumeric(w)) {
|
||||
return 'width:' + w + ';';
|
||||
} else {
|
||||
return 'width:' + (dropdown ? Math.max(320, w) : w) + 'px;';
|
||||
}
|
||||
},
|
||||
|
||||
bind: function () {
|
||||
var $this = this;
|
||||
|
||||
$(document).on('click', (this._mouteclick = function (e) {
|
||||
var $target = $(e.target);
|
||||
var $dropdown, $span, $input;
|
||||
if ($target.is('.city-picker-span')) {
|
||||
$span = $target;
|
||||
} else if ($target.is('.city-picker-span *')) {
|
||||
$span = $target.parents('.city-picker-span');
|
||||
}
|
||||
if ($target.is('.city-picker-input')) {
|
||||
$input = $target;
|
||||
}
|
||||
if ($target.is('.city-picker-dropdown')) {
|
||||
$dropdown = $target;
|
||||
} else if ($target.is('.city-picker-dropdown *')) {
|
||||
$dropdown = $target.parents('.city-picker-dropdown');
|
||||
}
|
||||
if ((!$input && !$span && !$dropdown) ||
|
||||
($span && $span.get(0) !== $this.$textspan.get(0)) ||
|
||||
($input && $input.get(0) !== $this.$element.get(0)) ||
|
||||
($dropdown && $dropdown.get(0) !== $this.$dropdown.get(0))) {
|
||||
$this.close(true);
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
this.$element.on('change', (this._changeElement = $.proxy(function () {
|
||||
this.close(true);
|
||||
this.refresh(true);
|
||||
}, this))).on('focus', (this._focusElement = $.proxy(function () {
|
||||
this.needBlur = true;
|
||||
this.open();
|
||||
}, this))).on('blur', (this._blurElement = $.proxy(function () {
|
||||
if (this.needBlur) {
|
||||
this.needBlur = false;
|
||||
this.close(true);
|
||||
}
|
||||
}, this)));
|
||||
|
||||
this.$textspan.on('click', function (e) {
|
||||
var $target = $(e.target), type;
|
||||
$this.needBlur = false;
|
||||
if ($target.is('.select-item')) {
|
||||
type = $target.data('count');
|
||||
$this.open(type);
|
||||
} else {
|
||||
if ($this.$dropdown.is(':visible')) {
|
||||
$this.close();
|
||||
} else {
|
||||
$this.open();
|
||||
}
|
||||
}
|
||||
}).on('mousedown', function () {
|
||||
$this.needBlur = false;
|
||||
});
|
||||
|
||||
this.$dropdown.on('click', '.city-select a', function () {
|
||||
var $select = $(this).parents('.city-select');
|
||||
var $active = $select.find('a.active');
|
||||
var last = $select.next().length === 0;
|
||||
$active.removeClass('active');
|
||||
$(this).addClass('active');
|
||||
if ($active.data('code') !== $(this).data('code')) {
|
||||
$select.data('item', {
|
||||
address: $(this).attr('title'), code: $(this).data('code')
|
||||
});
|
||||
$(this).trigger(EVENT_CHANGE);
|
||||
$this.feedText();
|
||||
$this.feedVal();
|
||||
if (last) {
|
||||
$this.close();
|
||||
}
|
||||
}
|
||||
}).on('click', '.city-select-tab a', function () {
|
||||
if (!$(this).hasClass('active')) {
|
||||
var type = $(this).data('count');
|
||||
$this.tab(type);
|
||||
}
|
||||
}).on('mousedown', function () {
|
||||
$this.needBlur = false;
|
||||
});
|
||||
|
||||
if (this.$province) {
|
||||
this.$province.on(EVENT_CHANGE, (this._changeProvince = $.proxy(function () {
|
||||
this.output(CITY);
|
||||
this.output(DISTRICT);
|
||||
this.tab(CITY);
|
||||
}, this)));
|
||||
}
|
||||
|
||||
if (this.$city) {
|
||||
this.$city.on(EVENT_CHANGE, (this._changeCity = $.proxy(function () {
|
||||
this.output(DISTRICT);
|
||||
this.tab(DISTRICT);
|
||||
}, this)));
|
||||
}
|
||||
},
|
||||
|
||||
open: function (type) {
|
||||
type = type || PROVINCE;
|
||||
this.$dropdown.show();
|
||||
this.$textspan.addClass('open').addClass('focus');
|
||||
this.tab(type);
|
||||
},
|
||||
|
||||
close: function (blur) {
|
||||
this.$dropdown.hide();
|
||||
this.$textspan.removeClass('open');
|
||||
if (blur) {
|
||||
this.$textspan.removeClass('focus');
|
||||
}
|
||||
},
|
||||
|
||||
unbind: function () {
|
||||
|
||||
$(document).off('click', this._mouteclick);
|
||||
|
||||
this.$element.off('change', this._changeElement);
|
||||
this.$element.off('focus', this._focusElement);
|
||||
this.$element.off('blur', this._blurElement);
|
||||
|
||||
this.$textspan.off('click');
|
||||
this.$textspan.off('mousedown');
|
||||
|
||||
this.$dropdown.off('click');
|
||||
this.$dropdown.off('mousedown');
|
||||
|
||||
if (this.$province) {
|
||||
this.$province.off(EVENT_CHANGE, this._changeProvince);
|
||||
}
|
||||
|
||||
if (this.$city) {
|
||||
this.$city.off(EVENT_CHANGE, this._changeCity);
|
||||
}
|
||||
},
|
||||
|
||||
getText: function () {
|
||||
var text = '';
|
||||
this.$dropdown.find('.city-select')
|
||||
.each(function () {
|
||||
var item = $(this).data('item'),
|
||||
type = $(this).data('count');
|
||||
if (item) {
|
||||
text += ($(this).hasClass('province') ? '' : '/') + '<span class="select-item" data-count="' +
|
||||
type + '" data-code="' + item.code + '">' + item.address + '</span>';
|
||||
}
|
||||
});
|
||||
return text;
|
||||
},
|
||||
|
||||
getPlaceHolder: function () {
|
||||
return this.$element.attr('placeholder') || this.options.placeholder;
|
||||
},
|
||||
|
||||
feedText: function () {
|
||||
var text = this.getText();
|
||||
if (text) {
|
||||
this.$textspan.find('>.placeholder').hide();
|
||||
this.$textspan.find('>.title').html(this.getText()).show();
|
||||
} else {
|
||||
this.$textspan.find('>.placeholder').text(this.getPlaceHolder()).show();
|
||||
this.$textspan.find('>.title').html('').hide();
|
||||
}
|
||||
},
|
||||
|
||||
getVal: function () {
|
||||
var text = '';
|
||||
this.$dropdown.find('.city-select')
|
||||
.each(function () {
|
||||
var item = $(this).data('item');
|
||||
if (item) {
|
||||
text += ($(this).hasClass('province') ? '' : '/') + item.address;
|
||||
}
|
||||
});
|
||||
return text;
|
||||
},
|
||||
|
||||
feedVal: function () {
|
||||
this.$element.val(this.getVal());
|
||||
},
|
||||
|
||||
output: function (type) {
|
||||
var options = this.options;
|
||||
//var placeholders = this.placeholders;
|
||||
var $select = this['$' + type];
|
||||
var data = type === PROVINCE ? {} : [];
|
||||
var item;
|
||||
var districts;
|
||||
var code;
|
||||
var matched = null;
|
||||
var value;
|
||||
|
||||
if (!$select || !$select.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
item = $select.data('item');
|
||||
|
||||
value = (item ? item.address : null) || options[type];
|
||||
|
||||
code = (
|
||||
type === PROVINCE ? 86 :
|
||||
type === CITY ? this.$province && this.$province.find('.active').data('code') :
|
||||
type === DISTRICT ? this.$city && this.$city.find('.active').data('code') : code
|
||||
);
|
||||
|
||||
districts = $.isNumeric(code) ? ChineseDistricts[code] : null;
|
||||
|
||||
if ($.isPlainObject(districts)) {
|
||||
$.each(districts, function (code, address) {
|
||||
var provs;
|
||||
if (type === PROVINCE) {
|
||||
provs = [];
|
||||
for (var i = 0; i < address.length; i++) {
|
||||
if (address[i].address === value) {
|
||||
matched = {
|
||||
code: address[i].code,
|
||||
address: address[i].address
|
||||
};
|
||||
}
|
||||
provs.push({
|
||||
code: address[i].code,
|
||||
address: address[i].address,
|
||||
selected: address[i].address === value
|
||||
});
|
||||
}
|
||||
data[code] = provs;
|
||||
} else {
|
||||
if (address === value) {
|
||||
matched = {
|
||||
code: code,
|
||||
address: address
|
||||
};
|
||||
}
|
||||
data.push({
|
||||
code: code,
|
||||
address: address,
|
||||
selected: address === value
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$select.html(type === PROVINCE ? this.getProvinceList(data) :
|
||||
this.getList(data, type));
|
||||
$select.data('item', matched);
|
||||
},
|
||||
|
||||
getProvinceList: function (data) {
|
||||
var list = [],
|
||||
$this = this,
|
||||
simple = this.options.simple;
|
||||
|
||||
$.each(data, function (i, n) {
|
||||
list.push('<dl class="clearfix">');
|
||||
list.push('<dt>' + i + '</dt><dd>');
|
||||
$.each(n, function (j, m) {
|
||||
list.push(
|
||||
'<a' +
|
||||
' title="' + (m.address || '') + '"' +
|
||||
' data-code="' + (m.code || '') + '"' +
|
||||
' class="' +
|
||||
(m.selected ? ' active' : '') +
|
||||
'">' +
|
||||
( simple ? $this.simplize(m.address, PROVINCE) : m.address) +
|
||||
'</a>');
|
||||
});
|
||||
list.push('</dd></dl>');
|
||||
});
|
||||
|
||||
return list.join('');
|
||||
},
|
||||
|
||||
getList: function (data, type) {
|
||||
var list = [],
|
||||
$this = this,
|
||||
simple = this.options.simple;
|
||||
list.push('<dl class="clearfix"><dd>');
|
||||
|
||||
$.each(data, function (i, n) {
|
||||
list.push(
|
||||
'<a' +
|
||||
' title="' + (n.address || '') + '"' +
|
||||
' data-code="' + (n.code || '') + '"' +
|
||||
' class="' +
|
||||
(n.selected ? ' active' : '') +
|
||||
'">' +
|
||||
( simple ? $this.simplize(n.address, type) : n.address) +
|
||||
'</a>');
|
||||
});
|
||||
list.push('</dd></dl>');
|
||||
|
||||
return list.join('');
|
||||
},
|
||||
|
||||
simplize: function (address, type) {
|
||||
address = address || '';
|
||||
if (type === PROVINCE) {
|
||||
return address.replace(/[省,市,自治区,壮族,回族,维吾尔]/g, '');
|
||||
} else if (type === CITY) {
|
||||
return address.replace(/[市,地区,回族,蒙古,苗族,白族,傣族,景颇族,藏族,彝族,壮族,傈僳族,布依族,侗族]/g, '')
|
||||
.replace('哈萨克', '').replace('自治州', '').replace(/自治县/, '');
|
||||
} else if (type === DISTRICT) {
|
||||
return address.length > 2 ? address.replace(/[市,区,县,旗]/g, '') : address;
|
||||
}
|
||||
},
|
||||
|
||||
tab: function (type) {
|
||||
var $selects = this.$dropdown.find('.city-select');
|
||||
var $tabs = this.$dropdown.find('.city-select-tab > a');
|
||||
var $select = this['$' + type];
|
||||
var $tab = this.$dropdown.find('.city-select-tab > a[data-count="' + type + '"]');
|
||||
if ($select) {
|
||||
$selects.hide();
|
||||
$select.show();
|
||||
$tabs.removeClass('active');
|
||||
$tab.addClass('active');
|
||||
}
|
||||
},
|
||||
|
||||
reset: function () {
|
||||
this.$element.val(null).trigger('change');
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
this.unbind();
|
||||
this.$element.removeData(NAMESPACE).removeClass('city-picker-input');
|
||||
this.$textspan.remove();
|
||||
this.$dropdown.remove();
|
||||
}
|
||||
};
|
||||
|
||||
CityPicker.DEFAULTS = {
|
||||
simple: false,
|
||||
responsive: false,
|
||||
placeholder: '请选择省/市/区',
|
||||
level: 'district',
|
||||
province: '',
|
||||
city: '',
|
||||
district: ''
|
||||
};
|
||||
|
||||
CityPicker.setDefaults = function (options) {
|
||||
$.extend(CityPicker.DEFAULTS, options);
|
||||
};
|
||||
|
||||
// Save the other citypicker
|
||||
CityPicker.other = $.fn.citypicker;
|
||||
|
||||
// Register as jQuery plugin
|
||||
$.fn.citypicker = function (option) {
|
||||
var args = [].slice.call(arguments, 1);
|
||||
|
||||
return this.each(function () {
|
||||
var $this = $(this);
|
||||
var data = $this.data(NAMESPACE);
|
||||
var options;
|
||||
var fn;
|
||||
|
||||
if (!data) {
|
||||
if (/destroy/.test(option)) {
|
||||
return;
|
||||
}
|
||||
|
||||
options = $.extend({}, $this.data(), $.isPlainObject(option) && option);
|
||||
$this.data(NAMESPACE, (data = new CityPicker(this, options)));
|
||||
}
|
||||
|
||||
if (typeof option === 'string' && $.isFunction(fn = data[option])) {
|
||||
fn.apply(data, args);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.citypicker.Constructor = CityPicker;
|
||||
$.fn.citypicker.setDefaults = CityPicker.setDefaults;
|
||||
|
||||
// No conflict
|
||||
$.fn.citypicker.noConflict = function () {
|
||||
$.fn.citypicker = CityPicker.other;
|
||||
return this;
|
||||
};
|
||||
|
||||
$(function () {
|
||||
$('[data-toggle="city-picker"]').citypicker();
|
||||
});
|
||||
});
|
50
src/js/main.js
Normal file
50
src/js/main.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
$(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
var $citypicker1 = $('#city-picker1');
|
||||
|
||||
$citypicker1.citypicker();
|
||||
|
||||
var $citypicker2 = $('#city-picker2');
|
||||
|
||||
$citypicker2.citypicker({
|
||||
province: '江苏省',
|
||||
city: '常州市',
|
||||
district: '溧阳市'
|
||||
});
|
||||
|
||||
var $citypicker3 = $('#city-picker3');
|
||||
|
||||
$('#reset').click(function () {
|
||||
$citypicker3.citypicker('reset');
|
||||
});
|
||||
|
||||
$('#destroy').click(function () {
|
||||
$citypicker3.citypicker('destroy');
|
||||
});
|
||||
//
|
||||
//$('#distpicker1').distpicker();
|
||||
//
|
||||
//$('#distpicker2').distpicker({
|
||||
// province: '---- 所在省 ----',
|
||||
// city: '---- 所在市 ----',
|
||||
// district: '---- 所在区 ----'
|
||||
//});
|
||||
//
|
||||
//$('#distpicker3').distpicker({
|
||||
// province: '浙江省',
|
||||
// city: '杭州市',
|
||||
// district: '西湖区'
|
||||
//});
|
||||
//
|
||||
//$('#distpicker4').distpicker({
|
||||
// placeholder: false
|
||||
//});
|
||||
//
|
||||
//$('#distpicker5').distpicker({
|
||||
// autoSelect: false
|
||||
//});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user