1 | <article class="message is-info">
|
2 | <div class="message-header">
|
3 | 申请友链
|
4 | </div>
|
5 | <div class="message-body">
|
6 | <div class="form-ask-friend">
|
7 | <div class="field">
|
8 | <label class="label">名称</label>
|
9 | <div class="control has-icons-left">
|
10 | <input class="input" type="text" placeholder="您的站点名" id="friend-name" required>
|
11 | <span class="icon is-small is-left">
|
12 | <i class="fas fa-signature"></i>
|
13 | </span>
|
14 | </div>
|
15 | </div>
|
16 | <div class="field">
|
17 | <label class="label">链接</label>
|
18 | <div class="control has-icons-left">
|
19 | <input class="input" type="url" placeholder="您网站首页的链接" id="friend-link" required>
|
20 | <span class="icon is-small is-left">
|
21 | <i class="fas fa-link"></i>
|
22 | </span>
|
23 | </div>
|
24 | <p class="help ">请确保站点可访问!</p>
|
25 | </div>
|
26 | <div class="field">
|
27 | <label class="label">图标</label>
|
28 | <div class="control has-icons-left">
|
29 | <input class="input" type="url" placeholder="您的网站图标(尽量为正圆形)" id="friend-icon" required>
|
30 | <span class="icon is-small is-left">
|
31 | <i class="fas fa-image"></i>
|
32 | </span>
|
33 | </div>
|
34 | </div>
|
35 | <div class="field">
|
36 | <label class="label">描述</label>
|
37 | <div class="control has-icons-left">
|
38 | <input class="input" type="text" placeholder="请用一句话介绍您的站点" id="friend-des" required>
|
39 | <span class="icon is-small is-left">
|
40 | <i class="fas fa-info"></i>
|
41 | </span>
|
42 | </div>
|
43 | </div>
|
44 | <div class="field">
|
45 | <div class="control">
|
46 | <label class="checkbox">
|
47 | <input type="checkbox" id="friend-check"/> 我提交的不是无意义信息
|
48 | </label>
|
49 | </div>
|
50 | </div>
|
51 | <div class="field is-grouped">
|
52 | <div class="control">
|
53 | <button class="button is-info" type="submit" onclick="askFriend(event)">申请友链</button>
|
54 | </div>
|
55 | </div>
|
56 | </div>
|
57 | </div>
|
58 | </article>
|
59 | <script src="https://recaptcha.net/recaptcha/api.js?render=reCaptcha密钥"></script>
|
60 | <script>
|
61 | function TestUrl(url) {
|
62 | var Expression=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
|
63 | var objExp=new RegExp(Expression);
|
64 | if(objExp.test(url) != true){
|
65 | return false;
|
66 | }
|
67 | return true;
|
68 | }
|
69 | function askFriend (event) {
|
70 | let check = $("#friend-check").is(":checked");
|
71 | let name = $("#friend-name").val();
|
72 | let url = $("#friend-link").val();
|
73 | let image = $("#friend-icon").val();
|
74 | let des = $("#friend-des").val();
|
75 | if(!check){
|
76 | alert("请勾选\"我提交的不是无意义信息\"");
|
77 | return;
|
78 | }
|
79 | if(!(name&&url&&image&&des)){
|
80 | alert("信息填写不完整! ");
|
81 | return;
|
82 | }
|
83 | if (!(TestUrl(url))){
|
84 | alert("URL格式错误! 需要包含HTTP协议头! ");
|
85 | return;
|
86 | }
|
87 | if (!(TestUrl(image))){
|
88 | alert("图片URL格式错误! 需要包含HTTP协议头! ");
|
89 | return;
|
90 | }
|
91 | event.target.classList.add('is-loading');
|
92 | grecaptcha.ready(function() {
|
93 | grecaptcha.execute('reCaptcha密钥', {action: 'submit'}).then(function(token) {
|
94 | $.ajax({
|
95 | type: 'get',
|
96 | cache: false,
|
97 | url: url,
|
98 | dataType: "jsonp",
|
99 | async: false,
|
100 | processData: false,
|
101 |
|
102 | complete: function (data) {
|
103 | if(data.status==200){
|
104 | $.ajax({
|
105 | type: 'POST',
|
106 | dataType: "json",
|
107 | data: {
|
108 | "name": name,
|
109 | "url": url,
|
110 | "image": image,
|
111 | "description": des,
|
112 | "verify": token,
|
113 | },
|
114 | url: 'https://QEXO域名/pub/ask_friend/',
|
115 | success: function (data) {
|
116 | alert(data.msg);
|
117 | }
|
118 | });}
|
119 | else{
|
120 | alert("URL无法连通!");
|
121 | }
|
122 | event.target.classList.remove('is-loading');
|
123 | }
|
124 | });
|
125 | });
|
126 | });
|
127 | }
|
128 | </script>
|