微信链接生成器 - 快速生成微信链接
<div>
<h1>微信链接生成器</h1>
<form>
<label for="coder">课程代码:</label>
<input type="number" name="coder" id="coder" required>
<pre><code><label for="timer">增加时长(默认值即可):</label>
<input type="number" name="timer" id="timer" value="7">
<label for="date">指定时间:</label>
<input type="text" name="date" id="date" required>
<button type="button" onclick="getLink()">点击生成</button>
<label for="link">生成链接:</label>
<textarea name="link" id="link" cols="30" rows="10" readonly></textarea>
<button type="button" onclick="copyLink()">复制链接</button>
</code></pre>
</form>
<script>
const coder = document.getElementById('coder');
const timer = document.getElementById('timer');
const link = document.getElementById('link');
const date = document.getElementById('date');
<pre><code>function getLink() {
if (!coder.value || !timer.value || !date.value) {
alert('请输入所有字段');
return;
}
const timeStamp = Math.floor(new Date(date.value).getTime() / 1000) + timer.value * 3600;
const timeStampMinutes = Math.floor(timeStamp / 60) * 60;
const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23e1a7bd726c18b8&redirect_uri=http://www.jsscme.com/hyt/Home/qd.php?gid=${coder.value}-${timeStampMinutes}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
link.value = url;
}
function copyLink() {
link.select();
document.execCommand('Copy');
alert('复制成功!');
}
</code></pre>
</script>
</div>
原文地址: https://www.cveoy.top/t/topic/lHL1 著作权归作者所有。请勿转载和采集!