wxcardreply.html
35.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
{template 'common/header'}
<style>
.wxcard{clear: both;margin-bottom: 20px; position: relative;}
.wxcard .panel-body .panel-wxcard {position:relative;}
.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;}
.wxcard .panel-body .panel-wxcard .wxcard-content img{width:60px; height:60px; position:absolute; top:15px; left:15px;}
.wxcard .panel-body .panel-wxcard .wxcard-content .title{position:absolute; left:90px; top:30px; font-size:19px}
.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;}
.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;}
.wxcard .panel-body:hover .mask{display:block}
.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%;}
.wxcard .del{right:-10px;}
.wxcard .no{left:-10px;background: #3071a9}
.wxcard .del:hover{background:rgba(0,0,0,0.7);}
.wxcard .panel:last-child{margin-bottom: 0;}
</style>
<ul class="nav nav-tabs">
<li {if $_GPC['do'] == 'couponmanage'}class="active" {/if}><a href="{php echo $this->createWeburl('couponmanage', array('op' => 'display'))}">卡券管理</a></li>
<li {if $_GPC['do'] == 'couponexchange'}class="active" {/if}><a href="{php echo $this->createWeburl('couponexchange', array('op' => 'display'))}">卡券兑换</a></li>
<li {if $_GPC['do'] == 'couponconsume'}class="active" {/if}><a href="{php echo $this->createWeburl('couponconsume', array('op' => 'display'))}">卡券核销</a></li>
<li {if $_GPC['do'] == 'memberproperty'}class="active" {/if}><a href="{php echo $this->createWeburl('memberproperty', array('op' => 'display'))}">会员属性</a></li>
<li {if $_GPC['do'] == 'couponmarket'}class="active" {/if}><a href="{php echo $this->createWeburl('couponmarket', array('op' => 'display'))}">优惠券派发</a></li>
<li {if $_GPC['do'] == 'wxcardreply'}class="active" {/if}><a href="{php echo $this->createWebUrl('wxcardreply', array('op' => 'display'))}">管理微信卡券回复</a></li>
</ul>
{if $_GPC['op'] == 'display'}
<div class="page-header clearfix">
<h4 class="pull-left">微信卡券回复管理</h4>
<div class="pull-right">
<a href="{php echo $this->createWeburl('wxcardreply', array('op' => 'post'))}" class="btn btn-primary we7-padding-horizontal">+添加微信卡券回复</a>
</div>
</div>
<div class="clearfix">
<div class="panel panel-info">
<div class="panel-heading">筛选</div>
<div class="panel-body">
<form action="./index.php" method="get" class="form-horizontal" role="form">
<input type="hidden" name="c" value="site">
<input type="hidden" name="a" value="entry">
<input type="hidden" name="m" value="wn_storex" />
<input type="hidden" name="do" value="wxcardreply">
<input type="hidden" name="status" value="{$status}" />
<div class="form-group">
<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
<div class="col-sm-8 col-lg-9 col-xs-12">
<div class="btn-group">
<a href="{php echo filter_url('status:-1');}" class="btn {if $_GPC['status'] == '-1'|| $_GPC['status'] == ''}btn-primary{else}btn-default{/if}">所有</a>
<a href="{php echo filter_url('status:1');}" class="btn {if $_GPC['status']== '1'}btn-primary{else}btn-default{/if}">启用</a>
<a href="{php echo filter_url('status:0');}" class="btn {if $_GPC['status'] == '0'}btn-primary{else}btn-default{/if}">禁用</a>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">规则名称</label>
<div class="col-sm-8 col-xs-12">
<input class="form-control" name="keyword" id="" type="text" value="{$_GPC['keyword']}">
</div>
<div class="col-xs-12 col-sm-2 col-lg-1 text-right">
<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
</div>
</div>
</form>
</div>
</div>
<form action="{php echo $this->createWebUrl('wxcardreply', array('op' => 'delete'));}" method="post" class="form-horizontal" role="form" id="form1">
<input type="hidden" name="m" value="wn_storex"/>
{if !empty($replies)}
<div>
{loop $replies $row}
<div class="panel panel-default">
<div class="panel-heading clearfix">
<label class="checkbox-inline" style="padding-top:0"><input type="checkbox" name="rid[]" value="{$row['id']}"/> {$row['name']}</label>
<span class="pull-right">
{if $row['displayorder'] > 0}
{if $row['displayorder'] == '255'}
<span class="label label-primary">置顶</span>
{else}
<span class="label label-info">优先级 {$row['displayorder']}</span>
{/if}
{/if}
{if $row['status'] == '0'}<span class="label label-danger">已禁用</span>{/if}
</span>
</div>
<div class="panel-body">
{loop $row['keywords'] $kw}
<span class="label label-default" data-toggle="tooltip" data-placement="top" title="{if $kw['type']==1}等于{elseif $kw['type']==2}包含{elseif $kw['type']==3}正则{/if}">{$kw['content']}</span>
{if $kw['type'] == 4}<span class="label label-info" data-toggle="tooltip" data-placement="top" title="托管">优先级在{$row['displayorder']}之下直接生效</span>{/if}
{/loop}
</div>
<div class="panel-footer clearfix">
<div class="btn-group pull-right">
<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('wxcardreply', array('op' => 'post', 'rid' => $row['id']))}"><i class="fa fa-edit"></i> 编辑</a>
<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('wxcardreply', array('op' => 'delete', 'rid' => $row['id']))}" onclick="return confirm('删除规则将同时删除关键字与回复,确认吗?');return false;"><i class="fa fa-times"></i> 删除</a>
<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('wxcardreply', array('id' => $row['id'], 'op' => 'stat_trend'))}"><i class="fa fa-bar-chart-o"></i> 使用率走势</a>
{if $row['options']}
<div class="btn-group">
<button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
功能选项
<span class="caret"></span>
</button>
<ul class="dropdown-menu" style="min-width:0px;">
{loop $row['options'] $opt}
<li><a href="{$opt['url']}">{$opt['title']}</a></li>
{/loop}
</ul>
</div>
{/if}
</div>
</div>
</div>
{/loop}
</div>
<div>
<label class="checkbox-inline" style="margin-top:-30px;margin-left:17px"><input type="checkbox" name="select_all" id="select_all" value="1"/></label>
<input type="submit" class="btn btn-danger" value="删除" onclick="if(!confirm('确定删除选中的规则吗?')) return false;"/>
<input type="hidden" name="token" value="{$_W['token']}"/>
</div>
{/if}
</form>
{$pager}
</div>
<script>
require(['bootstrap'], function($){
$(function () {
$('[data-toggle="tooltip"]').tooltip();
$('#select_all').click(function(){
$('#form1 :checkbox').prop('checked', $(this).prop('checked'));
});
$('#form1 :checkbox').click(function(){
if(!$(this).prop('checked')) {
$('#select_all').prop('checked', false);
} else {
var flag = 0;
$('#form1 :checkbox[name="rid[]"]').each(function(){
if(!$(this).prop('checked') && !flag) {
flag = 1;
}
});
if(flag) {
$('#select_all').prop('checked', false);
} else {
$('#select_all').prop('checked', true);
}
}
});
})
});
</script>
{/if}
{if $_GPC['op'] == 'post'}
<div class="page-header clearfix">
<h4 class="pull-left">添加微信卡券回复</h4>
<div class="pull-right">
<a href="{php echo $this->createWeburl('wxcardreply', array('op' => 'display'))}" class="btn btn-primary we7-padding-horizontal">返回微信卡券回复管理</a>
</div>
</div>
<div class="clearfix ng-cloak" id="js-reply-form" ng-controller="replyForm">
<form id="reply-form" class="form-horizontal form" action="{php echo $this->createWebUrl('wxcardreply', array('op' => 'post', 'rid' => $rid))}" method="post" enctype="multipart/form-data">
<div class="form-group">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">{if empty($rid)}添加{else}修改{/if}回复规则 <span class="text-muted">删除,修改规则、关键字以及回复后,请提交以保存操作。</span></div>
<ul class="list-group">
<li class="list-group-item">
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">回复规则名称</label>
<div class="col-sm-6 col-md-8 col-xs-12">
<input type="text" class="form-control" placeholder="请输入回复规则的名称" name="name" value="{if empty($reply['name']) && !empty($_GPC['name'])}{$_GPC['name']}{else}{$reply['name']}{/if}" />
<span class="help-block">
您可以给这条规则起一个名字, 方便下次修改和查看. <br/>
<strong class="text-danger">选择高级设置: 将会提供一系列的高级选项供专业用户使用.</strong>
</span>
</div>
<div class="col-sm-3 col-md-2">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="reply.advSetting" /> 高级设置
</label>
</div>
</div>
</div>
<div class="form-group" ng-show="reply.advSetting">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" name="status" value="1" {if $reply['status'] == 1 || empty($reply['status'])} checked="checked"{/if} /> 启用
</label>
<label class="radio-inline">
<input type="radio" name="status" value="0" {if !empty($reply) && $reply['status'] == 0} checked="checked"{/if} /> 禁用
</label>
<span class="help-block">您可以临时禁用这条回复.</span>
</div>
</div>
<div class="form-group" ng-show="reply.advSetting">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">置顶回复</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" name="istop" ng-model="reply.entry.istop" ng-value="1" value="1" {if intval($reply['displayorder'] >= 255)} checked="checked"{/if} /> 置顶
</label>
<label class="radio-inline">
<input type="radio" name="istop" ng-model="reply.entry.istop" ng-value="0" value="0" {if intval($reply['displayorder'] < 255)} checked="checked"{/if} /> 普通
</label>
<span class="help-block">“置顶”时无论在什么情况下均能触发且使终保持最优先级</span>
</div>
</div>
<div class="form-group" ng-show="reply.advSetting && !reply.entry.istop">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">优先级</label>
<div class="col-sm-9">
<input type="text" class="form-control" placeholder="输入这条回复规则优先级" name="displayorder_rule" value="{$reply['displayorder']}">
<span class="help-block">规则优先级,越大则越靠前,最大不得超过254</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">触发关键字</label>
<div class="col-sm-6 col-md-8 col-xs-12">
<input type="hidden" name="rid" value="{$rid}" />
<input type="text" class="form-control keyword" placeholder="请输入触发关键字" ng-model="trigger.items.default" id="keywordinput" onblur="checkKeyWord($(this));" />
<span class="help-block"></span>
<input type="hidden" name="keywords"/>
<span class="help-block">
当用户的对话内容符合以上的关键字定义时,会触发这个回复定义。多个关键字请使用逗号隔开。<a href="javascript:;" id="keyword"><i class="fa fa-github-alt"></i> 表情</a> <br />
<strong class="text-danger">选择高级触发: 将会提供一系列的高级触发方式供专业用户使用(注意: 如果你不了解, 请不要使用). </strong>
</span>
</div>
<div class="col-sm-3 col-md-2">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="reply.advTrigger" /> 高级触发
</label>
</div>
</div>
</div>
<div class="form-group" ng-show="reply.advTrigger">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">高级触发列表</label>
<div class="col-sm-9">
<div class="panel panel-default tab-content">
<div class="panel-heading">
<ul class="nav nav-pills">
<li class="active"><a href="#contains" data-toggle="tab">包含关键字</a></li>
<li><a href="#regexp" data-toggle="tab">正则表达式模式匹配</a></li>
<li><a href="#trustee" data-toggle="tab">直接接管</a></li>
</ul>
</div>
<ul class="tab-pane list-group active" id="contains">
<li class="list-group-item row" ng-repeat="entry in trigger.items.contains">
<div class="col-xs-12 col-sm-8">
<input type="text" class="form-control keyword" ng-hide="entry.saved" placeholder="{{entry.label}}" ng-model="entry.content" onblur="checkKeyWord($(this));" />
<span class="help-block"></span>
<p class="form-control-static" ng-show="entry.saved" ng-bind="entry.content"></p>
</div>
<div class="col-sm-4">
<div class="btn-group">
<a href="javascript:;" class="btn btn-default" ng-click="trigger.saveItem(entry);">{{entry.saved ? '编辑' : '保存'}}</a>
<a href="javascript:;" class="btn btn-default" ng-click="trigger.removeItem(entry);">删除</a>
</div>
</div>
</li>
</ul>
<ul class="tab-pane list-group" id="regexp">
<li class="list-group-item row" ng-repeat="entry in trigger.items.regexp">
<div class="col-xs-12 col-sm-8">
<input type="text" class="form-control keyword" ng-hide="entry.saved" placeholder="{{entry.label}}" ng-model="entry.content" onblur="checkKeyWord($(this));" />
<span class="help-block"></span>
<p class="form-control-static" ng-show="entry.saved" ng-bind="entry.content"></p>
</div>
<div class="col-sm-4">
<div class="btn-group">
<a href="javascript:;" class="btn btn-default" ng-click="trigger.saveItem(entry);">{{entry.saved ? '编辑' : '保存'}}</a>
<a href="javascript:;" class="btn btn-default" ng-click="trigger.removeItem(entry);">删除</a>
</div>
</div>
</li>
</ul>
<ul class="tab-pane list-group" id="trustee">
<li class="list-group-item row" ng-repeat="entry in trigger.items.trustee">
<div class="col-xs-12 col-sm-8">
<p class="form-control-static">符合优先级条件时, 这条回复将直接生效</p>
</div>
<div class="col-sm-4">
<a href="javascript:;" class="btn btn-default" ng-click="trigger.removeItem(entry);">取消接管</a>
</div>
</li>
</ul>
<div class="panel-footer">
<a href="javascript:;" class="btn btn-default" ng-click="trigger.addItem();" ng-bind="'添加' + trigger.labels[trigger.active]">添加</a>
<span class="help-block" ng-bind-html="trigger.descriptions[trigger.active]"></span>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="form-group">
<!--
<div class="col-sm-12">
{php echo module_build_form('wxcard', $rid);}
</div>
-->
<div class="alert alert-info" style="margin-top:-20px">
<i class="fa fa-info-circle"></i> 您可以添加多个回复卡券,系统将随机选择一个卡券推送给粉丝<br>
<i class="fa fa-info-circle"></i> 设置为回复的卡券要保证是可用的卡券.卡券的库存应该足够大,使用期限应该有效<br>
</div>
<input type="hidden" name="replies" value="">
<div class="panel panel-default clearfix">
<div class="panel-heading">回复内容</div>
<div class="panel-body">
<div class="row clearfix">
<div class="col-xs-6 col-sm-3 col-md-3">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group" style="margin:-15px">
<label class="col-xs-12 control-label" style="text-align:left; padding-bottom:7px">卡券发送成功提示语</label>
<div class="col-xs-12">
<textarea class="form-control" name="success">{$replies[0]['success']}</textarea>
</div>
</div>
<div class="form-group" style="margin:-15px">
<label class="col-xs-12 control-label" style="text-align:left; padding-bottom:7px">卡券发送失败提示语</label>
<div class="col-xs-12">
<textarea class="form-control" name="error">{$replies[0]['error']}</textarea>
</div>
</div>
</div>
</div>
<div class="panel panel-default wxcard" ng-repeat="item in context.items">
<div class="no">{{$index + 1}}</div>
<div class="panel-body">
<div class="panel-wxcard">
<div class="wxcard-content" ng-style="{'background-color' : item.color}">
<img src="" ng-src="{{item.logo_url}}" class="img-circle">
<div class="title">{{item.title}}</div>
</div>
<div class="wxcard-footer clearfix">
<div class="pull-right text-muted hide">2015-12-5</div>
<div>{{item.brand_name}}</div>
</div>
<div class="mask">
<a data-toggle="modal" data-target="#myModal" href="javascript:;" ng-click="context.selectCoupon(item)"><i class="fa fa-book"></i> 选择微信卡券</a>
</div>
</div>
</div>
<div class="del" ng-click="context.removeItem(item);"><i class="fa fa-times"></i></div>
</div>
<div class="btn btn-primary" ng-click="context.addItem()" style="margin-bottom:20px">添加一组回复</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" style="width: 800px;">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">选择卡券</h4>
</div>
<div class="modal-body">
{if empty($storex_coupon)}
您现在没有卡券,请先<a href="{php echo $this->createWeburl('couponmanage')}">添加卡券</a>。
{else}
<table class="table table-hover table-bordered">
<thead>
<tr>
<th width="130" class="text-center">标题</th>
<th class="text-center">类型</th>
<th width="250" class="text-center">卡券有效期</th>
<th class="text-center">库存/每人限领</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody>
{php $types = activity_get_coupon_label();}
{loop $storex_coupon $coupon}
<tr title="{$coupon['title']}">
<td>{$coupon['title']}</td>
<td>
{if $coupon['type'] == "1"}
<span class="label label-info">
{$coupon['extra']['discount']}折</span>
<span class="label label-success">折扣券</span>
{else if $coupon['type'] == "2"}
<span class="label label-info">{$coupon['extra']['reduce_cost']}元</span>
<span class="label label-danger">代金券</span>
{else if $coupon['type'] == "4"}
<span class="label label-danger">礼品券</span>
{else if $coupon['type'] == "3"}
<span class="label label-danger">团购券</span>
{else if $coupon['type'] == "5"}
<span class="label label-danger">优惠券</span>
{/if}
</td>
<td>
{if $coupon['date_info']['time_type'] == 1}
{$coupon['date_info']['time_limit_start']}~{$coupon['date_info']['time_limit_end']}
{else}
领取后{$coupon['date_info']['date_info']}天后生效,{$coupon['date_info']['limit']}天有效期
{/if}
</td>
<td>{$coupon['quantity']}/<strong class="text-danger">{$coupon['get_limit']}</strong></td>
<td><a href="javascript:;" class="btn btn-default add_coupon" data-title="{$coupon['title']}" data-attachid="{$coupon['id']}">选取</a></td>
</tr>
{/loop}
</tbody>
</table>
{/if}
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1" />
<input type="hidden" name="token" value="{$_W['token']}" />
</div>
</div>
</form>
</div>
<script>
require(['angular.sanitize', 'bootstrap', 'underscore', 'util'], function(angular, $, _, util){
angular.module('app', ['ngSanitize']).controller('replyForm', function($scope, $http){
$scope.reply = {
advSetting: false,
advTrigger: false,
entry: {php echo json_encode($reply)}
};
$scope.trigger = {};
$scope.trigger.descriptions = {};
$scope.trigger.descriptions.contains = '用户进行交谈时,对话中包含上述关键字就执行这条规则。';
$scope.trigger.descriptions.regexp = '用户进行交谈时,对话内容符合述关键字中定义的模式才会执行这条规则。<br/><strong>注意:如果你不明白正则表达式的工作方式,请不要使用正则匹配</strong> <br/><strong>注意:正则匹配使用MySQL的匹配引擎,请使用MySQL的正则语法</strong> <br /><strong>示例: </strong><br/><em>^微信</em>匹配以“微信”开头的语句<br /><em>微信$</em>匹配以“微信”结尾的语句<br /><em>^微信$</em>匹配等同“微信”的语句<br /><em>微信</em>匹配包含“微信”的语句<br /><em>[0-9\.\-]</em>匹配所有的数字,句号和减号<br /><em>^[a-zA-Z_]$</em>所有的字母和下划线<br /><em>^[[:alpha:]]{3}$</em>所有的3个字母的单词<br /><em>^a{4}$</em>aaaa<br /><em>^a{2,4}$</em>aa,aaa或aaaa<br /><em>^a{2,}$</em>匹配多于两个a的字符串';
$scope.trigger.descriptions.trustee = '如果没有比这条回复优先级更高的回复被触发,那么直接使用这条回复。<br/><strong>注意:如果你不明白这个机制的工作方式,请不要使用直接接管</strong>';
$scope.trigger.labels = {};
$scope.trigger.labels.contains = '包含关键字';
$scope.trigger.labels.regexp = '正则表达式模式';
$scope.trigger.labels.trustee = '直接接管操作';
$scope.trigger.active = 'contains';
$scope.trigger.items = {};
$scope.trigger.items.default = '';
$scope.trigger.items.contains = [];
$scope.trigger.items.regexp = [];
$scope.trigger.items.trustee = [];
if($scope.reply.entry) {
$scope.reply.entry.istop = $scope.reply.entry.displayorder >= 255 ? 1 : 0;
//$scope.reply.advSetting = $scope.reply.entry.displayorder!=0 || !$scope.reply.entry.status;
if($scope.reply.entry.keywords) {
angular.forEach($scope.reply.entry.keywords, function(v, k){
if(v.type == '1') {
this.default += (v.content + ',');
}
if(v.type == '2') {
this.contains.push({content: v.content, label: '请输入' + $scope.trigger.labels.contains, saved: true});
}
if(v.type == '3') {
this.regexp.push({content: v.content, label: '请输入' + $scope.trigger.labels.regexp, saved: true});
}
if(v.type == '4') {
this.trustee.push({});
}
}, $scope.trigger.items);
if($scope.trigger.items.default.length > 1) {
$scope.trigger.items.default = $scope.trigger.items.default.slice(0, $scope.trigger.items.default.length - 1);
}
if($scope.trigger.items.contains.length > 0 || $scope.trigger.items.regexp.length > 0 || $scope.trigger.items.trustee.length > 0) {
$scope.reply.advTrigger = true;
}
if($scope.trigger.items.contains.length > 0) {
$('a[data-toggle="tab"]').eq(0).tab('show');
$scope.trigger.active = 'contains';
} else if($scope.trigger.items.regexp.length > 0) {
$('a[data-toggle="tab"]').eq(1).tab('show');
$scope.trigger.active = 'regexp';
} else if($scope.trigger.items.trustee.length > 0) {
$('a[data-toggle="tab"]').eq(2).tab('show');
$scope.trigger.active = 'trustee';
}
}
}
$scope.trigger.addItem = function(){
var type = $scope.trigger.active;
if(type != 'trustee') {
$scope.trigger.items[type].push({content: '', label: '请输入' + $scope.trigger.labels[type], saved: false});
} else {
if($scope.trigger.items.trustee.length == 0) {
$scope.trigger.items.trustee.push({type:4, content:''});
}
}
};
$scope.trigger.saveItem = function(item){
item.saved = !item.saved;
};
$scope.trigger.removeItem = function(item) {
var type = $scope.trigger.active;
$scope.trigger.items[type] = _.without($scope.trigger.items[type], item);
$scope.$digest();
};
$scope.trigger.test = function(item) {
}
if($.isFunction(window.initReplyController)) {
window.initReplyController($scope, $http);
}
$('#reply-form').submit(function(){
if($.trim($(':text[name="name"]').val()) == '') {
util.message('必须输入回复规则名称');
return false;
}
var val = [];
$scope.$digest();
if($scope.trigger.items.default != '') {
var kws = $scope.trigger.items.default.replace(',', ',').split(',');
kws = _.union(kws);
angular.forEach(kws, function(v){
if(v != '') {
val.push({type: 1, content: v});
}
}, val);
}
angular.forEach($scope.trigger.items, function(v, name){
var flag = true;
if(name != 'default' && v.length > 0) {
if(name == 'contains' || name == 'regexp'){
angular.forEach(v, function(value){
if(value.content.trim() != '') {
this.push({
content: value.content,
type: name == 'contains' ? 2 : 3
});
}
}, val);
}
if(name == 'trustee'){
angular.forEach(v, function(value){
this.push({type:4, content:''});
}, val);
}
}
}, val);
if(val.length == 0 && $scope.trigger.active != 'trustee') {
util.message('请输入有效的触发关键字.');
return false;
}
$scope.$digest();
val = angular.toJson(val);
$(':hidden[name=keywords]').val(val);
if($.isFunction(window.validateReplyForm)) {
return window.validateReplyForm(this, $, _, util, $scope, $http);
}
return true;
});
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$scope.trigger.active = e.target.hash.replace(/#/, '');
$scope.$digest();
})
util.emotion($("#keyword"), $("#keywordinput")[0], function(txt, elm, target){
$scope.trigger.items.default = $(target).val();
$scope.$digest();
});
}).filter('nl2br', function($sce){
return function(text) {
return text ? $sce.trustAsHtml(text.replace(/\n/g, '<br/>')) : '';
};
}).directive('ngInvoker', function($parse){
return function (scope, element, attr) {
scope.$eval(attr.ngInvoker);
};
}).directive('ngMyEditor', function(){
var editor = {
'scope' : {
'value' : '=ngMyValue'
},
'template' : '<textarea id="editor" style="height:600px;width:100%;"></textarea>',
'link' : function ($scope, element, attr) {
if(!element.data('editor')) {
editor = UE.getEditor('editor', ueditoroption);
element.data('editor', editor);
editor.addListener('contentChange', function() {
$scope.value = editor.getContent().replace(/\"\;/g, '"');
$scope.$root.$$phase || $scope.$apply('value');
});
$(element).parents('form').submit(function() {
if (editor.queryCommandState('source')) {
editor.execCommand('source');
}
});
editor.addListener('ready', function(){
if (editor && editor.getContent() != $scope.value) {
editor.setContent($scope.value);
}
$scope.$watch('value', function (value) {
if (editor && editor.getContent() != value) {
editor.setContent(value ? value : '');
}
});
});
}
}
};
return editor;
});
angular.bootstrap($('#js-reply-form')[0], ['app']);
// 检测规则是否已经存在
window.checkKeyWord = function(key) {
var keyword = key.val().trim();
if (keyword == '') {
return false;
}
var type = key.attr('data-type');
var wordIndex = key.index('.keyword');
var isLeagl = true;
$('.keyword').each(function(index) {
var currentWord = $(this).val().trim();
if (keyword == currentWord && wordIndex != index) {
isLeagl = false;
return false;
}
});
if (isLeagl === false) {
key.next().text('');
util.message('该关键字已重复存在于当前规则中.');
return false;
}
$.post(location.href, {keyword:keyword}, function(resp){
if(resp != 'success') {
var rid = $('input[name="rid"]').val();
var rules = JSON.parse(resp);
var url = "{php echo $this->createWebUrl('wxcardreply', array('op' => 'post'));}";
var ruleurl = '';
for (rule in rules) {
if (rid != rules[rule].id) {
ruleurl += "<a href='" + url + "&rid=" + rules[rule].id + "' target='_blank'><strong class='text-danger'>" + rules[rule].name + "</strong></a> ";
}
}
if (ruleurl != '') {
key.next().html('该关键字已存在于 ' + ruleurl + ' 规则中.');
}
} else {
key.next().text('');
}
});
}
$('.keyword').each(function() {
$(this).attr('data-type', 'keyword');
});
});
</script>
<script>
window.initReplyController = function($scope, $http) {
$scope.context = {};
$scope.context.items = {php echo json_encode($replies)};
if(!$.isArray($scope.context.items)) {
$scope.context.items = [];
}
$scope.context.addItem = function(){
$scope.context.items.push(
{
id: '',
title: '',
logo_url: '',
color: '',
brand_name: ''
}
);
$scope.context.activeIndex = $scope.context.items.length - 1;
$scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
}
if($scope.context.items.length == 0) {
$scope.context.addItem();
}
$scope.context.activeIndex = 0;
$scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
$scope.context.removeItem = function(item){
if($scope.context.items.length == 1) {
util.message('至少有一组回复内容');
return false;
}
$scope.context.items = _.without($scope.context.items, item);
$scope.context.activeIndex = 0;
$scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
$scope.$digest();
}
$scope.context.selectCoupon = function(item) {
var index = $.inArray(item, $scope.context.items);
if(index == -1) return false;
$scope.context.activeIndex = index;
$scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
var option = {
'ignore' : {
'local' : true
},
'multiple' : false
};
$('.add_coupon').click(function() {
var storex_coupon = {php echo json_encode($storex_coupon);};
var attachid = $(this).data('attachid');
var coupon = storex_coupon[attachid];
$scope.context.activeItem.card_id = coupon.card_id;
$scope.context.activeItem.cid = coupon.id;
$scope.context.activeItem.title = coupon.title;
$scope.context.activeItem.logo_url = coupon.logo_url;
$scope.context.activeItem.brand_name = coupon.brand_name;
$scope.$digest();
$('#myModal').modal('hide');
});
};
};
window.validateReplyForm = function(form, $, _, util, $scope) {
if($scope.context.items.length == 0) {
util.message('没有回复内容', '', 'error');
return false;
}
var error = {empty: false, message: ''};
angular.forEach($scope.context.items, function(v, k){
if($.trim(v.cid) == '' || $.trim(v.card_id) == '') {
this.empty = true;
}
}, error);
if(error.empty) {
util.message('存在没有设置 "卡券" 的回复条目');
return false;
}
var val = angular.toJson($scope.context.items);
$(':hidden[name=replies]').val(val);
return true;
};
</script>
{/if}
{if $_GPC['op'] == 'stat_trend'}
<ul class="nav nav-tabs">
<li class="active"><a href="javascript:;">关键指标详解</a></li>
</ul>
<div class="clearfix" id="clear">
<div class="pull-left">
<form action="" id="form1">
<input type="hidden" name="c" value="site">
<input type="hidden" name="a" value="entry">
<input type="hidden" name="do" value="wxcardreply">
<input type="hidden" name="op" value="stat_trend">
<input type="hidden" name="id" value={$id}>
<input type="hidden" name="m" value="wn_storex">
{php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d', $starttime),'endtime'=>date('Y-m-d', $endtime)));}
</form>
</div>
<div class="clearfix"></div>
<br>
<div class="panel panel-default" style="padding:1em">
<nav role="navigation" class="navbar navbar-default navbar-static-top" style="margin: -1em -1em 1em -1em;">
<div class="container-fluid">
<div class="navbar-header">
<a href="javascript:;" class="navbar-brand">规则使用趋势图</a>
</div>
</div>
</nav>
<div style="margin-top:20px;">
<canvas id="myChart" height="80"></canvas>
</div>
</div>
{loop $keywords $id $row}
<div class="panel panel-default" style="padding:1em">
<nav role="navigation" class="navbar navbar-default navbar-static-top" style="margin: -1em -1em 1em -1em;">
<div class="container-fluid">
<div class="navbar-header">
<a href="javascript:;" class="navbar-brand">所属关键字使用趋势图 <small>(关键字:{$keywordnames[$id]['content']})</small></a>
</div>
</div>
</nav>
<div style="margin-top:20px">
<canvas id="trend_keyword_{$id}" height="80"></canvas>
</div>
</div>
{/loop}
</div>
<script>
require(['chart', 'daterangepicker'], function(c){
$('.daterange').on('apply.daterangepicker', function(ev, picker) {
$('#form1')[0].submit();
});
var label = {php echo json_encode($day)};
var datasets = {php echo json_encode($hit)};
var lineChartData = {
labels : label,
datasets : [
{
fillColor : "rgba(36,165,222,0.1)",
strokeColor : "rgba(36,165,222,1)",
pointColor : "rgba(36,165,222,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(36,165,222,1)",
data : datasets
}
]
}
var myLine = new Chart(document.getElementById("myChart").getContext("2d")).Line(lineChartData, {responsive : true});
{loop $keywords $id $row}
var label = {php echo json_encode($row['day'])};
var datasets = {php echo json_encode($row['hit'])};
var lineChartData = {
labels : label,
datasets : [
{
fillColor : "rgba(149,192,0,0.1)",
strokeColor : "rgba(149,192,0,1)",
pointColor : "rgba(149,192,0,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(149,192,0,1)",
data : datasets
}
]
}
var myLine = new Chart(document.getElementById("trend_keyword_{$id}").getContext("2d")).Line(lineChartData, {responsive : true});
{/loop}
});
</script>
{/if}
{template 'common/footer'}