social_queue_save.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. @extends('admin/layout')
  2. @section('header')
  3. <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
  4. <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
  5. @endsection
  6. @section('content')
  7. <style type="text/css">
  8. .radio-label,
  9. .radio-check {
  10. display: inline-block;
  11. position: relative;
  12. }
  13. .radio-label input[type="checkbox"] {
  14. appearance: none; /*清楚默认样式*/
  15. -webkit-appearance: none;
  16. /* opacity: 0; */
  17. outline: none;
  18. position: absolute;
  19. z-index: 2;
  20. width: 6px;
  21. height: 6px;
  22. top: 10px;
  23. left: 10px;
  24. border-radius: 50%;
  25. background: #b4b4b4;
  26. }
  27. .radio-label label {
  28. display: inline-block;
  29. min-width: 50px;
  30. height: 24px;
  31. line-height: 24px;
  32. text-align: center;
  33. padding-right: 10px;
  34. border-radius: 5px;
  35. padding-left: 25px;
  36. color: #fff;
  37. background-color: #c9c9c9;
  38. }
  39. .radio-label input[type="checkbox"]:checked {
  40. opacity: 0;
  41. }
  42. .radio-label input[type="checkbox"]:checked + label {
  43. color: #fff;
  44. background-color: #3597db;
  45. }
  46. .radio-label input[type="checkbox"]:checked + label::after {
  47. content: "";
  48. position: absolute;
  49. left: 12px;
  50. top: 5px;
  51. width: 5px;
  52. height: 12px;
  53. border-right: 1px solid #fff;
  54. border-bottom: 1px solid #fff;
  55. transform: rotate(45deg);
  56. }
  57. </style>
  58. <body class="gray-bg">
  59. <div class="wrapper wrapper-content animated fadeInRight">
  60. <div class="row">
  61. <div class="col-sm-12">
  62. <div class="ibox float-e-margins">
  63. <div class="ibox-content">
  64. <form method="get" class="form-horizontal" id="form">
  65. <div class="form-group">
  66. <label class="col-sm-2 control-label" for="url"><span class="red">* </span>地址:</label>
  67. <div class="col-sm-8 ">
  68. <input type="text" class="form-control" id="url" name="url"
  69. value="{{$data->url??''}}">
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <label class="col-sm-2 control-label" for="thumb">缩略图:</label>
  74. <div class="col-sm-8">
  75. <button type="button" class="btn btn-primary" onclick="units.triggerFile(this)">
  76. 缩略图上传
  77. </button>
  78. <input type="file" value="" style="display: none" name="uploadFile"
  79. onchange="units.fileUpload(this)">
  80. <input type="hidden" id="media" name="media" value="{{$data->media??''}}">
  81. </div>
  82. </div>
  83. <div class="form-group" @if (empty($data->media))style="display: none"
  84. @endif id="thumb_div">
  85. <div class="col-sm-8 col-sm-offset-2">
  86. <img style="height: 100px" src="{{$data->media??''}}">
  87. </div>
  88. </div>
  89. <div class="form-group">
  90. <label class="col-sm-2 control-label" for="content"><span
  91. class="red">* </span>内容:</label>
  92. <div class="col-sm-8 ">
  93. <textarea name="content" id="content" rows="10"
  94. class="form-control">{{$data->content??''}}</textarea>
  95. </div>
  96. </div>
  97. <div class="form-group">
  98. <label class="col-sm-2 control-label" for="publish_at"><span class="red">* </span>发布时间:</label>
  99. <div class="col-sm-4">
  100. <input type="text" class="form-control" id="publish_at" name="publish_at"
  101. value="{{$data->publish_at??''}}">
  102. </div>
  103. </div>
  104. <div class="form-group">
  105. <label class="col-sm-2 control-label" for="publish_at"><span class="red">* </span>发布间隔:</label>
  106. <div class="col-sm-4">
  107. <input type="text" class="form-control" name="release_interval"
  108. id="release_interval" style="display: inline-block;width: 90%;"> 天
  109. </div>
  110. </div>
  111. <div class="form-group">
  112. <label class="col-sm-2 control-label" for="publish_at"><span
  113. class="red">* </span>关键词:</label>
  114. <div class="col-sm-8">
  115. @foreach($labelList as $key=>$value)
  116. <div class="radio-label">
  117. <input class="checkbox-class" type="checkbox" id="color3_{{$key}}"
  118. name="color_{{$key}}"
  119. onclick="units.checkboxOnclick({{$key}})" data-key="{{$value}}"
  120. value="{{$key}}">
  121. <label for="color3_{{$key}}">{{$value}}</label>
  122. </div>
  123. @endforeach
  124. <button type="button" class="btn btn-md btn-primary"
  125. onclick="units.import()" style="margin-left: 10px">
  126. 导入标签词
  127. </button>
  128. </div>
  129. </div>
  130. <div class="form-group">
  131. <label class="col-sm-2 control-label" for="publish_at"><span
  132. class="red">* </span>社交账号类型:</label>
  133. <div class="col-sm-8">
  134. <select name="social_ids" class="form-control" multiple>
  135. @foreach($socialProfiles as $item)
  136. <option value="{{$item['id']}}">{{$item['type']}}
  137. -{{$item['socialNetworkUsername']}}</option>
  138. @endforeach
  139. </select>
  140. </div>
  141. </div>
  142. {{-- @php
  143. $result=$data->result??[];
  144. $resultStatus=$data->result_status??[];
  145. $errMap=$data->err??[];
  146. @endphp--}}
  147. {{-- <div class="form-group">
  148. <label class="col-sm-2 control-label" for="publish_at">发布结果:</label>
  149. <div class="col-sm-8 ">
  150. <span>{{implode(',',$errMap)}}</span>
  151. --}}{{-- <div><label>facebook:</label>
  152. <span>{{\App\Http\Models\SocialPublish::STATUS_TITLE[($resultStatus['facebook']??null)]??''}}</span>
  153. </div>
  154. <div><label>twitter:</label>
  155. <span>{{\App\Http\Models\SocialPublish::STATUS_TITLE[($resultStatus['twitter']??null)]??''}}</span>
  156. </div>
  157. <div><label>pinterest:</label>
  158. <span>{{\App\Http\Models\SocialPublish::STATUS_TITLE[($resultStatus['pin']??null)]??''}}</span>
  159. </div>
  160. <div><label>linkedIn:</label>
  161. <span>{{\App\Http\Models\SocialPublish::STATUS_TITLE[($resultStatus['linkedIn']??null)]??''}}</span>
  162. </div>--}}{{--
  163. </div>
  164. </div>--}}
  165. {{-- <div class="form-group">
  166. <label class="col-sm-2 control-label" for="publish_at">错误信息:</label>
  167. <div class="col-sm-8 ">
  168. <span>{{implode(',',$errMap)}}</span>
  169. </div>
  170. </div>--}}
  171. <div class="hr-line-dashed"></div>
  172. <div class="form-group">
  173. <div class="col-sm-4 col-sm-offset-2">
  174. @if(!$data)
  175. <button class="btn btn-primary" type="button"
  176. onclick="units.save()">
  177. 保存
  178. </button>
  179. @endif
  180. <button class="btn btn-white closeLayer" type="button">取消</button>
  181. </div>
  182. </div>
  183. </form>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. </div>
  189. </body>
  190. @endsection
  191. @section('footer')
  192. <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
  193. <script>
  194. laydate.render({
  195. elem: '#publish_at', //指定元素
  196. type: 'datetime'
  197. });
  198. var units = {
  199. checkboxOnclick: function (id) {
  200. var ids = "#color3_" + id;
  201. var label = ' #' + $(ids).data('key');
  202. var summary = $("#content").val();
  203. if ($(ids).is(':checked')) {
  204. $("#content").val(summary + label);
  205. } else {
  206. $("#content").val($("#content").val().replace(label, ''))
  207. }
  208. },
  209. import: function () {
  210. var str = '<div class="ibox-content" id="importLayer">' +
  211. '<form class="form-horizontal">' +
  212. '<div class="form-group">' +
  213. '<label class="col-sm-3 control-label">请选择excel文件:</label>' +
  214. '<div class="col-sm-6">' +
  215. '<input type="file" id="excel_file" class="form-control">' +
  216. '<input type="hidden" id="excel_path">' +
  217. '</div>' +
  218. '<div class="col-sm-2"><button class="btn btn-info" type="button" onclick="units.fileUploadExl()">上传</button></div>' +
  219. '</div>' +
  220. ' <div class="form-group">' +
  221. '<div class="col-sm-6 col-sm-offset-3">' +
  222. '<a href="{{asset('tpl/social_tag.xls')}}">请下载导入模板</a>' +
  223. '</div>' +
  224. '</div>' +
  225. '</form>' +
  226. '</div>';
  227. openIndex = layer.open({
  228. type: 1,
  229. content: str,
  230. area: ['60%', '30%'],
  231. title: '导入关键词'
  232. });
  233. },
  234. fileUploadExl: function () {
  235. var config = {
  236. url: '/admin/tool/excel-upload'
  237. };
  238. config.success = function (result) {
  239. var data = {excel_path: result.data.file_url, siteId: "{{$siteId}}"};
  240. var config = {
  241. url: '/admin/sites/' + {{$siteId}} +'/social-template-import',
  242. type: 'post',
  243. data: data,
  244. success: function (result) {
  245. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  246. layer.close(openIndex);
  247. window.location.reload();
  248. });
  249. }
  250. };
  251. tips.ajax(config);
  252. };
  253. tips.fileUpload($("#excel_file"), config);
  254. },
  255. save: function () {
  256. var checkbox = [];
  257. $(".checkbox-class").each(function () {
  258. if ($("#color3_" + $(this).val()).is(':checked')) {
  259. checkbox.push($(this).val())
  260. }
  261. });
  262. var data = tips.getFormValues("#form");
  263. data.label_ids = checkbox;
  264. data.social_ids = $("[name=social_ids]").val();
  265. var ajaxConfig = {
  266. url: '/admin/sites/social-queue/{{$data->id??0}}?siteId={{$siteId}}',
  267. type: 'post',
  268. data: data,
  269. success: function (result) {
  270. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  271. window.parent.tips.tableRefresh('#table');
  272. tips.closeParentLayer();
  273. });
  274. }
  275. };
  276. tips.ajax(ajaxConfig);
  277. },
  278. triggerFile: function (_this) { //文件上传
  279. $(_this).next().trigger('click');
  280. },
  281. fileUpload: function (_this) {
  282. var config = {
  283. url: '/admin/tool/upload'
  284. };
  285. config.success = function (result) {
  286. console.log(result);
  287. var data = result.data;
  288. var thumbDiv = $("#thumb_div");
  289. thumbDiv.css('display', '');
  290. thumbDiv.find("img").attr('src', data.file_url);
  291. $("#media").val(data.file_url);
  292. };
  293. tips.fileUpload(_this, config);
  294. }
  295. };
  296. </script>
  297. @endsection