[更新]整理模板代码

This commit is contained in:
Anyon 2017-05-08 15:22:05 +08:00
parent 09b6a6c32b
commit 6b928b146d
30 changed files with 265 additions and 533 deletions

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="content"} {block name="content"}
@ -39,21 +39,14 @@
callback: { callback: {
beforeClick: function (treeId, treeNode) { beforeClick: function (treeId, treeNode) {
if (treeNode.children.length < 1) { if (treeNode.children.length < 1) {
window.roleForm.ztree.checkNode(treeNode, !treeNode.checked, null, true); window.roleForm.ztree.checkNode(treeNode, !treeNode.checked, null, true);} else {
} else { window.roleForm.ztree.expandNode(treeNode);}
window.roleForm.ztree.expandNode(treeNode); return false;}}};
} this.listen();}
return false;
}
}
};
this.listen();
}
showTree.prototype = { showTree.prototype = {
constructor: showTree, constructor: showTree,
listen: function () { listen: function () {
this.getData(this); this.getData(this);},
},
getData: function (self) { getData: function (self) {
$.msg.loading(); $.msg.loading();
jQuery.get('{:url()}?id={$vo.id}', {action: 'getNode'}, function (ret) { jQuery.get('{:url()}?id={$vo.id}', {action: 'getNode'}, function (ret) {
@ -67,42 +60,28 @@
children.name = data[i].title || data[i].node; children.name = data[i].title || data[i].node;
children.checked = data[i].checked || false; children.checked = data[i].checked || false;
children.children = renderChildren(data[i]._sub_, level + 1); children.children = renderChildren(data[i]._sub_, level + 1);
childrenData.push(children); childrenData.push(children);}
} return childrenData;}
return childrenData;
}
self.data = renderChildren(ret.data, 1); self.data = renderChildren(ret.data, 1);
self.showTree(); self.showTree();}, 'JSON');},
}, 'JSON');
},
showTree: function () { showTree: function () {
this.ztree = jQuery.fn.zTree.init(jQuery("#zTree"), this.setting, this.data); this.ztree = jQuery.fn.zTree.init(jQuery("#zTree"), this.setting, this.data);
while (true) { while (true) {
var reNodes = this.ztree.getNodesByFilter(function (node) { var reNodes = this.ztree.getNodesByFilter(function (node) {
return (!node.node && node.children.length < 1); return (!node.node && node.children.length < 1);});
});
if (reNodes.length < 1) { if (reNodes.length < 1) {
break; break;}
}
for (var i in reNodes) { for (var i in reNodes) {
this.ztree.removeNode(reNodes[i]); this.ztree.removeNode(reNodes[i]);}}},
}
}
},
submit: function () { submit: function () {
var nodes = []; var nodes = [];
var data = this.ztree.getCheckedNodes(true); var data = this.ztree.getCheckedNodes(true);
for (var i in data) { for (var i in data) {
(data[i].node) && nodes.push(data[i].node); (data[i].node) && nodes.push(data[i].node);}
} $.form.load('{:url()}?id={$vo.id}&action=save', {nodes: nodes}, 'POST');}};
$.form.load('{:url()}?id={$vo.id}&action=save', {nodes: nodes}, 'POST');
}
};
window.roleForm = new showTree(); window.roleForm = new showTree();
$('[data-submit-role]').on('click', function () { $('[data-submit-role]').on('click', function () {
window.roleForm.submit(); window.roleForm.submit();});});
});
});
</script> </script>
{/block} {/block}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
<div class="nowrap pull-right" style="margin-top:10px"> <div class="nowrap pull-right" style="margin-top:10px">

View File

@ -11,7 +11,7 @@
{if sysconf('storage_type')!=='qiniu'} {if sysconf('storage_type')!=='qiniu'}
<option selected value='local'>本地服务器</option> <option selected value='local'>本地服务器</option>
<option value='qiniu'>七牛云存储</option> <option value='qiniu'>七牛云存储</option>
{else/} {else}
<option value='local'>本地服务器</option> <option value='local'>本地服务器</option>
<option selected value='qiniu'>七牛云存储</option> <option selected value='qiniu'>七牛云存储</option>
{/if} {/if}
@ -30,24 +30,24 @@
<label class="col-sm-2 control-label">Region <span class="nowrap">(存储区域)</span></label> <label class="col-sm-2 control-label">Region <span class="nowrap">(存储区域)</span></label>
<div class='col-sm-8'> <div class='col-sm-8'>
<select class="layui-input" name="storage_qiniu_region" required="required"> <select class="layui-input" name="storage_qiniu_region" required="required">
{if sysconf('storage_qiniu_region') eq '华东' } {if sysconf('storage_qiniu_region') eq '华东'}
<option selected value='华东'>华东</option> <option selected value='华东'>华东</option>
{else/} {else}
<option value='华东'>华东</option> <option value='华东'>华东</option>
{/if} {/if}
{if sysconf('storage_qiniu_region') eq '华北' } {if sysconf('storage_qiniu_region') eq '华北'}
<option selected value='华北'>华北</option> <option selected value='华北'>华北</option>
{else/} {else}
<option value='华北'>华北</option> <option value='华北'>华北</option>
{/if} {/if}
{if sysconf('storage_qiniu_region') eq '华南' } {if sysconf('storage_qiniu_region') eq '华南'}
<option selected value='华南'>华南</option> <option selected value='华南'>华南</option>
{else/} {else}
<option value='华南'>华南</option> <option value='华南'>华南</option>
{/if} {/if}
{if sysconf('storage_qiniu_region') eq '北美' } {if sysconf('storage_qiniu_region') eq '北美'}
<option selected value='北美'>北美</option> <option selected value='北美'>北美</option>
{else/} {else}
<option value='北美'>北美</option> <option value='北美'>北美</option>
{/if} {/if}
</select> </select>
@ -62,7 +62,7 @@
{if sysconf('storage_qiniu_is_https')!=='1'} {if sysconf('storage_qiniu_is_https')!=='1'}
<option selected value='0'>HTTP</option> <option selected value='0'>HTTP</option>
<option value='1'>HTTPS</option> <option value='1'>HTTPS</option>
{else/} {else}
<option value='0'>HTTP</option> <option value='0'>HTTP</option>
<option selected value='1'>HTTPS</option> <option selected value='1'>HTTPS</option>
{/if} {/if}
@ -127,8 +127,6 @@
<script> <script>
$(function () { $(function () {
$('[name="storage_type"]').on('change', function () { $('[name="storage_type"]').on('change', function () {
$("[data-storage-type]").not($("[data-storage-type='" + $(this).val() + "']").show()).hide(); $("[data-storage-type]").not($("[data-storage-type='" + $(this).val() + "']").show()).hide();}).trigger('change');});
}).trigger('change');
});
</script> </script>
{/block} {/block}

View File

@ -1,4 +1,4 @@
{extend name="extra@admin/main" /} {extend name="extra@admin/main"}
{block name='body'} {block name='body'}
{include file="extra@admin/main/top"} {include file="extra@admin/main/top"}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="content"} {block name="content"}
<div class="row"> <div class="row">

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
<div class="nowrap pull-right" style="margin-top:10px"> <div class="nowrap pull-right" style="margin-top:10px">

View File

@ -87,16 +87,12 @@
{block name="script"} {block name="script"}
<script> <script>
if (window.location.href.indexOf('#') > -1) { if (window.location.href.indexOf('#') > -1) {
window.location.href = window.location.href.split('#')[0]; window.location.href = window.location.href.split('#')[0];}
}
require(['jquery'], function ($) { require(['jquery'], function ($) {
$('[name="password"]').on('focus', function () { $('[name="password"]').on('focus', function () {
$('#left-hander').removeClass('initial_left_hand').addClass('left_hand'); $('#left-hander').removeClass('initial_left_hand').addClass('left_hand');
$('#right-hander').removeClass('initial_right_hand').addClass('right_hand') $('#right-hander').removeClass('initial_right_hand').addClass('right_hand')}).on('blur', function () {
}).on('blur', function () {
$('#left-hander').addClass('initial_left_hand').removeClass('left_hand'); $('#left-hander').addClass('initial_left_hand').removeClass('left_hand');
$('#right-hander').addClass('initial_right_hand').removeClass('right_hand') $('#right-hander').addClass('initial_right_hand').removeClass('right_hand')});});
});
});
</script> </script>
{/block} {/block}

View File

@ -6,7 +6,7 @@
<!--{foreach $menus as $menu}--> <!--{foreach $menus as $menu}-->
<!--{eq name='menu.id' value='$vo.pid|default=0'}--> <!--{eq name='menu.id' value='$vo.pid|default=0'}-->
<option selected value='{$menu.id}'>{$menu.spl}{$menu.title}</option> <option selected value='{$menu.id}'>{$menu.spl}{$menu.title}</option>
<!--{else/}--> <!--{else}-->
<option value='{$menu.id}'>{$menu.spl}{$menu.title}</option> <option value='{$menu.id}'>{$menu.spl}{$menu.title}</option>
<!--{/eq}--> <!--{/eq}-->
<!--{/foreach}--> <!--{/foreach}-->
@ -44,7 +44,6 @@
<script> <script>
require(['bootstrap.typeahead'], function () { require(['bootstrap.typeahead'], function () {
var subjects = JSON.parse('{$nodes|json_encode}'); var subjects = JSON.parse('{$nodes|json_encode}');
$('.typeahead').typeahead({source: subjects, items: 5}); $('.typeahead').typeahead({source: subjects, items: 5});});
});
</script> </script>
</form> </form>

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
<div class="nowrap pull-right" style="margin-top:10px"> <div class="nowrap pull-right" style="margin-top:10px">

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="content"} {block name="content"}
<table class="table table-hover"> <table class="table table-hover">
@ -26,7 +26,7 @@
{if substr_count($vo['node'],'/')==2} {if substr_count($vo['node'],'/')==2}
{notempty name='vo.is_auth'} {notempty name='vo.is_auth'}
<input name='is_auth.{$vo.node}' checked='checked' class="check-box" type='checkbox' value='1'/> <input name='is_auth.{$vo.node}' checked='checked' class="check-box" type='checkbox' value='1'/>
{else /} {else}
<input name='is_auth.{$vo.node}' class="check-box" type='checkbox' value='1'/> <input name='is_auth.{$vo.node}' class="check-box" type='checkbox' value='1'/>
{/notempty} {/notempty}
加入权限控制 加入权限控制
@ -37,7 +37,7 @@
{if substr_count($vo['node'],'/')==2} {if substr_count($vo['node'],'/')==2}
{notempty name='vo.is_menu'} {notempty name='vo.is_menu'}
<input name='is_menu.{$vo.node}' checked='checked' class='check-box' type='checkbox' value='1'/> <input name='is_menu.{$vo.node}' checked='checked' class='check-box' type='checkbox' value='1'/>
{else/} {else}
<input name='is_menu.{$vo.node}' class='check-box' type='checkbox' value='1'/> <input name='is_menu.{$vo.node}' class='check-box' type='checkbox' value='1'/>
{/notempty} {/notempty}
可设为菜单 可设为菜单
@ -55,15 +55,10 @@
$(function () { $(function () {
$('input.title-input').on('blur', function () { $('input.title-input').on('blur', function () {
$.form.load('{:url("save")}', {name: this.name, value: this.value}, 'POST', function (ret) { $.form.load('{:url("save")}', {name: this.name, value: this.value}, 'POST', function (ret) {
return false; return false;});});
});
});
$('input.check-box').on('click', function () { $('input.check-box').on('click', function () {
$.form.load('{:url("save")}', {name: this.name, value: this.checked ? 1 : 0}, 'POST', function (ret) { $.form.load('{:url("save")}', {name: this.name, value: this.checked ? 1 : 0}, 'POST', function (ret) {
return false; return false;});});});
});
});
});
</script> </script>
{/if} {/if}
{/block} {/block}

