190 行
8.7 KiB
JavaScript
190 行
8.7 KiB
JavaScript
define([], function () {
|
|
if (Config.modulename == 'admin' && Config.controllername == 'index' && Config.actionname == 'index') {
|
|
require.config({
|
|
paths: {
|
|
'vue': "../addons/shopro/libs/vue",
|
|
'moment': "../addons/shopro/libs/moment",
|
|
'text': "../addons/shopro/libs/require-text",
|
|
'chat': '../addons/shopro/libs/chat',
|
|
'ELEMENT': '../addons/shopro/libs/element/element',
|
|
},
|
|
shim: {
|
|
'ELEMENT': {
|
|
deps: ['css!../addons/shopro/libs/element/element.css']
|
|
},
|
|
},
|
|
});
|
|
require(['vue', 'jquery', 'chat', 'text!../addons/shopro/chat.html', 'ELEMENT', 'moment'], function (Vue, $, Chat, ChatTemp, ELEMENT, Moment) {
|
|
|
|
Vue.use(ELEMENT);
|
|
|
|
var wsUri;
|
|
Fast.api.ajax({
|
|
url: 'shopro/chat/index/init',
|
|
loading: false,
|
|
type: 'GET'
|
|
}, function (ret, res) {
|
|
if (res.data.config.type == 'shopro') {
|
|
|
|
let wg = 'ws';
|
|
if (res.data.config.system.is_ssl == 1) {
|
|
wg = 'wss';
|
|
}
|
|
wsUri = wg + '://' + window.location.hostname + ':' + res.data.config.system.gateway_port;
|
|
// 反向代理
|
|
if (res.data.config.system.is_ssl == 1 && res.data.config.system.ssl_type == 'reverse_proxy') {
|
|
wsUri = wg + '://' + window.location.hostname + '/websocket/';
|
|
}
|
|
$("body").append(`<div id="chatTemplateContainer" style="display:none"></div>
|
|
<div id="chatService"><Chat :passvalue="obj"></Chat></div>`);
|
|
|
|
$("#chatTemplateContainer").append(ChatTemp);
|
|
|
|
new Vue({
|
|
el: "#chatService",
|
|
data() {
|
|
return {
|
|
obj: {
|
|
commonWordsList: res.data.fast_reply,
|
|
token: res.data.token,
|
|
wsUri: wsUri,
|
|
expire_time: res.data.expire_time,
|
|
customer_service_id: res.data.customer_service.id,
|
|
adminData: res.data,
|
|
emoji_list: res.data.emoji
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
return false;
|
|
}, function (ret, res) {
|
|
if (res.msg == '') {
|
|
return false;
|
|
}
|
|
})
|
|
});
|
|
}
|
|
require.config({
|
|
paths: {
|
|
'summernote': '../addons/summernote/lang/summernote-zh-CN.min'
|
|
},
|
|
shim: {
|
|
'summernote': ['../addons/summernote/js/summernote.min', 'css!../addons/summernote/css/summernote.min.css'],
|
|
}
|
|
});
|
|
require(['form', 'upload'], function (Form, Upload) {
|
|
var _bindevent = Form.events.bindevent;
|
|
Form.events.bindevent = function (form) {
|
|
_bindevent.apply(this, [form]);
|
|
try {
|
|
//绑定summernote事件
|
|
if ($(Config.summernote.classname || '.editor', form).length > 0) {
|
|
var selectUrl = typeof Config !== 'undefined' && Config.modulename === 'index' ? 'user/attachment' : 'general/file/index?select=1';
|
|
require(['summernote'], function () {
|
|
var imageButton = function (context) {
|
|
var ui = $.summernote.ui;
|
|
var button = ui.button({
|
|
contents: '<i class="fa fa-file-image-o"/>',
|
|
tooltip: __('Choose'),
|
|
click: function () {
|
|
parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=image/", __('Choose'), {
|
|
area: ['100%', '100%'],
|
|
callback: function (data) {
|
|
var urlArr = data.url.split(/\,/);
|
|
$.each(urlArr, function () {
|
|
var url = Fast.api.cdnurl(this, true);
|
|
context.invoke('editor.insertImage', url);
|
|
});
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
});
|
|
return button.render();
|
|
};
|
|
var attachmentButton = function (context) {
|
|
var ui = $.summernote.ui;
|
|
var button = ui.button({
|
|
contents: '<i class="fa fa-file"/>',
|
|
tooltip: __('Choose'),
|
|
click: function () {
|
|
parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=*", __('Choose'), {
|
|
area: ['100%', '100%'],
|
|
callback: function (data) {
|
|
var urlArr = data.url.split(/\,/);
|
|
$.each(urlArr, function () {
|
|
var url = Fast.api.cdnurl(this, true);
|
|
var node = $("<a href='" + url + "'>" + url + "</a>");
|
|
context.invoke('insertNode', node[0]);
|
|
});
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
});
|
|
return button.render();
|
|
};
|
|
|
|
$(Config.summernote.classname || '.editor', form).each(function () {
|
|
$(this).summernote($.extend(true, {}, {
|
|
// height: 250,
|
|
minHeight: 250,
|
|
lang: 'zh-CN',
|
|
fontNames: [
|
|
'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
|
|
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
|
|
"Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
|
|
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
|
|
],
|
|
fontNamesIgnoreCheck: [
|
|
"Open Sans", "Microsoft YaHei",
|
|
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
|
|
],
|
|
toolbar: [
|
|
['style', ['style', 'undo', 'redo']],
|
|
['font', ['bold', 'underline', 'strikethrough', 'clear']],
|
|
['fontname', ['color', 'fontname', 'fontsize']],
|
|
['para', ['ul', 'ol', 'paragraph', 'height']],
|
|
['table', ['table', 'hr']],
|
|
['insert', ['link', 'picture', 'video']],
|
|
['select', ['image', 'attachment']],
|
|
['view', ['fullscreen', 'codeview', 'help']],
|
|
],
|
|
buttons: {
|
|
image: imageButton,
|
|
attachment: attachmentButton,
|
|
},
|
|
dialogsInBody: true,
|
|
followingToolbar: false,
|
|
callbacks: {
|
|
onChange: function (contents) {
|
|
$(this).val(contents);
|
|
$(this).trigger('change');
|
|
},
|
|
onInit: function () {
|
|
},
|
|
onImageUpload: function (files) {
|
|
var that = this;
|
|
//依次上传图片
|
|
for (var i = 0; i < files.length; i++) {
|
|
Upload.api.send(files[i], function (data) {
|
|
var url = Fast.api.cdnurl(data.url, true);
|
|
$(that).summernote("insertImage", url, 'filename');
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}, $(this).data("summernote-options") || {}));
|
|
});
|
|
});
|
|
}
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
};
|
|
});
|
|
|
|
}); |