diff --git a/application/wechat/controller/Menu.php b/application/wechat/controller/Menu.php index ceadb5016..3de25c0a5 100644 --- a/application/wechat/controller/Menu.php +++ b/application/wechat/controller/Menu.php @@ -1,4 +1,5 @@ deleteMenu(); $this->success('删除并取消微信菜单成功!', ''); } + foreach ($data as &$vo) { + if (isset($vo['content'])) { + $vo['content'] = str_replace('"', "'", $vo['content']); + } + } if (Db::name($this->table)->where('1=1')->delete() !== false && Db::name($this->table)->insertAll($data) !== false) { $result = $this->_push(); if ($result['status']) { @@ -110,10 +116,10 @@ class Menu extends BasicAdmin { */ protected function _push() { $result = Db::name($this->table) - ->field('id,index,pindex,name,type,content') - ->where('status', '1') - ->order('sort ASC,id ASC') - ->select(); + ->field('id,index,pindex,name,type,content') + ->where('status', '1') + ->order('sort ASC,id ASC') + ->select(); foreach ($result as &$row) { empty($row['content']) && $row['content'] = uniqid(); switch ($row['type']) { @@ -153,4 +159,5 @@ class Menu extends BasicAdmin { } return array('status' => false, 'errmsg' => $wechat->errMsg); } + } diff --git a/application/wechat/view/menu.index.html b/application/wechat/view/menu.index.html index f98bc036d..e17611337 100644 --- a/application/wechat/view/menu.index.html +++ b/application/wechat/view/menu.index.html @@ -231,7 +231,7 @@ var type = $span.attr('data-type') || 'text'; $html.find('input[name="menu-type"]').on('click', function () { $span.attr('data-type', this.value || 'text'); - var content = $span.attr('data-content') || ''; + var content = $span.data('content') || ''; var html = function () { switch (this.value) { case 'customservice': @@ -253,7 +253,7 @@ var select = [], tpl = '
'; if (!(options[content] || false)) { content = 'scancode_push'; - $span.attr('data-content', content); + $span.data('content', content); } for (var i in options) { select.push(tpl.replace('{value}', i).replace('{title}', options[i]).replace('{checked}', (i === content) ? 'checked' : '')); @@ -263,7 +263,7 @@ }.call(this); var $html = $(html), $input = $html.find('input,textarea'); $input.on('change keyup click', function () { - $span.attr('data-content', $(this).val() || $(this).html()); + $span.data('content', $(this).val() || $(this).html()); }); $('.editor-content-input').html($html); }).filter('input[value="{type}"]'.replace('{type}', type)).trigger('click'); @@ -280,7 +280,7 @@ var menudata = {}; menudata.name = $span.text(); menudata.type = $span.attr('data-type'); - menudata.content = $span.attr('data-content') || ''; + menudata.content = $span.data('content') || ''; return menudata; }