View File

@ -9,11 +9,11 @@
<link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"/> <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<script src="__PUBLIC__/static/plugs/jquery/jquery.min.js" type="text/javascript"></script> <script src="__PUBLIC__/static/plugs/jquery/jquery.min.js" type="text/javascript"></script>
<style> <style>
.bs-glyphicons-list { padding-left: 0; list-style: none } .bs-glyphicons-list { padding-left: 0; list-style: none}
.bs-glyphicons li { float: left; width: 20%; padding: 10px; font-size: 10px; line-height: 1.4; text-align: center; background-color: #f9f9f9; border: 1px solid #fff;cursor: pointer } .bs-glyphicons li { float: left; width: 20%; padding: 10px; font-size: 10px; line-height: 1.4; text-align: center; background-color: #f9f9f9; border: 1px solid #fff;cursor: pointer}
.bs-glyphicons .glyphicon, .bs-glyphicons .fa { margin-top: 5px; margin-bottom: 10px; font-size: 24px; } .bs-glyphicons .glyphicon, .bs-glyphicons .fa { margin-top: 5px; margin-bottom: 10px; font-size: 24px;}
.bs-glyphicons .glyphicon-class { display: block; text-align: center; white-space: nowrap; overflow: hidden; } .bs-glyphicons .glyphicon-class { display: block; text-align: center; white-space: nowrap; overflow: hidden;}
.bs-glyphicons li:hover { color: #fff; background-color: #563d7c } .bs-glyphicons li:hover { color: #fff; background-color: #563d7c}
</style> </style>
</head> </head>
<body> <body>
@ -1908,23 +1908,16 @@
/* global top */ /* global top */
if (document.all) { if (document.all) {
document.onselectstart = function () { document.onselectstart = function () {
return false; return false;};} else {
};
} else {
document.onmouseup = document.onmousedown = function () { document.onmouseup = document.onmousedown = function () {
return false; return false;};}
};
}
document.onselectstart = new Function('event.returnValue=false;'); document.onselectstart = new Function('event.returnValue=false;');
$('li').on('click', function () { $('li').on('click', function () {
var className = $(this).find('span.glyphicon,span.fa').get(0).className; var className = $(this).find('span.glyphicon,span.fa').get(0).className;
if (className) { if (className) {
top.$('[name="{$field}"]').val(className).trigger('change'); top.$('[name="{$field}"]').val(className).trigger('change');
var index = top.layer.getFrameIndex(window.name); var index = top.layer.getFrameIndex(window.name);
top.layer.close(index); top.layer.close(index);}});});
}
});
});
</script> </script>
</div> </div>
</body> </body>

View File

