index.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. {extend name="public/container"}
  2. {block name="head_top"}
  3. <title>编辑内容</title>
  4. <!--<link href="{__ADMIN_PATH}plug/umeditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">-->
  5. <link href="{__ADMIN_PATH}module/wechat/news/css/style.css" type="text/css" rel="stylesheet">
  6. <link href="{__FRAME_PATH}css/plugins/chosen/chosen.css" rel="stylesheet">
  7. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/jquery.min.js"></script>
  8. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/template.min.js"></script>
  9. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.config.js"></script>
  10. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/umeditor/umeditor.min.js"></script>
  11. <script src="{__ADMIN_PATH}plug/validate/jquery.validate.js"></script>
  12. <script src="{__FRAME_PATH}js/plugins/chosen/chosen.jquery.js"></script>
  13. <script src="{__ADMIN_PATH}plug/vue/dist/vue.min.js"></script>
  14. <script type="text/javascript" src="{__ADMIN_PATH}js/request.js"></script>
  15. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/third-party/zeroclipboard/ZeroClipboard.js"></script>
  16. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.config.js"></script>
  17. <script type="text/javascript" charset="utf-8" src="{__ADMIN_PATH}plug/ueditor/ueditor.all.min.js"></script>
  18. <script type="text/javascript" src="{__ADMIN_PATH}plug/ueditor/lang/zh-cn/zh-cn.js"></script>
  19. <script type="text/javascript" src="{__ADMIN_PATH}js/aliyun-oss-sdk-4.4.4.min.js"></script>
  20. <script type="text/javascript" src="{__MODULE_PATH}widget/lib/plupload-2.1.2/js/plupload.full.min.js"></script>
  21. <script type="text/javascript" src="{__MODULE_PATH}widget/OssUpload.js"></script>
  22. <style>
  23. .edui-btn-toolbar .edui-btn.edui-active .edui-icon-fullscreen.edui-icon {
  24. display: none;
  25. }
  26. .edui-container {
  27. overflow: initial !important;
  28. }
  29. button.btn-success.dim {
  30. box-shadow: inset 0 0 0 #1872ab, 0 5px 0 0 #1872ab, 0 10px 5px #999;
  31. }
  32. .float-e-margins .btn {
  33. margin-bottom: 5px;
  34. }
  35. button.dim {
  36. display: inline-block;
  37. color: #fff;
  38. text-decoration: none;
  39. text-transform: uppercase;
  40. text-align: center;
  41. padding-top: 6px;
  42. margin-right: 10px;
  43. position: relative;
  44. cursor: pointer;
  45. border-radius: 5px;
  46. font-weight: 600;
  47. margin-bottom: 20px !important;
  48. }
  49. .btn-success {
  50. background-color: #1c84c6;
  51. border-color: #1c84c6;
  52. color: #FFF;
  53. }
  54. .btn {
  55. border-radius: 3px;
  56. }
  57. .btn-success {
  58. color: #fff;
  59. background-color: #0093dd;
  60. border-color: #0093dd;
  61. }
  62. .btn {
  63. display: inline-block;
  64. padding: 6px 12px;
  65. margin-bottom: 0;
  66. font-size: 14px;
  67. font-weight: 400;
  68. line-height: 1.42857143;
  69. text-align: center;
  70. white-space: nowrap;
  71. vertical-align: middle;
  72. -ms-touch-action: manipulation;
  73. touch-action: manipulation;
  74. cursor: pointer;
  75. -webkit-user-select: none;
  76. -moz-user-select: none;
  77. -ms-user-select: none;
  78. user-select: none;
  79. background-image: none;
  80. border: 1px solid transparent;
  81. border-radius: 4px;
  82. }
  83. button, input, select, textarea {
  84. font-family: inherit;
  85. font-size: inherit;
  86. line-height: inherit;
  87. }
  88. button.btn-success.dim:active {
  89. box-shadow: inset 0 0 0 #1872ab, 0 2px 0 0 #1872ab, 0 5px 3px #999;
  90. }
  91. button.dim:active {
  92. bottom: 4px;
  93. }
  94. .btn-success.active, .btn-success:active, .open .dropdown-toggle.btn-success {
  95. background-image: none;
  96. }
  97. .btn-success.active, .btn-success:active, .btn-success:focus, .btn-success:hover, .open .dropdown-toggle.btn-success {
  98. background-color: #1a7bb9;
  99. border-color: #1a7bb9;
  100. color: #FFF;
  101. }
  102. .m-t-5 {
  103. margin-top: 5px;
  104. }
  105. .edui-default .edui-for-image .edui-icon {
  106. background-position: -380px 0px;
  107. }
  108. </style>
  109. {/block}
  110. {block name="content"}
  111. <div class="layui-fluid">
  112. <div class="layui-row layui-col-space15" id="app">
  113. <div class="layui-col-md12">
  114. <div class="layui-card">
  115. <div class="layui-card-header">{$title}</div>
  116. <div class="layui-card-body">
  117. <textarea id="myEditor" style="width:100%;height: 500px">{$content ? $content : ''}</textarea>
  118. </div>
  119. <button class="btn btn-success" style="margin-left: 45%;" @click="submit" type="button">提交编辑</button>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. <script type="text/javascript" src="{__ADMIN_PATH}js/layuiList.js"></script>
  125. {/block}
  126. {block name="script"}
  127. <script type="text/javascript">
  128. var _vue = new Vue({
  129. el:'#app',
  130. data:{
  131. uploader: null,
  132. ue: null,
  133. //上传类型
  134. mime_types: {
  135. Image: "jpg,gif,png,JPG,GIF,PNG",
  136. Video: "mp4,MP4",
  137. },
  138. host: ossUpload.host + '/',
  139. },
  140. methods:{
  141. submit:function () {
  142. var that = this;
  143. $.ajax({
  144. url:"{:Url('save',['id'=>$id])}",
  145. data:{content:that.ue.getContent()},
  146. type:'post',
  147. dataType:'json',
  148. success:function(res){
  149. if(res.code == 200){
  150. location.reload();
  151. return $eb.message('success',res.msg);
  152. }else{
  153. return $eb.message('error',res.msg);
  154. }
  155. }
  156. })
  157. }
  158. },
  159. mounted:function () {
  160. var that = this;
  161. //选择图片插入到编辑器中
  162. window.insertEditor = function (list) {
  163. that.ue.execCommand('insertimage', list);
  164. };
  165. that.$nextTick(function () {
  166. layList.form.render();
  167. //实例化编辑器
  168. UE.registerUI('imagenone', function (editor, name) {
  169. var $btn = new UE.ui.Button({
  170. name: 'image',
  171. onclick: function () {
  172. ossUpload.createFrame('选择图片', {fodder: 'editor'},{w:800,h:550});
  173. },
  174. title: '选择图片'
  175. });
  176. return $btn;
  177. });
  178. that.ue = UE.getEditor('myEditor');
  179. });
  180. that.$nextTick(function () {
  181. that.uploader = ossUpload.upload({
  182. id: 'ossupload',
  183. FilesAddedSuccess: function () {
  184. },
  185. uploadIng: function (file) {
  186. },
  187. success: function (res) {
  188. layList.msg('上传成功');
  189. },
  190. fail: function (err) {
  191. layList.msg(err);
  192. }
  193. })
  194. });
  195. }
  196. })
  197. function changeIMG(index,pic){
  198. _vue._data.newListIndex.image_input = pic;
  199. _vue._data.newList[_vue._data.indexItem].image_input = pic;
  200. };
  201. </script>
  202. {/block}