js生成网址短链接,js实现短网址生成代码教程如下:
输入网址
实现结果:转换成缩短网址
js实现代码如下:
/**
* @act dwzurl
* @version 1.0
* @author youngxj
* @date 2018-03-24
* @url http://www.youngxj.cn
*/
var cache=getCookie('cache_url');
$('#form-control').val(cache);
control('璇疯緭鍏ョ綉鍧€锛�');
$('#btn_state').click(function () {
act();
});
function act(){
var val = $('input:radio:checked').val();
if($('.form-control').val()==''){
layer.msg('鍐呭娌℃湁濉啓瀹屾暣锛�');
$('.form-controls').hide();
return false;
}
console.log(val);
if (val=='dwzurl') {
dwzurl();
}else if(val=='dwzqrcode'){
dwzqrcode();
}else if(val=='sinadwz'){
sinadwz();
}else if(val=='sinalong'){
sinalong();
}else if(val=='eps_gs_un'){
eps_gs_un();
}else if(val=='eps_gs'){
eps_gs();
}else{
layer.msg('鎰忓鐨勯敊璇紒');
}
layer.msg('绋嶇瓑鈥︹€�');
}
function dwzurl(){
if ($('.form-control').val() == "") {layer.alert('浣犳槸涓嶆槸蹇樿濉唴瀹逛簡锛�');return false;}
$.getJSON("https://api.yum6.cn/url.php?url="+$('.form-control').val(),function(data){
if (data.code=="1") {
setCookie('cache_url',$('.form-control').val(),365);
$(".form-contr