filesite
1 year ago
5 changed files with 66 additions and 3 deletions
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
<form action="" method="post" class="px-2"> |
||||
<input type="text" name="share_content" value="" placeholder="请粘贴分享网址/内容" class="form-controll txt-input"> |
||||
<select name="tag" class="form-controll"> |
||||
<option value="">选分类</option> |
||||
<?php |
||||
if (!empty($viewData['tags'])) { //显示tags分类 |
||||
foreach($viewData['tags'] as $id => $item) { |
||||
echo <<<eof |
||||
<option value="{$item['name']}">{$item['name']}</option> |
||||
eof; |
||||
} |
||||
} |
||||
?> |
||||
</select> |
||||
<button class="btn" type="button" id="btn_addfav">保存</button> |
||||
</form> |
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
/* for theme TaJian */ |
||||
(function() { |
||||
|
||||
$('#btn_addfav').click(function(e) { |
||||
var share_content = $('input[name=share_content]').val(), |
||||
select_tag = $('select[name=tag]').val(); |
||||
if (!share_content) { |
||||
alert('请填写分享内容或网址!'); |
||||
return false; |
||||
}else if (/https:\/\/[\w\.]+\/[\w]+/ig.test(share_content) == false) { |
||||
alert('目前只支持抖音、快手、西瓜视频和Bilibili的分享网址哦!'); |
||||
return false; |
||||
} |
||||
|
||||
var btn = this; |
||||
$(btn).prop('disabled', true); |
||||
|
||||
var postData = {content: share_content}; |
||||
if (select_tag) { |
||||
postData.tag = select_tag; |
||||
} |
||||
|
||||
$.ajax({ |
||||
url: '/api/addfav', |
||||
method: 'POST', |
||||
dataType: 'JSON', |
||||
data: postData |
||||
}).done(function(data, textStatus, jqXHR) { |
||||
$(btn).prop('disabled', false); |
||||
|
||||
if (data.code == 1) { |
||||
alert(data.msg || data.err); |
||||
}else { |
||||
alert('保存失败,请稍后重试!'); |
||||
} |
||||
}).fail(function(jqXHR, textStatus, errorThrown) { |
||||
$(btn).props('disabled', false); |
||||
alert('服务器异常了:' + errorThrown); |
||||
}); |
||||
}); |
||||
|
||||
})(); |
Loading…
Reference in new issue