@ -45,13 +45,11 @@
$('#' + file.id).attr('data-md5', file.md5).attr('data-src', url); $('#' + file.id).attr('data-md5', file.md5).attr('data-src', url);
/* {if $mode === 'one'} */ /* {if $mode === 'one'} */
top.$('[name="{$field}"]').map(function () { top.$('[name="{$field}"]').map(function () {
top.$(this).attr('data-srcs', ret.url).attr('data-md5', file.md5).val(url).trigger('change'); top.$(this).attr('data-srcs', ret.url).attr('data-md5', file.md5).val(url).trigger('change');});
});
//top.$.msg.tips('文件上传成功!'); //top.$.msg.tips('文件上传成功!');
var index = top.layer.getFrameIndex(window.name); var index = top.layer.getFrameIndex(window.name);
top.layer.close(index); top.layer.close(index);
/* {/if} {$mode}*/ /* {/if} {$mode}*/}
}
function confirmSelected() { function confirmSelected() {
var srcs = new Array(); var srcs = new Array();
@ -59,26 +57,19 @@
$('[data-md5] .success').map(function () { $('[data-md5] .success').map(function () {
var $li = $(this).parents('[data-md5]'); var $li = $(this).parents('[data-md5]');
md5s.push($li.attr('data-md5')); md5s.push($li.attr('data-md5'));
srcs.push($li.attr('data-src')); srcs.push($li.attr('data-src'));});
});
if (srcs.length < 1) { if (srcs.length < 1) {
return top.$.msg.tips('还没有选择文件,请勾选需要使用的文件!'); return top.$.msg.tips('还没有选择文件,请勾选需要使用的文件!');}
}
top.$('[name="{$field}"]').map(function () { top.$('[name="{$field}"]').map(function () {
top.$(this).attr('data-srcs', srcs.join('|')).attr('data-md5', md5s.join('|')).val(srcs.join('|')).trigger('change'); top.$(this).attr('data-srcs', srcs.join('|')).attr('data-md5', md5s.join('|')).val(srcs.join('|')).trigger('change');});
});
var index = top.layer.getFrameIndex(window.name); var index = top.layer.getFrameIndex(window.name);
top.layer.close(index); top.layer.close(index);}
}
function completed() { function completed() {
var btnHTML = '完成上传'; var btnHTML = '完成上传';
$('.uploadBtn').on('click', function () { $('.uploadBtn').on('click', function () {
if (this.innerHTML === btnHTML) { if (this.innerHTML === btnHTML) {
confirmSelected.call(this); confirmSelected.call(this);}}).html(btnHTML);}
}
}).html(btnHTML);
}
// 当domReady的时候开始初始化 // 当domReady的时候开始初始化
$(function () { $(function () {
@ -113,33 +104,24 @@
var support = true; var support = true;
data.onload = data.onerror = function () { data.onload = data.onerror = function () {
if (this.width != 1 || this.height != 1) { if (this.width != 1 || this.height != 1) {
support = false; support = false;}};
}
};
data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
return support; return support;}.call(this)),
}.call(this)),
/*检测是否已经安装flash检测flash的版本*/ /*检测是否已经安装flash检测flash的版本*/
flashVersion = (function () { flashVersion = (function () {
var version; var version;
try { try {
version = navigator.plugins[ 'Shockwave Flash' ]; version = navigator.plugins[ 'Shockwave Flash' ];
version = version.description; version = version.description;} catch (ex) {
} catch (ex) {
try { try {
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version'); version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');} catch (ex2) {
} catch (ex2) { version = '0.0';}}
version = '0.0';
}
}
version = version.match(/\d+/g); version = version.match(/\d+/g);
return parseFloat(version[ 0 ] + '.' + version[ 1 ], 10); return parseFloat(version[ 0 ] + '.' + version[ 1 ], 10);})(),
})(),
supportTransition = (function () { supportTransition = (function () {
var s = document.createElement('p').style, r = 'transition' in s || 'WebkitTransition' in s || 'MozTransition' in s || 'msTransition' in s || 'OTransition' in s; var s = document.createElement('p').style, r = 'transition' in s || 'WebkitTransition' in s || 'MozTransition' in s || 'msTransition' in s || 'OTransition' in s;
s = null; s = null;
return r; return r;})(),
})(),
uploader; uploader;
if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) { if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) {
/*flash 安装了但是版本过低*/ /*flash 安装了但是版本过低*/
@ -155,36 +137,27 @@
break; break;
default: default:
alert('安装已成功,请刷新!'); alert('安装已成功,请刷新!');
break; break;}
} delete window['expressinstallcallback'];};
delete window['expressinstallcallback'];
};
var swf = '__PUBLIC__/static/plugs/uploader/expressInstall.swf'; var swf = '__PUBLIC__/static/plugs/uploader/expressInstall.swf';
var html = '<object type="application/' + 'x-shockwave-flash" data="' + swf + '" '; var html = '<object type="application/' + 'x-shockwave-flash" data="' + swf + '" ';
if (WebUploader.browser.ie) { if (WebUploader.browser.ie) {
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '; html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';}
}
html += 'width="100%" height="100%" style="outline:0">' + html += 'width="100%" height="100%" style="outline:0">' +
'<param name="movie" value="' + swf + '" />' + '<param name="movie" value="' + swf + '" />' +
'<param name="wmode" value="transparent" />' + '<param name="wmode" value="transparent" />' +
'<param name="allowscriptaccess" value="always" />' + '<param name="allowscriptaccess" value="always" />' +
'</object>'; '</object>';
container.html(html); container.html(html);})($wrap);} else {
})($wrap); $wrap.html('<a href="http://www.adobe.com/go/getflashplayer" target="_blank" border="0"><img alt="get flash player" src="http://www.adobe.com/macromedia/style_guide/images/160x41_Get_Flash_Player.jpg" /></a>');}
} else { return;} else if (!WebUploader.Uploader.support()) {
$wrap.html('<a href="http://www.adobe.com/go/getflashplayer" target="_blank" border="0"><img alt="get flash player" src="http://www.adobe.com/macromedia/style_guide/images/160x41_Get_Flash_Player.jpg" /></a>');
}
return;
} else if (!WebUploader.Uploader.support()) {
alert('Web Uploader 不支持您的浏览器!'); alert('Web Uploader 不支持您的浏览器!');
return; return;}
}
WebUploader.Uploader.register({'before-send-file': 'preupload'}, {preupload: function (file) { WebUploader.Uploader.register({'before-send-file': 'preupload'}, {preupload: function (file) {
var me = this, owner = this.owner, deferred = WebUploader.Deferred(); var me = this, owner = this.owner, deferred = WebUploader.Deferred();
owner.md5File(file.source).fail(function () { owner.md5File(file.source).fail(function () {
deferred.reject(); deferred.reject();}).then(function (md5) {
}).then(function (md5) {
file.md5 = md5; file.md5 = md5;
var data = {id: file.id, md5: md5, uptype: '{$uptype}', filename: file.name}; var data = {id: file.id, md5: md5, uptype: '{$uptype}', filename: file.name};
$.ajax("{:url('admin/plugs/upstate')}", {dataType: 'json', method: 'post', data: data, success: function (ret) { $.ajax("{:url('admin/plugs/upstate')}", {dataType: 'json', method: 'post', data: data, success: function (ret) {
@ -193,38 +166,29 @@
uploaded.call(uploader, ret.data, file); uploaded.call(uploader, ret.data, file);
percentages[file.id] = [file.size, 1]; percentages[file.id] = [file.size, 1];
updateTotalProgress(); updateTotalProgress();
console.log('文件秒传成功 --> ' + file.name); console.log('文件秒传成功 --> ' + file.name);} else {
} else {
file.md5 = md5; file.md5 = md5;
file.token = ret.data.token; file.token = ret.data.token;
file.key = ret.data.file_url; file.key = ret.data.file_url;
me.options.server = ret.data.server; me.options.server = ret.data.server;}
} deferred.resolve();}});});
deferred.resolve(); return deferred.promise();}});
}
});
});
return deferred.promise();
}
});
// 实例化 // 实例化
uploader = WebUploader.create({ uploader = WebUploader.create({
pick: { pick: {
id: '#filePicker', id: '#filePicker',
label: '点击选择文件', label: '点击选择文件',
multiple: false multiple: false},
},
accept: { accept: {
title: '选择文件', title: '选择文件',
extensions: '{$types}', //'gif,jpg,jpeg,bmp,png', extensions: '{$types}', //'gif,jpg,jpeg,bmp,png',
mimeTypes: '{$mimes}' mimeTypes: '{$mimes}'},
},
formData: {}, formData: {},
/*{if $mode === 'one'}*/ /*{if $mode === 'one'}*/
fileNumLimit: 1, fileNumLimit: 1,
auto: true, auto: true,
/* {else /} */ /* {else} */
auto: false, auto: false,
fileNumLimit: 300, fileNumLimit: 300,
/* {/if} */ /* {/if} */
@ -237,8 +201,7 @@
server: '{:url("admin/plugs/upload")}', server: '{:url("admin/plugs/upload")}',
disableGlobalDnd: true, disableGlobalDnd: true,
fileSizeLimit: 200 * 1024 * 1024, // 200 M fileSizeLimit: 200 * 1024 * 1024, // 200 M
fileSingleSizeLimit: 200 * 1024 * 1024 // 200 M fileSingleSizeLimit: 200 * 1024 * 1024 // 200 M});
});
/** /**
* 处理上传后的结果 * 处理上传后的结果
@ -248,10 +211,8 @@
uploader.on('uploadAccept', function (fieldata, ret) { uploader.on('uploadAccept', function (fieldata, ret) {
if (ret.code === 'SUCCESS') { if (ret.code === 'SUCCESS') {
uploaded.call(uploader, ret.data, fieldata.file); uploaded.call(uploader, ret.data, fieldata.file);
return true; return true;}
} return false;});
return false;
});
// 拖拽时不接受 js, txt 文件。 // 拖拽时不接受 js, txt 文件。
uploader.on('dndAccept', function (items) { uploader.on('dndAccept', function (items) {
@ -260,11 +221,8 @@
for (var i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
if (~unAllowed.indexOf(items[ i ].type)) { if (~unAllowed.indexOf(items[ i ].type)) {
denied = true; denied = true;
break; break;}}
} return !denied;});
}
return !denied;
});
/* 上传开始前的处理 */ /* 上传开始前的处理 */
uploader.on('uploadBeforeSend', function (file, data, header) { uploader.on('uploadBeforeSend', function (file, data, header) {
@ -272,18 +230,15 @@
data['allowed_types'] = this.options.accept[0].extensions.split(',').join('|'); data['allowed_types'] = this.options.accept[0].extensions.split(',').join('|');
data['md5'] = file.file.md5; data['md5'] = file.file.md5;
data['key'] = file.file.key; data['key'] = file.file.key;
data['token'] = file.file.token; data['token'] = file.file.token;});
});
// 添加“添加文件”的按钮, // 添加“添加文件”的按钮,
uploader.addButton({ uploader.addButton({
id: '#filePicker2', id: '#filePicker2',
label: '继续添加' label: '继续添加'});
});
uploader.on('ready', function () { uploader.on('ready', function () {
window.uploader = uploader; window.uploader = uploader;});
});
// 当有文件添加进来时执行负责view的创建 // 当有文件添加进来时执行负责view的创建
function addFile(file) { function addFile(file) {
@ -309,72 +264,51 @@
break; break;
default: default:
text = '上传失败,请重试'; text = '上传失败,请重试';
break; break;}
} $info.text(text).appendTo($li);};
$info.text(text).appendTo($li);
};
if (file.getStatus() === 'invalid') { if (file.getStatus() === 'invalid') {
showError(file.statusText); showError(file.statusText);} else {
} else {
// @todo lazyload // @todo lazyload
$wrap.text('预览中'); $wrap.text('预览中');
uploader.makeThumb(file, function (error, src) { uploader.makeThumb(file, function (error, src) {
var img; var img;
if (error) { if (error) {
$wrap.text('不能预览'); $wrap.text('不能预览');
return; return;}
}
if (isSupportBase64) { if (isSupportBase64) {
img = $('<img src="' + src + '">'); img = $('<img src="' + src + '">');
$wrap.empty().append(img); $wrap.empty().append(img);} else {
} else {
$.ajax('{"plugs/file/preview"|url}', {method: 'POST', data: src, dataType: 'json'}).done(function (response) { $.ajax('{"plugs/file/preview"|url}', {method: 'POST', data: src, dataType: 'json'}).done(function (response) {
if (response.result) { if (response.result) {
img = $('<img src="' + response.result + '">'); img = $('<img src="' + response.result + '">');
$wrap.empty().append(img); $wrap.empty().append(img);} else {
} else { $wrap.text("预览出错");}});}}, thumbnailWidth, thumbnailHeight);
$wrap.text("预览出错");
}
});
}
}, thumbnailWidth, thumbnailHeight);
percentages[ file.id ] = [file.size, 0]; percentages[ file.id ] = [file.size, 0];
file.rotation = 0; file.rotation = 0;
$upload.html('开始上传'); $upload.html('开始上传');}
}
file.on('statuschange', function (cur, prev) { file.on('statuschange', function (cur, prev) {
if (prev === 'progress') { if (prev === 'progress') {
$prgress.hide().width(0); $prgress.hide().width(0);} else if (prev === 'queued') {
} else if (prev === 'queued') {
$li.off('mouseenter mouseleave'); $li.off('mouseenter mouseleave');
$btns.remove(); $btns.remove();}
}
// 成功 // 成功
if (cur === 'error' || cur === 'invalid') { if (cur === 'error' || cur === 'invalid') {
showError(file.statusText); showError(file.statusText);
percentages[ file.id ][ 1 ] = 1; percentages[ file.id ][ 1 ] = 1;} else if (cur === 'interrupt') {
} else if (cur === 'interrupt') { showError('interrupt');} else if (cur === 'queued') {
showError('interrupt'); percentages[ file.id ][ 1 ] = 0;} else if (cur === 'progress') {
} else if (cur === 'queued') {
percentages[ file.id ][ 1 ] = 0;
} else if (cur === 'progress') {
$info.remove(); $info.remove();
$prgress.css('display', 'block'); $prgress.css('display', 'block');} else if (cur === 'complete') {
} else if (cur === 'complete') { $li.append('<span class="success"></span>');}
$li.append('<span class="success"></span>');
}
$li.removeClass('state-' + prev).addClass('state-' + cur); $li.removeClass('state-' + prev).addClass('state-' + cur);});
});
$li.on('mouseenter', function () { $li.on('mouseenter', function () {
$btns.stop().animate({height: 30}); $btns.stop().animate({height: 30});});
});
$li.on('mouseleave', function () { $li.on('mouseleave', function () {
$btns.stop().animate({height: 0}); $btns.stop().animate({height: 0});});
});
$btns.on('click', 'span', function () { $btns.on('click', 'span', function () {
var index = $(this).index(), deg; var index = $(this).index(), deg;
@ -387,62 +321,47 @@
break; break;
case 2: case 2:
file.rotation -= 90; file.rotation -= 90;
break; break;}
}
if (supportTransition) { if (supportTransition) {
deg = 'rotate(' + file.rotation + 'deg)'; deg = 'rotate(' + file.rotation + 'deg)';
$wrap.css({'-webkit-transform': deg, '-mos-transform': deg, '-o-transform': deg, 'transform': deg}); $wrap.css({'-webkit-transform': deg, '-mos-transform': deg, '-o-transform': deg, 'transform': deg});} else {
} else { $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');}});
$wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')'); $li.appendTo($queue);}
}
});
$li.appendTo($queue);
}
// 负责view的销毁 // 负责view的销毁
function removeFile(file) { function removeFile(file) {
var $li = $('#' + file.id); var $li = $('#' + file.id);
delete percentages[ file.id ]; delete percentages[ file.id ];
updateTotalProgress(); updateTotalProgress();
$li.off().find('.file-panel').off().end().remove(); $li.off().find('.file-panel').off().end().remove();}
}
function updateTotalProgress() { function updateTotalProgress() {
var loaded = 0, total = 0, spans = $progress.children(), percent; var loaded = 0, total = 0, spans = $progress.children(), percent;
$.each(percentages, function (k, v) { $.each(percentages, function (k, v) {
total += v[ 0 ]; total += v[ 0 ];
loaded += v[ 0 ] * v[ 1 ]; loaded += v[ 0 ] * v[ 1 ];});
});
percent = total ? loaded / total : 0; percent = total ? loaded / total : 0;
spans.eq(0).text(Math.round(percent * 100) + '%'); spans.eq(0).text(Math.round(percent * 100) + '%');
spans.eq(1).css('width', Math.round(percent * 100) + '%'); spans.eq(1).css('width', Math.round(percent * 100) + '%');
updateStatus(); updateStatus();}
}
function updateStatus() { function updateStatus() {
var text = '', stats; var text = '', stats;
if (state === 'ready') { if (state === 'ready') {
text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。'; text = '选中' + fileCount + '个文件,共' + WebUploader.formatSize(fileSize) + '。';} else if (state === 'confirm') {
} else if (state === 'confirm') {
stats = uploader.getStats(); stats = uploader.getStats();
if (stats.uploadFailNum) { if (stats.uploadFailNum) {
text = '已成功上传' + stats.successNum + '个文件,' + stats.uploadFailNum + '个文件上传失败,<a class="retry" href="#">重新上传</a>失败文件' text = '已成功上传' + stats.successNum + '个文件,' + stats.uploadFailNum + '个文件上传失败,<a class="retry" href="#">重新上传</a>失败文件'}} else {
}
} else {
stats = uploader.getStats(); stats = uploader.getStats();
text = '共' + fileCount + '个(' + WebUploader.formatSize(fileSize) + '),已上传' + stats.successNum + '个'; text = '共' + fileCount + '个(' + WebUploader.formatSize(fileSize) + '),已上传' + stats.successNum + '个';
if (stats.uploadFailNum) { if (stats.uploadFailNum) {
text += ',失败' + stats.uploadFailNum + '个'; text += ',失败' + stats.uploadFailNum + '个';}}
} $info.html(text);}
}
$info.html(text);
}
function setState(val) { function setState(val) {
var file, stats; var file, stats;
if (val === state) { if (val === state) {
return; return;}
}
$upload.removeClass('state-' + state); $upload.removeClass('state-' + state);
$upload.addClass('state-' + val); $upload.addClass('state-' + val);
state = val; state = val;
@ -476,51 +395,41 @@
stats = uploader.getStats(); stats = uploader.getStats();
if (stats.successNum && !stats.uploadFailNum) { if (stats.successNum && !stats.uploadFailNum) {
setState('finish'); setState('finish');
return; return;}
}
break; break;
case 'finish': case 'finish':
stats = uploader.getStats(); stats = uploader.getStats();
if (stats.successNum) { if (stats.successNum) {
completed.call(this); completed.call(this);} else {
} else {
// 没有成功的文件,重设 // 没有成功的文件,重设
state = 'done'; state = 'done';
location.reload(); location.reload();}
} break;}
break; updateStatus();}
}
updateStatus();
}
uploader.onUploadProgress = function (file, percentage) { uploader.onUploadProgress = function (file, percentage) {
var $li = $('#' + file.id), $percent = $li.find('.progress span'); var $li = $('#' + file.id), $percent = $li.find('.progress span');
$percent.css('width', percentage * 100 + '%'); $percent.css('width', percentage * 100 + '%');
percentages[ file.id ][ 1 ] = percentage; percentages[ file.id ][ 1 ] = percentage;
updateTotalProgress(); updateTotalProgress();};
};
uploader.onFileQueued = function (file) { uploader.onFileQueued = function (file) {
fileCount++; fileCount++;
fileSize += file.size; fileSize += file.size;
if (fileCount === 1) { if (fileCount === 1) {
$placeHolder.addClass('element-invisible'); $placeHolder.addClass('element-invisible');
$statusBar.show(); $statusBar.show();}
}
addFile(file); addFile(file);
setState('ready'); setState('ready');
updateTotalProgress(); updateTotalProgress();};
};
uploader.onfieldequeued = function (file) { uploader.onfieldequeued = function (file) {
fileCount--; fileCount--;
fileSize -= file.size; fileSize -= file.size;
if (!fileCount) { if (!fileCount) {
setState('pedding'); setState('pedding');}
}
removeFile(file); removeFile(file);
updateTotalProgress(); updateTotalProgress();};
};
uploader.on('all', function (type) { uploader.on('all', function (type) {
switch (type) { switch (type) {
@ -532,34 +441,24 @@
break; break;
case 'stopUpload': case 'stopUpload':
setState('paused'); setState('paused');
break; break;}});
}
});
uploader.onError = function (code) { uploader.onError = function (code) {
//alert('Eroor: ' + code); //alert('Eroor: ' + code);};
};
$upload.on('click', function () { $upload.on('click', function () {
if ($(this).hasClass('disabled')) { if ($(this).hasClass('disabled')) {
return false; return false;}
}
if (state === 'ready') { if (state === 'ready') {
uploader.upload(); uploader.upload();} else if (state === 'paused') {
} else if (state === 'paused') { uploader.upload();} else if (state === 'uploading') {
uploader.upload(); uploader.stop();}});
} else if (state === 'uploading') {
uploader.stop();
}
});
$info.on('click', '.retry', function () { $info.on('click', '.retry', function () {
uploader.retry(); uploader.retry();});
});
$upload.addClass('state-' + state); $upload.addClass('state-' + state);
updateTotalProgress(); updateTotalProgress();});
});
</script> </script>
</body> </body>

