提交 28d32abb 编写于 作者: G gongfuxiang

新增在线客服应用

上级 e8239bcb
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2018 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\plugins\commononlineservice;
use app\service\PluginsService;
/**
* 在线客服 - 管理
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Admin
{
/**
* 首页
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public function index($params = [])
{
$ret = PluginsService::PluginsData('commononlineservice');
if($ret['code'] == 0)
{
// 数据处理
$ret['data']['online_service'] = str_replace("\n", '<br />', $ret['data']['online_service']);
// 数组组装
$data = [
'data' => $ret['data'],
];
return DataReturn('处理成功', 0, $data);
} else {
return $ret;
}
}
/**
* 编辑页面
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public function saveinfo($params = [])
{
$ret = PluginsService::PluginsData('commononlineservice');
if($ret['code'] == 0)
{
// 是否
$is_whether_list = [
0 => array('id' => 0, 'name' => '否'),
1 => array('id' => 1, 'name' => '是', 'checked' => true),
];
// 数组组装
$data = [
'is_whether_list' => $is_whether_list,
'data' => $ret['data'],
];
return DataReturn('处理成功', 0, $data);
} else {
return $ret;
}
}
/**
* 数据保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public function save($params = [])
{
return PluginsService::PluginsDataSave(['plugins'=>'commononlineservice', 'data'=>$params]);
}
}
?>
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2018 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\plugins\commononlineservice;
use app\service\PluginsService;
/**
* 在线客服 - 钩子入口
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Hook
{
/**
* 应用响应入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-09T14:25:44+0800
* @param [array] $params [输入参数]
*/
public function run($params = [])
{
// 是否控制器钩子
// is_control 当前为控制器业务处理
// hook_name 钩子名称
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
{
// 参数一 描述
// 参数二 0 为处理成功, 负数为失败
// 参数三 返回数据
return DataReturn('返回描述', 0);
// 默认返回视图
} else {
if(!empty($params['hook_name']))
{
switch($params['hook_name'])
{
case 'plugins_css' :
$ret = __MY_ROOT_PUBLIC__.'static/plugins/css/commononlineservice/style.css';
break;
case 'plugins_js' :
$ret = __MY_ROOT_PUBLIC__.'static/plugins/js/commononlineservice/style.js';
break;
case 'plugins_view_common_bottom' :
$ret = $this->html($params);
break;
default :
$ret = '';
}
return $ret;
} else {
return '';
}
}
}
/**
* 视图
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-06T16:16:34+0800
* @param [array] $params [输入参数]
*/
public function html($params = [])
{
// 当前模块/控制器/方法
$module_name = strtolower(request()->module());
$controller_name = strtolower(request()->controller());
$action_name = strtolower(request()->action());
// 获取应用数据
$ret = PluginsService::PluginsData('commononlineservice', ['images']);
// html拼接
$html = '<div class="commononlineservice"';
$content = '';
if($ret['code'] == 0)
{
// 非全局
if($ret['data']['is_overall'] != 1)
{
// 非首页则空
if($module_name.$controller_name.$action_name != 'indexindexindex')
{
return '';
}
}
// 距离顶部距离
if(isset($ret['data']['distance_top']))
{
$html .= ' style="top:'.intval($ret['data']['distance_top']).'%"';
}
// li数量
$online_service_li_count = 0;
// 客服
$online_service = empty($ret['data']['online_service']) ? [] : explode("\n", $ret['data']['online_service']);
$online_service_html = '';
if(!empty($online_service))
{
foreach($online_service as $v)
{
$items = explode('|', $v);
if(!empty($items) && count($items) == 2)
{
$online_service_html .= '<li>
<span>'.$items[0].'</span>
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin='.$items[1].'&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:'.$items[1].':51" alt="点击这里给我发消息" title="点击这里给我发消息"/></a>
</li>';
$online_service_li_count++;
}
}
}
// 电话
$tel_html = '';
if(!empty($ret['data']['tel']))
{
$tel_html .= '<li>
<span>电话:'.$ret['data']['tel'].'</span>
</li>';
$online_service_li_count++;
}
// 背景色
$bg_color = empty($ret['data']['bg_color']) ? '' : 'background:'.$ret['data']['bg_color'].';';
// 组装
$content = '<div class="float-left" style="'.$bg_color.'">
<a class="btn-open" title="查看在线客服" href="javascript:void(0);">展开</a>
<a class="btn-ctn" title="关闭在线客服" href="javascript:void(0);">收缩</a>
</div>
<div class="content" style="'.(($online_service_li_count <= 2) ? 'border-radius:0;'.$bg_color : $bg_color).'">
<div class="cn">
<h3 class="title">'.$ret['data']['title'].'</h3>
<ul>'.$online_service_html.$tel_html.'
</ul>
</div>
</div>';
} else {
$content = $ret['msg'];
}
$html .= '>';
$html .= $content;
$html .= '</div>';
return $html;
}
}
?>
\ No newline at end of file
{
"base":{
"plugins":"commononlineservice",
"name":"在线客服",
"logo":"\/static\/upload\/images\/plugins_commononlineservice\/2019\/02\/17\/1550393245526672.png",
"author":"Devil",
"author_url":"https:\/\/shopxo.net\/",
"version":"1.0.0",
"desc":"在线客服、QQ、电话",
"apply_terminal":[
"pc",
"h5"
],
"apply_version":[
"1.3.0"
],
"is_home":false
},
"hook":{
"plugins_css":[
"app\\plugins\\commononlineservice\\Hook"
],
"plugins_js":[
"app\\plugins\\commononlineservice\\Hook"
],
"plugins_view_common_bottom":[
"app\\plugins\\commononlineservice\\Hook"
]
}
}
\ No newline at end of file
{{include file="public/header" /}}
<!-- right content start -->
<div class="content-right">
<div class="content">
<legend>
<span class="fs-16">在线客服</span>
<a href="{{:MyUrl('admin/pluginsadmin/index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
</legend>
<div class="commononlineservice-content">
<div class="items">
<label>标题</label>
<div>
{{if !empty($data['title'])}}
{{$data.title}}
{{else /}}
未填写
{{/if}}
</div>
</div>
<div class="items">
<label>在线客服</label>
<div>
{{if !empty($data['online_service'])}}
{{$data.online_service|raw}}
{{else /}}
未填写
{{/if}}
</div>
</div>
<div class="items">
<label>电话</label>
<div>
{{if !empty($data['tel'])}}
{{$data.tel}}
{{else /}}
未填写
{{/if}}
</div>
</div>
<div class="items">
<label>是否全局</label>
<div>
{{if isset($data['is_overall']) and $data['is_overall'] eq 1}}
{{else /}}
{{/if}}
</div>
</div>
<div class="items">
<label>背景色</label>
<div class="bg-color-tag" {{if !empty($data['bg_color'])}}style="background:{{$data.bg_color}}"{{/if}}></div>
</div>
<div class="items">
<label>距离顶部</label>
<div>
{{if !empty($data['distance_top'])}}
{{$data.distance_top}}
{{else /}}
0
{{/if}}
%
</div>
</div>
<a href="{{:PluginsAdminUrl('commononlineservice', 'admin', 'saveinfo')}}" class="am-btn am-btn-secondary am-radius btn-loading-example am-btn-sm am-btn-block edit-submit">编辑</a>
</div>
</div>
</div>
<!-- right content end -->
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->
\ No newline at end of file
{{include file="public/header" /}}
<!-- right content start -->
<div class="content-right">
<div class="content">
<!-- form start -->
<form class="am-form form-validation view-save" action="{{:PluginsAdminUrl('commononlineservice', 'admin', 'save')}}" method="POST" request-type="ajax-url" request-value="{{:PluginsAdminUrl('commononlineservice', 'admin', 'index')}}" enctype="multipart/form-data">
<legend>
<span class="fs-16">在线客服</span>
<a href="{{:PluginsAdminUrl('commononlineservice', 'admin', 'index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-form-group">
<label>标题</label>
<input type="text" name="title" placeholder="标题" minlength="2" maxlength="16" data-validation-message="标题格式 2~16 个字符之间" class="am-radius" value="{{if !empty($data)}}{{$data.title}}{{/if}}" required />
</div>
<div class="am-form-group am-form-file">
<label class="block">在线客服<span class="fs-12 fw-100 cr-999">(一行一个、以竖线 | 分割、如:客服一|123456)</span></label>
<textarea rows="5" name="online_service" class="am-radius am-field-valid" placeholder="在线客服" data-validation-message="请填写在线客服" required>{{if !empty($data['online_service'])}}{{$data.online_service}}{{/if}}</textarea>
</div>
<div class="am-form-group">
<label>电话</label>
<input type="text" name="tel" placeholder="电话" data-validation-message="请填写电话" class="am-radius" value="{{if !empty($data)}}{{$data.tel}}{{/if}}" />
</div>
<div class="am-form-group">
<label>是否全局<span class="fs-12 fw-100 cr-999">(否则只在首页显示,是则全局展示)</span></label>
<div>
{{foreach $is_whether_list as $v}}
<label class="am-radio-inline m-r-10">
<input type="radio" name="is_overall" value="{{$v.id}}" {{if isset($data['is_overall']) and $data['is_overall'] eq $v['id']}}checked="checked"{{else /}}{{if !isset($data['is_overall']) and isset($v['checked']) and $v['checked'] eq true}}checked="checked"{{/if}}{{/if}} data-am-ucheck /> {{$v.name}}
</label>
{{/foreach}}
</div>
</div>
<div class="am-form-group">
<label>背景色</label>
<input type="hidden" name="bg_color" value="{{if !empty($data['bg_color'])}}{{$data.bg_color}}{{/if}}" />
<button class="am-btn am-btn-default colorpicker-submit bg-color-tag am-btn-block bk-cr-white t-r" type="button" data-input-tag="button.bg-color-tag" data-color-tag="input[name='bg_color']" data-color-style="background-color" {{if !empty($data['bg_color'])}}style="background:{{$data.bg_color}}"{{/if}}>
<img src="{{$attachment_host}}/static/common/images/colorpicker.png" />
</button>
</div>
<div class="am-form-group">
<label>距离顶部<span class="fs-12 fw-100 cr-999">(默认距离顶部30%)</span></label>
<input type="number" name="distance_top" placeholder="距离顶部" min="0" max="100" data-validation-message="距离顶部 0~100" class="am-radius" value="{{if isset($data['distance_top'])}}{{$data.distance_top}}{{else /}}30{{/if}}" required />
</div>
<div class="am-form-group">
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
</div>
</form>
<!-- form end -->
</div>
</div>
<!-- right content end -->
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->
\ No newline at end of file
/**
* 首页
*/
.commononlineservice-content .items {
margin: 10px 0 20px 0;
border-bottom: 1px dashed #f1f1f1;
padding-bottom: 20px;
}
.commononlineservice-content .items .immages-tag {
border: 1px solid #eee;
text-align: center;
max-width: 100px;
padding: 5px;
}
.commononlineservice-content .items .immages-tag img {
max-width: 100%;
}
.commononlineservice-content .items .bg-color-tag {
width: 50px;
height: 50px;
border: 1px solid #eee;
}
.commononlineservice-content .edit-submit {
margin-bottom: 20px;
}
\ No newline at end of file
.commononlineservice .float-left, .commononlineservice .content {
background:#d2364c;
}
.commononlineservice {
font-size: 12px;
position: fixed;
top: 30%;
right: 0px;
z-index: 1000;
}
.commononlineservice .float-left {
width: 36px;
float:left;
position: relative;
z-index:1;
margin-top: 0;
height: 120px;
border-radius: 6px 0px 0 6px;
}
.commononlineservice .float-left a {
font-size:0;
text-indent: -999em;
}
.commononlineservice .content {
float: left;
padding: 5px;
overflow:hidden;
width: 140px;
margin-right:-150px;
border-radius: 0 0px 0 6px;
}
.commononlineservice .content .cn {
background:#F7F7F7;
border-radius:6px;
}
.commononlineservice .cn .title {
font-size: 14px;
color: #333;
font-weight:600;
line-height:24px;
padding:5px;
text-align:center;
margin: 0;
}
.commononlineservice .cn ul {
padding:0px;
margin: 0;
}
.commononlineservice .cn ul li {
line-height: 38px;
height:38px;
border-bottom: solid 1px #E6E4E4;
overflow: hidden;
text-align:center;
}
.commononlineservice .cn ul li:last-child {
border: 0;
}
.commononlineservice .cn ul li span, .commononlineservice .cn ul li a {
color: #777;
}
.commononlineservice .cn ul li img {
vertical-align: middle;
}
.commononlineservice .btn-open, .commononlineservice .btn-ctn {
position: relative;
z-index:9;
top:0;
left: 0;
background-image: url(../../images/commononlineservice/btn-ctn.png);
background-repeat: no-repeat;
display:block;
height: 120px;
background-size: 55px;
}
.commononlineservice .btn-open {
background-position: 3px 10px;
}
.commononlineservice .btn-ctn {
background-position: -24px 10px;
display: none;
}
.commononlineservice ul li.top {
border-bottom: solid #ACE5F9 1px;
}
.commononlineservice ul li.bot {
border-bottom: none;
}
\ No newline at end of file
$(function()
{
// 在线客服
$('.commononlineservice .btn-open').click(function()
{
$('.commononlineservice .content').animate({'margin-right':'0px'}, 300);
$('.commononlineservice .btn-open').css('display', 'none');
$('.commononlineservice .btn-ctn').css('display', 'block');
});
$('.commononlineservice .btn-ctn').click(function()
{
$('.commononlineservice .content').animate({'margin-right':'-150px'}, 300);
$('.commononlineservice .btn-open').css('display', 'block');
$('.commononlineservice .btn-ctn').css('display', 'none');
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册