<h1>微信授权链接生成器</h1>
<p>输入课程代码、增加小时数和指定时间,点击“点击生成”按钮,即可生成微信授权链接。</p>
<form>
  <label for="coder">课程代码:</label>
  <input type="number" name="" id="coder" required><br/>
  <label for="timer">增加小时数:</label>
  <input type="number" name="" value="7" id="timer" required><br/>
  <label for="date">指定时间:</label>
  <input type="datetime-local" value="" name="" id="date" required><br/>
  <button type="button" onclick="getLink()">点击生成</button>
</form>
<br>
<label for="link">微信授权链接:</label>
<textarea name="" id="link" cols="30" rows="10" readonly></textarea><br/>
<button type="button" onclick="copyLink()">复制链接</button>
<script>
  const coder = document.getElementById('coder');
  const timer = document.getElementById('timer');
  const link = document.getElementById('link');
  const date = document.getElementById('date');
<p>function getLink(){
const dateValue = new Date(date.value.replace(/-/g, '/')); // 因为Safari和Firefox不支持以“-”分隔的日期格式,所以需要替换为“/”
const timeStamp = Math.floor(dateValue.getTime() / 1000) + timer.value * 3600;
const timeStampMinutes = Math.floor(timeStamp / 60) * 60;
const url = <code>https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23e1a7bd726c18b8&amp;redirect_uri=http://www.jsscme.com/hyt/Home/qd.php?gid=${coder.value}-${timeStampMinutes}&amp;response_type=code&amp;scope=snsapi_userinfo&amp;state=STATE#wechat_redirect</code>;
link.value = url;
}</p>
<p>function copyLink(){
link.select();
document.execCommand(&quot;Copy&quot;);
alert(&quot;复制成功!&quot;);
}
</script></p>
</body>
</html>
微信授权链接生成器 - 快速生成微信授权链接

原文地址: https://www.cveoy.top/t/topic/lHLX 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录