人人商城

broadcast.html 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. {php $newUI = true;}
  2. {template 'common/header'}
  3. <ul class="nav nav-tabs">
  4. <li{if $do == 'display'} class="active"{/if}><a href="{php echo url('mc/broadcast')}"><i class="icon-group"></i> 发送通知消息</a></li>
  5. </ul>
  6. {if !$_W['ispost'] || empty($count)}
  7. <div class="main">
  8. <form action="{php echo url('mc/broadcast');}" method="post" class="form-horizontal form">
  9. <div class="panel panel-default">
  10. <div class="panel-heading">
  11. 批量发送通知
  12. </div>
  13. <div class="panel-body">
  14. <div class="form-group">
  15. <label class="col-xs-12 col-sm-3 col-md-2 control-label">通知方式</label>
  16. <div class="col-sm-9 col-xs-12">
  17. <label class="radio-inline">
  18. <input type="radio" name="type" value="email"{if $_GPC['type'] == 'email' || empty($_GPC['type'])} checked="checked"{/if}/>
  19. 邮件
  20. </label>
  21. <label class="radio-inline">
  22. <input type="radio" name="type" value="wechat"{if $_GPC['type'] == 'wechat'} checked="checked"{/if} onclick="location.href='{php echo url("material/mass")}'"/>
  23. 微信
  24. </label>
  25. <span class="help-block">请指定你要发送通知的方式, 不同的方式能到达的用户也不同</span>
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label class="col-xs-12 col-sm-3 col-md-2 control-label">用户组</label>
  30. <div class="col-sm-9 col-xs-12">
  31. <select name="group" class="form-control">
  32. <option value="">不限</option>
  33. {loop $groups $group}
  34. <option value="{$group['groupid']}"{if $_GPC['group'] == $group['groupid']} selected="selected"{/if}>{$group['title']}</option>
  35. {/loop}
  36. </select>
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label class="col-xs-12 col-sm-3 col-md-2 control-label">用户</label>
  41. <div class="col-sm-9 col-xs-12">
  42. <input type="text" class="form-control" name="username" value="{$_GPC['username']}" />
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  47. <div class="col-sm-9 col-xs-12">
  48. <input type="submit" class="btn btn-primary" value="筛选用户" />
  49. {if isset($count) && empty($count)}
  50. <span class="help-block">没有查找到符合条件的用户, 请更换条件</span>
  51. {/if}
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </form>
  57. </div>
  58. {else}
  59. <div class="main" ng-controller="doNotifySend">
  60. <form action="{php echo url('mc/broadcast');}" method="post" class="form-horizontal form">
  61. <div class="panel panel-default">
  62. <div class="panel-heading">通知目标</div>
  63. <div class="panel-body">
  64. <div class="form-group">
  65. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  66. <div class="col-sm-10 col-xs-12">
  67. 已经搜索到 {$count} 位用户 &nbsp; <a href="javascript:;" onclick="history.go(-1);">重新搜索</a>
  68. </div>
  69. </div>
  70. {if $_GPC['type'] == 'email'}
  71. <div class="form-group">
  72. <label class="col-xs-12 col-sm-3 col-md-2 control-label">邮件标题</label>
  73. <div class="col-sm-10 col-xs-12">
  74. <input type="text" ng-model="params.title" class="form-control" />
  75. </div>
  76. </div>
  77. <div class="form-group">
  78. <label class="col-xs-12 col-sm-3 col-md-2 control-label">邮件内容</label>
  79. <div class="col-sm-10 col-xs-12">
  80. {php echo tpl_ueditor('editor')}
  81. </div>
  82. </div>
  83. {/if}
  84. <div class="form-group">
  85. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  86. <div class="col-sm-10 col-xs-12">
  87. <input type="button" class="btn btn-primary" value="群发通知" ng-disabled="isRunning" ng-click="send(1);" />
  88. <span class="help-block label-result"></span>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </form>
  94. </div>
  95. <script>
  96. var editor = UE.getEditor('editor');
  97. var running = false;
  98. var success = failed = 0;
  99. window.onbeforeunload = function(e) {
  100. if(running) {
  101. return (e || window.event).returnValue = '正在进行群发操作, 离开页面将会中止执行.';
  102. }
  103. }
  104. angular.module('app', []).controller('doNotifySend', function($scope, $http) {
  105. $scope.params = {
  106. type : '{$_GPC['type']}',
  107. group : '{$_GPC['group']}',
  108. username : '{$_GPC['username']}'
  109. };
  110. $scope.isRunning = running = false;
  111. $scope.send = function(pindex) {
  112. var params = {};
  113. var params = angular.copy($scope.params);
  114. {if $_GPC['type'] == 'email'}
  115. params.title = $scope.params.title ? $scope.params.title : '';
  116. params.content = editor.getContent();
  117. if(params.title == '' || params.content == '') {
  118. util.message('请输入完整的通知内容.', '', 'error');
  119. return;
  120. }
  121. {/if}
  122. $scope.isRunning = running = true;
  123. params.method = 'send';
  124. params.next = pindex;
  125. if(pindex == 1) {
  126. success = failed = 0;
  127. var label = '正在发送中, 总共 {$count}';
  128. angular.element('.label-result').html(label);
  129. }
  130. $http.post(location.href, params).success(function(dat, status){
  131. if(!angular.isObject(dat)) {
  132. util.message('执行错误, 请稍后重试', location.href);
  133. return;
  134. }
  135. success += dat.success;
  136. failed += dat.failed;
  137. var label = '正在发送中, 总共 ' + dat.total + ', 发送成功 ' + success + ', 发送失败 ' + failed;
  138. angular.element('.label-result').html(label);
  139. if(dat.total <= (success + failed) || dat.next == -1) {
  140. $scope.isRunning = running = false;
  141. if(dat.total <= failed) {
  142. util.message('没有发送成功任何通知消息, 请检查配置项', '', 'error');
  143. }
  144. } else {
  145. $scope.send(dat.next);
  146. }
  147. });
  148. };
  149. });
  150. angular.bootstrap(document, ['app']);
  151. </script>
  152. {/if}
  153. {template 'common/footer'}