mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
[更新]微信菜单增加小程序支持
This commit is contained in:
parent
095b306c47
commit
6436925093
@ -116,13 +116,16 @@ class Menu extends BasicAdmin {
|
|||||||
*/
|
*/
|
||||||
protected function _push() {
|
protected function _push() {
|
||||||
$result = Db::name($this->table)
|
$result = Db::name($this->table)
|
||||||
->field('id,index,pindex,name,type,content')
|
->field('id,index,pindex,name,type,content')
|
||||||
->where('status', '1')
|
->where('status', '1')
|
||||||
->order('sort ASC,id ASC')
|
->order('sort ASC,id ASC')
|
||||||
->select();
|
->select();
|
||||||
foreach ($result as &$row) {
|
foreach ($result as &$row) {
|
||||||
empty($row['content']) && $row['content'] = uniqid();
|
empty($row['content']) && $row['content'] = uniqid();
|
||||||
switch ($row['type']) {
|
switch ($row['type']) {
|
||||||
|
case 'miniprogram':
|
||||||
|
list($row['appid'], $row['pagepath']) = explode(',', $row['content']);
|
||||||
|
break;
|
||||||
case 'view':
|
case 'view':
|
||||||
$row['url'] = preg_match('#^(\w+:)?//#i', $row['content']) ? $row['content'] : url($row['content'], '', true, true);
|
$row['url'] = preg_match('#^(\w+:)?//#i', $row['content']) ? $row['content'] : url($row['content'], '', true, true);
|
||||||
break;
|
break;
|
||||||
|
@ -89,6 +89,9 @@
|
|||||||
<label class="col-xs-5 font-noraml">
|
<label class="col-xs-5 font-noraml">
|
||||||
<input class="cuci-radio" type="radio" name="menu-type" value="event"> 事件功能
|
<input class="cuci-radio" type="radio" name="menu-type" value="event"> 事件功能
|
||||||
</label>
|
</label>
|
||||||
|
<label class="col-xs-5 font-noraml">
|
||||||
|
<input class="cuci-radio" type="radio" name="menu-type" value="miniprogram"> 小程序
|
||||||
|
</label>
|
||||||
<label class="col-xs-5 font-noraml">
|
<label class="col-xs-5 font-noraml">
|
||||||
<input class="cuci-radio" type="radio" name="menu-type" value="customservice"> 多客服
|
<input class="cuci-radio" type="radio" name="menu-type" value="customservice"> 多客服
|
||||||
</label>
|
</label>
|
||||||
@ -232,8 +235,17 @@
|
|||||||
$html.find('input[name="menu-type"]').on('click', function () {
|
$html.find('input[name="menu-type"]').on('click', function () {
|
||||||
$span.attr('data-type', this.value || 'text');
|
$span.attr('data-type', this.value || 'text');
|
||||||
var content = $span.data('content') || '';
|
var content = $span.data('content') || '';
|
||||||
|
var type = this.value;
|
||||||
var html = function () {
|
var html = function () {
|
||||||
switch (this.value) {
|
switch (type) {
|
||||||
|
case 'miniprogram':
|
||||||
|
var tpl = '<div><div>小程序APPID<input style="display:block;margin-bottom:10px" class="form-control input-sm" value="{appid}" name="appid"/></div>Pagepath<textarea style="resize:none;height:180px;" name="pagepath" class="form-control input-sm">{content}</textarea></div>';
|
||||||
|
var _appid = '', _content = '';
|
||||||
|
if (content.indexOf(',') > 0) {
|
||||||
|
_appid = content.split(',')[0];
|
||||||
|
_content = content.split(',')[1];
|
||||||
|
}
|
||||||
|
return tpl.replace('{appid}', _appid).replace('{content}', _content);
|
||||||
case 'customservice':
|
case 'customservice':
|
||||||
case 'text':
|
case 'text':
|
||||||
return '<div>回复内容<textarea style="resize:none;height:225px" name="content" class="form-control input-sm">{content}</textarea></div>'.replace('{content}', content);
|
return '<div>回复内容<textarea style="resize:none;height:225px" name="content" class="form-control input-sm">{content}</textarea></div>'.replace('{content}', content);
|
||||||
@ -262,7 +274,12 @@
|
|||||||
}.call(this);
|
}.call(this);
|
||||||
var $html = $(html), $input = $html.find('input,textarea');
|
var $html = $(html), $input = $html.find('input,textarea');
|
||||||
$input.on('change keyup click', function () {
|
$input.on('change keyup click', function () {
|
||||||
$span.data('content', $(this).val() || $(this).html());
|
// 将input值写入到span上
|
||||||
|
$span.data(this.name, $(this).val() || $(this).html());
|
||||||
|
// 如果是小程序,合并内容到span的content上
|
||||||
|
if (type === 'miniprogram') {
|
||||||
|
$span.data('content', $span.data('appid') + ',' + $span.data('pagepath'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
$('.editor-content-input').html($html);
|
$('.editor-content-input').html($html);
|
||||||
}).filter('input[value="{type}"]'.replace('{type}', type)).trigger('click');
|
}).filter('input[value="{type}"]'.replace('{type}', type)).trigger('click');
|
||||||
@ -274,12 +291,16 @@
|
|||||||
*/
|
*/
|
||||||
menu.prototype.submit = function () {
|
menu.prototype.submit = function () {
|
||||||
var data = [];
|
var data = [];
|
||||||
|
|
||||||
function getdata($span) {
|
function getdata($span) {
|
||||||
var menudata = {};
|
var menudata = {};
|
||||||
menudata.name = $span.text();
|
menudata.name = $span.text();
|
||||||
menudata.type = $span.attr('data-type');
|
menudata.type = $span.attr('data-type');
|
||||||
menudata.content = $span.data('content') || '';
|
// 小程序要特殊处理
|
||||||
|
if (menudata.type === 'miniprogram') {
|
||||||
|
menudata.content = $span.data('appid') + ',' + $span.data('pagepath');
|
||||||
|
} else {
|
||||||
|
menudata.content = $span.data('content') || '';
|
||||||
|
}
|
||||||
return menudata;
|
return menudata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user