View File

@ -5,7 +5,7 @@
<div class="layui-input-block"> <div class="layui-input-block">
{if $vo and $vo.username} {if $vo and $vo.username}
<input type="text" readonly="" disabled="" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input disabled"> <input type="text" readonly="" disabled="" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input disabled">
{else/} {else}
<input type="text" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input"> <input type="text" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input">
{/if} {/if}
</div> </div>
@ -17,7 +17,7 @@
{foreach $authorizes as $authorize} {foreach $authorizes as $authorize}
{if in_array($authorize['id'],$vo['authorize'])} {if in_array($authorize['id'],$vo['authorize'])}
<input type="checkbox" checked name="authorize[]" value="{$authorize.id}" title="{$authorize.title}"> <input type="checkbox" checked name="authorize[]" value="{$authorize.id}" title="{$authorize.title}">
{else/} {else}
<input type="checkbox" name="authorize[]" value="{$authorize.id}" title="{$authorize.title}"> <input type="checkbox" name="authorize[]" value="{$authorize.id}" title="{$authorize.title}">
{/if} {/if}
{/foreach} {/foreach}

View File

@ -5,7 +5,7 @@
<div class="layui-input-block"> <div class="layui-input-block">
{if $vo and isset($vo.username)} {if $vo and isset($vo.username)}
<input type="text" readonly="" disabled="" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input disabled"> <input type="text" readonly="" disabled="" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input disabled">
{else/} {else}
<input type="text" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input"> <input type="text" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input">
{/if} {/if}
</div> </div>
@ -32,7 +32,7 @@
{foreach $authorizes as $authorize} {foreach $authorizes as $authorize}
{if in_array($authorize['id'],$vo['authorize'])} {if in_array($authorize['id'],$vo['authorize'])}
<input type="checkbox" checked name="authorize[]" value="{$authorize.id}" title="{$authorize.title}"> <input type="checkbox" checked name="authorize[]" value="{$authorize.id}" title="{$authorize.title}">
{else/} {else}
<input type="checkbox" name="authorize[]" value="{$authorize.id}" title="{$authorize.title}"> <input type="checkbox" name="authorize[]" value="{$authorize.id}" title="{$authorize.title}">
{/if} {/if}
{/foreach} {/foreach}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
<div class="nowrap pull-right" style="margin-top:10px"> <div class="nowrap pull-right" style="margin-top:10px">

View File

@ -5,7 +5,7 @@
<div class="layui-input-block"> <div class="layui-input-block">
{if $vo and $vo.username} {if $vo and $vo.username}
<input type="text" readonly="" disabled="" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input disabled"> <input type="text" readonly="" disabled="" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input disabled">
{else/} {else}
<input type="text" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input"> <input type="text" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input">
{/if} {/if}
</div> </div>

View File

@ -158,7 +158,7 @@ return [
// 日志保存目录 // 日志保存目录
'path' => LOG_PATH, 'path' => LOG_PATH,
// 日志记录级别 log,error,info,sql,notice,alert,debug // 日志记录级别 log,error,info,sql,notice,alert,debug
'level' => ['error','log','sql','notice','alert','debug'], 'level' => ['error', 'log', 'sql', 'notice', 'alert', 'debug'],
// error和sql日志单独记录 // error和sql日志单独记录
'apart_level' => ['error', 'sql'], 'apart_level' => ['error', 'sql'],
], ],

View File

@ -12,7 +12,7 @@
class="topbar-home-link topbar-btn topbar-left"> class="topbar-home-link topbar-btn topbar-left">
<span>{notempty name='$pmenu.icon'}<i class="{$pmenu.icon}"></i>{/notempty} {$pmenu.title}</span> <span>{notempty name='$pmenu.icon'}<i class="{$pmenu.icon}"></i>{/notempty} {$pmenu.title}</span>
</a> </a>
{else/} {else}
<a data-menu-target='m-{$pmenu.id}' class="topbar-home-link topbar-btn topbar-left"> <a data-menu-target='m-{$pmenu.id}' class="topbar-home-link topbar-btn topbar-left">
<span>{notempty name='$pmenu.icon'}<i class="{$pmenu.icon}"></i>{/notempty} {$pmenu.title}</span> <span>{notempty name='$pmenu.icon'}<i class="{$pmenu.icon}"></i>{/notempty} {$pmenu.title}</span>
</a> </a>

View File

