Browse Source

20220601

pull/81/head
xiaoz 3 years ago
parent
commit
1c46e70b95
  1. 64
      class/Api.php
  2. 59
      controller/api.php
  3. 3872
      static/bootstrap4/css/bootstrap-grid.css
  4. 1
      static/bootstrap4/css/bootstrap-grid.css.map
  5. 7
      static/bootstrap4/css/bootstrap-grid.min.css
  6. 1
      static/bootstrap4/css/bootstrap-grid.min.css.map
  7. 325
      static/bootstrap4/css/bootstrap-reboot.css
  8. 1
      static/bootstrap4/css/bootstrap-reboot.css.map
  9. 8
      static/bootstrap4/css/bootstrap-reboot.min.css
  10. 1
      static/bootstrap4/css/bootstrap-reboot.min.css.map
  11. 10315
      static/bootstrap4/css/bootstrap.css
  12. 1
      static/bootstrap4/css/bootstrap.css.map
  13. 7
      static/bootstrap4/css/bootstrap.min.css
  14. 1
      static/bootstrap4/css/bootstrap.min.css.map
  15. 6972
      static/bootstrap4/js/bootstrap.bundle.js
  16. 1
      static/bootstrap4/js/bootstrap.bundle.js.map
  17. 7
      static/bootstrap4/js/bootstrap.bundle.min.js
  18. 1
      static/bootstrap4/js/bootstrap.bundle.min.js.map
  19. 4357
      static/bootstrap4/js/bootstrap.js
  20. 1
      static/bootstrap4/js/bootstrap.js.map
  21. 7
      static/bootstrap4/js/bootstrap.min.js
  22. 1
      static/bootstrap4/js/bootstrap.min.js.map
  23. 487
      static/module/iconHhys/iconHhysFa.js

64
class/Api.php

