人人商城

display.html 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. {php $newUI = true;}
  2. {template 'common/header'}
  3. <style>
  4. .panel .btn-group{width:100%}
  5. .panel-image .btn-group .btn{width:33.333%}
  6. .panel-voice .btn-group .btn{width:33.333%}
  7. .panel-video .btn-group .btn{width:25%}
  8. .panel-news .btn-group .btn{width:33.333%}
  9. .panel .panel-body .content{position: relative; margin-bottom: 10px}
  10. .panel .panel-body .content span{overflow:hidden; display:block; width:100%; padding-right:10px; position:absolute; bottom:0; left:0; line-height:25px; background:rgba(0,0,0,0.5); color:#fff; text-align:right;}
  11. .panel .panel-body .audio-msg{position:relative; padding-left:65px; height:70px;}
  12. .panel .panel-body .audio-msg .icon span{position:absolute; left:0; top:0; background:#ccc; width:60px; height:60px; line-height:60px; vertical-align:middle; display:inline-block; cursor:pointer; font-size: 25px; text-align: center;}
  13. .panel .panel-body .audio-msg .audio-content .audio-title{ width:100%; margin-bottom:10px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;}
  14. .panel .panel-body .video-content{margin-bottom:10px;}
  15. .panel .panel-body .video-content .title,.panel .panel-body .video-content .abstract{white-space:nowrap; word-break:break-all; overflow:hidden; text-overflow:ellipsis;}
  16. .panel .panel-body .video-content img{max-width:100%; height:140px;}
  17. .panel .panel-body .video-content .video{position:relative; margin:10px 0;}
  18. .panel .panel-body .video-content .video .video-length{display:block; width:100%; padding-right:10px; position:absolute; bottom:0; left:0; line-height:25px; background:rgba(0,0,0,0.5); color:#fff; text-align:right;}
  19. </style>
  20. <ul class="nav nav-tabs">
  21. <li {if $type == 'image'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'image'));}">图片</a></li>
  22. <li {if $type == 'voice'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'voice'));}">语音</a></li>
  23. <li {if $type == 'video'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'video'));}">视频</a></li>
  24. <li {if $type == 'news' || $action == 'post'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'news'));}">图文</a></li>
  25. </ul>
  26. {if $do == 'list'}
  27. <div ng-controller="download" style="margin-bottom: 15px">
  28. <div class="panel panel-default download" style="display: none;" ng-show="flag == 1">
  29. <div class="panel-heading">同步微信素材</div>
  30. <div class="panel-body">
  31. <div class="progress">
  32. <div class="progress-bar progress-bar-danger" ng-style="style">
  33. {{pragress}}
  34. </div>
  35. </div>
  36. <span class="help-block">正在同步中,请勿关闭浏览器</span>
  37. <div class="alert alert-danger" ng-show="fails.length > 0">
  38. <i class="fa fa-info-circle"></i> 有{{fails.length}}个文件同步失败,您可以选择重新同步
  39. </div>
  40. <table class="table table-hover table-bordered" ng-show="fails.length > 0">
  41. <thead>
  42. <tr>
  43. <th>media_id</th>
  44. <th>原因</th>
  45. </tr>
  46. </thead>
  47. <tr ng-repeat="file in fails">
  48. <td>{{file.media_id}}</td>
  49. <td>{{file.message}}</td>
  50. </tr>
  51. </table>
  52. </div>
  53. </div>
  54. <a href="javascript:;" class="btn btn-primary" ng-click="sync()" ng-bind="disable == 1 ? '同步中' : '同步微信素材'" ng-disabled="disable == 1"></a>
  55. <a href="javascript:;" class="btn btn-danger init-hide" style="display: none" ng-click="flag = 0" ng-show="fails.length > 0 && flag == 1">收起</a>
  56. {if $type == 'news'}
  57. <a href="{php echo url('material/post/news');}" class="btn btn-primary">新增图文素材</a>
  58. {/if}
  59. </div>
  60. {if $type == 'image'}
  61. <div class="panel panel-default clearfix">
  62. <div class="panel-heading">
  63. <a href="javascript:;" data-type="image" class="btn-upload btn btn-success">新增永久图片</a>
  64. </div>
  65. <div class="panel-body">
  66. {loop $lists $list}
  67. <div class="col-md-3">
  68. <div class="panel panel-default panel-image">
  69. <div class="panel-body">
  70. <div class="content">
  71. <img src="{php echo tomedia($list['attachment'], true);}" width="100%" height="160" alt="{$list['filename']}">
  72. <span>{$list['filename']}</span>
  73. </div>
  74. <div class="btn-group">
  75. <a href="javascript:;" class="btn btn-default btn-sm btn-send" data-id="{$list['id']}" data-type="{$list['type']}">群发</a>
  76. <a href="javascript:;" class="btn btn-default btn-sm btn-view" data-media-id="{$list['media_id']}" data-type="{$list['type']}">预览</a>
  77. <a href="javascript:;" class="btn btn-default btn-sm btn-del" data-id="{$list['id']}" data-type="{$list['type']}">删除</a>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. {/loop}
  83. </div>
  84. </div>
  85. {elseif $type == 'voice'}
  86. <div class="panel panel-default">
  87. <div class="panel-heading">
  88. <a href="javascript:;" data-type="voice" class="btn-upload btn btn-success">新增永久语音</a>
  89. </div>
  90. <div class="panel-body">
  91. {loop $lists $list}
  92. <div class="col-md-3">
  93. <div class="panel panel-default panel-voice">
  94. <div class="panel-body">
  95. <div class="audio-msg">
  96. <div class="icon audio-player-play" data-attach="{php echo tomedia($list['attachment'], true);}"><span><i class="fa fa-play"></i></span></div>
  97. <div class="audio-content">
  98. <div class="audio-title">{$list['filename']}dklaklakla看见了的角度看都看绝对空间都看得见看得见看到绝对看得见肯定健康的健康的就</div>
  99. <div class="audio-date text-muted">创建于:{php echo date('m月d日', $list['createtime'])}</div>
  100. </div>
  101. </div>
  102. <div class="btn-group">
  103. <a href="javascript:;" class="btn btn-default btn-sm btn-send" data-id="{$list['id']}" data-type="{$list['type']}">群发</a>
  104. <a href="javascript:;" class="btn btn-default btn-sm btn-view" data-media-id="{$list['media_id']}" data-type="{$list['type']}">预览</a>
  105. <a href="javascript:;" class="btn btn-default btn-sm btn-del" data-id="{$list['id']}" data-type="{$list['type']}">删除</a>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. {/loop}
  111. </div>
  112. </div>
  113. {elseif $type == 'video'}
  114. <div class="panel panel-default">
  115. <div class="panel-heading">
  116. <a href="javascript:;" data-type="video" class="btn-upload btn btn-success">新增永久视频</a>
  117. </div>
  118. <div class="panel-body">
  119. {loop $lists $list}
  120. <div class="col-md-3">
  121. <div class="panel panel-default panel-video">
  122. <div class="panel-body">
  123. <div class="video-content">
  124. <h4 class="title text-muted">{$list['tag']['title']}</h4>
  125. <div class="date text-muted">{php echo date('m月d日 H:i', $list['createtime']);}</div>
  126. <div class="video">
  127. <img src="../web/resource/images/banner-bg.png" alt="" />
  128. </div>
  129. <div class="abstract text-muted" style="overflow:hidden">{$list['tag']['description']}</div>
  130. </div>
  131. <div class="btn-group">
  132. <a href="{$list['tag']['down_url']}" target="_blank" class="btn btn-default btn-sm">下载</a>
  133. <a href="javascript:;" class="btn btn-default btn-sm btn-send" data-id="{$list['id']}" data-type="{$list['type']}">群发</a>
  134. <a href="javascript:;" class="btn btn-default btn-sm btn-view" data-media-id="{$list['media_id']}" data-type="{$list['type']}">预览</a>
  135. <a href="javascript:;" class="btn btn-default btn-sm btn-del" data-id="{$list['id']}" data-type="{$list['type']}">删除</a>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. {/loop}
  141. </div>
  142. </div>
  143. {elseif $type == 'news'}
  144. <div class="alert alert-info">
  145. <i class="fa fa-info-circle"></i> 因图文素材的封面使用的是图片素材,因此查看图文素材时请确保已经成功同步过图片素材<br>
  146. <i class="fa fa-info-circle"></i> 系统不支持直接添加微信图文素材,您可以在微信公众平台添加后同步到本系统<br>
  147. </div>
  148. <div class="panel panel-default panel-news">
  149. <div class="panel-heading">图文素材</div>
  150. <div class="panel-body">
  151. <div class="reply" id="mpnews" style="position: relative">
  152. {loop $lists $list}
  153. <div class="col-xs-12 col-sm-12 col-md-6 col-lg-3 water">
  154. <div class="panel-group">
  155. {loop $list['items'] $key $item}
  156. {if !$key}
  157. <div class="panel panel-default">
  158. <div class="panel-body">
  159. <div class="img">
  160. <i class="default"></i>
  161. <a href="{php echo $item['url']}" target="_blank"><img src="{php echo tomedia($item['thumb_url'], true);}"></a>
  162. <span class="text-left">{$item['title']}</span>
  163. </div>
  164. </div>
  165. </div>
  166. {else}
  167. <div class="panel panel-default">
  168. <div class="panel-body">
  169. <a href="{php echo $item['url']}" target="_blank">
  170. <div class="text">
  171. <h4>{$item['title']}</h4>
  172. </div>
  173. <div class="img">
  174. <img src="{php echo tomedia($item['thumb_url'], true);}">
  175. <i class="default">缩略图</i>
  176. </div>
  177. </a>
  178. </div>
  179. </div>
  180. {/if}
  181. {/loop}
  182. <div class="panel panel-default">
  183. <div class="panel-body" style="height:20px; padding-bottom:40px; padding-top:7px">
  184. <div class="btn-group">
  185. <a href="javascript:;" class="btn btn-default btn-sm btn-send" data-id="{$list['id']}" data-type="{$list['type']}">群发</a>
  186. <a href="javascript:;" class="btn btn-default btn-sm btn-view" data-media-id="{$list['media_id']}" data-type="{$list['type']}">预览</a>
  187. <a href="javascript:;" class="btn btn-default btn-sm btn-del" data-id="{$list['id']}" data-type="{$list['type']}">删除</a>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. {/loop}
  194. </div>
  195. </div>
  196. </div>
  197. {/if}
  198. {$pager}
  199. {/if}
  200. <!-- 群发预览 -->
  201. <div class="modal fade" id="modal-view" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  202. <form action="">
  203. <div class="modal-dialog" role="document">
  204. <div class="modal-content">
  205. <div class="modal-header">
  206. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  207. <h4 class="modal-title">请输入接受人的微信号</h4>
  208. </div>
  209. <div class="modal-body">
  210. <div class="form-group">
  211. <label for="wxname">微信号</label>
  212. <input type="text" class="form-control" id="wxname" name="wxname">
  213. <span class="help-block">微信号不能为空</span>
  214. </div>
  215. </div>
  216. <div class="modal-footer">
  217. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  218. <button type="button" class="btn btn-primary btn-view">发送</button>
  219. </div>
  220. </div>
  221. </div>
  222. </form>
  223. </div>
  224. <div class="modal fade" id="modal-send" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  225. <form action="" class="form form-horizontal">
  226. <div class="modal-dialog" role="document">
  227. <div class="modal-content modal-lg">
  228. <div class="modal-header">
  229. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  230. <h4 class="modal-title">设置群发</h4>
  231. </div>
  232. <div class="modal-body">
  233. <div class="form-group">
  234. <label class="col-xs-12 col-sm-3 col-md-2 control-label">选择粉丝分组</label>
  235. <div class="col-sm-9 col-xs-12">
  236. <select name="group" id="group" class="form-control">
  237. <option value="-1" selected>所有粉丝</option>
  238. {if !empty($groups)}
  239. {loop $groups $group}
  240. <option value="{$group['id']}">{$group['name']}【{$group['count']}人】</option>
  241. {/loop}
  242. {/if}
  243. </select>
  244. <span class="help-block">如果您需要定时群发,请<a href="{php echo url('material/mass/');}"> 点击链接</a></span>
  245. </div>
  246. </div>
  247. </div>
  248. <div class="modal-footer">
  249. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  250. <button type="button" class="btn btn-primary btn-send">发送</button>
  251. </div>
  252. </div>
  253. </div>
  254. </form>
  255. </div>
  256. <script>
  257. require(['fileUploader', 'jquery.jplayer', 'jquery.wookmark'], function(uploader){
  258. $('.init_hide').show();
  259. $('.btn-upload').click(function(){
  260. var type = $(this).data('type');
  261. var options = {type: type, direct: true, multiple: false, isWechat: true};
  262. uploader.init(function(){location.reload();}, options);
  263. });
  264. $('.btn-send').click(function(){
  265. var id = $(this).data('id');
  266. var type = $(this).data('type');
  267. $('#modal-send').modal('show');
  268. $('#modal-send .btn-send').unbind().click(function(){
  269. var group = $.trim($('#modal-send #group').val());
  270. $('#modal-send').modal('hide');
  271. $.post("{php echo url('material/display/send/');}", {id:id, group:group, type:type}, function(data){
  272. if(data != 'success') {
  273. util.message(data, '', 'error');
  274. } else {
  275. util.message('发送成功', '', 'success');
  276. }
  277. });
  278. return false;
  279. });
  280. });
  281. $('#mpnews .water').wookmark({
  282. align: 'center',
  283. autoResize: false,
  284. container: $('#mpnews'),
  285. autoResize :true
  286. });
  287. //语音播放
  288. $(".audio-player-play").click(function(){
  289. var src = $(this).data("attach");
  290. if(!src) {
  291. return;
  292. }
  293. if ($("#player")[0]) {
  294. var player = $("#player");
  295. } else {
  296. var player = $('<div id="player"></div>');
  297. $(document.body).append(player);
  298. }
  299. player.data('control', $(this));
  300. player.jPlayer({
  301. playing: function() {
  302. $(this).data('control').find("i").removeClass("fa-play").addClass("fa-stop");
  303. },
  304. pause: function (event) {
  305. $(this).data('control').find("i").removeClass("fa-stop").addClass("fa-play");
  306. },
  307. swfPath: "resource/components/jplayer",
  308. supplied: "mp3,wma,wav,amr",
  309. solution: "html, flash"
  310. });
  311. player.jPlayer("setMedia", {mp3: $(this).data("attach")}).jPlayer("play");
  312. if($(this).find("i").hasClass("fa-stop")) {
  313. player.jPlayer("stop");
  314. } else {
  315. $('.audio-msg').find('.fa-stop').removeClass("fa-stop").addClass("fa-play");
  316. player.jPlayer("setMedia", {mp3: $(this).data("attach")}).jPlayer("play");
  317. }
  318. });
  319. //群发预览
  320. $('.btn-view').click(function(){
  321. var media_id = $(this).data('media-id');
  322. var type = $(this).data('type');
  323. $('#modal-view').modal('show');
  324. $('#modal-view .btn-view').unbind().click(function(){
  325. var wxname = $.trim($('#modal-view #wxname').val());
  326. if(!wxname) {
  327. util.message('微信号不能为空', '', 'error');
  328. return false;
  329. }
  330. $('#modal-view').modal('hide');
  331. $.post("{php echo url('material/display/purview/');}", {media_id: media_id, wxname:wxname, type:type}, function(data){
  332. if(data != 'success') {
  333. util.message(data, '', 'error');
  334. } else {
  335. util.message('发送成功', '', 'success');
  336. }
  337. });
  338. return false;
  339. });
  340. });
  341. //删除微信素材
  342. $('.btn-del').click(function(){
  343. if(!confirm('删除将不可恢复,确定删除吗?')) {
  344. return false;
  345. }
  346. var id = $(this).data('id');
  347. $.post("{php echo url('material/display/del/');}", {id:id}, function(data){
  348. if(data != 'success') {
  349. util.message(data, '', 'error');
  350. } else {
  351. location.reload();
  352. }
  353. });
  354. return false;
  355. });
  356. //同步微信素材
  357. var running = false;
  358. window.onbeforeunload = function(e) {
  359. if(running) {
  360. return (e || window.event).returnValue = '正在进行微信素材数据同步,确定离开页面吗.';
  361. }
  362. }
  363. angular.module('app', []).controller('download', function($scope, $http){
  364. $('.download').show();
  365. $scope.sync = function(){
  366. running = true;
  367. $scope.flag = 1;
  368. $scope.disable = 1;
  369. $scope.fails = [];
  370. var i = 0;
  371. var total = 1;
  372. var num = 0;
  373. var type = "{$type}";
  374. var proc = function(page) {
  375. if(page == 1) {
  376. $scope.pragress = "3%";
  377. $scope.style = {'width': '3%'};
  378. } else {
  379. $scope.pragress = (i/total).toFixed(2)*100 + "%";
  380. $scope.style = {'width':(i/total).toFixed(2)*100+"%"};
  381. }
  382. $http.post("{php echo url('material/display/down');}", {page:page, type:type}).success(function(dat){
  383. if(dat.message.errno > 0) {
  384. page++;
  385. i += dat.message.message.item_count;
  386. total = dat.message.errno;
  387. if(dat.message.message.fail) {
  388. angular.forEach(dat.message.message.fail, function(v){
  389. $scope.fails.push(v);
  390. });
  391. }
  392. } else if(dat.message.errno == -2) {
  393. running = false;
  394. if($scope.fails.length > 0) {
  395. $scope.flag = 1;
  396. } else {
  397. $scope.flag = 0;
  398. }
  399. $scope.disable = 0;
  400. $scope.pragress = "100%";
  401. $scope.style = {'width':'100%'};
  402. var url = location.href.replace('sync=1', '');
  403. util.message('同步素材完成', url, 'success');
  404. return false;
  405. } else if(dat.message.errno == -1) {
  406. if(num < 3) {
  407. page = page;
  408. } else {
  409. util.message(dat.message.message, '', 'error');
  410. return false;
  411. }
  412. num++;
  413. }
  414. proc(page);
  415. }).error(function(){
  416. util.message('访问出错', '', 'error');
  417. return false;
  418. });
  419. }
  420. proc(1);
  421. };
  422. {if $_GPC['sync'] == 1}
  423. $scope.sync();
  424. {/if}
  425. });
  426. angular.bootstrap(document, ['app']);
  427. });
  428. </script>
  429. {template 'common/footer'}