@ -1,14 +1,12 @@
{extend name="extra@admin/content"} {extend name="extra@admin/content"}
{block name="content"} {block name="content"}
<form onsubmit="return false;" action="__SELF__" data-auto="true" method="post" <form onsubmit="return false;" action="__SELF__" data-auto="true" method="post" class='form-horizontal' style='padding-top:20px'>
class='form-horizontal' style='padding-top:20px'>
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">URL <span class="nowrap">(服务器地址)</span></label> <label class="col-sm-2 control-label">URL <span class="nowrap">(服务器地址)</span></label>
<div class="col-sm-8"> <div class="col-sm-8">
<input onmouseenter="this.select()" class="layui-input" readonly="readonly" <input onmouseenter="this.select()" class="layui-input" readonly="readonly" value="{:url('@wechat/api','',true,true)}"/>
value="{:url('@wechat/api','',true,true)}"/>
<p class="help-block"> <p class="help-block">
请复制此URL地址填写在公众号平台 [ 开发 >> 基本配置 ] [ URL ( 服务器地址 ) ] 请复制此URL地址填写在公众号平台 [ 开发 >> 基本配置 ] [ URL ( 服务器地址 ) ]
<br/><b>注意</b>URL主域名必需备案微信服务接口只支持 80 端口 ( http ) 443 端口 ( https ) <br/><b>注意</b>URL主域名必需备案微信服务接口只支持 80 端口 ( http ) 443 端口 ( https )
@ -21,9 +19,8 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">AppID <span class="nowrap">(应用ID)</span></label> <label class="col-sm-2 control-label">AppID <span class="nowrap">(应用ID)</span></label>
<div class='col-sm-8'> <div class='col-sm-8'>
<input type="text" name="wechat_appid" title="请输入以wx开头的18位公众号APPID" <input type="text" name="wechat_appid" title="请输入以wx开头的18位公众号APPID" placeholder="公众号APPID必填"
pattern="^wx[0-9a-z]{16}$" maxlength="18" required="required" pattern="^wx[0-9a-z]{16}$" maxlength="18" required="required" value="{:sysconf('wechat_appid')}" class="layui-input">
placeholder="公众号APPID必填" value="{:sysconf('wechat_appid')}" class="layui-input">
<p class="help-block"> <p class="help-block">
公众号应用ID是所有接口必要参数可以在公众号平台 [ 开发 >> 基本配置 ] 页面获取。 公众号应用ID是所有接口必要参数可以在公众号平台 [ 开发 >> 基本配置 ] 页面获取。
</p> </p>
@ -36,8 +33,7 @@
<div class='col-sm-8'> <div class='col-sm-8'>
<input type="password" name="wechat_appsecret" required="required" title="请输入32位公众号AppSecret" <input type="password" name="wechat_appsecret" required="required" title="请输入32位公众号AppSecret"
placeholder="公众号AppSecret必填" value="{:sysconf('wechat_appsecret')}" placeholder="公众号AppSecret必填" value="{:sysconf('wechat_appsecret')}"
maxlength="32" pattern="^[0-9a-z]{32}$" maxlength="32" pattern="^[0-9a-z]{32}$" class="layui-input">
class="layui-input">
<p class="help-block"> <p class="help-block">
公众号应用密钥是所有接口必要参数,可以在公众号平台 [ 开发 >> 基本配置 ] 页面授权后获取。 公众号应用密钥是所有接口必要参数,可以在公众号平台 [ 开发 >> 基本配置 ] 页面授权后获取。
</p> </p>
@ -49,8 +45,7 @@
<label class="col-sm-2 control-label">Token <span class="nowrap">(令牌)</span></label> <label class="col-sm-2 control-label">Token <span class="nowrap">(令牌)</span></label>
<div class='col-sm-8'> <div class='col-sm-8'>
<input type="text" name="wechat_token" required="required" title="请输入接口Token(令牌)" <input type="text" name="wechat_token" required="required" title="请输入接口Token(令牌)"
placeholder="Token令牌" value="{:sysconf('wechat_token')}" placeholder="Token令牌" value="{:sysconf('wechat_token')}" class="layui-input">
class="layui-input">
<p class="help-block"> <p class="help-block">
公众号平台与系统对接认证Token请优先填写此参数并保存然后再在微信公众号平台操作对接。 公众号平台与系统对接认证Token请优先填写此参数并保存然后再在微信公众号平台操作对接。
</p> </p>
@ -77,6 +72,7 @@
<button class="layui-btn" type="submit">保存配置</button> <button class="layui-btn" type="submit">保存配置</button>
</div> </div>
</div> </div>
</form> </form>
{/block} {/block}

View File

@ -5,13 +5,11 @@
.pay-qrc-test { .pay-qrc-test {
height: 248px; height: 248px;
width: 248px; width: 248px;
background: url('__PUBLIC__/static/plugs/layui/css/modules/layer/default/loading-2.gif') no-repeat center center background: url('__PUBLIC__/static/plugs/layui/css/modules/layer/default/loading-2.gif') no-repeat center center}
}
.refund-qrc-test { .refund-qrc-test {
text-align: center; text-align: center;
padding: 8px padding: 8px}
}
</style> </style>
{/block} {/block}
@ -55,7 +53,7 @@
type="button" class="layui-btn layui-btn-primary"> type="button" class="layui-btn layui-btn-primary">
{if file_exists(sysconf('wechat_cert_key'))} {if file_exists(sysconf('wechat_cert_key'))}
已上传 apiclient_key.pem 已上传 apiclient_key.pem
{else/} {else}
请上传 apiclient_key.pem 请上传 apiclient_key.pem
{/if} {/if}
</button> </button>
@ -63,7 +61,7 @@
type="button" class="layui-btn layui-btn-primary"> type="button" class="layui-btn layui-btn-primary">
{if file_exists(sysconf('wechat_cert_cert'))} {if file_exists(sysconf('wechat_cert_cert'))}
已上传 apiclient_cert.pem 已上传 apiclient_cert.pem
{else/} {else}
请上传 apiclient_cert.pem 请上传 apiclient_cert.pem
{/if} {/if}
</button> </button>
@ -93,8 +91,7 @@
/* 证书上传动作 */ /* 证书上传动作 */
$('[name="wechat_cert_key_md5"],[name="wechat_cert_cert_md5"]').on('change', function () { $('[name="wechat_cert_key_md5"],[name="wechat_cert_cert_md5"]').on('change', function () {
this.value = $(this).attr('data-md5'); this.value = $(this).attr('data-md5');
$('[data-field="' + this.name + '"]').html('已选择 ' + this.title); $('[data-field="' + this.name + '"]').html('已选择 ' + this.title);});
});
var isShow = false; var isShow = false;
var timer = null; var timer = null;
@ -105,11 +102,9 @@
if (ret.code === 1 || ret.code === 2) { if (ret.code === 1 || ret.code === 2) {
if (ret.code === 2) { if (ret.code === 2) {
ret.url = '__PUBLIC__/static/theme/default/img/wechat/qrc_payed.jpg'; ret.url = '__PUBLIC__/static/theme/default/img/wechat/qrc_payed.jpg';
timer && window.clearInterval(timer), timer = null; timer && window.clearInterval(timer), timer = null;}
}
if (isShow) { if (isShow) {
$('.pay-qrc-test').attr('src', ret.url) $('.pay-qrc-test').attr('src', ret.url)} else {
} else {
layer.open({ layer.open({
type: 1, title: false, closeBtn: 1, shadeClose: true, type: 1, title: false, closeBtn: 1, shadeClose: true,
content: '<img class="pay-qrc-test" src="' + ret.url + '"/>' content: '<img class="pay-qrc-test" src="' + ret.url + '"/>'
@ -117,19 +112,12 @@
+ '<p class="refund-qrc-test"><a class="btn btn-xs btn-warning">退款测试</a></p>', + '<p class="refund-qrc-test"><a class="btn btn-xs btn-warning">退款测试</a></p>',
end: function () { end: function () {
timer && window.clearInterval(timer), timer = null; timer && window.clearInterval(timer), timer = null;
isShow = false; isShow = false;},
},
success: function (layero, index) { success: function (layero, index) {
isShow = true; isShow = true;
layIndex = index; layIndex = index;
timer = setInterval(payTest, 3000); timer = setInterval(payTest, 3000);}});}}
} return false;}, !isShow);}
});
}
}
return false;
}, !isShow);
}
$('[data-pay-test]').on('click', payTest); $('[data-pay-test]').on('click', payTest);
@ -139,12 +127,7 @@
if (ret.code === 1) { if (ret.code === 1) {
timer && window.clearInterval(timer), timer = null; timer && window.clearInterval(timer), timer = null;
return $.msg.success(ret.msg, 3, function () { return $.msg.success(ret.msg, 3, function () {
layer.close(layIndex); layer.close(layIndex);}), false;}});});});
}), false;
}
});
});
});
</script> </script>
{/block} {/block}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
@ -141,7 +141,6 @@
$('body').on('click', '[data-add-tag]', function () { $('body').on('click', '[data-add-tag]', function () {
var fans_id = this.getAttribute('data-add-tag'); var fans_id = this.getAttribute('data-add-tag');
var used_id = this.getAttribute('data-used-id'); var used_id = this.getAttribute('data-used-id');
alert(used_id); alert(used_id);});
});
</script> </script>
{/block} {/block}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="style"} {block name="style"}
<style> <style>
@ -222,9 +222,7 @@
/*! 取消编辑 */ /*! 取消编辑 */
$('[data-cancel-edit]').on('click', function () { $('[data-cancel-edit]').on('click', function () {
$.msg.confirm('确定取消编辑吗?', function () { $.msg.confirm('确定取消编辑吗?', function () {
history.back(); history.back();});});
});
});
/*! 默认类型事件 */ /*! 默认类型事件 */
$('body').off('change', 'select[name=type]').on('change', 'select[name=type]', function () { $('body').off('change', 'select[name=type]').on('change', 'select[name=type]', function () {
@ -243,28 +241,22 @@
case 'music': case 'music':
return $('[name="music_url"]').trigger('change'); return $('[name="music_url"]').trigger('change');
case 'voice': case 'voice':
return $('[name="voice_url"]').trigger('change'); return $('[name="voice_url"]').trigger('change');}});
}
});
function showReview(params) { function showReview(params) {
$('#phone-preview').attr('src', '{:url("@wechat/review")}?' + $.param(params || {})); $('#phone-preview').attr('src', '{:url("@wechat/review")}?' + $.param(params || {}));}
}
// 图文显示预览 // 图文显示预览
$('body').off('change', '[name="news_id"]').on('change', '[name="news_id"]', function () { $('body').off('change', '[name="news_id"]').on('change', '[name="news_id"]', function () {
showReview({type: 'news', content: this.value}); showReview({type: 'news', content: this.value});});
});
// 文字显示预览 // 文字显示预览
$('body').off('change', '[name="content"]').on('change', '[name="content"]', function () { $('body').off('change', '[name="content"]').on('change', '[name="content"]', function () {
showReview({type: 'text', content: this.value}); showReview({type: 'text', content: this.value});});
});
// 图片显示预览 // 图片显示预览
$('body').off('change', '[name="image_url"]').on('change', '[name="image_url"]', function () { $('body').off('change', '[name="image_url"]').on('change', '[name="image_url"]', function () {
showReview({type: 'image', content: this.value}); showReview({type: 'image', content: this.value});});
});
// 音乐显示预览 // 音乐显示预览
var musicSelector = '[name="music_url"],[name="music_title"],[name="music_desc"],[name="music_image"]'; var musicSelector = '[name="music_url"],[name="music_title"],[name="music_desc"],[name="music_image"]';
@ -274,8 +266,7 @@
params.url = $parent.find('[name="music_url"]').val(); params.url = $parent.find('[name="music_url"]').val();
params.image = $parent.find('[name="music_image"]').val(); params.image = $parent.find('[name="music_image"]').val();
params.desc = $parent.find('[name="music_desc"]').val(); params.desc = $parent.find('[name="music_desc"]').val();
showReview(params); showReview(params);});
});
// 视频显示预览 // 视频显示预览
var videoSelector = '[name="video_title"],[name="video_url"],[name="video_desc"]'; var videoSelector = '[name="video_title"],[name="video_url"],[name="video_desc"]';
@ -284,13 +275,10 @@
params.title = $parent.find('[name="video_title"]').val(); params.title = $parent.find('[name="video_title"]').val();
params.url = $parent.find('[name="video_url"]').val(); params.url = $parent.find('[name="video_url"]').val();
params.desc = $parent.find('[name="video_desc"]').val(); params.desc = $parent.find('[name="video_desc"]').val();
showReview(params); showReview(params);});
});
// 默认事件触发 // 默认事件触发
$('select[name=type]').map(function () { $('select[name=type]').map(function () {
$(this).trigger('change'); $(this).trigger('change');});});
});
});
</script> </script>
{/block} {/block}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
<div class="nowrap pull-right" style="margin-top:10px"> <div class="nowrap pull-right" style="margin-top:10px">
@ -127,27 +127,21 @@
case 'music': case 'music':
return $('[name="music_url"]').trigger('change'); return $('[name="music_url"]').trigger('change');
case 'voice': case 'voice':
return $('[name="voice_url"]').trigger('change'); return $('[name="voice_url"]').trigger('change');}});
}
});
function showReview(params) { function showReview(params) {
params = params || {}; params = params || {};
$('#phone-preview').attr('src', '{"@wechat/review"|app_url}&' + $.param(params)); $('#phone-preview').attr('src', '{"@wechat/review"|app_url}&' + $.param(params));}
}
// 图文显示预览 // 图文显示预览
$('body').off('change', '[name="news_id"]').on('change', '[name="news_id"]', function () { $('body').off('change', '[name="news_id"]').on('change', '[name="news_id"]', function () {
showReview({type: 'news', content: this.value}); showReview({type: 'news', content: this.value});});
});
// 文字显示预览 // 文字显示预览
$('body').off('change', '[name="content"]').on('change', '[name="content"]', function () { $('body').off('change', '[name="content"]').on('change', '[name="content"]', function () {
showReview({type: 'text', content: this.value}); showReview({type: 'text', content: this.value});});
});
// 图片显示预览 // 图片显示预览
$('body').off('change', '[name="image_url"]').on('change', '[name="image_url"]', function () { $('body').off('change', '[name="image_url"]').on('change', '[name="image_url"]', function () {
showReview({type: 'image', content: this.value}); showReview({type: 'image', content: this.value});});
});
// 音乐显示预览 // 音乐显示预览
var musicSelector = '[name="music_url"],[name="music_title"],[name="music_desc"],[name="music_image"]'; var musicSelector = '[name="music_url"],[name="music_title"],[name="music_desc"],[name="music_image"]';
$('body').off('change', musicSelector).on('change', musicSelector, function () { $('body').off('change', musicSelector).on('change', musicSelector, function () {
@ -156,8 +150,7 @@
params.url = $parent.find('[name="music_url"]').val(); params.url = $parent.find('[name="music_url"]').val();
params.image = $parent.find('[name="music_image"]').val(); params.image = $parent.find('[name="music_image"]').val();
params.desc = $parent.find('[name="music_desc"]').val(); params.desc = $parent.find('[name="music_desc"]').val();
showReview(params); showReview(params);});
});
// 视频显示预览 // 视频显示预览
var videoSelector = '[name="video_title"],[name="video_url"],[name="video_desc"]'; var videoSelector = '[name="video_title"],[name="video_url"],[name="video_desc"]';
$('body').off('change', videoSelector).on('change', videoSelector, function () { $('body').off('change', videoSelector).on('change', videoSelector, function () {
@ -165,13 +158,11 @@
params.title = $parent.find('[name="video_title"]').val(); params.title = $parent.find('[name="video_title"]').val();
params.url = $parent.find('[name="video_url"]').val(); params.url = $parent.find('[name="video_url"]').val();
params.desc = $parent.find('[name="video_desc"]').val(); params.desc = $parent.find('[name="video_desc"]').val();
showReview(params); showReview(params);});
});
// 默认事件触发 // 默认事件触发
$('select[name=type]').map(function () { $('select[name=type]').map(function () {
$(this).trigger('change'); $(this).trigger('change');});
});
/*! 删除关键字 */ /*! 删除关键字 */
$('[data-delete]').on('click', function () { $('[data-delete]').on('click', function () {
@ -180,11 +171,6 @@
$.msg.confirm('确定要删除这条记录吗?', function () { $.msg.confirm('确定要删除这条记录吗?', function () {
$.form.load(url, {id: id}, 'POST', function (ret) { $.form.load(url, {id: id}, 'POST', function (ret) {
if (ret.code === "SUCCESS") { if (ret.code === "SUCCESS") {
window.location.reload(); window.location.reload();}});})});});
}
});
})
});
});
</script> </script>
{/block} {/block}

