push.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <form data-auto='true' action='{:request()->url()}' style="position:relative">
  2. <div class="col-xs-2 news-container">
  3. <h5 class="text-center" style="margin:10px 0">微信图文</h5>
  4. <div class="news-box">
  5. {foreach $vo.articles as $key=>$value}
  6. <div class="news-item transition" data-id="{$value.id}">
  7. <div class="news-image" style='background-image:url({$value.local_url})'></div>
  8. <span class="news-title">{$value.title}</span>
  9. </div>
  10. <hr/>
  11. {/foreach}
  12. </div>
  13. </div>
  14. <div class="col-xs-2 list-container">
  15. <h5 class="text-center" style="margin:10px 0">指定粉丝标签推送 <a data-check-all> 全选 </a></h5>
  16. <div class="list-item">
  17. {foreach $fans_tags as $tag}
  18. <label class='control-label layui-form-label' style='text-align:left!important'>
  19. <input name="fans_tags[]" value='{$tag.id}' type="checkbox"/> {$tag.name} ({$tag.count})
  20. </label>
  21. {/foreach}
  22. {literal}
  23. <script id="push" type="text/template">
  24. {{if data}}
  25. {{each data as value key}}
  26. {{if key <= 200}}
  27. <label>{{value}}</label>
  28. {{/if}}
  29. {{/each}}
  30. {{if (data.length > 200)}}
  31. <label>...</label>
  32. {{/if}}
  33. {{else}}
  34. <h5></h5>
  35. {{/if}}
  36. </script>
  37. {/literal}
  38. </div>
  39. <div id='push-tags' class="list-item"></div>
  40. </div>
  41. <div style="clear:both;max-height:60px"></div>
  42. <div class="bottom-btn text-center">
  43. <button class="layui-btn">立即推送图文</button>
  44. <button type='button' data-close='' data-confirm='确定要取消推送图文吗?' class="layui-btn layui-btn-danger">取消推送图文
  45. </button>
  46. </div>
  47. </form>
  48. <script>
  49. require(['jquery', 'template'], function () {
  50. var $allbtn = $('[data-check-all]').on('click', function () {
  51. var check_status = check_checked();
  52. $('input[name*=fans_tags]').map(function () {
  53. this.checked = !check_status;
  54. });
  55. check_checked(), postpush();
  56. });
  57. /*重置和全选的效果处理*/
  58. function check_checked() {
  59. var allcheck = true;
  60. $('input[name*=fans_tags]').map(function () {
  61. (!this.checked) && (allcheck = false);
  62. });
  63. return ((allcheck) ? $allbtn.html('重置') : $allbtn.html('全选')), allcheck;
  64. }
  65. /*点击每一个选项都触发事件*/
  66. $('input[name*=fans_tags]').on('click', function () {
  67. check_checked();
  68. postpush();
  69. });
  70. /*数据异步获取并显示出来*/
  71. function postpush() {
  72. var inp = $('input[name*=fans_tags]');
  73. var group = [];
  74. for (var i = 0; i < inp.length; i++) {
  75. if (inp[i].checked === true) {
  76. group.push(inp[i].value);
  77. }
  78. }
  79. $.post("{:url('wechat/news/push')}?action=getuser", {group: group.join(',')}, function (ret) {
  80. var html = template('push', ret);
  81. document.getElementById('push-tags').innerHTML = html;
  82. });
  83. }
  84. });
  85. </script>
  86. <style>
  87. body{min-width:500px}
  88. #push-tags{max-height:300px;overflow:auto}
  89. .bottom-btn{bottom:0;width:100%;padding:10px;display:block;background:#F7F7F7;position:absolute}
  90. .news-container{width:200px;padding-right:8px}
  91. .list-container{width:578px;padding-left:0;padding-right:8px}
  92. .list-container h5 a{float:right;font-size:12px}
  93. .list-container .list-item{padding:8px;overflow:auto;max-height:300px;border:1px solid #eee}
  94. .list-container .list-item:after{content:'';clear:both;width:100%;display:block}
  95. .list-container .list-item label{width:25%;float:left;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
  96. .news-container .news-box{padding:8px;border:1px solid #eee}
  97. .news-container .news-box hr{margin:4px}
  98. .news-container .news-box .container{cursor:pointer;overflow:hidden;position:relative;border-radius:2px;border:1px solid #cecece}
  99. .news-container .news-box .news-image{height:90px;background-size:100%;background-position:center center}
  100. .news-container .news-box .news-title{position:absolute;background:rgba(0,0,0,.5);color:#fff;padding:2px;margin:0;bottom:0;left:0;right:0;text-align:right;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
  101. </style>