Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

upload_m.htm 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>可视化编辑</title>
  5. <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
  6. <link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css">
  7. {load href="__STATIC__/common/js/jquery.min.js" /}
  8. {load href="__PUBLIC__/plugins/layer-v3.1.0/layer.js" /}
  9. <style type="text/css">
  10. .controls {
  11. width: 100%;
  12. padding: 4px 0;
  13. }
  14. .bg{
  15. background-color: #FDFDFD;
  16. overflow: hidden;
  17. height: auto;
  18. padding: 8px 0;
  19. border-top:1px solid #f7f7f7;
  20. border-bottom:1px solid #f7f7f7;
  21. }
  22. .container-fluid {
  23. padding: 10px 10px;
  24. overflow: hidden;
  25. }
  26. .control-group {
  27. }
  28. .title{
  29. float: left;
  30. width: 70px;
  31. text-align: right;
  32. color: #888;
  33. }
  34. .left {
  35. float: left;
  36. width: 250px;
  37. }
  38. .btn{
  39. background-color: #4fc0e8;
  40. color: #FFF;
  41. border-radius: 4px;
  42. padding: 6px 20px;
  43. }
  44. .btn:hover {
  45. color: #FFF;
  46. background-color: #3aa8cf;
  47. }
  48. .input-txt{
  49. width: 100%;
  50. }
  51. .pl70{
  52. padding-left: 70px;
  53. }
  54. .div_litpic_local [type=file]{
  55. color: #666;
  56. }
  57. .controls label{
  58. color: #666;
  59. }
  60. .imgsrc{
  61. position: relative;
  62. width: 60px;
  63. height: 60px;
  64. display: inline-block;
  65. border: 1px solid #eee;
  66. overflow: hidden;
  67. }
  68. .imgsrc .upload-btn{
  69. width: 60px;
  70. height: 60px;
  71. position: absolute;
  72. top: 0;
  73. left: 0;
  74. bottom: 0;
  75. opacity: 0;
  76. z-index: 3;
  77. }
  78. .imgsrc em {
  79. height: 18px;
  80. position: absolute;
  81. bottom: 0;
  82. line-height: 18px;
  83. display: block;
  84. width: 100%;
  85. background: rgba(0, 0, 0, 0.5);
  86. color: #fff;
  87. text-align: center;
  88. font-size: 12px;
  89. font-style: normal;
  90. font-family: 宋体;
  91. }
  92. </style>
  93. </head>
  94. <body>
  95. <div class="container-fluid">
  96. <div class="row-fluid">
  97. <div class="span12">
  98. <form class="form-horizontal" id="post_form" onsubmit="return check_submit();">
  99. <div class="control-group">
  100. <div class="controls">
  101. <div class="title">原图片:</div>
  102. <div class="imgsrc">
  103. <input class="upload-btn" type="file" name="litpic_local" id="litpic_local" value="{$field.litpic_local|default=''}">
  104. <img src="" width="60" height="60" />
  105. <em>更换图片</em>
  106. </div>
  107. </div>
  108. </div>
  109. <div class="control-group bg">
  110. <div class="controls">
  111. <div class="title">&nbsp;</div>
  112. <!-- <div class="left div_litpic_local" {if condition="isset($field.is_remote) AND $field.is_remote == 1"}style="display: none;"{/if}>
  113. <input type="file" name="litpic_local" id="litpic_local" value="{$field.litpic_local|default=''}">
  114. </div> -->
  115. <div class="left">
  116. <input type="text" id="litpic_remote" name="litpic_remote" value="{$field.litpic_remote|default=''}" autocomplete="off" placeholder="http://" class="input-txt" {if condition="!isset($field.is_remote) OR empty($field.is_remote)"} style="display: none;"{/if}>
  117. <label style="cursor: pointer;"><input type="checkbox" name="is_remote" id="is_remote" value="1" {if condition="isset($field.is_remote) AND $field.is_remote == 1"}checked="checked"{/if} onClick="clickRemote(this, 'litpic');">远程图片</label>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="control-group">
  122. <div class="controls pl70">
  123. <input type="hidden" name="oldhtml" value="">
  124. <input type="hidden" name="id" value="{$field.id|default=''}">
  125. <input type="hidden" name="type" value="{$field.type|default=''}">
  126. <input type="hidden" name="page" value="{$field.page|default=''}">
  127. <input type="hidden" name="v" value="{$v|default='pc'}">
  128. <input type="hidden" name="lang" value="{$field.lang|default='cn'}">
  129. <input type="hidden" name="idcode" value="{$field.idcode|default=''}">
  130. <input type="hidden" name="iframe" value="1">
  131. <label class="checkbox"><input type="button" class="btn" value="确认提交" onclick="check_submit();" /></label>
  132. </div>
  133. </div>
  134. </form>
  135. </div>
  136. </div>
  137. </div>
  138. <script type="text/javascript">
  139. $(function(){
  140. var oldhtml = parent.eyou_getOldHtml();
  141. var oldimgsrc = parent.eyou_getOldImgsrc();
  142. $('input[name=oldhtml]').val(oldhtml);
  143. $('.imgsrc img').attr('src',oldimgsrc);
  144. //在input file内容改变的时候触发事件
  145. $('#litpic_local').change(function(){
  146. //获取input file的files文件数组;
  147. //$('#filed')获取的是jQuery对象,.get(0)转为原生对象;
  148. //这边默认只能选一个,但是存放形式仍然是数组,所以取第一个元素使用[0];
  149. var file = $('#litpic_local').get(0).files[0];
  150. //创建用来读取此文件的对象
  151. var reader = new FileReader();
  152. //使用该对象读取file文件
  153. reader.readAsDataURL(file);
  154. //读取文件成功后执行的方法函数
  155. reader.onload=function(e){
  156. //读取成功后返回的一个参数e,整个的一个进度事件
  157. //选择所要显示图片的img,要赋值给img的src就是e中target下result里面
  158. //的base64编码格式的地址
  159. $('.imgsrc img').get(0).src = e.target.result;
  160. }
  161. })
  162. });
  163. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  164. // 远程/本地上传图片切换
  165. function clickRemote(obj, id)
  166. {
  167. if ($(obj).is(':checked')) {
  168. $('#litpic_remote').focus();
  169. $('#'+id+'_remote').show();
  170. $('.div_'+id+'_local').hide();
  171. } else {
  172. $('.div_'+id+'_local').show();
  173. $('#'+id+'_remote').hide();
  174. }
  175. }
  176. function check_submit()
  177. {
  178. parent.eyou_layer_loading('正在处理');
  179. var formData = new FormData($("#post_form")[0]);
  180. var url = "{:url('api/Uiset/submit', ['_ajax'=>1])}";
  181. $.ajax({
  182. url: url,
  183. type: 'POST',
  184. data: formData,
  185. // async: false,
  186. cache: false,
  187. contentType: false,
  188. processData: false,
  189. dataType: 'JSON',
  190. success: function(res){
  191. parent.layer.closeAll();
  192. if (res.code == 1) {
  193. $('input[name=oldhtml]').val(res.data.html);
  194. $('.imgsrc img').attr('src', res.data.imgsrc);
  195. $('#workspace', window.parent.document).attr('src', $('#workspace', window.parent.document).attr('src'));
  196. parent.layer.msg(res.msg, {icon: 1, shade: 0.3, time: 1000});
  197. } else {
  198. parent.eyou_showErrorAlert(res.msg);
  199. }
  200. },
  201. error: function(e){
  202. parent.layer.closeAll();
  203. parent.eyou_showErrorAlert(e.responseText);
  204. }
  205. });
  206. }
  207. </script>
  208. </body>
  209. </html>