作者 Karson

前台采用RequireJS加载

修复压缩打包的BUG
移除无关的冗余数据
... ... @@ -4,9 +4,7 @@
<link rel="shortcut icon" href="__CDN__/assets/img/favicon.ico" />
<!-- Loading Bootstrap -->
<link href="__CDN__/assets/build/backend.css?v={$Think.config.site.version}" rel="stylesheet">
<link rel="shortcut icon" href="__CDN__/assets/img/favicon.ico">
<link href="__CDN__/assets/{$Think.config.app_debug?'build/backend':'css/backend.min'}.css?v={$Think.config.site.version}" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
<!--[if lt IE 9]>
... ...
<script src="__CDN__/assets/js/require.js" data-main="__CDN__/assets/js/require-backend.js?v={$site.version}"></script>
\ No newline at end of file
<script src="__CDN__/assets/js/require.js" data-main="__CDN__/assets/js/require-backend{$Think.config.app_debug?'':'.min'}.js?v={$site.version}"></script>
\ No newline at end of file
... ...
... ... @@ -3,14 +3,17 @@
namespace app\common\controller;
use app\common\library\Auth;
use app\common\model\Configvalue;
use think\Config;
use think\Controller;
use think\Lang;
class Frontend extends Controller
{
/**
*
* @var \app\common\library\Auth
* @var Auth
*/
protected $user = null;
... ... @@ -44,6 +47,25 @@ class Frontend extends Controller
{
$this->view->engine->layout('layout/' . $this->layout);
}
// 语言检测
$lang = Lang::detect();
// 配置信息
$config = [
'site' => Config::get("site"),
'upload' => Configvalue::upload(),
'modulename' => $modulename,
'controllername' => $controllername,
'actionname' => $actionname,
'jsname' => 'frontend/' . str_replace('.', '/', $controllername),
'subdomain' => 0,
'language' => $lang
];
Lang::load(APP_PATH . $modulename . '/lang/' . $lang . '/' . str_replace('.', '/', $controllername) . '.php');
$this->assign('site', Config::get("site"));
$this->assign('config', $config);
}
}
... ...
... ... @@ -1643,147 +1643,4 @@
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
//Popover & Tooltip
$('.bs-component [data-toggle="popover"]').popover();
$('.bs-component [data-toggle="tooltip"]').tooltip();
//Toastr
var i = -1;
var toastCount = 0;
var $toastlast;
var getMessage = function () {
var msgs = ['My name is Inigo Montoya. You killed my father. Prepare to die!',
'<div><input class="input-small" value="textbox"/>&nbsp;<a href="http://johnpapa.net" target="_blank">This is a hyperlink</a></div><div><button type="button" id="okBtn" class="btn btn-primary">Close me</button><button type="button" id="surpriseBtn" class="btn" style="margin: 0 8px 0 8px">Surprise me</button></div>',
'Are you the six fingered man?',
'Inconceivable!',
'I do not think that means what you think it means.',
'Have fun storming the castle!'
];
i++;
if (i === msgs.length) {
i = 0;
}
return msgs[i];
};
$('#showtoast').click(function () {
var shortCutFunction = $("#toastTypeGroup input:radio:checked").val();
var msg = $('#message').val();
var title = $('#title').val() || '';
var $showDuration = $('#showDuration');
var $hideDuration = $('#hideDuration');
var $timeOut = $('#timeOut');
var $extendedTimeOut = $('#extendedTimeOut');
var $showEasing = $('#showEasing');
var $hideEasing = $('#hideEasing');
var $showMethod = $('#showMethod');
var $hideMethod = $('#hideMethod');
var toastIndex = toastCount++;
toastr.options = {
closeButton: $('#closeButton').prop('checked'),
debug: $('#debugInfo').prop('checked'),
positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right',
onclick: null
};
if ($('#addBehaviorOnToastClick').prop('checked')) {
toastr.options.onclick = function () {
alert('You can perform some custom action after a toast goes away');
};
}
if ($showDuration.val().length) {
toastr.options.showDuration = $showDuration.val();
}
if ($hideDuration.val().length) {
toastr.options.hideDuration = $hideDuration.val();
}
if ($timeOut.val().length) {
toastr.options.timeOut = $timeOut.val();
}
if ($extendedTimeOut.val().length) {
toastr.options.extendedTimeOut = $extendedTimeOut.val();
}
if ($showEasing.val().length) {
toastr.options.showEasing = $showEasing.val();
}
if ($hideEasing.val().length) {
toastr.options.hideEasing = $hideEasing.val();
}
if ($showMethod.val().length) {
toastr.options.showMethod = $showMethod.val();
}
if ($hideMethod.val().length) {
toastr.options.hideMethod = $hideMethod.val();
}
if (!msg) {
msg = getMessage();
}
$("#toastrOptions").text("Command: toastr["
+ shortCutFunction
+ "](\""
+ msg
+ (title ? "\", \"" + title : '')
+ "\")\n\ntoastr.options = "
+ JSON.stringify(toastr.options, null, 2)
);
var $toast = toastr[shortCutFunction](msg, title); // Wire up an event handler to a button in the toast, if it exists
$toastlast = $toast;
if ($toast.find('#okBtn').length) {
$toast.delegate('#okBtn', 'click', function () {
alert('you clicked me. i was toast #' + toastIndex + '. goodbye!');
$toast.remove();
});
}
if ($toast.find('#surpriseBtn').length) {
$toast.delegate('#surpriseBtn', 'click', function () {
alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.');
});
}
});
function getLastToast() {
return $toastlast;
}
$('#clearlasttoast').click(function () {
toastr.clear(getLastToast());
});
$('#cleartoasts').click(function () {
toastr.clear();
});
$(document).on("click", "#dialog-normal", function () {
BootstrapDialog.show({
title: 'Say-hello dialog',
message: 'Hi Apple!'
});
});
$(document).on("click", "#dialog-alert", function () {
BootstrapDialog.alert('Hi Apple!');
});
$(document).on("click", "#dialog-confirm", function () {
BootstrapDialog.confirm('Hi Apple, are you sure?', function (result) {
if (result) {
alert('Yup.');
} else {
alert('Nope.');
}
});
});
});
</script>
\ No newline at end of file
</div>
\ No newline at end of file
... ...
... ... @@ -146,13 +146,4 @@
</form>
</div>
<img src="" alt="" id='qrcodeimg' />
</div>
<script>
$(function () {
$("form").submit(function () {
$("#qrcodeimg").prop("src", "{:url('demo/qrcode')}?" + $(this).serialize());
return false;
});
$("form").trigger('submit');
});
</script>
\ No newline at end of file
</div>
\ No newline at end of file
... ...
... ... @@ -6,29 +6,26 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="基于ThinkPHP5和Bootstrap的极速后台开发系统">
<link rel="shortcut icon" href="__CDN__/assets/img/favicon.ico" />
<link href="__CDN__/assets/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
<link href="__CDN__/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="__CDN__/assets/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="__CDN__/assets/libs/bootstrap3-dialog/dist/css/bootstrap-dialog.css" rel="stylesheet" type="text/css"/>
<!-- Loading Bootstrap -->
<link href="__CDN__/assets/{$Think.config.app_debug?'build/frontend':'css/frontend.min'}.css?v={$Think.config.site.version}" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
var require = {
config: {
'config': {$config|json_encode}
}
};
</script>
<style>
html{height:100%;overflow:auto;-webkit-overflow-scrolling: touch;}
body{padding:70px 0;}
</style>
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js" type="text/javascript"></script>
<script src="__CDN__/assets/libs/bootstrap/dist/js/bootstrap.min.js" type="text/javascript"></script>
<script src="__CDN__/assets/libs/bootstrap3-dialog/dist/js/bootstrap-dialog.min.js" type="text/javascript"></script>
<!--script>
var less=less || {};
less.env='development';
</script-->
<script src="__CDN__/assets/libs/less/dist/less.min.js" type="text/javascript"></script>
<script>
var _hmt = _hmt || [];
(function () {
... ... @@ -64,5 +61,6 @@
{__CONTENT__}
<script src="__CDN__/assets/js/require.js" data-main="__CDN__/assets/js/require-frontend{$Think.config.app_debug?'':'.min'}.js?v={$site.version}"></script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@
optimize: 'none',
removeCombined: false,
name: "require-backend",
include: ['css', 'layer', 'toastr', 'frontend', 'table', 'form', 'dragsort', 'drag', 'drop', 'addtabs'],
include: ['css', 'layer', 'toastr', 'backend', 'table', 'form', 'dragsort', 'drag', 'drop', 'addtabs'],
out: "../js/require-backend.min.js",
packages: [{
name: 'moment',
... ... @@ -52,7 +52,7 @@
'summernote': '../libs/summernote/dist/lang/summernote-zh-CN.min',
'validator': '../libs/nice-validator/dist/local/zh-CN',
'plupload': '../libs/plupload/js/plupload.min',
'toastr': '../libs/toastr/toastr.min',
'toastr': '../libs/toastr/toastr',
'jstree': '../libs/jstree/dist/jstree.min',
'layer': '../libs/layer/src/layer',
'echarts': '../libs/echarts/dist/echarts.min',
... ...
... ... @@ -52,7 +52,7 @@
'summernote': '../libs/summernote/dist/lang/summernote-zh-CN.min',
'validator': '../libs/nice-validator/dist/local/zh-CN',
'plupload': '../libs/plupload/js/plupload.min',
'toastr': '../libs/toastr/toastr.min',
'toastr': '../libs/toastr/toastr',
'jstree': '../libs/jstree/dist/jstree.min',
'layer': '../libs/layer/src/layer',
'echarts': '../libs/echarts/dist/echarts.min',
... ...
body {
background: #f1f4f6;
}
.selection {
position: absolute;
border: 1px solid #8B9;
background-color: #BEC;
}
.note-dialog .modal {
z-index: 1060;
}
.bootstrap-dialog .modal-dialog {
/*width: 70%;*/
max-width: 885px;
}
#header {
background: #fff;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(0, 0, 0, 0.05);
}
.content-wrapper {
position: relative;
}
.tab-addtabs {
overflow: hidden;
}
.tab-addtabs .tab-pane {
height: 100%;
width: 100%;
}
/*
* RIBBON
*/
#ribbon {
overflow: hidden;
padding: 15px 15px 0 15px;
position: relative;
}
#ribbon a {
color: #777 !important;
text-decoration: none !important;
}
#ribbon .breadcrumb {
display: inline-block;
margin: 0;
padding: 0;
background: none;
vertical-align: top;
}
#ribbon .breadcrumb > .active,
#ribbon .breadcrumb li:last-child {
color: #aaa;
}
#ribbon .shortcut a {
margin-left: 10px;
}
.is-dialog #main {
background: #fff;
}
.is-dialog form label {
font-weight: normal;
}
/*panel扩展描述样式*/
.panel-intro {
margin-bottom: 0;
border: none;
}
.panel-intro .panel-heading {
padding: 15px;
padding-bottom: 0;
background: #e8edf0;
border-color: #e8edf0;
position: relative;
}
.panel-intro .panel-heading .panel-lead {
margin-bottom: 15px;
}
.panel-intro .panel-heading .panel-lead em {
display: block;
font-weight: bold;
font-style: normal;
}
.panel-intro .panel-heading .panel-title {
height: 25px;
font-weight: normal;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.panel-intro .panel-heading .panel-control {
height: 42px;
position: absolute;
top: 8px;
right: 8px;
}
.panel-intro .panel-heading .panel-control .fa {
font-size: 14px;
}
.panel-intro .panel-heading .nav-tabs {
border-bottom: 0;
margin-bottom: 0;
}
.panel-intro .panel-heading .nav-tabs > li > a {
margin-right: 4px;
color: #95a5a6;
background-color: #d8e0e6;
border: 1px solid #e8edf0;
border-bottom-color: transparent;
}
.panel-intro .panel-heading .nav-tabs > li > a:hover,
.panel-intro .panel-heading .nav-tabs > li > a:focus {
border: 1px solid #e8edf0;
color: #7b8a8b;
background-color: #c9d4dc;
}
.panel-intro .panel-heading .nav-tabs > li.active > a,
.panel-intro .panel-heading .nav-tabs > li.active > a:hover,
.panel-intro .panel-heading .nav-tabs > li.active > a:focus {
color: #7b8a8b;
background-color: #ffffff;
border-bottom-color: transparent;
cursor: default;
}
/*单表格*/
.panel-tabs .panel-heading {
padding: 12px 15px 12px 15px;
}
.panel-tabs .panel-heading .panel-lead {
margin-bottom: 0px;
}
/*选项卡*/
.panel-nav .panel-heading {
padding: 0px;
padding-bottom: 0;
background: #f1f4f6;
border-color: #f1f4f6;
}
.panel-nav .nav-tabs > li > a {
padding: 12px 15px;
background-color: #e8edf0;
border: 1px solid #f1f4f6;
}
.panel-nav .nav-tabs > li > a:hover,
.panel-nav .nav-tabs > li > a:focus {
border: 1px solid #e8edf0;
background-color: #e8edf0;
}
.panel-nav .nav-tabs > li.active > a,
.panel-nav .nav-tabs > li.active > a:hover,
.panel-nav .nav-tabs > li.active > a:focus {
border-color: #f1f4f6;
border-bottom-color: transparent;
}
/*顶栏addtabs*/
.nav-addtabs {
border: none;
}
.nav-addtabs > li {
margin: 0;
}
.nav-addtabs > li > a {
height: 49px;
line-height: 49px;
padding: 0 15px;
border-radius: 0;
border: none;
border-right: 1px solid rgba(0, 0, 0, 0.05);
margin: 0;
color: #95a5a6;
}
.nav-addtabs > li > a:hover,
.nav-addtabs > li > a:focus {
border: none;
color: #2c3e50;
border-right: 1px solid rgba(0, 0, 0, 0.05);
}
.nav-addtabs > li > a i {
margin-right: 3px;
}
.nav-addtabs > li.active > a {
height: 49px;
line-height: 49px;
padding: 0 15px;
border-radius: 0;
border: none;
border-right: 1px solid rgba(0, 0, 0, 0.05);
background: #f1f4f6;
color: #2c3e50;
overflow: hidden;
}
.nav-addtabs > li.active > a:hover,
.nav-addtabs > li.active > a:focus {
border: none;
color: #2c3e50;
border-right: 1px solid rgba(0, 0, 0, 0.05);
background: #f1f4f6;
}
.nav-addtabs > li .close-tab {
font-size: 10px;
position: absolute;
right: 5px;
top: 50%;
margin-top: -7px;
z-index: 100;
cursor: hand;
cursor: pointer;
color: #fff;
display: none;
}
.nav-addtabs .open > a:hover,
.nav-addtabs .open > a:focus {
border-right: 1px solid rgba(0, 0, 0, 0.05);
}
.nav-addtabs ul li {
position: relative;
}
.nav-addtabs li:hover > .close-tab {
display: block;
}
#treeview .jstree-container-ul .jstree-node {
display: block;
clear: both;
}
#treeview .jstree-leaf:not(:first-child) {
float: left;
background: none;
margin-left: 0;
width: 80px;
clear: none;
color: #BBBDC3;
}
#treeview .jstree-leaf {
float: left;
margin-left: 0;
padding-left: 24px;
width: 80px;
clear: none;
color: #ccc;
}
#treeview .jstree-leaf > .jstree-icon,
#treeview .jstree-leaf .jstree-themeicon {
display: none;
}
#treeview .jstree-last {
background-image: url("../img/32px.png");
background-position: -292px -4px;
background-repeat: repeat-y;
}
#treeview .jstree-children:before,
#treeview .jstree-children:after {
content: " ";
display: table;
}
#treeview .jstree-children:after {
clear: both;
}
#treeview .jstree-children:before,
#treeview .jstree-children:after {
content: " ";
display: table;
}
#treeview .jstree-children:after {
clear: both;
}
#treeview .jstree-themeicon {
display: none;
}
/*去除bootstrap-table的边框*/
.fixed-table-container {
border: none!important;
}
.pjax-loader-bar .progress {
position: fixed;
top: 0;
left: 0;
height: 2px;
background: #77b6ff;
box-shadow: 0 0 10px rgba(119, 182, 255, 0.7);
-webkit-transition: width 0.4s ease;
transition: width 0.4s ease;
}
.dropdown-menu.text-left a,
.dropdown-menu.text-left li {
text-align: left!important;
}
.bootstrap-table .fixed-table-toolbar .dropdown-menu {
overflow: visible;
}
.bootstrap-table table tbody tr:first-child td .bs-checkbox {
vertical-align: middle;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu > .dropdown-menu {
overflow: auto;
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
-webkit-border-radius: 0 6px 6px 6px;
-webkit-background-clip: padding-box;
-moz-border-radius: 0 6px 6px 6px;
-moz-background-clip: padding;
border-radius: 0 6px 6px 6px;
background-clip: padding-box;
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
}
.dropdown-submenu:hover > a:after {
border-left-color: #fff;
}
.dropdown-submenu > a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left > .dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-webkit-background-clip: padding-box;
-moz-border-radius: 6px 0 6px 6px;
-moz-background-clip: padding;
border-radius: 6px 0 6px 6px;
background-clip: padding-box;
}
/*重写toast的几个背景色*/
.toast-primary {
background-color: #48c9b0!important;
}
.toast-success {
background-color: #2ecc71!important;
}
.toast-error {
background-color: #e74c3c!important;
}
.toast-info {
background-color: #5dade2!important;
}
.toast-warning {
background-color: #f1c40f!important;
}
.toast-inverse {
background-color: #34495e!important;
}
.toast-default {
background-color: #bdc3c7!important;
}
.layui-layer-title {
background: #2c3e50!important;
color: #fff!important;
}
/*避免出现多滚动条*/
.layui-layer-noborder {
border: none!important;
box-shadow: 1px 1px 50px rgba(0, 0, 0, 0.3) !important;
}
.layui-layer-moves {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.layui-layer-iframe {
overflow: hidden!important;
}
.layui-layer-iframe .layui-layer-content {
-webkit-overflow-scrolling: touch;
overflow-y: hidden!important;
overflow: hidden;
}
/*自定义底部灰色操作区*/
.layui-layer-btn {
text-align: center!important;
padding: 10px!important;
background: #ecf0f1;
}
.layui-layer-footer {
padding: 8px 20px;
background-color: #ecf0f1;
height: auto;
text-align: inherit!important;
}
.layui-layer-btn a {
background-color: #95a5a6!important;
border-color: #95a5a6!important;
color: #fff!important;
}
.layui-layer-btn .layui-layer-btn0 {
background-color: #18bc9c!important;
border-color: #18bc9c!important;
}
.layui-layer-setwin {
top: 10px!important;
}
.layui-layer-setwin > a {
background: none!important;
}
.layui-layer-setwin > a cite {
display: none;
}
.layui-layer-setwin > a:after {
content: "\e625";
font-family: iconfont;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
position: absolute;
font-size: 18px;
color: #fff;
margin: 0;
z-index: 1;
}
.layui-layer-setwin > a:hover {
text-decoration: none!important;
background: none!important;
}
.layui-layer-setwin > a:focus {
text-decoration: none!important;
}
.layui-layer-setwin .layui-layer-min:after {
content: "\e625";
}
.layui-layer-setwin .layui-layer-max:after {
content: "\e623";
}
.layui-layer-setwin .layui-layer-maxmin:after {
content: "\e624";
}
.layui-layer-setwin .layui-layer-close1:after {
content: "\e626";
}
/*手机版样式*/
@media (max-width: 480px) {
.nav-addtabs {
display: none;
}
}
/*平板样式*/
/*# sourceMappingURL=frontend-func.css.map */
\ No newline at end of file
body {
background: #ecf0f5;
}
.info-box {
z-index: 2;
}
.tips .col-xs-12 {
position: relative;
}
.headline {
color: #fff;
position: absolute;
top: -115px;
right: 10px;
z-index: -1;
font-size: 120px;
font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
/* transform: rotate(90deg);
-webkit-transform: rotate(90deg);*/
}
.error-content p {
margin-bottom: 0;
}
h3 {
margin-top: 10px;
}
.tips {
float: none;
display: block;
margin: 150px auto;
max-width: 500px;
}
.tips .box {
padding: 19px 25px;
-webkit-box-shadow: none;
box-shadow: none;
}
.tips .media-left > span {
line-height: 1.72222;
}
.tips .media-left span {
font-size: 80px;
margin: 0 10px 0 0;
}
.tips .media-left span.fa-info-circle {
color: #5dade2;
}
.tips .media-left span.fa-times-circle {
color: #ec7063;
}
.tips .media-left span.fa-check-circle {
color: #1abc9c;
}
.tips .media-body {
margin-top: 25px;
}
.tips .media-body p {
margin-bottom: 10px;
}
.tips .media-heading {
margin: 15px 0 15px 0;
line-height: 30px;
font-weight: 400;
}
/*# sourceMappingURL=tips.min.css.map */
\ No newline at end of file
define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config', 'validator', 'adminlte'], function ($, undefined, Toastr, Layer, Lang, Config, undefined, AdminLTE) {
define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang', 'config'], function ($, undefined, Toastr, Layer, Lang, Config) {
var Backend = {
config: {
//toastr默认配置
... ...
define(['jquery', 'bootstrap', 'frontend', 'config'], function ($, undefined, Frontend, Config) {
var Controller = {
qrcode: function () {
$("form").submit(function () {
$("#qrcodeimg").prop("src", (Config.subdomain == "1" ? '' : '/index') + "/demo/qrcode?" + $(this).serialize());
return false;
});
$("form").trigger('submit');
},
bootstrap: function () {
//Popover & Tooltip
$('.bs-component [data-toggle="popover"]').popover();
$('.bs-component [data-toggle="tooltip"]').tooltip();
//Toastr
var i = -1;
var toastCount = 0;
var $toastlast;
var getMessage = function () {
var msgs = ['My name is Inigo Montoya. You killed my father. Prepare to die!',
'<div><input class="input-small" value="textbox"/>&nbsp;<a href="http://johnpapa.net" target="_blank">This is a hyperlink</a></div><div><button type="button" id="okBtn" class="btn btn-primary">Close me</button><button type="button" id="surpriseBtn" class="btn" style="margin: 0 8px 0 8px">Surprise me</button></div>',
'Are you the six fingered man?',
'Inconceivable!',
'I do not think that means what you think it means.',
'Have fun storming the castle!'
];
i++;
if (i === msgs.length) {
i = 0;
}
return msgs[i];
};
$('#showtoast').click(function () {
var shortCutFunction = $("#toastTypeGroup input:radio:checked").val();
var msg = $('#message').val();
var title = $('#title').val() || '';
var $showDuration = $('#showDuration');
var $hideDuration = $('#hideDuration');
var $timeOut = $('#timeOut');
var $extendedTimeOut = $('#extendedTimeOut');
var $showEasing = $('#showEasing');
var $hideEasing = $('#hideEasing');
var $showMethod = $('#showMethod');
var $hideMethod = $('#hideMethod');
var toastIndex = toastCount++;
Toastr.options = {
closeButton: $('#closeButton').prop('checked'),
debug: $('#debugInfo').prop('checked'),
positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right',
onclick: null
};
if ($('#addBehaviorOnToastClick').prop('checked')) {
Toastr.options.onclick = function () {
alert('You can perform some custom action after a toast goes away');
};
}
if ($showDuration.val().length) {
Toastr.options.showDuration = $showDuration.val();
}
if ($hideDuration.val().length) {
Toastr.options.hideDuration = $hideDuration.val();
}
if ($timeOut.val().length) {
Toastr.options.timeOut = $timeOut.val();
}
if ($extendedTimeOut.val().length) {
Toastr.options.extendedTimeOut = $extendedTimeOut.val();
}
if ($showEasing.val().length) {
Toastr.options.showEasing = $showEasing.val();
}
if ($hideEasing.val().length) {
Toastr.options.hideEasing = $hideEasing.val();
}
if ($showMethod.val().length) {
Toastr.options.showMethod = $showMethod.val();
}
if ($hideMethod.val().length) {
Toastr.options.hideMethod = $hideMethod.val();
}
if (!msg) {
msg = getMessage();
}
$("#toastrOptions").text("Command: toastr["
+ shortCutFunction
+ "](\""
+ msg
+ (title ? "\", \"" + title : '')
+ "\")\n\nToastr.options = "
+ JSON.stringify(Toastr.options, null, 2)
);
var $toast = Toastr[shortCutFunction](msg, title); // Wire up an event handler to a button in the toast, if it exists
$toastlast = $toast;
if ($toast.find('#okBtn').length) {
$toast.delegate('#okBtn', 'click', function () {
alert('you clicked me. i was toast #' + toastIndex + '. goodbye!');
$toast.remove();
});
}
if ($toast.find('#surpriseBtn').length) {
$toast.delegate('#surpriseBtn', 'click', function () {
alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.');
});
}
});
function getLastToast() {
return $toastlast;
}
$('#clearlasttoast').click(function () {
Toastr.clear(getLastToast());
});
$('#cleartoasts').click(function () {
Toastr.clear();
});
$(document).on("click", "#dialog-normal", function () {
BootstrapDialog.show({
title: 'Say-hello dialog',
message: 'Hi Apple!'
});
});
$(document).on("click", "#dialog-alert", function () {
BootstrapDialog.alert('Hi Apple!');
});
$(document).on("click", "#dialog-confirm", function () {
BootstrapDialog.confirm('Hi Apple, are you sure?', function (result) {
if (result) {
alert('Yup.');
} else {
alert('Nope.');
}
});
});
},
};
return Controller;
});
\ No newline at end of file
... ...
define(['jquery', 'bootstrap', 'frontend', 'frontend-ebook', 'layer', 'config'], function ($, undefined, Frontend, Ebook, Layer, Config) {
Ebook.setupMonthNav();
Ebook.setupFunctionNav();
Ebook.setupPlayWXVideo();
var Controller = {
index: function () {
},
buynow: function () {
var pagecount = parseInt($("#pageCount").text()) + 1;
var nums = Math.max(1, parseInt($('#nums').val()));
var amount = 0;
var get_amount = function () {
if ($('#printtype').val() == 'fourcolor')
{
amount = pagecount * parseFloat(Config.product['printtype.fourcolor.price']);
} else if ($('#printtype').val() == 'sixcolor') {
amount = pagecount * parseFloat(Config.product['printtype.sixcolor.price']);
}
if ($('#bindtype').val() == 'paperback') {
amount += parseFloat(Config.product['bindtype.paperback.price']) * parseFloat(Config.product['sale.discount']);
} else if ($('#bindtype').val() == 'hardback') {
amount += parseFloat(Config.product['bindtype.hardback.price']) * parseFloat(Config.product['sale.discount']);
}
amount = Math.floor(amount);
amount *= nums;
return amount;
}
var get_sale_amount = function () {
return Math.floor(get_amount() * parseFloat(Config.product['sale.discount']));
}
var refreshamount = function () {
$('#total_amount').text('¥' + get_amount());
$('#sale_amount').text('¥' + get_sale_amount());
$('#sale_desc').text('');
}
$("#buynow_form").submit(function () {
if (parseInt($('#pageCount').text()) < 20) {
layer.msg('您的作品少于20页不能装订成书,请补充内容重新提交。', {time: 3000, icon: 5});
return false;
} else if ($('#address').val() == '' || $('#receiver').val() == '' || $('#mobile').val() == '') {
layer.msg('收货地址、收件人和联系方式不能为空。', {time: 3000, icon: 5});
return false;
} else {
return true;
}
});
refreshamount();
//增减数量
$(document).on('click', 'span[data-type]', function () {
var spinnums = Math.max(parseInt($('#spinnums').val()), 1);
$('#spinnums').val($(this).data("type") == 'plus' ? spinnums + 1 : Math.max(spinnums - 1, 1));
$("input[name=nums]").val($('#spinnums').val());
nums = Math.max(parseInt($('#spinnums').val()), 1);
refreshamount();
$('.spin_minus').toggleClass('minus_disabled', parseInt($('#spinnums').val()) > 1);
});
//类型选择
$(document).on('click', 'span[data-value]', function () {
var parent = $(this).parent();
$("input", parent).val($(this).data("value"));
refreshamount();
$("span[data-value]", parent).removeClass("selected");
$(this).addClass("selected");
});
if (Config.invokejson) {
var onBridgeReady = function () {
WeixinJSBridge.invoke('editAddress', Config.invokejson,
function (res) {
if (res.err_msg == "edit_address:ok") {
$("input[name=address]").val(res.proviceFirstStageName + res.addressCitySecondStageName + res.addressCountiesThirdStageName + res.addressDetailInfo);
$("input[name=receiver]").val(res.userName);
$("input[name=mobile]").val(res.telNumber);
$.post('service/save_address', {
address: $("input[name=address]").val(), receiver: $("input[name=receiver]").val(), mobile: $("input[name=mobile]").val()
});
}
}
);
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
} else {
onBridgeReady();
}
}
$(".nav_bar .r_bar").html('<a class="btn btn-danger btn-block btn-submit" href="javascript:;"><span class="fa fa-check"></span>&nbsp;提交</a>');
$(document).on('click', '.btn-submit', function(){
$("#buynow_form").trigger('submit');
});
},
preview: function () {
window.imageLoaded = Ebook.imageLoaded;
$(".ebook_container").on("load", "img", function () {
$(this).parent().removeClass('img_loading');
});
require(['angular', 'angular-app', 'ngcontrol/preface', 'ngcontrol/preview'], function (angular, app) {
angular.bootstrap(document, ["App"]);
});
},
shelf: function () {
require(['angular', 'angular-app', 'ngcontrol/shelf'], function (angular, app) {
angular.bootstrap(document, ["App"]);
});
},
order: function () {
require(['angular', 'angular-app', 'ngcontrol/order'], function (angular, app) {
angular.bootstrap(document, ["App"]);
});
},
design: function () {
require(['angular', 'angular-app', 'ngcontrol/design'], function (angular, app) {
angular.bootstrap(document, ["App"]);
});
},
preface: function () {
require(['angular', 'angular-app', 'ngcontrol/preface'], function (angular, app) {
angular.bootstrap(document, ["App"]);
});
},
make: function () {
require(['angular', 'angular-app', 'ngcontrol/common'], function (angular, app) {
angular.bootstrap(document, ["App"]);
});
},
import: function () {
require(['angular', 'angular-app', 'ngcontrol/common'], function (angular, app) {
angular.bootstrap(document, ["App"]);
});
},
choosemonth: function () {
$(document).on("click", "a.month_item", function () {
var month = $(this).text().substr(0, 2);
var year = $(this).closest(".month_list").prev().find(".pull-left").text().substr(0, 4);
var that = $(this);
layer.load(1);
$.ajax({
type: "POST",
url: "/service/" + ($(this).hasClass("deleted") ? "recover_month" : "delete_month"),
data: {"year": year, "month": month, "id": bookId},
success: function (response) {
if (response == "success") {
layer.closeAll('loading');
that.toggleClass('deleted');
} else {
layer.msg("操作失败");
}
},
error: function () {
layer.closeAll('loading');
layer.msg("操作失败");
}
});
});
$(document).on("click", ".title_year a", function () {
var year = $(this).parents().prev().text().substr(0, 4);
var that = $(this);
layer.load(1);
$.ajax({
type: "POST",
url: "/service/" + ($(this).hasClass("deleted") ? "recover_year" : "delete_year"),
data: {"year": year, "id": bookId},
success: function (response) {
if (response == "success") {
var months = $(that).closest(".title_year").next().find("li a")
if ($(that).hasClass("deleted")) {
months.removeClass("deleted");
} else {
months.addClass("deleted");
}
layer.closeAll('loading');
that.toggleClass('deleted');
} else {
layer.msg("操作失败");
}
},
error: function () {
layer.closeAll('loading');
layer.msg("操作失败");
}
});
});
},
additem: function () {
if (Ebook.isSupportLocalStorage())
{
try {
oldContent = localStorage.getItem(backupContentKey);
if (oldContent != null)
$('#msg_content').val(oldContent);
} catch (e) {
}
Ebook.backupEditContent();
}
$('a#save_message').click(function () {
$('a#save_message').text('保存中...').addClass('disabled');
$.ajax({
type: "POST",
url: '/service/add_item/' + bookId,
data: $('#add_message').serialize(),
success: function (data) {
if (data == "success")
{
$('a#save_message').text('保存').removeClass('disabled');
alert('添加信息成功,您可以继续编写下一条。');
if (Ebook.isSupportLocalStorage()) {
if (timer != null)
clearTimeout(timer);
localStorage.removeItem(backupContentKey);
}
location.reload();
} else {
$('a#save_message').text('保存').removeClass('disabled');
alert("操作失败,请稍后重试");
}
},
error: function (jqXHR, textStatus, errorThrown)
{
$('a#save_message').text('保存').removeClass('disabled');
alert("操作失败,请稍后重试");
}
});
});
require(["dropzone", "mobiscroll"], function (Dropzone, undefined) {
$('#msg_time').mobiscroll().calendar({
controls: ['calendar', 'date', 'time'],
dateFormat: 'yy-mm-dd',
timeFormat: 'HH:ii:ss',
lang: 'zh',
yearSuffix: '年',
monthSuffix: '月',
daySuffix: '日',
display: 'bubble',
});
Dropzone.autoDiscover = false;
$("#upload_photo").dropzone({
paramName: "file",
url: Config.upload.uploadurl,
clickable: true,
maxFiles: 1000,
maxFilesize: 1000,
acceptedFiles: "image/*",
previewsContainer: "#upload_preview_area",
parallelUploads: 1,
dictMaxFilesExceeded: "已超过10张照片",
dictFileTooBig: "照片大小不能超过10M",
headers: {
'Cache-Control': null,
'X-Requested-With': null
},
params: {
'policy': Config.upload.multipart.policy,
'signature': Config.upload.multipart.signature,
'ext-param': '123'
},
init: function () {
$(this.element).addClass("dropzone");
this.on("maxfilesreached", function (file) {
//this.removeFile(file);
});
this.on("sending", function (file) {
$('a#save_message').text('正在上传图片...').addClass('disabled');
});
this.on("success", function (file, data) {
var r = $.parseJSON(data);
if (r.code == 200) {
$('#add_message').append("<input type='hidden' name='photos[" + r['sign'] + "][url]' value='" + r['url'] + "'>");
$('#add_message').append("<input type='hidden' name='photos[" + r['sign'] + "][width]' value='" + r['image-width'] + "'>");
$('#add_message').append("<input type='hidden' name='photos[" + r['sign'] + "][height]' value='" + r['image-height'] + "'>");
}
});
this.on("queuecomplete", function (file) {
$('a#save_message').text('保存').removeClass('disabled');
});
this.on("error", function (file, errorMessage) {
layer.msg(errorMessage);
});
}
});
});
},
edit: function () {
var editImage = null;
var imageWidth = 0;
var imageHeight = 0;
var layerWidth = 800;
var layerHeight = 600;
var weixinVideoHint = true;
var checkCanDelete = function (item, id, delete_func) {
layer.open({
type: 0, //page层
title: '确认',
closeBtn: 0,
content: '该信息为<strong style="color:green;">微信小视频</strong>内容,电子书中点击<strong style="color:green;">绿色二维码</strong>可以预览视频。手机扫描成品书中二维码可播放视频(<strong style="color:red;">依赖微信服务</strong>)。<br>确认要删除此信息嘛?',
area: '200px',
btn: ['删除', '保留'],
yes: function (index, layero) {
deleteItem(item, id);
layer.close(index);
},
btn2: function (index, layero) {
layer.close(index);
}
});
weixinVideoHint = false;//弹出提示框只出现一次
};
var deletePhoto = function (item, photo_id) {
var item_id = item.closest(".msg_item").attr("id");
$.ajax({
type: "POST",
url: '/service/delete_photo/' + bookId,
data: {id: bookId, action: "delete_photo", item_id: item_id, photo_id: photo_id},
success: function (data) {
item.parent().fadeTo(300, 0, function () {
item.parent().remove();
});
},
error: function (jqXHR, textStatus, errorThrown)
{
alert("操作失败,请稍后重试");
}
});
};
var deleteItem = function (item, item_id) {
$.ajax({
url: '/service/delete_item/' + bookId,
type: "POST",
data: {id: bookId, action: "delete_item", item_id: item_id},
success: function (response) {
var remove_item = item.parent().parent().parent();
remove_item.fadeTo(300, 0, function () {
remove_item.remove();
});
},
error: function (jqXHR, textStatus, errorThrown)
{
alert("操作失败,请稍后重试");
}
});
};
var initDropzone = function (obj) {
obj.dropzone({
paramName: "file",
//url: "/service/upload_photo/" + bookId,
url: Config.upload.uploadurl,
clickable: true,
maxFiles: 1000,
maxFilesize: 1000,
acceptedFiles: "image/*",
previewsContainer: false,
parallelUploads: 1,
dictMaxFilesExceeded: "已超过10张照片",
dictFileTooBig: "照片大小不能超过10M",
headers: {
'Cache-Control': null,
'X-Requested-With': null
},
params: {
'policy': Config.upload.multipart.policy,
'signature': Config.upload.multipart.signature,
'ext-param': '123'
},
init: function () {
$(this.element).addClass("dropzone");
this.old_addedfile = this.defaultOptions.addedfile;
this.on("addedfile", function (file) {
e = document.createElement('div');
$(e).addClass('msg_photo').addClass('dropzone').addClass('dropzone-previews');
file.wzw = e;
$(this.element).parent().before(e);
this.previewsContainer = e;
this.old_addedfile(file);
this.previewsContainer = false;
});
//this.on("uploadprogress", function(file, progress, bytesSent) {
//$(file.wzw).html(bytesSent);
//});
this.on("success", function (file, data) {
var template = '<div class="msg_photo" id="id_value"><a id="a_id_value" href="path_value"><img class="msg_photo_edit msg_photo_item" src="path_value"></a><a href="javascript:;" class="delete_photo"><span class="fa fa-close"></span></a></div>';
var r = $.parseJSON(data);
if (r.code == 200) {
var item_id = obj.closest(".msg_item").attr("id");
$.ajax({
type: "POST",
url: '/service/append_photo/' + bookId,
data: {id: bookId, action: "append_photo", item_id: item_id, width: r['image-width'], height: r['image-height'], url: r['url']},
dataType: 'json',
success: function (data) {
$(file.wzw).replaceWith($(template.replace(/id_value/g, data.id).replace(/path_value/g, Config.upload.cdnurl + r.url).replace(/a_id_value/g, 'a_' + data.id)));
},
error: function ()
{
layer.msg("操作失败,请稍后重试");
}
});
} else {
layer.msg("上传图片失败,请重试");
}
});
this.on("error", function (file, errorMessage) {
layer.msg(errorMessage);
});
this.on("maxfilesreached", function (file) {
//this.removeFile(file);
});
}
});
};
$(document).on('click', '.msg_photo_item', function () {
var this_item = $(this);
var item_id = this_item.closest(".msg_item").attr("id");
var photo_id = $(this).parent().parent().attr('id');
var imageSrc = $(this).attr("src").split('!')[0];
var rotate = $(this).attr("data-rotate");
if (rotate == null)
rotate = 0;
var originalRotate = rotate;
var html = '<div class="editImageBox">\
<image id="wangzw" onload="rotate(getRotate())" data-rotate=' + rotate + ' src="' + imageSrc + '" height = "' + layerHeight * 5 / 7 + '">\
<a class="rotate_left_button" href="javascript:void(0)" onclick="javascript:turnLeft();"><span class="fa fa-rotate-left"></span> 向左旋转</a>\
<a class="rotate_right_button" href="javascript:void(0)" onclick="javascript:turnRight();"><span class="fa fa-rotate-right"></span> 向右旋转</a>\
</div>';
layer.open({
type: 1, //page层
area: [layerWidth + 'px', layerHeight + 'px'],
title: '编辑照片',
shade: 0.6, //遮罩透明度
moveType: false,
shift: -1, //0-6的动画形式,-1不开启
closeBtn: false,
btn: ['确定', '取消'],
content: html,
yes: function (index, layero) {
var rotate = getRotate();
if (rotate != originalRotate) {
var style = new Object();
style.rotate = rotate;
$.ajax({
type: "POST",
url: '/service/rotate_photo',
data: {id: bookId, action: "rotate_photo", item_id: item_id, photo_id: photo_id, style: JSON.stringify(style)},
success: function (data) {
$('#' + photo_id + ' img').attr('src', data).attr("data-rotate", rotate);
layer.close(index);
editImage = null;
},
error: function (jqXHR, textStatus, errorThrown)
{
alert("操作失败,请稍后重试");
}
});
} else {
layer.close(index);
editImage = null;
}
},
btn2: function (index) {
editImage = null;
return true;
}
});
return false;
});
$(document).on('click', '.delete_item', function () {
var this_item = $(this);
var cur_item_id = $(this).parent().parent().parent().attr('id');
if (weixinVideoHint && $('.wx_video', this_item.parent().parent()).length > 0) {
checkCanDelete(this_item, cur_item_id, deleteItem);
} else {
deleteItem(this_item, cur_item_id);
}
});
$(document).on('click', '.delete_photo', function () {
var this_item = $(this);
var photo_id = $(this).parent().attr('id');
if (weixinVideoHint && $('.wx_video', this_item.parent().parent()).length > 0) {
checkCanDelete(this_item, photo_id, deletePhoto);
} else {
deletePhoto(this_item, photo_id);
}
});
require(["dropzone", "mobiscroll"], function (Dropzone, undefined) {
Dropzone.autoDiscover = false;
initDropzone($(".upload_photo_form"));
});
$(document).on('click', '.edit_text', function () {
var edit_item = $(this);
var edit_item_id = $(this).parent().attr('id');
var defaut_val = $(this).parent().find('.message_edit').text();
layer.myPrompt({title: "修改信息文字", formType: 2, maxlength: 100000, value: defaut_val}, function (value, index, elem) {
if (true) {
$.ajax({
url: '/service/edit_text/' + bookId,
type: "POST",
data: {id: bookId, action: "edit_text", item_id: edit_item_id, content: value},
success: function (response)
{
edit_item.parent().find('.message_edit').text(value);
},
error: function (jqXHR, textStatus, errorThrown)
{
alert("保存失败,请稍后重试");
}
});
layer.close(index);
}
});
});
load_more_res_selector = ".ebook .msg_item";
load_more_end_string = "没有更多内容了...";
load_more_res_callback = function (res) {
initDropzone(res.find(".upload_photo_form"));
};
scroll_height_to_load = 50;
scroll_each_selector = ".msg_item";
scroll_each_callback = function ($item) {
$('#nav_title_content').text($item.find('.page_header_title').text());
};
Ebook.setupDimension();
Ebook.setupLoadMore();
Ebook.setupScrolling();
if (isMobile) {
layerWidth = page_width;
layerHeight = page_height;
}
window.getRotate = function () {
if (editImage == null) {
editImage = $("#wangzw")[0];
imageWidth = editImage.width;
imageHeight = editImage.height;
$("#wangzw").css("display", "none");
}
return Number(editImage.getAttribute("data-rotate")) || 0;
}
window.turnLeft = function () {
var r = getRotate();
r -= 90;
if (r < 0)
r = 270;
rotate(r);
}
window.turnRight = function () {
var r = getRotate();
r += 90;
if (r >= 360)
r = 0;
rotate(r);
}
window.rotate = function (r) {
//canvas旋转
if (editImage == null) {
editImage = $("#wangzw")[0];
imageWidth = editImage.width;
imageHeight = editImage.height;
$("#wangzw").css("display", "none");
}
var canvas = $("#canvas_wangzw")[0] || document.createElement("canvas");
canvas.width = layerWidth * 23 / 25;
canvas.height = layerHeight - 140;
canvasRate = canvas.height / canvas.width;
canvas.id = "canvas_wangzw";
//img.style.position = "absolute";
//img.style.visibility = "hidden";
context = canvas.getContext("2d");
x = 0, y = 0;
switch (r) {
case 0:
if (imageHeight / imageWidth > canvasRate)
{
drawHeight = canvas.height;
drawWidth = imageWidth * (drawHeight / imageHeight);
x = (canvas.width - drawWidth) / 2;
y = 0;
} else
{
drawWidth = canvas.width;
drawHeight = imageHeight * (drawWidth / imageWidth);
x = 0;
y = (canvas.height - drawHeight) / 2;
}
break;
case 90:
if (imageWidth / imageHeight > canvasRate)
{
drawWidth = canvas.height;
drawHeight = imageHeight * (drawWidth / imageWidth);
x = 0;
y = -(drawHeight + canvas.width) / 2;
} else
{
drawHeight = canvas.width;
drawWidth = imageWidth * (drawHeight / imageHeight);
x = (canvas.height - drawWidth) / 2;
y = -drawHeight;
}
break;
case 180:
if (imageHeight / imageWidth > canvasRate)
{
drawHeight = canvas.height;
drawWidth = imageWidth * (drawHeight / imageHeight);
x = -(drawWidth + canvas.width) / 2;
y = -drawHeight;
} else
{
drawWidth = canvas.width;
drawHeight = imageHeight * (drawWidth / imageWidth);
x = -drawWidth;
y = -(drawHeight + canvas.height) / 2;
}
break;
case 270:
if (imageWidth / imageHeight > canvasRate)
{
drawWidth = canvas.height;
drawHeight = imageHeight * (drawWidth / imageWidth);
x = -drawWidth;
y = (canvas.width - drawHeight) / 2;
} else
{
drawHeight = canvas.width;
drawWidth = imageWidth * (drawHeight / imageHeight);
x = -(drawWidth + canvas.height) / 2;
y = 0;
}
break;
}
context.clearRect(0, 0, canvas.width, canvas.height);
context.save();
context.rotate(r * Math.PI / 180);
context.drawImage(editImage, x, y, drawWidth, drawHeight);
context.restore();
editImage.parentNode.insertBefore(canvas, editImage.parentNode.childNodes[0]);
editImage.setAttribute("data-rotate", r);
};
layer.myPrompt = function (options, yes) {
options = options || {};
if (typeof options === 'function')
yes = options;
var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input">' + (options.value || '') + '</textarea>' : function () {
return '<input type="' + (options.formType == 1 ? 'password' : 'text') + '" class="layui-layer-input" value="' + (options.value || '') + '">';
}();
return layer.open($.extend({
btn: ['&#x786E;&#x5B9A;', '&#x53D6;&#x6D88;'],
content: content,
skin: 'layui-layer-prompt',
success: function (layero) {
prompt = layero.find('.layui-layer-input');
prompt.focus();
}, yes: function (index) {
var value = prompt.val();
if (value.length > (options.maxlength || 500)) {
layer.tips('&#x6700;&#x591A;&#x8F93;&#x5165;' + (options.maxlength || 500) + '&#x4E2A;&#x5B57;&#x6570;', prompt, {tips: 1});
} else {
yes && yes(value, index, prompt);
}
}
}, options));
};
},
recyclebin: function () {
$(document).on('click', '.recover_item', function () {
var this_item = $(this);
var item_id = $(this).parent().parent().parent().attr('id');
$.ajax({
url: '/service/recover_item/' + bookId,
type: "POST",
data: {id: bookId, action: "recover_item", item_id: item_id},
success: function (response) {
var remove_item = this_item.parent().parent().parent();
remove_item.fadeTo(300, 0, function () {
remove_item.remove();
});
}
});
});
$(document).on('click', '.recover_photo', function () {
var this_item = $(this);
var item_id = $(this).parent().parent().parent().attr('id');
var photo_id = $(this).parent().attr('id');
$.ajax({
url: '/service/recover_photo/' + bookId,
type: "POST",
data: {id: bookId, action: "recover_photo", item_id: item_id, photo_id: photo_id},
success: function (response) {
if (this_item.parent().parent().find('.msg_photo').length == 1) {
this_item.parent().parent().parent().fadeTo(300, 0, function () {
this_item.parent().parent().parent().remove();
});
} else {
this_item.parent().fadeTo(300, 0, function () {
this_item.parent().remove();
});
}
}
});
});
}
};
return Controller;
});
\ No newline at end of file
define(['jquery', 'bootstrap', 'frontend', 'frontend-ebook', 'layer', 'config'], function ($, undefined, Frontend, Ebook, Layer, Config) {
var Controller = {
index: function () {
},
pay: function () {
this.info();
},
info: function () {
console.log(1332);
$(document).on('click', '#payorder', function () {
if (Config.invokejson) {
WeixinJSBridge.invoke('getBrandWCPayRequest', Config.invokejson,
function (res) {
if (res.err_msg == "get_brand_wcpay_request:ok") {
layer.msg('支付成功!', {}, function () {
location.href = "/ebook/shelf";
});
}
}
);
} else {
Layer.msg("请使用微信扫描上方二维码支付!");
}
});
$(document).on('click', '#deleteorder', function () {
var that = this;
layer.confirm('确认取消订单?', {
btn: ['确定', '取消'] //按钮
}, function () {
Layer.load();
$.ajax({
url: 'service/delete_order',
data: {id: $(that).attr("book-id"), order_id: $(that).attr("order-id")},
type: 'post',
success: function (ret) {
Layer.closeAll('loading');
if (ret == 'success') {
Layer.msg("取消订单成功!", {icon: 1}, function () {
location.href = '/ebook/shelf';
});
} else {
Ebook.popMessage("取消订单失败!");
}
}, error: function () {
Layer.closeAll('loading');
Ebook.popMessage("操作失败!请重试!");
}
})
}, function () {
});
});
if (Config.invokejson) {
var onBridgeReady = function () {
if (Config.paynow == 1) {
$('#payorder').trigger('click');
}
}
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
} else if (document.attachEvent) {
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
}
} else {
onBridgeReady();
}
} else {
if (Config.paynow == 1) {
$('#payorder').trigger('click');
}
}
}
};
return Controller;
});
\ No newline at end of file
... ... @@ -45,7 +45,7 @@ require.config({
'summernote': '../libs/summernote/dist/lang/summernote-zh-CN.min',
'validator': '../libs/nice-validator/dist/local/zh-CN',
'plupload': '../libs/plupload/js/plupload.min',
'toastr': '../libs/toastr/toastr.min',
'toastr': '../libs/toastr/toastr',
'jstree': '../libs/jstree/dist/jstree.min',
'layer': '../libs/layer/src/layer',
'echarts': '../libs/echarts/dist/echarts.min',
... ...
此 diff 太大无法显示。
... ... @@ -45,7 +45,7 @@ require.config({
'summernote': '../libs/summernote/dist/lang/summernote-zh-CN.min',
'validator': '../libs/nice-validator/dist/local/zh-CN',
'plupload': '../libs/plupload/js/plupload.min',
'toastr': '../libs/toastr/toastr.min',
'toastr': '../libs/toastr/toastr',
'jstree': '../libs/jstree/dist/jstree.min',
'layer': '../libs/layer/src/layer',
'echarts': '../libs/echarts/dist/echarts.min',
... ...
此 diff 太大无法显示。