View File

@ -1,13 +1,13 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="style"} {block name="style"}
<style> <style>
.mobile-preview { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; -khtml-user-select: none; user-select: none; } .mobile-preview { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; -khtml-user-select: none; user-select: none;}
.menu-editor { left: 317px; display: block; max-width: 500px; width: 500px; height: 580px; border-radius: 0; border-color: #e7e7eb; box-shadow: none } .menu-editor { left: 317px; display: block; max-width: 500px; width: 500px; height: 580px; border-radius: 0; border-color: #e7e7eb; box-shadow: none}
.menu-editor .arrow { top: auto !important; bottom: 15px } .menu-editor .arrow { top: auto !important; bottom: 15px}
.menu-editor .popover-title { margin-top: 0 } .menu-editor .popover-title { margin-top: 0}
.menu-delete { font-weight: 400; font-size: 12px; } .menu-delete { font-weight: 400; font-size: 12px;}
.menu-submit { margin-right: 10px } .menu-submit { margin-right: 10px}
</style> </style>
{/block} {/block}
@ -121,8 +121,7 @@
var menu = function () { var menu = function () {
this.version = '1.0'; this.version = '1.0';
this.$btn; this.$btn;
this.listen(); this.listen();};
};
/** /**
* 控件默认事件 * 控件默认事件
* @returns {undefined} * @returns {undefined}
@ -131,17 +130,12 @@
var self = this; var self = this;
$('.mobile-footer').on('click', 'li a', function () { $('.mobile-footer').on('click', 'li a', function () {
self.$btn = $(this); self.$btn = $(this);
self.$btn.parent('li').hasClass('menu-add') ? self.add() : self.checkShow(); self.$btn.parent('li').hasClass('menu-add') ? self.add() : self.checkShow();}).find('li:first a:first').trigger('click');
}).find('li:first a:first').trigger('click');
$('.menu-delete').on('click', function () { $('.menu-delete').on('click', function () {
var index = $.msg.confirm('删除后菜单下设置的内容将被删除!', function () { var index = $.msg.confirm('删除后菜单下设置的内容将被删除!', function () {
self.del(), $.msg.close(index); self.del(), $.msg.close(index);});});
});
});
$('.menu-submit').on('click', function () { $('.menu-submit').on('click', function () {
self.submit(); self.submit();});};
});
};
/** /**
* 添加一个菜单 * 添加一个菜单
* @returns {undefined} * @returns {undefined}
@ -151,12 +145,9 @@
if ($ul.hasClass('mobile-footer')) { /* 添加一级菜单 */ if ($ul.hasClass('mobile-footer')) { /* 添加一级菜单 */
var $li = $('<li class="parent-menu"><a class="active"><i class="icon-sub hide"></i> <span>一级菜单</span></a></li>').insertBefore($add); var $li = $('<li class="parent-menu"><a class="active"><i class="icon-sub hide"></i> <span>一级菜单</span></a></li>').insertBefore($add);
this.$btn = $li.find('a'); this.$btn = $li.find('a');
$('<div class="sub-menu text-center hide"><ul><li class="menu-add"><a><i class="icon-add"></i></a></li></ul><i class="arrow arrow_out"></i><i class="arrow arrow_in"></i></div>').appendTo($li); $('<div class="sub-menu text-center hide"><ul><li class="menu-add"><a><i class="icon-add"></i></a></li></ul><i class="arrow arrow_out"></i><i class="arrow arrow_in"></i></div>').appendTo($li);} else { /* 添加二级菜单 */
} else { /* 添加二级菜单 */ this.$btn = $('<li><a class="bottom-border"><span>二级菜单</span></a></li>').prependTo($ul).find('a');}
this.$btn = $('<li><a class="bottom-border"><span>二级菜单</span></a></li>').prependTo($ul).find('a'); this.checkShow();};
}
this.checkShow();
};
/** /**
* 数据校验显示 * 数据校验显示
* @returns {unresolved} * @returns {unresolved}
@ -165,8 +156,7 @@
var $li = this.$btn.parent('li'), $ul = $li.parent('ul'); var $li = this.$btn.parent('li'), $ul = $li.parent('ul');
/* 选中一级菜单时显示二级菜单 */ /* 选中一级菜单时显示二级菜单 */
if ($li.hasClass('parent-menu')) { if ($li.hasClass('parent-menu')) {
$('.parent-menu .sub-menu').not(this.$btn.parent('li').find('.sub-menu').removeClass('hide')).addClass('hide'); $('.parent-menu .sub-menu').not(this.$btn.parent('li').find('.sub-menu').removeClass('hide')).addClass('hide');}
}
/* 一级菜单添加按钮 */ /* 一级菜单添加按钮 */
var $add = $('li.parent-menu:last'); var $add = $('li.parent-menu:last');
@ -174,19 +164,16 @@
/* 二级菜单添加按钮 */ /* 二级菜单添加按钮 */
$add.siblings('li').map(function () { $add.siblings('li').map(function () {
var $add = $(this).find('ul li:last'); var $add = $(this).find('ul li:last');
$add.siblings('li').size() >= 5 ? $add.addClass('hide') : $add.removeClass('hide'); $add.siblings('li').size() >= 5 ? $add.addClass('hide') : $add.removeClass('hide');});
});
/* 处理一级菜单 */ /* 处理一级菜单 */
var parentWidth = 100 / $('li.parent-menu:visible').size() + '%'; var parentWidth = 100 / $('li.parent-menu:visible').size() + '%';
$('li.parent-menu').map(function () { $('li.parent-menu').map(function () {
var $icon = $(this).find('.icon-sub'); var $icon = $(this).find('.icon-sub');
$(this).width(parentWidth).find('ul li').size() > 1 ? $icon.removeClass('hide') : $icon.addClass('hide'); $(this).width(parentWidth).find('ul li').size() > 1 ? $icon.removeClass('hide') : $icon.addClass('hide');});
});
/* 更新选择中状态 */ /* 更新选择中状态 */
$('.mobile-footer a.active').not(this.$btn.addClass('active')).removeClass('active'); $('.mobile-footer a.active').not(this.$btn.addClass('active')).removeClass('active');
this.renderEdit(); this.renderEdit();
return $ul; return $ul;};
};
/** /**
* 删除当前菜单 * 删除当前菜单
* @returns {undefined} * @returns {undefined}
@ -195,20 +182,15 @@
var $li = this.$btn.parent('li'), $ul = $li.parent('ul'); var $li = this.$btn.parent('li'), $ul = $li.parent('ul');
var $default = function () { var $default = function () {
if ($li.prev('li').size() > 0) { if ($li.prev('li').size() > 0) {
return $li.prev('li'); return $li.prev('li');}
}
if ($li.next('li').size() > 0 && !$li.next('li').hasClass('menu-add')) { if ($li.next('li').size() > 0 && !$li.next('li').hasClass('menu-add')) {
return $li.next('li'); return $li.next('li');}
}
if ($ul.parents('li.parent-menu').size() > 0) { if ($ul.parents('li.parent-menu').size() > 0) {
return $ul.parents('li.parent-menu'); return $ul.parents('li.parent-menu');}
} return $('null');}.call(this);
return $('null');
}.call(this);
$li.remove(); $li.remove();
this.$btn = $default.find('a:first'); this.$btn = $default.find('a:first');
this.checkShow(); this.checkShow();};
};
/** /**
* 显示当前菜单的属性值 * 显示当前菜单的属性值
* @returns {undefined} * @returns {undefined}
@ -219,14 +201,11 @@
if ($li.find('ul li').size() > 1) { /*父菜单*/ if ($li.find('ul li').size() > 1) { /*父菜单*/
$html = $($('.menu-editor-parent-tpl').html()); $html = $($('.menu-editor-parent-tpl').html());
$html.find('input[name="menu-name"]').val($span.text()).on('change keyup', function () { $html.find('input[name="menu-name"]').val($span.text()).on('change keyup', function () {
$span.text(this.value || ' '); $span.text(this.value || ' ');});
}); $('.menu-editor .menu-content').html($html);} else {
$('.menu-editor .menu-content').html($html);
} else {
$html = $($('.menu-editor-content-tpl').html()); $html = $($('.menu-editor-content-tpl').html());
$html.find('input[name="menu-name"]').val($span.text()).on('change keyup', function () { $html.find('input[name="menu-name"]').val($span.text()).on('change keyup', function () {
$span.text(this.value || ' '); $span.text(this.value || ' ');});
});
$('.menu-editor .menu-content').html($html); $('.menu-editor .menu-content').html($html);
var type = $span.attr('data-type') || 'text'; var type = $span.attr('data-type') || 'text';
$html.find('input[name="menu-type"]').on('click', function () { $html.find('input[name="menu-type"]').on('click', function () {
@ -248,27 +227,18 @@
'pic_sysphoto': '弹出系统拍照发图', 'pic_sysphoto': '弹出系统拍照发图',
'pic_photo_or_album': '弹出拍照或者相册发图', 'pic_photo_or_album': '弹出拍照或者相册发图',
'pic_weixin': '弹出微信相册发图器', 'pic_weixin': '弹出微信相册发图器',
'location_select': '弹出地理位置选择器' 'location_select': '弹出地理位置选择器'};
};
var select = [], tpl = '<div><label class="font-noraml"><input class="cuci-radio" name="content" type="radio" {checked} value="{value}"> {title}</label></div>'; var select = [], tpl = '<div><label class="font-noraml"><input class="cuci-radio" name="content" type="radio" {checked} value="{value}"> {title}</label></div>';
if (!(options[content] || false)) { if (!(options[content] || false)) {
content = 'scancode_push'; content = 'scancode_push';
$span.data('content', content); $span.data('content', content);}
}
for (var i in options) { for (var i in options) {
select.push(tpl.replace('{value}', i).replace('{title}', options[i]).replace('{checked}', (i === content) ? 'checked' : '')); select.push(tpl.replace('{value}', i).replace('{title}', options[i]).replace('{checked}', (i === content) ? 'checked' : ''));}
} return select.join('');}}.call(this);
return select.join('');
}
}.call(this);
var $html = $(html), $input = $html.find('input,textarea'); var $html = $(html), $input = $html.find('input,textarea');
$input.on('change keyup click', function () { $input.on('change keyup click', function () {
$span.data('content', $(this).val() || $(this).html()); $span.data('content', $(this).val() || $(this).html());});
}); $('.editor-content-input').html($html);}).filter('input[value="{type}"]'.replace('{type}', type)).trigger('click');}};
$('.editor-content-input').html($html);
}).filter('input[value="{type}"]'.replace('{type}', type)).trigger('click');
}
};
/** /**
* 提交数据 * 提交数据
* @returns {undefined} * @returns {undefined}
@ -281,8 +251,7 @@
menudata.name = $span.text(); menudata.name = $span.text();
menudata.type = $span.attr('data-type'); menudata.type = $span.attr('data-type');
menudata.content = $span.data('content') || ''; menudata.content = $span.data('content') || '';
return menudata; return menudata;}
}
$('li.parent-menu').map(function (index, item) { $('li.parent-menu').map(function (index, item) {
if (!$(item).hasClass('menu-add')) { if (!$(item).hasClass('menu-add')) {
@ -297,16 +266,11 @@
submenudata.index = (index + 1) + '' + (ii + 1); submenudata.index = (index + 1) + '' + (ii + 1);
submenudata.pindex = menudata.index; submenudata.pindex = menudata.index;
submenudata.sort = ii; submenudata.sort = ii;
data.push(submenudata); data.push(submenudata);});}});
}); $.form.load('{:url("$classuri/edit")}', {data: data}, 'POST');};
}
});
$.form.load('{:url("$classuri/edit")}', {data: data}, 'POST');
};
/** /**
* 实例菜单控件 * 实例菜单控件
*/ */
new menu(); new menu();});
});
</script> </script>
{/block} {/block}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name='content'} {block name='content'}
@ -115,13 +115,11 @@
var editDdata = {$vo.articles | default = [] | json_encode}; var editDdata = {$vo.articles | default = [] | json_encode};
for (var i in editDdata) { for (var i in editDdata) {
$('.news-item').eq(i).data('item', editDdata[i]); $('.news-item').eq(i).data('item', editDdata[i]);}
}
$('body').on('change', '.upload-image-box input', function () { $('body').on('change', '.upload-image-box input', function () {
$('.news-item.active').css('background-image', 'url(' + this.value + ')'); $('.news-item.active').css('background-image', 'url(' + this.value + ')');
$(this).parent('.upload-image-box').css('background-image', 'url(' + this.value + ')'); $(this).parent('.upload-image-box').css('background-image', 'url(' + this.value + ')');});
});
require(['ueditor'], function () { require(['ueditor'], function () {
@ -144,22 +142,17 @@
$form.submit(); $form.submit();
if (!syncEditor($('.news-item.active'))) { if (!syncEditor($('.news-item.active'))) {
editor.setContent('文章内容不能留空,请输入内容!'); editor.setContent('文章内容不能留空,请输入内容!');
return false; return false;}
}
$('.news-item').map(function () { $('.news-item').map(function () {
var item = $(this).data('item'); var item = $(this).data('item');
item.content = item.content || '文章内容不能留空,请输入内容!'; item.content = item.content || '文章内容不能留空,请输入内容!';
data.push(item); data.push(item);});
}); $.form.load('__SELF__', {data: data}, "post");});
$.form.load('__SELF__', {data: data}, "post");
});
/*! 输入标题显示 */ /*! 输入标题显示 */
$form.find('[name="title"]').on('keyup', function () { $form.find('[name="title"]').on('keyup', function () {
if ($item) { if ($item) {
$item.find('.news-title').html(this.value).show(); $item.find('.news-title').html(this.value).show();}});
}
});
/*! 同步编辑器 */ /*! 同步编辑器 */
function syncEditor($pItem) { function syncEditor($pItem) {
@ -176,11 +169,8 @@
if ($form.find('input.validate-error').size() > 0 || data.content.length < 1) { if ($form.find('input.validate-error').size() > 0 || data.content.length < 1) {
((data.content || '').length < 1) && editor.setContent('文章内容不能留空,请输入内容!'); ((data.content || '').length < 1) && editor.setContent('文章内容不能留空,请输入内容!');
$pItem.addClass('active').siblings().removeClass('active'); $pItem.addClass('active').siblings().removeClass('active');
return false; return false;}}
} return true;}
}
return true;
}
/*! 显示编辑器 */ /*! 显示编辑器 */
function showEditor() { function showEditor() {
@ -193,60 +183,46 @@
data.content = data.content || ''; data.content = data.content || '';
data.author = data.author || ''; data.author = data.author || '';
data.show_cover_pic = data.show_cover_pic || 0; data.show_cover_pic = data.show_cover_pic || 0;
return data; return data;};
};
// 重置表单 // 重置表单
$form.get(0).reset(); $form.get(0).reset();
// 获取当前数据 // 获取当前数据
var data = this.get(); var data = this.get();
for (var i in data) { for (var i in data) {
if (i !== 'content' && i !== 'show_cover_pic') { if (i !== 'content' && i !== 'show_cover_pic') {
$form.find('[name="' + i + '"]').val(data[i]).trigger('change'); $form.find('[name="' + i + '"]').val(data[i]).trigger('change');}}
}
}
if (parseInt(data.show_cover_pic) === 1) { if (parseInt(data.show_cover_pic) === 1) {
$form.find('[name="show_cover_pic"]').get(0).checked = true; $form.find('[name="show_cover_pic"]').get(0).checked = true;}
} editor.setContent(data.content);}
editor.setContent(data.content);
}
/*! 添加新图文 */ /*! 添加新图文 */
$body.off('click', '.news-box .article-add').on('click', '.news-box .article-add', function () { $body.off('click', '.news-box .article-add').on('click', '.news-box .article-add', function () {
var $html = $('<div class="news-item transition" style="background-image:url(__PUBLIC__/static/plugs/uploader/theme/image.png)"><span class="news-title"></span></div><hr />'); var $html = $('<div class="news-item transition" style="background-image:url(__PUBLIC__/static/plugs/uploader/theme/image.png)"><span class="news-title"></span></div><hr />');
$html.insertBefore(this).trigger('click'); $html.insertBefore(this).trigger('click');
$('.news-item').size() >= 7 && $(this).hide(); $('.news-item').size() >= 7 && $(this).hide();});
});
/*! 列表选择 */ /*! 列表选择 */
$body.off('click', '.news-item').on('click', '.news-item', function () { $body.off('click', '.news-item').on('click', '.news-item', function () {
if (syncEditor($('.news-item.active'))) { if (syncEditor($('.news-item.active'))) {
$(this).addClass('active').siblings().removeClass('active'); $(this).addClass('active').siblings().removeClass('active');
showEditor($item); showEditor($item);}});
}
});
/*! 隐藏删除按钮 */ /*! 隐藏删除按钮 */
$body.off('mouseleave').on('mouseleave', '.news-item', function () { $body.off('mouseleave').on('mouseleave', '.news-item', function () {
$(this).find('.upload-multiple-close').addClass('hide'); $(this).find('.upload-multiple-close').addClass('hide');});
});
/*! 显示删除按钮 */ /*! 显示删除按钮 */
$body.off('mouseenter', '.news-item').on('mouseenter', '.news-item', function () { $body.off('mouseenter', '.news-item').on('mouseenter', '.news-item', function () {
$('.upload-multiple-close').addClass('hide'); $('.upload-multiple-close').addClass('hide');
$(this).find('.upload-multiple-close').removeClass('hide'); $(this).find('.upload-multiple-close').removeClass('hide');});
});
/*! 删除操作图文 */ /*! 删除操作图文 */
$body.off('click', '.upload-multiple-close').on('click', '.upload-multiple-close', function () { $body.off('click', '.upload-multiple-close').on('click', '.upload-multiple-close', function () {
$(this).parents('.news-item').remove(); $(this).parents('.news-item').remove();
$('.news-item').size() < 7 && $('.news-box .article-add').show(); $('.news-item').size() < 7 && $('.news-box .article-add').show();});
});
/*! 默认显示第一个 */ /*! 默认显示第一个 */
$('.news-box .news-item:first').trigger('click'); $('.news-box .news-item:first').trigger('click');});});});
});
});
});
</script> </script>
{/block} {/block}

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
<div class="nowrap pull-right" style="margin-top:10px"> <div class="nowrap pull-right" style="margin-top:10px">
@ -42,10 +42,8 @@
<script> <script>
$('body').on('mouseenter', '.news_item', function () { $('body').on('mouseenter', '.news_item', function () {
$(this).find('.news_tools').removeClass('hide'); $(this).find('.news_tools').removeClass('hide');}).on('mouseleave', '.news_item', function () {
}).on('mouseleave', '.news_item', function () { $(this).find('.news_tools').addClass('hide');});
$(this).find('.news_tools').addClass('hide');
});
require(['jquery.masonry'], function (Masonry) { require(['jquery.masonry'], function (Masonry) {
var container = document.querySelector('#news_box'); var container = document.querySelector('#news_box');
@ -58,13 +56,8 @@
if (ret.code) { if (ret.code) {
$(self).parents('.news_item').remove(); $(self).parents('.news_item').remove();
msnry.layout(); msnry.layout();
return $.msg.success(ret.msg), false; return $.msg.success(ret.msg), false;}
} return $.msg.error(ret.msg), false;});});});});
return $.msg.error(ret.msg), false;
});
});
});
});
</script> </script>
{/block} {/block}