@ -5,7 +5,7 @@
* author:xiaoz<xiaoz93@outlook.com> * author:xiaoz<xiaoz93@outlook.com>
* blog:xiaoz.me * blog:xiaoz.me
*/ */
define("API_URL","http://down.onenav.top"); define("API_URL","https://onenav.xiaoz.top");
class Api { class Api {
protected $db; protected $db;
public function __construct($db){ public function __construct($db){
@ -156,7 +156,7 @@ class Api {
* name:返回错误(json) * name:返回错误(json)
* *
*/ */
protected function err_msg($code,$err_msg){ public function err_msg($code,$err_msg){
$data = [ $data = [
'code' => $code, 'code' => $code,
'err_msg' => $err_msg 'err_msg' => $err_msg
@ -1465,6 +1465,66 @@ class Api {
$this->return_json(-2000,'','网络请求失败,请重试!'); $this->return_json(-2000,'','网络请求失败,请重试!');
} }
} }
/**
* 验证订阅是否存在
*/
public function is_subscribe() {
//获取订阅SESSION状态
session_start();
//获取session订阅状态
$is_subscribe = $_SESSION['subscribe'];
//如果订阅是空的,则请求接口获取订阅状态
if ( !isset($is_subscribe) ) {
//获取当前站点信息
$subscribe = $this->db->get('on_options','value',[ 'key' => "s_subscribe" ]);
$domain = $_SERVER['HTTP_HOST'];
$subscribe = unserialize($subscribe);
//api请求地址
$api_url = API_URL."/v1/check_subscribe.php?order_id=".$subscribe['order_id']."&email=".$subscribe['email']."&domain=".$domain;
try {
#GET HTTPS
$curl = curl_init($api_url);
#设置useragent
#curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
#设置超时时间,最小为1s(可选)
curl_setopt($curl , CURLOPT_TIMEOUT, 30);
$html = curl_exec($curl);
curl_close($curl);
//解析json
$data = json_decode($html);
//var_dump($data->data->end_time);
//echo strtotime($data->data->end_time);
//var_dump($data->code);
//如果状态码返回200,并且订阅没有到期
if( (intval($data->code) === 200) && ( $data->data->end_time > ( strtotime( date("Y-m-d",time()) ) )) ) {
$_SESSION['subscribe'] = TRUE;
return TRUE;
}
else if( intval($data->code === -1000 ) ) {
$_SESSION['subscribe'] = FALSE;
return FALSE;
}
else{
$_SESSION['subscribe'] = NULL;
}
} catch (\Throwable $th) {
$_SESSION['subscribe'] = NULL;
}
}
if( $is_subscribe == TRUE ) {
return TRUE;
}
else{
return FALSE;
}
}
/** /**
* 无脑下载更新程序 * 无脑下载更新程序
*/ */

59
controller/api.php

@ -46,6 +46,10 @@ function add_category($api){
$description = htmlspecialchars($description); $description = htmlspecialchars($description);
//获取字体图标 //获取字体图标
$font_icon = htmlspecialchars($_POST['font_icon'],ENT_QUOTES); $font_icon = htmlspecialchars($_POST['font_icon'],ENT_QUOTES);
//搜索字体图标是否包含'fa ',如果不包含则自动加上
if( !strstr($font_icon,'fa ') ) {
$font_icon = 'fa '.$font_icon;
}
$api->add_category($token,$name,$property,$weight,$description,$font_icon,$fid); $api->add_category($token,$name,$property,$weight,$description,$font_icon,$fid);
} }
/** /**
@ -70,6 +74,10 @@ function edit_category($api){
$description = htmlspecialchars($description); $description = htmlspecialchars($description);
//字体图标 //字体图标
$font_icon = htmlspecialchars($_POST['font_icon'],ENT_QUOTES); $font_icon = htmlspecialchars($_POST['font_icon'],ENT_QUOTES);
//搜索字体图标是否包含'fa ',如果不包含则自动加上
if( !strstr($font_icon,'fa ') ) {
$font_icon = 'fa '.$font_icon;
}
$api->edit_category($token,$id,$name,$property,$weight,$description,$font_icon,$fid); $api->edit_category($token,$id,$name,$property,$weight,$description,$font_icon,$fid);
} }
/** /**
@ -295,10 +303,41 @@ function set_site($api) {
$data['custom_footer'] = $_POST['custom_footer']; $data['custom_footer'] = $_POST['custom_footer'];
//序列化存储 //序列化存储
$value = serialize($data); $value = serialize($data);
if( !empty($data['custom_footer']) ) {
if( !$api->is_subscribe() ) {
$api->err_msg(-2000,'保存失败,自定义footer需要订阅用户才能使用,若未订阅请留空!');
}
}
$api->set_option('s_site',$value); $api->set_option('s_site',$value);
} }
//阻止非订阅用户保存设置
function _deny_set($content,$err_msg) {
global $api;
//验证订阅,返回TRUE或FALSE
if ( !isset($_SESSION['subscribe']) ) {
//验证订阅,返回TRUE或FALSE
$result = $api->is_subscribe();
}
//如果内容是空的,直接允许
if ( empty($content) ) {
return TRUE;
}
else{
if( $_SESSION['subscribe'] === TRUE ) {
return TRUE;
}
else{
$api->err_msg(-2000,$err_msg);
}
}
}
//设置订阅信息 //设置订阅信息
function set_subscribe($api) { function set_subscribe($api) {
//获取订单ID //获取订单ID
@ -307,6 +346,9 @@ function set_subscribe($api) {
$data['email'] = htmlspecialchars( trim($_REQUEST['email']) ); $data['email'] = htmlspecialchars( trim($_REQUEST['email']) );
//到期时间 //到期时间
$data['end_time'] = htmlspecialchars( trim($_REQUEST['end_time']) ); $data['end_time'] = htmlspecialchars( trim($_REQUEST['end_time']) );
//重置订阅状态
session_start();
$_SESSION['subscribe'] = NULL;
//序列化存储 //序列化存储
$value = serialize($data); $value = serialize($data);
@ -337,9 +379,24 @@ function set_transition_page($api) {
$data['visitor_stay_time'] = intval($_POST['visitor_stay_time']); $data['visitor_stay_time'] = intval($_POST['visitor_stay_time']);
//获取管理员停留时间 //获取管理员停留时间
$data['admin_stay_time'] = intval($_POST['admin_stay_time']); $data['admin_stay_time'] = intval($_POST['admin_stay_time']);
//获取菜单
$data['menu'] = $_POST['menu'];
//获取footer
$data['footer'] = $_POST['footer'];
//获取广告
$data['a_d_1'] = $_POST['a_d_1'];
$data['a_d_2'] = $_POST['a_d_2'];
//验证订阅
_deny_set($data['menu'],'保存失败,过渡页菜单需要订阅用户才能使用!');
_deny_set($data['footer'],'保存失败,自定义footer需要订阅用户才能使用!');
_deny_set($data['a_d_1'],'保存失败,自定义广告需要订阅用户才能使用!');
_deny_set($data['a_d_2'],'保存失败,自定义广告需要订阅用户才能使用!');
//序列化存储 //序列化存储
$value = serialize($data); $value = serialize($data);
$api->set_option('s_transition_page',$value); $api->set_option('s_transition_page',$value);
} }

3872
static/bootstrap4/css/bootstrap-grid.css vendored

File diff suppressed because it is too large Load Diff

1
static/bootstrap4/css/bootstrap-grid.css.map

File diff suppressed because one or more lines are too long

7
static/bootstrap4/css/bootstrap-grid.min.css vendored

File diff suppressed because one or more lines are too long

1
static/bootstrap4/css/bootstrap-grid.min.css.map

File diff suppressed because one or more lines are too long

325
static/bootstrap4/css/bootstrap-reboot.css vendored

@ -0,0 +1,325 @@
/*!
* Bootstrap Reboot v4.6.1 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus:not(:focus-visible) {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]):not([class]) {
color: inherit;
text-decoration: none;
}
a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
-ms-overflow-style: scrollbar;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
[role="button"] {
cursor: pointer;
}
select {
word-wrap: normal;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button:not(:disabled),
[type="button"]:not(:disabled),
[type="reset"]:not(:disabled),
[type="submit"]:not(:disabled) {
cursor: pointer;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

1
static/bootstrap4/css/bootstrap-reboot.css.map

File diff suppressed because one or more lines are too long

8
static/bootstrap4/css/bootstrap-reboot.min.css vendored

@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v4.6.1 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus:not(:focus-visible){outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([class]){color:inherit;text-decoration:none}a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto;-ms-overflow-style:scrollbar}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit;text-align:-webkit-match-parent}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */

1
static/bootstrap4/css/bootstrap-reboot.min.css.map

File diff suppressed because one or more lines are too long

10315
static/bootstrap4/css/bootstrap.css vendored

File diff suppressed because it is too large Load Diff

1
static/bootstrap4/css/bootstrap.css.map

File diff suppressed because one or more lines are too long

7
static/bootstrap4/css/bootstrap.min.css vendored

File diff suppressed because one or more lines are too long

1
static/bootstrap4/css/bootstrap.min.css.map

File diff suppressed because one or more lines are too long

6972
static/bootstrap4/js/bootstrap.bundle.js

File diff suppressed because it is too large Load Diff

1
static/bootstrap4/js/bootstrap.bundle.js.map

File diff suppressed because one or more lines are too long

7
static/bootstrap4/js/bootstrap.bundle.min.js vendored

File diff suppressed because one or more lines are too long

1
static/bootstrap4/js/bootstrap.bundle.min.js.map

File diff suppressed because one or more lines are too long

4357
static/bootstrap4/js/bootstrap.js vendored

File diff suppressed because it is too large Load Diff

1
static/bootstrap4/js/bootstrap.js.map

File diff suppressed because one or more lines are too long

7
static/bootstrap4/js/bootstrap.min.js vendored

File diff suppressed because one or more lines are too long

1
static/bootstrap4/js/bootstrap.min.js.map

File diff suppressed because one or more lines are too long

487
static/module/iconHhys/iconHhysFa.js

@ -0,0 +1,487 @@
/**
* iconHhysFa 1.0 字体图标选择
* User: jackhhy
* Date: 2020/06/23-11:09
* Link: https://gitee.com/luckygyl/iconFonts
*/
layui.define(['laypage', 'form'], function (exports) {
"use strict";
var IconHhys =function () {
this.v = '1.0';
}, _MOD = 'iconHhysFa',
_this = this,
$ = layui.jquery,
laypage = layui.laypage,
form = layui.form,
BODY = 'body',
TIPS = '请选择图标';
/**
* 渲染组件
*/
IconHhys.prototype.render = function (options) {
var opts = options,
// DOM选择器
elem = opts.elem,
// 数据类型:fontClass/awesome
type = opts.type == null ? 'fontClass' : opts.type,
//当数据类型为awesome 的时候 需要配置 url
url = opts.url ,
// 是否分页:true/false
page = opts.page == null ? true : opts.page,
// 每页显示数量
limit = opts.limit == null ? 12 : opts.limit,
// 是否开启搜索:true/false
search = opts.search == null ? true : opts.search,
// 每个图标格子的宽度:'43px'或'20%'
cellWidth = opts.cellWidth == null ? '20%':opts.cellWidth,
// 点击回调
click = opts.click,
// 渲染成功后的回调
success = opts.success,
// json数据
data = {},
value = opts.value == null ? '' : opts.value,
// 唯一标识
tmp = new Date().getTime(),
// 初始化时input的值
ORIGINAL_ELEM_VALUE = value,
TITLE = 'layui-select-title',
TITLE_ID = 'layui-select-title-' + tmp,
ICON_BODY = 'layui-iconpicker-' + tmp,
PICKER_BODY = 'layui-iconpicker-body-' + tmp,
PAGE_ID = 'layui-iconpicker-page-' + tmp,
LIST_BOX = 'layui-iconpicker-list-box',
selected = 'layui-form-selected',
unselect = 'layui-unselect';
var a = {
init: function () {
if (type.indexOf("fontClass") > -1){
data = common.getfont[type]();
}else{
data = common.getData(url);
}
a.hideElem().createSelect().createBody().toggleSelect();
a.preventEvent().inputListen();
common.loadCss();
if (success) {
success(this.successHandle());
}
return a;
},
successHandle: function () {
var d = {
options: opts,
data: data,
id: tmp,
elem: $('#' + ICON_BODY)
};
return d;
},
/**
* 隐藏elem
*/
hideElem: function () {
$(elem).hide();
return a;
},
/**
* 绘制select下拉选择框
*/
createSelect: function () {
if (type.indexOf("fontClass") > -1){
var oriIcon = '<i class="layui-icon">';
// 默认图标
if(ORIGINAL_ELEM_VALUE === '') {
ORIGINAL_ELEM_VALUE = 'layui-icon-circle-dot';
}
oriIcon = '<i class="layui-icon '+ ORIGINAL_ELEM_VALUE +'">';
oriIcon += '</i>';
var selectHtml = '<div class="layui-iconpicker layui-unselect layui-form-select" id="'+ ICON_BODY +'">' +
'<div class="'+ TITLE +'" id="'+ TITLE_ID +'">' +
'<div class="layui-iconpicker-item">'+
'<span class="layui-iconpicker-icon layui-unselect">' +
oriIcon +
'</span>'+
'<i class="layui-edge"></i>' +
'</div>'+
'</div>' +
'<div class="layui-anim layui-anim-upbit" style="">' +
'123' +
'</div>';
$(elem).after(selectHtml);
return a;
}else{
var oriIcon = '<i class="fa">';
// 默认图标
if (ORIGINAL_ELEM_VALUE === '') {
ORIGINAL_ELEM_VALUE = 'fa-adjust';
}
oriIcon = '<i class="fa ' + ORIGINAL_ELEM_VALUE + '">';
oriIcon += '</i>';
var selectHtml = '<div class="layui-iconpicker layui-unselect layui-form-select" id="' + ICON_BODY + '">' +
'<div class="' + TITLE + '" id="' + TITLE_ID + '">' +
'<div class="layui-iconpicker-item">' +
'<span class="layui-iconpicker-icon layui-unselect">' +
oriIcon +
'</span>' +
'<i class="layui-edge"></i>' +
'</div>' +
'</div>' +
'<div class="layui-anim layui-anim-upbit" style="">' +
'123' +
'</div>';
$(elem).after(selectHtml);
return a;
}
},
/**
* 展开/折叠下拉框
*/
toggleSelect: function () {
var item = '#' + TITLE_ID + ' .layui-iconpicker-item,#' + TITLE_ID + ' .layui-iconpicker-item .layui-edge';
a.event('click', item, function (e) {
var $icon = $('#' + ICON_BODY);
if ($icon.hasClass(selected)) {
$icon.removeClass(selected).addClass(unselect);
} else {
// 隐藏其他picker
$('.layui-form-select').removeClass(selected);
// 显示当前picker
$icon.addClass(selected).removeClass(unselect);
}
e.stopPropagation();
});
return a;
},
/**
* 绘制主体部分
*/
createBody: function () {
// 获取数据
var searchHtml = '';
if (search) {
searchHtml = '<div class="layui-iconpicker-search">' +
'<input class="layui-input">' +
'<i class="layui-icon">&#xe615;</i>' +
'</div>';
}
// 组合dom
var bodyHtml = '<div class="layui-iconpicker-body" id="'+ PICKER_BODY +'">' +
searchHtml +
'<div class="'+ LIST_BOX +'"></div> '+
'</div>';
$('#' + ICON_BODY).find('.layui-anim').eq(0).html(bodyHtml);
a.search().createList().check().page();
return a;
},
/**
* 绘制图标列表
* @param text 模糊查询关键字
* @returns {string}
*/
createList: function (text) {
var d = data,
l = d.length,
pageHtml = '',
listHtml = $('<div class="layui-iconpicker-list">')//'<div class="layui-iconpicker-list">';
// 计算分页数据
var _limit = limit, // 每页显示数量
_pages = l % _limit === 0 ? l / _limit : parseInt(l / _limit + 1), // 总计多少页
_id = PAGE_ID;
// 图标列表
var icons = [];
for (var i = 0; i < l; i++) {
var obj = d[i];
// 判断是否模糊查询
if (text && obj.indexOf(text) === -1) {
continue;
}
// 是否自定义格子宽度
var style = '';
if (cellWidth !== null) {
style += ' style="width:' + cellWidth + '"';
}
// 每个图标dom
var icon = '<div class="layui-iconpicker-icon-item" title="'+ obj +'" '+ style +'>';
if(type.indexOf("fontClass") >-1){
icon += '<i class="layui-icon '+ obj +'"></i>';
}else {
icon += '<i class="fa ' + obj + '"></i>';
}
icon += '</div>';
icons.push(icon);
}
// 查询出图标后再分页
l = icons.length;
_pages = l % _limit === 0 ? l / _limit : parseInt(l / _limit + 1);
for (var i = 0; i < _pages; i++) {
// 按limit分块
var lm = $('<div class="layui-iconpicker-icon-limit" id="layui-iconpicker-icon-limit-' + tmp + (i+1) +'">');
for (var j = i * _limit; j < (i+1) * _limit && j < l; j++) {
lm.append(icons[j]);
}
listHtml.append(lm);
}
// 无数据
if (l === 0) {
listHtml.append('<p class="layui-iconpicker-tips">无数据</p>');
}
// 判断是否分页
if (page){
$('#' + PICKER_BODY).addClass('layui-iconpicker-body-page');
pageHtml = '<div class="layui-iconpicker-page" id="'+ PAGE_ID +'">' +
'<div class="layui-iconpicker-page-count">' +
'<span id="'+ PAGE_ID +'-current">1</span>/' +
'<span id="'+ PAGE_ID +'-pages">'+ _pages +'</span>' +
' (<span id="'+ PAGE_ID +'-length">'+ l +'</span>)' +
'</div>' +
'<div class="layui-iconpicker-page-operate">' +
'<i class="layui-icon" id="'+ PAGE_ID +'-prev" data-index="0" prev>&#xe603;</i> ' +
'<i class="layui-icon" id="'+ PAGE_ID +'-next" data-index="2" next>&#xe602;</i> ' +
'</div>' +
'</div>';
}
$('#' + ICON_BODY).find('.layui-anim').find('.' + LIST_BOX).html('').append(listHtml).append(pageHtml);
return a;
},
// 阻止Layui的一些默认事件
preventEvent: function() {
var item = '#' + ICON_BODY + ' .layui-anim';
a.event('click', item, function (e) {
e.stopPropagation();
});
return a;
},
// 分页
page: function () {
var icon = '#' + PAGE_ID + ' .layui-iconpicker-page-operate .layui-icon';
$(icon).unbind('click');
a.event('click', icon, function (e) {
var elem = e.currentTarget,
total = parseInt($('#' +PAGE_ID + '-pages').html()),
isPrev = $(elem).attr('prev') !== undefined,
// 按钮上标的页码
index = parseInt($(elem).attr('data-index')),
$cur = $('#' +PAGE_ID + '-current'),
// 点击时正在显示的页码
current = parseInt($cur.html());
// 分页数据
if (isPrev && current > 1) {
current=current-1;
$(icon + '[prev]').attr('data-index', current);
} else if (!isPrev && current < total){
current=current+1;
$(icon + '[next]').attr('data-index', current);
}
$cur.html(current);
// 图标数据
$('#'+ ICON_BODY + ' .layui-iconpicker-icon-limit').hide();
$('#layui-iconpicker-icon-limit-' + tmp + current).show();
e.stopPropagation();
});
return a;
},
/**
* 搜索
*/
search: function () {
var item = '#' + PICKER_BODY + ' .layui-iconpicker-search .layui-input';
a.event('input propertychange', item, function (e) {
var elem = e.target,
t = $(elem).val();
a.createList(t);
});
return a;
},
/**
* 点击选中图标
*/
check: function () {
if(type.indexOf("fontClass") >-1){
var item = '#' + PICKER_BODY + ' .layui-iconpicker-icon-item';
a.event('click', item, function (e) {
var el = $(e.currentTarget).find('.layui-icon'),
icon = '';
var clsArr = el.attr('class').split(/[\s\n]/),
cls = clsArr[1],
icon = cls;
$('#' + TITLE_ID).find('.layui-iconpicker-item .layui-icon').html('').attr('class', clsArr.join(' '));
$('#' + ICON_BODY).removeClass(selected).addClass(unselect);
$(elem).val(icon).attr('value', icon);
// 回调
if (click) {
click({
icon: icon
});
}
});
}else{
var item = '#' + PICKER_BODY + ' .layui-iconpicker-icon-item';
a.event('click', item, function (e) {
var el = $(e.currentTarget).find('.fa'),
icon = '';
var clsArr = el.attr('class').split(/[\s\n]/),
cls = clsArr[1],
icon = cls;
$('#' + TITLE_ID).find('.layui-iconpicker-item .fa').html('').attr('class', clsArr.join(' '));
$('#' + ICON_BODY).removeClass(selected).addClass(unselect);
$(elem).val(icon).attr('value', icon);
// 回调
if (click) {
click({
icon: icon
});
}
});
}
return a;
},
// 监听原始input数值改变
inputListen: function(){
var el = $(elem);
a.event('change', elem, function(){
var value = el.val();
})
// el.change(function(){
// });
return a;
},
event: function (evt, el, fn) {
$(BODY).on(evt, el, fn);
}
};
var common = {
/**
* 加载样式表
*/
loadCss: function () {
var css = '.layui-iconpicker {max-width: 280px;}.layui-iconpicker .layui-anim{display:none;position:absolute;left:0;top:42px;padding:5px 0;z-index:899;min-width:100%;border:1px solid #d2d2d2;max-height:300px;overflow-y:auto;background-color:#fff;border-radius:2px;box-shadow:0 2px 4px rgba(0,0,0,.12);box-sizing:border-box;}.layui-iconpicker-item{border:1px solid #e6e6e6;width:90px;height:36px;border-radius:4px;cursor:pointer;position:relative;}.layui-iconpicker-icon{border-right:1px solid #e6e6e6;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;width:60px;height:100%;float:left;text-align:center;background:#fff;transition:all .3s;}.layui-iconpicker-icon i{line-height:38px;font-size:18px;}.layui-iconpicker-item > .layui-edge{left:70px;}.layui-iconpicker-item:hover{border-color:#D2D2D2!important;}.layui-iconpicker-item:hover .layui-iconpicker-icon{border-color:#D2D2D2!important;}.layui-iconpicker.layui-form-selected .layui-anim{display:block;}.layui-iconpicker-body{padding:6px;}.layui-iconpicker .layui-iconpicker-list{background-color:#fff;border:1px solid #ccc;border-radius:4px;}.layui-iconpicker .layui-iconpicker-icon-item{display:inline-block;width:21.1%;line-height:36px;text-align:center;cursor:pointer;vertical-align:top;height:36px;margin:4px;border:1px solid #ddd;border-radius:2px;transition:300ms;}.layui-iconpicker .layui-iconpicker-icon-item i.layui-icon{font-size:17px;}.layui-iconpicker .layui-iconpicker-icon-item:hover{background-color:#eee;border-color:#ccc;-webkit-box-shadow:0 0 2px #aaa,0 0 2px #fff inset;-moz-box-shadow:0 0 2px #aaa,0 0 2px #fff inset;box-shadow:0 0 2px #aaa,0 0 2px #fff inset;text-shadow:0 0 1px #fff;}.layui-iconpicker-search{position:relative;margin:0 0 6px 0;border:1px solid #e6e6e6;border-radius:2px;transition:300ms;}.layui-iconpicker-search:hover{border-color:#D2D2D2!important;}.layui-iconpicker-search .layui-input{cursor:text;display:inline-block;width:86%;border:none;padding-right:0;margin-top:1px;}.layui-iconpicker-search .layui-icon{position:absolute;top:11px;right:4%;}.layui-iconpicker-tips{text-align:center;padding:8px 0;cursor:not-allowed;}.layui-iconpicker-page{margin-top:6px;margin-bottom:-6px;font-size:12px;padding:0 2px;}.layui-iconpicker-page-count{display:inline-block;}.layui-iconpicker-page-operate{display:inline-block;float:right;cursor:default;}.layui-iconpicker-page-operate .layui-icon{font-size:12px;cursor:pointer;}.layui-iconpicker-body-page .layui-iconpicker-icon-limit{display:none;}.layui-iconpicker-body-page .layui-iconpicker-icon-limit:first-child{display:block;}';
var $style = $('head').find('style[iconpicker]');
if ($style.length === 0) {
$('head').append('<style rel="stylesheet" iconpicker>'+css+'</style>');
}
},
/**
* 获取数据
*/
getfont: {
fontClass: function () {
var arr = ["layui-icon-rate-half","layui-icon-rate","layui-icon-rate-solid","layui-icon-cellphone","layui-icon-vercode","layui-icon-login-wechat","layui-icon-login-qq","layui-icon-login-weibo","layui-icon-password","layui-icon-username","layui-icon-refresh-3","layui-icon-auz","layui-icon-spread-left","layui-icon-shrink-right","layui-icon-snowflake","layui-icon-tips","layui-icon-note","layui-icon-home","layui-icon-senior","layui-icon-refresh","layui-icon-refresh-1","layui-icon-flag","layui-icon-theme","layui-icon-notice","layui-icon-website","layui-icon-console","layui-icon-face-surprised","layui-icon-set","layui-icon-template-1","layui-icon-app","layui-icon-template","layui-icon-praise","layui-icon-tread","layui-icon-male","layui-icon-female","layui-icon-camera","layui-icon-camera-fill","layui-icon-more","layui-icon-more-vertical","layui-icon-rmb","layui-icon-dollar","layui-icon-diamond","layui-icon-fire","layui-icon-return","layui-icon-location","layui-icon-read","layui-icon-survey","layui-icon-face-smile","layui-icon-face-cry","layui-icon-cart-simple","layui-icon-cart","layui-icon-next","layui-icon-prev","layui-icon-upload-drag","layui-icon-upload","layui-icon-download-circle","layui-icon-component","layui-icon-file-b","layui-icon-user","layui-icon-find-fill","layui-icon-loading","layui-icon-loading-1","layui-icon-add-1","layui-icon-play","layui-icon-pause","layui-icon-headset","layui-icon-video","layui-icon-voice","layui-icon-speaker","layui-icon-fonts-del","layui-icon-fonts-code","layui-icon-fonts-html","layui-icon-fonts-strong","layui-icon-unlink","layui-icon-picture","layui-icon-link","layui-icon-face-smile-b","layui-icon-align-left","layui-icon-align-right","layui-icon-align-center","layui-icon-fonts-u","layui-icon-fonts-i","layui-icon-tabs","layui-icon-radio","layui-icon-circle","layui-icon-edit","layui-icon-share","layui-icon-delete","layui-icon-form","layui-icon-cellphone-fine","layui-icon-dialogue","layui-icon-fonts-clear","layui-icon-layer","layui-icon-date","layui-icon-water","layui-icon-code-circle","layui-icon-carousel","layui-icon-prev-circle","layui-icon-layouts","layui-icon-util","layui-icon-templeate-1","layui-icon-upload-circle","layui-icon-tree","layui-icon-table","layui-icon-chart","layui-icon-chart-screen","layui-icon-engine","layui-icon-triangle-d","layui-icon-triangle-r","layui-icon-file","layui-icon-set-sm","layui-icon-add-circle","layui-icon-404","layui-icon-about","layui-icon-up","layui-icon-down","layui-icon-left","layui-icon-right","layui-icon-circle-dot","layui-icon-search","layui-icon-set-fill","layui-icon-group","layui-icon-friends","layui-icon-reply-fill","layui-icon-menu-fill","layui-icon-log","layui-icon-picture-fine","layui-icon-face-smile-fine","layui-icon-list","layui-icon-release","layui-icon-ok","layui-icon-help","layui-icon-chat","layui-icon-top","layui-icon-star","layui-icon-star-fill","layui-icon-close-fill","layui-icon-close","layui-icon-ok-circle","layui-icon-add-circle-fine"];
return arr;
}
},
/**
* 获取数据
*/
getData: function (url) {
var iconlist = [];
$.ajax({
url: url,
type: 'get',
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
async: false,
success: function (ret) {
var exp = /fa-var-(.*):/ig;
var result;
while ((result = exp.exec(ret)) != null) {
iconlist.push('fa-' + result[1]);
}
},
error: function (xhr, textstatus, thrown) {
layer.msg('fa图标接口有误');
}
});
return iconlist;
}
};
a.init();
return new IconHhys();
}
/**
* 选中图标
* @param filter lay-filter
* @param iconName 图标名称自动识别fontClass/unicode
*/
/** IconHhys.prototype.checkIcon = function (filter, iconName){
var el = $('*[lay-filter='+ filter +']'),
p = el.next().find('.layui-iconpicker-item .layui-icon'),
c = iconName;
if (c.indexOf('#xe') > -1){
p.html(c);
} else {
p.html('').attr('class', 'layui-icon ' + c);
}
el.attr('value', c).val(c);
};*/
/**
* 选中图标auwosome
* @param filter lay-filter
* @param iconName 图标名称自动识别fontClass/unicode
*/
/** IconHhys.prototype.checkAwesome = function (filter, iconName) {
var el = $('*[lay-filter=' + filter + ']'),
p = el.next().find('.layui-iconpicker-item .fa'),
c = iconName;
if (c.indexOf('#xe') > 0) {
p.html(c);
} else {
p.html('').attr('class', 'fa ' + c);
}
el.attr('value', c).val(c);
};*/
var iconHhys = new IconHhys();
exports(_MOD, iconHhys);
});
Loading…
Cancel
Save