Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

288 wiersze
12 KiB

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>{=empty($novel)?'创建作品':'管理作品'} - 原创专区 - {$kx.config.sitename}</title>
  6. <link rel="stylesheet" href="{$kx.config.resurl}/template/kxwebno1/author/css/style.css"/>
  7. <link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
  8. <meta name="author" content="www.ptcms.com">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  10. <meta name="renderer" content="webkit">
  11. <meta name="viewport" content="width=device-width"/>
  12. <meta name="applicable-device" content="pc">
  13. <meta http-equiv="Cache-Control" content="no-siteapp"/>
  14. <meta http-equiv="Cache-Control" content="no-transform"/>
  15. <link rel="canonical" href="{$kx.config.pcurl}__SELF__"/>
  16. <style>
  17. .labels {
  18. height: 51px;
  19. }
  20. .labels li {
  21. padding: 15px 40px;
  22. background-color: #e5e5e5;
  23. color: #929297;
  24. display: inline-block;
  25. float: left;
  26. }
  27. .labels li:hover,
  28. .labels li.active {
  29. background-color: #fff;
  30. color: #323237;
  31. }
  32. .container {
  33. padding: 20px;
  34. }
  35. .cover {
  36. width: 126px;
  37. height: 167px;
  38. background: url("{$kx.config.resurl}/template/kxwebno1/author/images/default_cover.jpg") no-repeat;
  39. -webkit-background-size: 100% 100%;
  40. background-size: 100% 100%;
  41. margin-top: 60px;
  42. }
  43. .cover .name {
  44. padding-top: 120px;
  45. width: 100%;
  46. text-align: center;
  47. color: #323237;
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. {include file="/author/system/header"}
  53. <div class="body">
  54. {include file="/author/system/left"}
  55. <div class="right">
  56. {if $novel}
  57. <div class="labels">
  58. <ul>
  59. <li><a href="{link=author.chapter.index novelid=$kx.get.novelid type='draft'}">草稿箱</a></li>
  60. <li><a href="{link=author.chapter.index novelid=$kx.get.novelid type='published'}">已发布</a></li>
  61. <li><a href="{link=author.chapter.index novelid=$kx.get.novelid type='recycle'}">回收站</a></li>
  62. <li class="active"><a href="{link=author.novel.index novelid=$kx.get.novelid}">作品设置</a></li>
  63. </ul>
  64. </div>
  65. {/if}
  66. <div class="container bg-white">
  67. <input type="file" id="file_cover" style="display: none" name="file">
  68. <form method="post">
  69. {if $novel}
  70. <input type="hidden" name="id" value="{$novel.id}">
  71. {/if}
  72. <div class="h100 fl text-center" style="width: 280px;">
  73. <div class="cover ma">
  74. {if $novel.cover}
  75. <img class="w100 h100" src="{$novel.cover}" alt="">
  76. {else}
  77. <div class="name bold">{$novel.name}</div>
  78. {/if}
  79. </div>
  80. <input type="hidden" name="cover" value="{$novel.cover}">
  81. <button type="button" class="inline-block plr20 ptb5 border mt20 color0 uploadCover"
  82. style="background-color:#f7f8f8;">上传封面
  83. </button>
  84. </div>
  85. <div class="h100 fl" style="width: 600px;">
  86. <div class="form-item">
  87. <label class="form-label" for="field_name">作品名称</label>
  88. <div class="form-input-block">
  89. <input type="text" name="name" id="field_name" value="{$novel.name}">
  90. </div>
  91. </div>
  92. <div class="form-item">
  93. <label class="form-label" for="field_category">作品类型</label>
  94. <div class="form-input-block">
  95. <select name="channel_id" id="field_channel">
  96. <option value="1" {if $novel.channel_id == 1}selected{/if}>男生</option>
  97. <option value="2" {if $novel.channel_id == 2}selected{/if}>女生</option>
  98. </select>
  99. <select name="category_id" id="field_category">
  100. </select>
  101. </div>
  102. </div>
  103. <div class="form-item">
  104. <label class="form-label" for="field_tags">作品类型</label>
  105. <div class="form-input-block">
  106. <input type="text" name="tags" id="field_tags" value="{$novel.tags}">
  107. </div>
  108. <div class="form-tips">选择小说风格及特色</div>
  109. </div>
  110. <div class="form-item">
  111. <label class="form-label" for="field_intro">作品简介</label>
  112. <div class="form-input-block">
  113. <textarea name="intro" id="field_intro" cols="30" rows="10">{$novel.intro}</textarea>
  114. </div>
  115. <div class="form-tips">50-200字</div>
  116. </div>
  117. <div class="form-item">
  118. <label class="form-label"></label>
  119. <div class="form-input-block">
  120. <button type="button" class="bg-red color1 plr40 ptb5 pt-submit">保存</button>
  121. </div>
  122. </div>
  123. </div>
  124. <div style="clear: both"></div>
  125. </form>
  126. </div>
  127. </div>
  128. </div>
  129. {include file="/author/system/footer"}
  130. <link rel="stylesheet" href="{$kx.config.resurl}/template/kxwebno1/author/js/cropper/cropper.min.css"/>
  131. <script src="{$kx.config.resurl}/template/kxwebno1/author/js/cropper/cropper.min.js"></script>
  132. {block method="category.list" name=list_boy withall=0 pid=1}
  133. {block method="category.list" name=list_girl withall=0 pid=2}
  134. <script>
  135. $('#field_name').keyup(function () {
  136. $('.cover .name').html(this.value);
  137. });
  138. $('.uploadCover').click(function () {
  139. $('#file_cover').click();
  140. });
  141. $('#file_cover').change(function () {
  142. console.log(this);
  143. var cropper;
  144. var files = this.files;
  145. done = function (url) {
  146. layer.open({
  147. type: 1,
  148. area: ['600px', '500px'],
  149. resize: false,
  150. scrollbar: false,
  151. content: '<img src="' + url + '">',
  152. btn: ['确认'],
  153. success: function (layero, index) {
  154. cropper = new Cropper(layero.find('img')[0], {
  155. aspectRatio: 126 / 167
  156. });
  157. },
  158. end: function () {
  159. cropper.destroy();
  160. },
  161. yes: function (index, layero) {
  162. if (cropper) {
  163. var loading = null;
  164. canvas = cropper.getCroppedCanvas({
  165. width: 126,
  166. height: 167,
  167. });
  168. canvas.toBlob(function (blob) {
  169. var formData = new FormData();
  170. formData.append('file', blob, 'avatar.jpg');
  171. $.ajax({
  172. url: '{link=author.novel.uploadCover}',
  173. method: 'POST',
  174. data: formData,
  175. dataType: 'json',
  176. processData: false,
  177. contentType: false,
  178. beforeSend: function () {
  179. if (loading === null) {
  180. loading = layer.load(1, {shade: [0.1, '#000']});
  181. }
  182. },
  183. xhr: function () {
  184. var xhr = new XMLHttpRequest();
  185. xhr.upload.onprogress = function (e) {
  186. var percent = '0';
  187. var percentage = '0%';
  188. if (e.lengthComputable) {
  189. percent = Math.round((e.loaded / e.total) * 100);
  190. percentage = percent + '%';
  191. console.log(percentage);
  192. }
  193. };
  194. return xhr;
  195. },
  196. success: function (res) {
  197. console.log(res);
  198. if (res.code) {
  199. layer.msg(res.msg);
  200. } else {
  201. $('input[name=cover]').val(res.data.src);
  202. $('.cover').html('<img class="w100 h100" src="' + res.data.src + '">');
  203. }
  204. },
  205. error: function () {
  206. layer.msg('上传失败,请刷新页面后重试!');
  207. },
  208. complete: function () {
  209. if (loading !== null) {
  210. layer.close(loading);
  211. loading = null;
  212. }
  213. },
  214. });
  215. });
  216. }
  217. layer.close(index);
  218. }
  219. });
  220. };
  221. if (files && files.length > 0) {
  222. file = files[0];
  223. if (URL) {
  224. done(URL.createObjectURL(file));
  225. } else if (FileReader) {
  226. reader = new FileReader();
  227. reader.onload = function (e) {
  228. done(reader.result);
  229. };
  230. reader.readAsDataURL(file);
  231. }
  232. }
  233. });
  234. $('#field_channel').change(function () {
  235. var data = {
  236. '1':{=json_encode(array_combine(array_column($list_boy,'id'),array_column($list_boy,'name')))},
  237. '2':{=json_encode(array_combine(array_column($list_girl,'id'),array_column($list_girl,'name')))}
  238. }
  239. $('#field_category option').remove();
  240. $.each(data[$(this).val()],function (k, v) {
  241. $('#field_category').append('<option value="' + k + '" '+('{$novel.category_id}' == k?'selected':'')+'>' + v + '</option>');
  242. });
  243. }).change();
  244. $('.pt-submit').click(function () {
  245. var loading = null;
  246. $.ajax('{link=""}', {
  247. type: 'post',
  248. dataType: 'json',
  249. data: $('form').serialize(),
  250. beforeSend: function () {
  251. if (loading == null) {
  252. loading = layer.load(1, {shade: [0.1, '#000']});
  253. }
  254. },
  255. complete: function () {
  256. if (loading != null) {
  257. layer.close(loading);
  258. loading = null;
  259. }
  260. },
  261. success: function (res) {
  262. if (res.code) {
  263. layer.alert(res.msg, {icon: 2,}, function (index) {
  264. if (res.data.redirect) {
  265. window.location.href = res.data.redirect;
  266. } else {
  267. layer.close(index);
  268. }
  269. });
  270. } else {
  271. layer.msg('操作成功!');
  272. }
  273. },
  274. error: function () {
  275. layer.alert('收藏失败,请刷新页面后重试!', {icon: 2,});
  276. }
  277. });
  278. });
  279. </script>
  280. </body>
  281. </html>