View File

@ -27,7 +27,7 @@
<script id="push" type="text/template"> <script id="push" type="text/template">
{{if data}} {{if data}}
{{each data as value key}} {{each data as value key}}
{{if key <= 200 }} {{if key <= 200}}
<label>{{value}}</label> <label>{{value}}</label>
{{/if}} {{/if}}
{{/each}} {{/each}}
@ -46,40 +46,30 @@
var check_status = check_checked(); var check_status = check_checked();
/*重置和全选数据变化处理*/ /*重置和全选数据变化处理*/
$('input[name*=fans_tags]').map(function () { $('input[name*=fans_tags]').map(function () {
this.checked = !check_status; this.checked = !check_status;});
});
check_checked(); check_checked();
postpush(); postpush();});
});
/*重置和全选的效果处理*/ /*重置和全选的效果处理*/
function check_checked() { function check_checked() {
var allcheck = true; var allcheck = true;
$('input[name*=fans_tags]').map(function () { $('input[name*=fans_tags]').map(function () {
(!this.checked) && (allcheck = false); (!this.checked) && (allcheck = false);});
}); return ((allcheck) ? $allbtn.html('重置') : $allbtn.html('全选')), allcheck;}
return ((allcheck) ? $allbtn.html('重置') : $allbtn.html('全选')), allcheck;
}
/*点击每一个选项都触发事件*/ /*点击每一个选项都触发事件*/
$('input[name*=fans_tags]').on('click', function () { $('input[name*=fans_tags]').on('click', function () {
check_checked(); check_checked();
postpush(); postpush();});
});
/*数据异步获取并显示出来*/ /*数据异步获取并显示出来*/
function postpush() { function postpush() {
var inp = $('input[name*=fans_tags]'); var inp = $('input[name*=fans_tags]');
var group = []; var group = [];
for (var i = 0; i < inp.length; i++) { for (var i = 0; i < inp.length; i++) {
if (inp[i].checked === true) { if (inp[i].checked === true) {
group.push(inp[i].value); group.push(inp[i].value);}}
}
}
$.post("{:url('wechat/news/push')}?action=getuser", {group: group.join(',')}, function (ret) { $.post("{:url('wechat/news/push')}?action=getuser", {group: group.join(',')}, function (ret) {
var html = template('push', ret); var html = template('push', ret);
document.getElementById('push-tags').innerHTML = html; document.getElementById('push-tags').innerHTML = html;});}});
});
}
});
</script> </script>
</div> </div>
<div id='push-tags' class="list-item"></div> <div id='push-tags' class="list-item"></div>
@ -94,18 +84,18 @@
</form> </form>
<style> <style>
body { min-width: 500px } body { min-width: 500px}
#push-tags{height:300px;overflow:auto} #push-tags{height:300px;overflow:auto}
.bottom-btn { display: block; background: #F7F7F7; padding: 10px; position: absolute; position: fixed; bottom: 0; width: 100% } .bottom-btn { display: block; background: #F7F7F7; padding: 10px; position: absolute; position: fixed; bottom: 0; width: 100%}
.news-container { width: 200px; padding-right: 8px } .news-container { width: 200px; padding-right: 8px}
.list-container { width: 578px; padding-right: 8px; padding-left: 0 } .list-container { width: 578px; padding-right: 8px; padding-left: 0}
.list-container h5 a { font-size: 12px; float: right } .list-container h5 a { font-size: 12px; float: right}
.list-container .list-item { border: 1px solid #eee; padding: 8px } .list-container .list-item { border: 1px solid #eee; padding: 8px}
.list-container .list-item:after { content: ''; display: block; clear: both; width: 100% } .list-container .list-item:after { content: ''; display: block; clear: both; width: 100%}
.list-container .list-item label { display: block; width: 25%; float: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis } .list-container .list-item label { display: block; width: 25%; float: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis}
.news-container .news-box { border: 1px solid #eee; padding: 8px } .news-container .news-box { border: 1px solid #eee; padding: 8px}
.news-container .news-box hr { margin: 4px } .news-container .news-box hr { margin: 4px}
.news-container .news-box .news-item { position: relative; border: 1px solid #cecece; border-radius: 2px; overflow: hidden; cursor: pointer } .news-container .news-box .news-item { position: relative; border: 1px solid #cecece; border-radius: 2px; overflow: hidden; cursor: pointer}
.news-container .news-box .news-image {background-position:center center;background-size:100%;height:90px} .news-container .news-box .news-image {background-position:center center;background-size:100%;height:90px}
.news-container .news-box .news-title { position: absolute; background: rgba(0, 0, 0, 0.5); color: #fff; padding: 2px; margin: 0; bottom: 0; left: 0; right: 0; text-align: right; white-space: nowrap; text-overflow: ellipsis; overflow: hidden } .news-container .news-box .news-title { position: absolute; background: rgba(0, 0, 0, 0.5); color: #fff; padding: 2px; margin: 0; bottom: 0; left: 0; right: 0; text-align: right; white-space: nowrap; text-overflow: ellipsis; overflow: hidden}
</style> </style>

View File

@ -170,9 +170,7 @@
<script> <script>
$(function () { $(function () {
$('[data-href]').on('click', function () { $('[data-href]').on('click', function () {
window.location.href = this.getAttribute('data-href'); window.location.href = this.getAttribute('data-href');});});
});
});
</script> </script>
{/if} {/if}
</body> </body>

View File

@ -1,4 +1,4 @@
{extend name='extra@admin/content' /} {extend name='extra@admin/content'}
{block name="button"} {block name="button"}
<div class="nowrap pull-right" style="margin-top:10px"> <div class="nowrap pull-right" style="margin-top:10px">