Commit 8d257cbb authored by liyadong's avatar liyadong

update

parent 2f57c012
This diff is collapsed.
...@@ -456,8 +456,8 @@ ...@@ -456,8 +456,8 @@
} }
#file { #file {
.pa(); .pa();
left: 1.5rem; left: 0;
top: 2rem; top: 0;
width: 7.6rem; width: 7.6rem;
height: 4.2rem; height: 4.2rem;
background: none; background: none;
...@@ -679,6 +679,130 @@ ...@@ -679,6 +679,130 @@
} }
} }
// message
.toast-item-wrapper {
min-width: auto;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
padding: .2rem;
box-sizing: border-box;
font-size: .4rem;
color: #343434;
overflow: hidden;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
background: #fff;
&.toast-top-left {
left: 20px;
top: 20px;
}
&.toast-top-right {
right: 20px;
top: 20px;
}
&.toast-top-center {
margin: 0 auto;
top: 40%;
}
&.toast-bottom-left {
left: 20px;
bottom: 20px;
}
&.toast-bottom-right {
right: 20px;
bottom: 20px;
}
&.toast-bottom-center {
margin: 0 auto;
bottom: 20%;
}
p {
margin: 0
}
.toast-message {
font-size: 0.4rem;
color: #343434;
svg {
display: inline-block;
vertical-align: middle;
margin-right: .1rem;
}
}
.success {
.toast-message {
svg {
color: #0E9A00;
}
}
}
.error {
.toast-message {
svg {
color: #f00;
}
}
}
}
.message-container {
box-sizing: border-box;
margin: 0;
padding: 0;
color: rgba(0, 0, 0, .65);
font-size: .4rem;
font-variant: tabular-nums;
line-height: 1.5;
list-style: none;
font-feature-settings: "tnum";
position: fixed;
top: 40%;
left: 0;
z-index: 1010;
width: 100%;
pointer-events: none;
text-align: center;
.transition();
@successColor: #52c41a;
.message-content {
display: inline-block;
padding: .25rem .35rem;
background: #fff;
border-radius: 4px;
box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
pointer-events: all;
i {
vertical-align: middle;
margin-right: .1rem;
}
&.success {
i {
color: @successColor;
}
}
}
}
@keyframes Rotate { @keyframes Rotate {
0% { 0% {
transform: rotate(0); transform: rotate(0);
......
...@@ -4,6 +4,18 @@ var card = { ...@@ -4,6 +4,18 @@ var card = {
bindInfo:{}, bindInfo:{},
bindFlag : true bindFlag : true
}; };
card.showToast = function (params) {
$.Toast("", params.msg, params.type ? params.type : 'warn', {
stack: true,
has_icon: false,
has_close_btn: false,
fullscreen: false,
timeout: 2000,
sticky: false,
has_progress: false,
rtl: false,
});
}
card.ajax = function (data, callback) { card.ajax = function (data, callback) {
data.data['_token'] = $('meta[name="token"]').attr("value"); data.data['_token'] = $('meta[name="token"]').attr("value");
$.ajax({ $.ajax({
...@@ -14,9 +26,13 @@ card.ajax = function (data, callback) { ...@@ -14,9 +26,13 @@ card.ajax = function (data, callback) {
error: function (err) { error: function (err) {
try{ try{
var error = err.responseText; var error = err.responseText;
alert(error.message) card.showToast({
msg:error.message
})
}catch (e) { }catch (e) {
alert('系统开小差~~') card.showToast({
msg:'系统开小差~~'
})
} }
}, },
success: function (res) { success: function (res) {
...@@ -59,7 +75,9 @@ card.handleGetRoleList = function (params){ ...@@ -59,7 +75,9 @@ card.handleGetRoleList = function (params){
data:params data:params
},function (res){ },function (res){
if(res.error == 80001){ if(res.error == 80001){
alert(res.message); card.showToast({
msg:res.message
})
return false; return false;
} }
var data = res.data, var data = res.data,
...@@ -98,9 +116,12 @@ card.bindRole = function (params){ ...@@ -98,9 +116,12 @@ card.bindRole = function (params){
},function (res){ },function (res){
if(res.error === 0){ if(res.error === 0){
$('.dialog').hide(); $('.dialog').hide();
$('.role-select').html('');
location.href='/card/html?roleId='+params.roleId+'&serverId='+params.serverId; location.href='/card/html?roleId='+params.roleId+'&serverId='+params.serverId;
}else{ }else{
alert(res.message) card.showToast({
msg:res.message
})
} }
}) })
} }
...@@ -120,10 +141,14 @@ $(function (){ ...@@ -120,10 +141,14 @@ $(function (){
roleId = $('.role-select option:selected').val(); roleId = $('.role-select option:selected').val();
roleName = $('.role-select option:selected').text(); roleName = $('.role-select option:selected').text();
if(!serverId || serverId == '-1'){ if(!serverId || serverId == '-1'){
alert('请选择服务器') card.showToast({
msg:'请选择服务器'
})
return false; return false;
}else if(!roleId || roleId == '-1'){ }else if(!roleId || roleId == '-1'){
alert('请选择角色') card.showToast({
msg:'请选择角色'
})
return false; return false;
} }
var params = { var params = {
...@@ -147,4 +172,49 @@ $(function (){ ...@@ -147,4 +172,49 @@ $(function (){
} }
initRoleList(serverId); initRoleList(serverId);
}); });
$('.close').click(function (){
$('select').html('');
$('.dialog').fadeOut();
});
$('.btn-start').click(function (){
card.handleGetServer();
});
function baseImageUrl() {
setTimeout(function () {
html2canvas(document.querySelector("#test"), { //关键在于new
removeContainer: true,
allowTaint: false,
width: window.screen.availWidth,
windowWidth: document.body.scrollWidth,
x: 0,
y: 0,
useCORS: true,
logging:true
}).then(canvas => {
var image = canvas.toDataURL('image/jpeg', 1.0);
var img = '<img src="' + image + '">';
$('.dialog-img-content .img-scroll').html(img);
$('.dialog-img').show();
$('.loading').hide();
});
$('.postcard-container').addClass('fixed');
}, 2000)
}
$('.btn-save').click(function () {
var height = $('.postcard-container').height();
$('.postcard-container').height(height);
$('.loading').show();
$('.btn-save,.btn-share,.login-info').hide();
$('html,body').animate({
scrollTop: 0
}, 0);
baseImageUrl();
$('.postcard-container').addClass('fixed');
});
$('.dialog-img,.share-img').click(function () {
$(this).fadeOut();
$('.btn-save,.btn-share,.login-info').show();
$('.postcard-container').removeClass('fixed');
});
}) })
\ No newline at end of file
var card={relationRole:{},clickFlag:!0,bindInfo:{},bindFlag:!0};card.ajax=function(e,a){e.data._token=$('meta[name="token"]').attr("value"),$.ajax({type:e.type?e.type:"GET",url:location.origin+e.url,dataType:"json",data:e.data,error:function(e){try{var a=e.responseText;alert(a.message)}catch(e){alert("系统开小差~~")}},success:function(e){return 1019==e.error?(location.href="/login",!1):4003==e.error?(location.href="/bind/ald/code",!1):void a(e)}}),setTimeout(function(){card.clickFlag=!0},1e3)},card.handleGetServer=function(e){$(".loading").show(),this.ajax({url:"/ald_bind_info",type:"get",data:{}},function(e){card.bindInfo=e.data;var a={serverId:e.data.serverId,userId:e.data.userId};card.handleGetRoleList(a)})},card.handleGetRoleList=function(e){this.ajax({url:"/get_role_list",type:"POST",data:e},function(e){if(80001==e.error)return alert(e.message),!1;var a=e.data,r="",t=[];card.relationRole=a;for(var n in a)t.push({id:n,name:a[n].name});r='<option value="-1">请选择</option>',$(t).each(function(e,a){var t="";t=a.name.indexOf("非硬核-")>-1?a.name.replace("非硬核-",""):a.name.indexOf("硬核-")>-1?a.name.replace("硬核-",""):a.name.indexOf("越狱-")>-1?a.name.replace("越狱-",""):a.name,r+='<option value="'+a.id+'">'+t+"</option>"}),$(".server-select").html(r),$(".loading").hide(),$(".dialog-server").fadeIn()})},card.bindRole=function(e){card.bindFlag=!1,this.ajax({url:"/bind/ald/role",type:"POST",data:e},function(a){0===a.error?($(".dialog").hide(),location.href="/card/html?roleId="+e.roleId+"&serverId="+e.serverId):alert(a.message)})};var initRoleList=function(e){var a=card.relationRole[e].list,r='<option value="-1">请选择</option>';$(a).each(function(e,a){r+='<option value="'+a.roleId+'">'+a.roleName+"</option>"}),$(".role-select").html(r)};$(function(){$(".btn-card-bind-role").click(function(){var e=$(".server-select option:selected").val(),a=$(".server-select option:selected").text(),r=$(".role-select option:selected").val();if(roleName=$(".role-select option:selected").text(),!e||"-1"==e)return alert("请选择服务器"),!1;if(!r||"-1"==r)return alert("请选择角色"),!1;var t={roleId:r,serverId:e,serverName:a,roleName:roleName};card.bindFlag&&(setTimeout(function(){card.bindFlag=!0},3e3),card.bindRole(t))}),$(".server-select").change(function(){var e=$(this).val();if(-1==e)return $(".role-select").html(""),!1;initRoleList(e)})}); var card={relationRole:{},clickFlag:!0,bindInfo:{},bindFlag:!0};card.showToast=function(e){$.Toast("",e.msg,e.type?e.type:"warn",{stack:!0,has_icon:!1,has_close_btn:!1,fullscreen:!1,timeout:2e3,sticky:!1,has_progress:!1,rtl:!1})},card.ajax=function(e,a){e.data._token=$('meta[name="token"]').attr("value"),$.ajax({type:e.type?e.type:"GET",url:location.origin+e.url,dataType:"json",data:e.data,error:function(e){try{var a=e.responseText;card.showToast({msg:a.message})}catch(e){card.showToast({msg:"系统开小差~~"})}},success:function(e){return 1019==e.error?(location.href="/login",!1):4003==e.error?(location.href="/bind/ald/code",!1):void a(e)}}),setTimeout(function(){card.clickFlag=!0},1e3)},card.handleGetServer=function(e){$(".loading").show(),this.ajax({url:"/ald_bind_info",type:"get",data:{}},function(e){card.bindInfo=e.data;var a={serverId:e.data.serverId,userId:e.data.userId};card.handleGetRoleList(a)})},card.handleGetRoleList=function(e){this.ajax({url:"/get_role_list",type:"POST",data:e},function(e){if(80001==e.error)return card.showToast({msg:e.message}),!1;var a=e.data,t="",o=[];card.relationRole=a;for(var n in a)o.push({id:n,name:a[n].name});t='<option value="-1">请选择</option>',$(o).each(function(e,a){var o="";o=a.name.indexOf("非硬核-")>-1?a.name.replace("非硬核-",""):a.name.indexOf("硬核-")>-1?a.name.replace("硬核-",""):a.name.indexOf("越狱-")>-1?a.name.replace("越狱-",""):a.name,t+='<option value="'+a.id+'">'+o+"</option>"}),$(".server-select").html(t),$(".loading").hide(),$(".dialog-server").fadeIn()})},card.bindRole=function(e){card.bindFlag=!1,this.ajax({url:"/bind/ald/role",type:"POST",data:e},function(a){0===a.error?($(".dialog").hide(),$(".role-select").html(""),location.href="/card/html?roleId="+e.roleId+"&serverId="+e.serverId):card.showToast({msg:a.message})})};var initRoleList=function(e){var a=card.relationRole[e].list,t='<option value="-1">请选择</option>';$(a).each(function(e,a){t+='<option value="'+a.roleId+'">'+a.roleName+"</option>"}),$(".role-select").html(t)};$(function(){$(".btn-card-bind-role").click(function(){var e=$(".server-select option:selected").val(),a=$(".server-select option:selected").text(),t=$(".role-select option:selected").val();if(roleName=$(".role-select option:selected").text(),!e||"-1"==e)return card.showToast({msg:"请选择服务器"}),!1;if(!t||"-1"==t)return card.showToast({msg:"请选择角色"}),!1;var o={roleId:t,serverId:e,serverName:a,roleName:roleName};card.bindFlag&&(setTimeout(function(){card.bindFlag=!0},3e3),card.bindRole(o))}),$(".server-select").change(function(){var e=$(this).val();if(-1==e)return $(".role-select").html(""),!1;initRoleList(e)}),$(".close").click(function(){$("select").html(""),$(".dialog").fadeOut()}),$(".btn-start").click(function(){card.handleGetServer()}),$(".btn-save").click(function(){var e=$(".postcard-container").height();$(".postcard-container").height(e),$(".loading").show(),$(".btn-save,.btn-share,.login-info").hide(),$("html,body").animate({scrollTop:0},0),setTimeout(function(){html2canvas(document.querySelector("#test"),{removeContainer:!0,allowTaint:!1,width:window.screen.availWidth,windowWidth:document.body.scrollWidth,x:0,y:0,useCORS:!0,logging:!0}).then(e=>{var a='<img src="'+e.toDataURL("image/jpeg",1)+'">';$(".dialog-img-content .img-scroll").html(a),$(".dialog-img").show(),$(".loading").hide()}),$(".postcard-container").addClass("fixed")},2e3),$(".postcard-container").addClass("fixed")}),$(".dialog-img,.share-img").click(function(){$(this).fadeOut(),$(".btn-save,.btn-share,.login-info").show(),$(".postcard-container").removeClass("fixed")})});
\ No newline at end of file \ No newline at end of file
...@@ -19,13 +19,12 @@ ...@@ -19,13 +19,12 @@
window.onresize = function () { window.onresize = function () {
reSizeRem(); reSizeRem();
} }
window.onerror = function (e) {
alert(e)
}
</script> </script>
<link rel="stylesheet" href="{{ asset('postcard/css/style.css?v=20210607') }}"> <link rel="stylesheet" href="{{ asset('postcard/css/style.css?v=20210607') }}">
<script src="{{ asset('js/jquery.2.1.3.min.js') }}"></script> <script src="{{ asset('js/jquery.2.1.3.min.js') }}"></script>
<script src="{{ asset('postcard/js/html2canvas.js') }}"></script> <script src="{{ asset('postcard/js/html2canvas.js') }}"></script>
<script src="{{ asset('js/toast.js') }}"></script>
<script src="{{ asset('postcard/js/main.js?v=20210607') }}"></script>
</head> </head>
<body> <body>
<div class="container postcard-container" id="test"> <div class="container postcard-container" id="test">
...@@ -131,11 +130,11 @@ ...@@ -131,11 +130,11 @@
<div class="ggsk-container"> <div class="ggsk-container">
<div class="img-container"> <div class="img-container">
@if($userImgStatus == -1) <img src="{{ asset('postcard/images/img_add.jpg') }}" class="img img-add" alt=""> @if($userImgStatus == -1) <img src="{{ asset('postcard/images/img_add.jpg') }}" class="img img-add" alt="">
<input type="file" id="file" accept="image/jpg, image/jpeg, image/png"> @endif <input type="file" id="file" accept="image/*" multiple> @endif
@if($userImgStatus == 0) <img src="{{ asset('postcard/images/img_sh.jpg') }}" class="img img-sh" alt=""> @endif @if($userImgStatus == 0) <img src="{{ asset('postcard/images/img_sh.jpg') }}" class="img img-sh" alt=""> @endif
@if($userImgStatus == 1) <img src="{{ $userImg }}" class="img img-sh" alt=""> @endif @if($userImgStatus == 1) <img src="{{ $userImg }}" class="img img-sh" alt=""> @endif
@if($userImgStatus == 2) <img src="{{ asset('postcard/images/sh_fail.jpg') }}" class="img img-sh" alt=""> @if($userImgStatus == 2) <img src="{{ asset('postcard/images/sh_fail.jpg') }}" class="img img-sh" alt="">
<input type="file" id="file" accept="image/jpg, image/jpeg, image/png"> @endif <input type="file" id="file" accept="image/*" multiple> @endif
</div> </div>
@if($userImgStatus != 1) @if($userImgStatus != 1)
<span>建议尺寸(710*414px)jpg,jpeg,png</span> <span>建议尺寸(710*414px)jpg,jpeg,png</span>
...@@ -169,7 +168,6 @@ ...@@ -169,7 +168,6 @@
</div> </div>
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script> <script>
$(function () { $(function () {
var isWeixin = function () { var isWeixin = function () {
//判断是否是微信 //判断是否是微信
...@@ -212,17 +210,22 @@ ...@@ -212,17 +210,22 @@
try{ try{
// //文件类型判断 // //文件类型判断
if (file && file.type && !acceptFileTypes.test(file.type)) { if (file && file.type && !acceptFileTypes.test(file.type)) {
alert('请上传jpg、jpeg或png格式的文件'); card.showToast({
msg: '请上传jpg、jpeg或png格式的文件'
});
return false; return false;
} }
//文件大小判断 //文件大小判断
if (file && file.size > (2 * 1024 * 1024)) { if (file && file.size > (2 * 1024 * 1024)) {
alert('请上传不超过2M的文件'); card.showToast({
msg: '请上传不超过2M的文件'
});
return false; return false;
} }
}catch (e) { }catch (e) {
console.log(e) console.log(e)
} }
formData.append("imgFile", file); formData.append("imgFile", file);
formData.append("roleId", roleId); formData.append("roleId", roleId);
formData.append("serverId", serverId); formData.append("serverId", serverId);
...@@ -235,62 +238,24 @@ ...@@ -235,62 +238,24 @@
processData: false, processData: false,
contentType: false, contentType: false,
dataType: "json", dataType: "json",
success: function (data) { success: function (res) {
if(res.error != 0){
card.showToast({
msg: res.message
});
return false;
}
$('.img-add').hide(); $('.img-add').hide();
$('.img-container').html('<img src="{{ asset('postcard/images/img_sh.jpg') }}" class="img img-sh" alt="">'); $('.img-container').html('<img src="{{ asset('postcard/images/img_sh.jpg') }}" class="img img-sh" alt="">');
}, },
error: function (data) { error: function (data) {
card.showToast({
} msg: '系统错误'
});
});
function baseImageUrl() {
setTimeout(function () {
html2canvas(document.querySelector("#test"), { //关键在于new
removeContainer: true,
allowTaint: false,
width: window.screen.availWidth,
windowWidth: document.body.scrollWidth,
x: 0,
y: 0,
useCORS: true,
logging:true
}).then(canvas => {
var image = canvas.toDataURL('image/jpeg', 1.0);
var img = '<img src="' + image + '">';
$('.dialog-img-content .img-scroll').html(img);
$('.dialog-img').show();
$('.loading').hide();
}); });
$('.postcard-container').addClass('fixed');
}, 2000)
} }
$('.btn-save').click(function () {
var height = $('.postcard-container').height();
$('.postcard-container').height(height);
$('.loading').show();
$('.btn-save,.btn-share,.login-info').hide();
$('html,body').animate({
scrollTop: 0
}, 0);
baseImageUrl();
$('.postcard-container').addClass('fixed');
});
$('.dialog-img,.share-img').click(function () {
$(this).fadeOut();
$('.btn-save,.btn-share,.login-info').show();
$('.postcard-container').removeClass('fixed');
}); });
$('.btn-share').click(function () {
if(isWeixin()){
$('.share-img').show();
}
}); });
function _wechatConfig(o) { function _wechatConfig(o) {
wx.config({ wx.config({
...@@ -368,6 +333,11 @@ ...@@ -368,6 +333,11 @@
wx.error(function (res) { wx.error(function (res) {
console.log(res); console.log(res);
}); });
$('.btn-share').click(function () {
if(isWeixin()){
$('.share-img').show();
}
});
}); });
</script> </script>
</body> </body>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
</script> </script>
<link rel="stylesheet" href="{{ asset('postcard/css/style.css?v=20210607') }}"> <link rel="stylesheet" href="{{ asset('postcard/css/style.css?v=20210607') }}">
<script src="{{ asset('js/jquery.2.1.3.min.js') }}"></script> <script src="{{ asset('js/jquery.2.1.3.min.js') }}"></script>
<script src="{{ asset('js/toast.js') }}"></script>
<script src="{{ asset('postcard/js/main.js?v=20210607') }}"></script> <script src="{{ asset('postcard/js/main.js?v=20210607') }}"></script>
</head> </head>
<body> <body>
...@@ -63,20 +64,12 @@ ...@@ -63,20 +64,12 @@
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script> <script>
$(function(){ $(function(){
$('.close').click(function (){
$('select').html('');
$('.dialog').fadeOut();
});
$('.btn-start').click(function (){
card.handleGetServer();
});
var isWeixin = function () { var isWeixin = function () {
//判断是否是微信 //判断是否是微信
var ua = navigator.userAgent.toLowerCase(); var ua = navigator.userAgent.toLowerCase();
return ua.match(/MicroMessenger/i) == "micromessenger"; return ua.match(/MicroMessenger/i) == "micromessenger";
}; };
function _wechatConfig(o) { function _wechatConfig(o) {
wx.config({ wx.config({
debug: false, debug: false,
appId: o.appId, appId: o.appId,
...@@ -100,17 +93,14 @@ ...@@ -100,17 +93,14 @@
} }
}); });
} }
if (isWeixin()) { if (isWeixin()) {
_getWechatJsSdkInfo(_wechatConfig); _getWechatJsSdkInfo(_wechatConfig);
} }
wx.checkJsApi({ wx.checkJsApi({
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'], jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'],
success: function (res) { success: function (res) {
} }
}); });
function wx_share(title, link, imgurl, desc) { function wx_share(title, link, imgurl, desc) {
//朋友圈 //朋友圈
wx.onMenuShareTimeline({ wx.onMenuShareTimeline({
...@@ -148,7 +138,6 @@ ...@@ -148,7 +138,6 @@
desc = "阿拉德之怒-明信片"; desc = "阿拉德之怒-明信片";
wx_share(title,link,img,desc); wx_share(title,link,img,desc);
}); });
wx.error(function (res) { wx.error(function (res) {
console.log(res); console.log(res);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment