You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

242 lines
6.5 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<title>CP-ACC 设置Table</title>
<!-- Google font file. If you want you can change. -->
<link href="https://fonts.googleapis.com/css?family=Nunito:400,600,700,900" rel="stylesheet">
<!-- Fontawesome font file css -->
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<!-- Template global css file. Requared all pages -->
<link rel="stylesheet" type="text/css" href="css/global.style.css">
<script>var block_aplayer = true;</script>
<script type="text/javascript" src="https://cdn.yimian.xyz/ushio-js/ushio-head.min.js"></script>
<script type="text/javascript">page.auth = ['email', 'nickname'];</script>
</head>
<body>
<div class="wrapper">
<div class="wrapper-inline">
<!-- Header area start -->
<header> <!-- extra class no-background -->
<a class="go-back-link" href="./"><i class="fa fa-arrow-left"></i></a>
<h1 class="page-title">设置公共账户信息</h1>
</header>
<!-- Header area end -->
<!-- Page content start -->
<main>
<div class="container">
<div class="form-divider"></div>
<p>请输入公共账户名字:</p>
<div class="form-row-group with-icons">
<div class="form-row no-padding">
<i class="fa "></i>
<input type="text" id="name" name="name" class="form-element" value="">
</div>
</div>
<br/>
<p>请输入触发阈值: (请使用整数,比如20磅)</p>
<div class="form-row-group with-icons">
<div class="form-row no-padding">
<i class="fa "></i>
<input type="number" id="threshold" name="threshold" class="form-element" placeholder="" value="20">
</div>
</div>
<div class="form-divider"></div>
<div class="form-row">
<a href="#" id="ok" class="button circle block orange">完成设置</a>
</div>
<br/><br/>
<div id="qr" align="center" style="display: none;">
<p>请让成员打开链接或扫描二维码加入账户:</p>
<input width="60%" type="text" id="url"><button id="copy">copy</button>
<div id="qrcode"></div>
</div>
</div>
</main>
<!-- Page content end -->
</div>
</div>
<!--Page loader DOM Elements. Requared all pages-->
<div class="sweet-loader">
<div class="box">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
</div>
</div>
<!-- JQuery library file. requared all pages -->
<script src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://cdn.yimian.xyz/ushio-js/ushio-footer.min.js"></script>
<!-- Template global script file. requared all pages -->
<script src="js/global.script.js"></script>
<script src="js/qrcode.min.js"></script>
<script type="text/javascript">
var qrcode = new QRCode("qrcode", {
text: '',
width: 150,
height: 150,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.M
});
try{
if(page.params.hasOwnProperty('tableId')){
if(cookie.get('cache')){
data = JSON.parse(decodeURIComponent(escape(atob(cookie.get('cache')))));
$('#name').val(data.name);
$('#threshold').val(data.threshold);
}
}
}catch(e){}
function checkInput(){
var n = $('#name').val();
var th = $('#threshold').val();
if(n.length < 3){
tips.warning({
message: '名称太短啦!'
});
return false;
}
if(n.length > 30){
tips.warning({
message: '名称太长啦!'
});
return false;
}
th = parseInt(th);
if(th <= 0){
tips.warning({
message: '请输入大于0整数!'
});
return false;
}
return true;
}
session.onload(function(){
if(page.params.hasOwnProperty('tableId')){
$.get('./api/getData.php?hash='+session.get('hash'), function(data){
data.forEach(function(item){
if(item.id == page.params.tableId){
$('#name').val(item.name);
$('#threshold').val(item.threshold);
}
});
});
$('#qr').show();
$('#url').val('https://cp-acc.yimian.xyz/?tableId='+page.params.tableId);
qrcode.makeCode('https://cp-acc.yimian.xyz/?tableId='+page.params.tableId);
$('#ok').click(function(){
if(!checkInput()) return;
$.get('./api/updateTable.php?tableId='+page.params.tableId+'&name='+$('#name').val() + "&threshold="+$('#threshold').val(), (res)=>{
tips.success({
message: '更新成功!'
});
});
});
}else{
$('#ok').click(function(){
if(!checkInput()) return;
$.get('./api/createTable.php?hash='+session.get('hash')+'&name='+$('#name').val() + "&threshold="+$('#threshold').val(), (res) => {
$('#qr').show();
qrcode.makeCode('https://cp-acc.yimian.xyz/?tableId='+res.tableId);
$('#url').val('https://cp-acc.yimian.xyz/?tableId='+res.tableId);
cookie.set('tableId', res.tableId);
delete window.localStorage[session.get('hash')];
});
});
}
});
window.Clipboard = (function(window, document, navigator) {
var textArea,
copy;
// 判断是不是ios端
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
//创建文本元素
function createTextArea(text) {
textArea = document.createElement('textArea');
textArea.value = text;
document.body.appendChild(textArea);
}
//选择内容
function selectText() {
var range,
selection;
if (isOS()) {
range = document.createRange();
range.selectNodeContents(textArea);
selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
textArea.setSelectionRange(0, 999999);
} else {
textArea.select();
}
}
//复制到剪贴板
function copyToClipboard() {
try{
if(document.execCommand("Copy")){
alert("链接复制成功!");
}else{
alert("复制失败!请手动复制!");
}
}catch(err){
alert("复制错误!请手动复制!")
}
document.body.removeChild(textArea);
}
copy = function(text) {
createTextArea(text);
selectText();
copyToClipboard();
};
return {
copy: copy
};
})(window, document, navigator);
$('#copy').click(function(){
Clipboard.copy($('#url').val());
});
</script>
</body>
</html>