display.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {php load()->func('tpl')}
  2. <style>
  3. .wxcard{clear: both;margin-bottom: 20px; position: relative;}
  4. .wxcard .panel-body .panel-wxcard {position:relative;}
  5. .wxcard .panel-body .panel-wxcard .wxcard-content{width:100%; height:90px; border-radius:5px; border-bottom-left-radius:0; border-bottom-right-radius:0; border:1px solid #e7e7eb; border-bottom:0; position:relative; background-color:#A9D92C; color:#fff; font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
  6. .wxcard .panel-body .panel-wxcard .wxcard-content img{width:60px; height:60px; position:absolute; top:15px; left:15px;}
  7. .wxcard .panel-body .panel-wxcard .wxcard-content .title{position:absolute; left:90px; top:30px; font-size:19px}
  8. .wxcard .panel-body .panel-wxcard .wxcard-footer{background-color:#fff; height:35px; line-height:35px; border:1px solid #e7e7eb; padding:0 10px; border-bottom-left-radius:5px; border-bottom-right-radius:5px;}
  9. .wxcard .panel-body .mask{position:absolute; width:100%; height:100%; line-height:104px; left:0; top:0; z-index:999; background-color:rgba(229, 229, 229, 0.85) !important; text-align:center; display:none;}
  10. .wxcard .panel-body:hover .mask{display:block}
  11. .wxcard .del,.panel .no{position: absolute; top:-10px; width:20px; height:20px; color:#fff; background:rgba(0,0,0,0.3); text-align:center; line-height:20px; cursor:pointer; border-radius:100%;}
  12. .wxcard .del{right:-10px;}
  13. .wxcard .no{left:-10px;background: #3071a9}
  14. .wxcard .del:hover{background:rgba(0,0,0,0.7);}
  15. .wxcard .panel:last-child{margin-bottom: 0;}
  16. </style>
  17. <div class="alert alert-info" style="margin-top:-20px">
  18. <i class="fa fa-info-circle"></i> 您可以添加多个回复卡券,系统将随机选择一个卡券推送给粉丝<br>
  19. <i class="fa fa-info-circle"></i> 设置为回复的卡券要保证是可用的卡券.卡券的库存应该足够大,使用期限应该有效<br>
  20. </div>
  21. <input type="hidden" name="replies" value="">
  22. <div class="panel panel-default clearfix">
  23. <div class="panel-heading">回复内容</div>
  24. <div class="panel-body">
  25. <div class="row clearfix">
  26. <div class="col-xs-6 col-sm-3 col-md-3">
  27. <div class="panel panel-default">
  28. <div class="panel-body">
  29. <div class="form-group" style="margin:-15px">
  30. <label class="col-xs-12 control-label" style="text-align:left; padding-bottom:7px">卡券发送成功提示语</label>
  31. <div class="col-xs-12">
  32. <textarea class="form-control" name="success">{$replies[0]['success']}</textarea>
  33. </div>
  34. </div>
  35. <div class="form-group" style="margin:-15px">
  36. <label class="col-xs-12 control-label" style="text-align:left; padding-bottom:7px">卡券发送失败提示语</label>
  37. <div class="col-xs-12">
  38. <textarea class="form-control" name="error">{$replies[0]['error']}</textarea>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="panel panel-default wxcard" ng-repeat="item in context.items">
  44. <div class="panel-body">
  45. <div class="panel-wxcard">
  46. <div class="wxcard-content" ng-style="{'background-color' : item.color}">
  47. <img src="" ng-src="{{item.logo_url}}" class="img-circle">
  48. <div class="title">{{item.title}}</div>
  49. </div>
  50. <div class="wxcard-footer clearfix">
  51. <div class="pull-right text-muted hide">2015-12-5</div>
  52. <div>{{item.brand_name}}</div>
  53. </div>
  54. <div class="mask">
  55. <a href="javascript:;" ng-click="context.selectCoupon(item)"><i class="fa fa-book"></i> 选择微信卡券</a>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="no">{{$index + 1}}</div>
  60. <div class="del" ng-click="context.removeItem(item);"><i class="fa fa-times"></i></div>
  61. </div>
  62. <div class="btn btn-primary" ng-click="context.addItem()" style="margin-bottom:20px">添加一组回复</div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <script>
  68. window.initReplyController = function($scope, $http) {
  69. $scope.context = {};
  70. $scope.context.items = {php echo json_encode($replies)};
  71. if(!$.isArray($scope.context.items)) {
  72. $scope.context.items = [];
  73. }
  74. $scope.context.addItem = function(){
  75. $scope.context.items.push(
  76. {
  77. id: '',
  78. title: '',
  79. logo_url: '',
  80. color: '',
  81. brand_name: ''
  82. }
  83. );
  84. $scope.context.activeIndex = $scope.context.items.length - 1;
  85. $scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
  86. }
  87. if($scope.context.items.length == 0) {
  88. $scope.context.addItem();
  89. }
  90. $scope.context.activeIndex = 0;
  91. $scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
  92. $scope.context.removeItem = function(item){
  93. if($scope.context.items.length == 1) {
  94. util.message('至少有一组回复内容');
  95. return false;
  96. }
  97. $scope.context.items = _.without($scope.context.items, item);
  98. $scope.context.activeIndex = 0;
  99. $scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
  100. $scope.$digest();
  101. }
  102. $scope.context.selectCoupon = function(item) {
  103. var index = $.inArray(item, $scope.context.items);
  104. if(index == -1) return false;
  105. $scope.context.activeIndex = index;
  106. $scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
  107. var option = {
  108. 'ignore' : {
  109. 'local' : true
  110. }
  111. };
  112. util.coupon(function(coupon){
  113. $scope.context.activeItem.card_id = coupon.card_id;
  114. $scope.context.activeItem.cid = coupon.id;
  115. $scope.context.activeItem.title = coupon.title;
  116. $scope.context.activeItem.logo_url = coupon.logo_url;
  117. $scope.context.activeItem.brand_name = coupon.brand_name;
  118. $scope.$digest();
  119. }, option);
  120. };
  121. };
  122. window.validateReplyForm = function(form, $, _, util, $scope) {
  123. if($scope.context.items.length == 0) {
  124. util.message('没有回复内容', '', 'error');
  125. return false;
  126. }
  127. var error = {empty: false, message: ''};
  128. angular.forEach($scope.context.items, function(v, k){
  129. if($.trim(v.cid) == '' || $.trim(v.card_id) == '') {
  130. this.empty = true;
  131. }
  132. }, error);
  133. if(error.empty) {
  134. util.message('存在没有设置 "卡券" 的回复条目');
  135. return false;
  136. }
  137. var val = angular.toJson($scope.context.items);
  138. $(':hidden[name=replies]').val(val);
  139. return true;
  140. };
  141. </script>