templatehandle_mini.html
34.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
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
<!doctype html>
<html ng-app="app">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="stylesheet" href="__PUBLIC__/pickercolor/css/colorpicker.css" type="text/css" />
<link rel="stylesheet" media="screen" type="text/css" href="__PUBLIC__/pickercolor/css/layout.css" />
<link href="__PUBLIC__/static/js/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css"/>
<link href="__PUBLIC__/static/font/css/font-awesome.min.css" rel="stylesheet" />
<!--[if IE 7]>
<link rel="stylesheet" href="__PUBLIC__/static/font/css/font-awesome-ie7.min.css">
<![endif]-->
<link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap.min.css" type="text/css" />
<link type="text/css" rel="stylesheet" href="__PUBLIC__/static/css/jquery-ui.min.css">
<link type="text/css" rel="stylesheet" href="__PUBLIC__/static/css/font-awesome-4.7.0/css/font-awesome.css"/>
<!--<link rel="stylesheet" href="/public/colorpicker/css/colorpicker.min.css" type="text/css">-->
<link type="text/css" rel="stylesheet" href="__PUBLIC__/static/css/model/slider.css">
<!--<link rel="stylesheet" href="__PUBLIC__/colorpicker/css/colorpicker.css" type="text/css">-->
<link type="text/css" rel="stylesheet" href="__WEBPUBLIC__/static/css/main.css?v=__CSSVERSION__" />
<link type="text/css" rel="stylesheet" href="__PUBLIC__/static/css/model/temp.css?v=__CSSVERSION__" />
<link type="text/css" rel="stylesheet" href="__PUBLIC__/static/css/model/index_top.css?v=__CSSVERSION__" />
<script type="text/javascript" src="__PUBLIC__/js/rem_new2.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.js"></script>
<!--<script type="text/javascript" src="/public/static/js/jquery-ui.min.js"></script>-->
<script type="text/javascript" src="__WEBPUBLIC__/static/js/jquery-ui/jquery-ui.min.js?v=__CSSVERSION__"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.nicescroll.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/model/angularjs.js?v=__CSSVERSION__"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/model/angular-sanitize.min.js?v=__CSSVERSION__"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/model/sortable.js?v=__CSSVERSION__"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/bootstrap.min.js"></script>
<!--<script type="text/javascript" src="__PUBLIC__/static/js/colorpicker.js"></script>-->
<script src="__PUBLIC__/colorpicker/js/bootstrap-colorpicker-module.min.js" ></script>
<script type="text/javascript" src="__PUBLIC__/static/js/model/slider.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/model/TouchSlide.1.1.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/global.js?v=__CSSVERSION__"></script>
<script type="text/javascript" src="__PUBLIC__/js/ang_upload_img.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/model/index.js?v=__CSSVERSION__"></script>
<script type="text/javascript" src="__PUBLIC__/static/js/model/self_check2.js?v=__CSSVERSION__"></script>
<script type="text/javascript">
/*
* 参考 地址 http://fex.baidu.com/ueditor/
*/
window.UEDITOR_Admin_URL = "/public/plugins/Ueditor/";
var URL_upload = "/index.php/admin/Ueditor/imageUp/savepath/goods/savepath1/ppt.html";
var URL_fileUp = "/index.php/admin/Ueditor/fileUp/savepath/goods/savepath1/ppt.html";
var URL_scrawlUp = "/index.php/admin/Ueditor/scrawlUp/savepath/goods/savepath1/ppt.html";
var URL_getRemoteImage = "/index.php/admin/Ueditor/getRemoteImage/savepath/goods/savepath1/ppt.html";
var URL_imageManager = "/index.php/admin/Ueditor/imageManager/savepath/goods/savepath1/ppt.html";
var URL_imageUp = "/index.php/admin/Ueditor/imageUp/savepath/goods/savepath1/ppt.html";
var URL_getMovie = "/index.php/admin/Ueditor/getMovie/savepath/goods/savepath1/ppt.html";
var URL_home = "";
</script>
<script type="text/javascript" charset="utf-8" src="/public/plugins/Ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/public/plugins/Ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/public/static/js/model/angular-ueditor.min.js"></script>
<script type="text/javascript" src="/public/pickercolor/js/colorpicker.js"></script>
<script type="text/javascript" src="/public/pickercolor/js/eye.js"></script>
<script type="text/javascript" src="/public/pickercolor/js/utils.js"></script>
<script type="text/javascript" src="/public/pickercolor/js/layout.js?ver=1.0.2"></script>
<style>
.ui-sortable-placeholder{border: 1px dashed #ff0000;height:40px;margin: 0;}
.color_Selector {
background: url("/public/colorpicker/img/select2.png") no-repeat center center;
cursor: pointer;
display: inline-block;
height: 28px;
position: relative;
width: 28px;
overflow: hidden;
}
.colorchild_span{display: inline-block; width: 40px;height:40px;}
label{font-weight: normal;}
.w50{width: 48%;}
.w100{width: 100%;}
</style>
</head>
<body ng-controller="ctrl" style="overflow-y: auto;">
<div id="topdiv">
<!--<div class="indexbox">-->
<!--模块div-->
<div class="navBox">
<div ui-sortable="sortableOptions" ng-model="firdata" class="first">
<div class="nav" ng-repeat="item in firdata track by $index" ename="{{item.ename}}">
<div class="ico">
<img src="{{item.icon}}" style="width: 100%;height: 100%;" />
</div>
<p class="cut" ng-bind="item.name"></p>
</div>
</div>
</div>
<!--编辑预览div-->
<div id="yushow" class="yushow">
<div class="phone">
<div class="header"></div>
<div id="phone_content" class="content" style="background-color:{{config.bkcolor}}" ruby-drop="vm.drop(event,{$v.id})" ruby-dragover="vm.dragover(event)">
<!--顶上标题-->
<div class="title">
<img src="__PUBLIC__/static/images/model/titlebar.png" style="width: 100%;" />
<div class="tit">
<span>{{config.title}}</span>
</div>
</div>
<div class="phone_content">
<div class="content_show">
<div ui-sortable="sortableOptions" ng-model="slicedata" class="item" style="min-height: 500px;">
<div ng-repeat="item in slicedata track by $index" ng-click="editSlice(item,$index)" class="bitem">
<div ng-class='{focus: $index==focus}' style="height:auto;position:relative;overflow: hidden; min-height:40px;">
<div class="deltype fa fa-trash-o" ng-click="delelem($index);$event.stopPropagation();" style="color: #ddd"></div>
<div class="itembox" ng-if="item.type==0" ng-include="'/public/template/html/'+item.ename+'/showhtm.html'"></div>
<div class="itembox" style="text-align: center; line-height: 40px" ng-if="item.type==1" ng-include="'/public/template/custom/showhtm.html'"></div>
<!--<div ng-if="item.ename == 'custom'" class="customName"></div>-->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="home"></div>
</div>
<!--编辑控制div-->
<div class="editbox">
<div class="editPage">
<div class="editScroll">
<div class="basics">
<p>页面基础设置</p>
<ul class="basics_ul">
<li >
<label class="col-sm-3">页面标题</label>
<div class="col-sm-8">
<input id="ftitle" class="form-control input-sm" ng-model="config.title" type="text" style="width:300px"><span id="ftitle_err" style="color: red;"></span>
</div>
<div class="clear"></div>
</li>
<li>
<label class="col-sm-3">页面描述</label>
<div class="col-sm-8">
<input ng-model="config.descr" class="form-control input-sm" type="text" placeholder="用户通过微信分享给朋友时,会自动显示页面描述" style="width: 300px"/>
</div>
<div class="clear"></div>
</li>
<li>
<label class="col-sm-3">颜色选择</label>
<div class="col-sm-8">
<span onclick="setcolor('config','bkcolor',this)" class="color_Selector" style="background-color: {{config.bkcolor}}"></span>
<input type="button" value="重置" class="btn addNav" onclick="bg_reset()" />
<label><input ng-model="config.isright" type="checkbox">右侧挂件</label>
</div>
<div class="clear"></div>
</li>
<li class="dn">
<label class="col-sm-3">图片</label>
<div class="col-sm-8">
<div class="upimg">
<div class="topbg">
<a onclick="add_img()">+添加图片</a>
<img style="display: none;" src="__PUBLIC__/images/del/original.jpg" />
<span class="dis_vm"></span>
<div class="tit dn">重新选择</div>
</div>
<span>建议尺寸:640 x 430 像素</span>
</div>
</div>
<div class="clear"></div>
</li>
<if condition="$new neq 1 && !empty($Think.request.id)">
<li>
<label class="col-sm-3">恢复商品图片</label>
<div class="col-sm-8">
<input type="button" value="恢复" class="btn addNav" onclick="back_good_img()" />
</div>
<div class="clear"></div>
</li>
</if>
</ul>
</div>
<div id="control" class="basics"></div>
<div class="control_bottom"></div>
</div>
</div>
</div>
<!--</div>-->
</div>
<div class="foot">
<a class="btn btn_blue" ng-click="save()">保存</a>
<a class="btn btn_white" onclick="javascript :history.back(-1)" >返回<font id="fheight2"></font></a>
</div>
<if condition="$new neq 1">
<input id="id" name="id" type="hidden" value="{$Think.request.id}">
<else/>
<input id="id" name="id" type="hidden" value="">
<input id="from_id" name="from_id" type="hidden" value="{$from_id}">
</if>
<div id="ffcustom" style="display: none">
<div>自定义模块</div>
<p>选择风格:<select id="customsele" ng-change="changeval(x)" ng-model="x" >
<option value="">请选择</option>
<foreach name="customlist" item="v">
<option value="{$v.eng_name}" <if condition="$type eq 1">selected</if>>{$v.name}</option>
</foreach>
</select>
<input class="cusname" value="" ng_model="content.name" type="hidden">
</p>
</div>
<div id="ffcustomval">
<foreach name="customlist" item="v">
<div val="{$v.eng_name}" name="{$v.name}"></div>
</foreach>
</div>
<input id="ftupimg" value="" type="hidden"/>
<input id="ferpid" value="{:getERPId()}" type="hidden"/>
<!--会员类型 0商家后台,1总后台-->
<input id="admintype" type="hidden" value="0">
<!--链接地址-->
<include file="./public/url_sele.html"/>
<include file="./public/audio_sele.html"/>
<include file="./public/ware_sele.html"/>
<!--拾色器-->
<div id="ffcolorSelector" style="display: none; width: 10px; height: 10px;"></div>
<input id="col_controllist" ind="" value="" type="hidden"/>
<!--团购秒杀-->
<include file="./public/group_skill_sele.html"/>
</body>
<script type="text/javascript">
/*--滚动的回调--*/
function sback() {
if($('.edui-editor').length>0) {
if ($('.edui-editor').offset().top <= 0) {
$(".edui-editor-toolbarbox").css('position', "fixed");
$(".edui-editor-toolbarbox").css('z-index', "1000");
var au = $(".editPage").find('.editScroll').css('transform').replace(/[^0-9\-,]/g, '').split(',');
var op = -au[5];
$(".edui-editor-toolbarbox").css('top', op + "px");
$("#fheight").text(op);
} else {
$(".edui-editor-toolbarbox").css('position', "static");
$(".edui-editor-toolbarbox").css('top', '0px');
}
}
}
//拾色器start
var col_sele_obj=null;
/*---链接地址,a是content的一级名称,b是二级名称,ob是对象---*/
function setcolor(a,b,ob){
var obj=$(ob).parent().parent();
var ind=0;
url_sele_obj=ob;
if(a==""){
$("#controllist").val(b);
}else{
$("#controllist").val(a+'-'+b);
var n=0;
while(!obj.hasClass('parent')){
obj=obj.parent();
n++;
if(n>=4) break;
}
ind=obj.index();
}
$("#col_controllist").attr("ind",ind);
$('#ffcolorSelector').click();
x=$(ob).offset().left;
y=$(ob).offset().top+30;
$(".colorpicker").css("left",(x-326)+'px');
$(".colorpicker").css("top",y+'px')
}
/*---colorpick---*/
$('#ffcolorSelector').ColorPicker({
color: '#0000ff',
onShow: function (colpkr) {
$(colpkr).fadeIn(500);
return false;
},
onHide: function (colpkr) {
$(colpkr).fadeOut(500);
return false;
},
onChange: function (hsb, hex, rgb) {
$('#colorSelector div').css('backgroundColor', '#' + hex);
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
//调用msg变量,并改变msg的值
var v = $("#controllist").val();
var ind = parseInt($("#col_controllist").attr('ind'));
var ary = v.split("-");
var c = $("#controllist").attr('utitle');
if (ary[0]== "config") {
var b = ary[1];
$scope.config[b] = '#' + hex;
} else {
if (ary.length == 1) {
$scope.content[v] = '#' + hex;
} else {
var a = ary[0];
var b = ary[1];
/*--修改链接的地址--*/
$scope.content[a][ind][b] = '#' + hex;
}
}
//同步到Angular控制器中
$scope.$apply();
}
});
//拾色器end
$(".itembox").live('click', function(event) {
event.preventDefault();
});
var err0="{$err}";
$(function () {
$("#ftitle").focus(function () {
$("#ftitle_err").text("");
});
if(err0!=""){
layer.alert(err0);
}
// var w=$("#topdiv").width()-$(".navBox").width()-$(".yushow").width();
// $(".editbox").css("width",w);
//滚动条美化
$(".navBox").niceScroll({
cursorwidth: "5px",// 滚动条的宽度
cursorborderradius: "5px", // 滚动条圆角(像素)
cursoropacitymax: 0.5,// 当滚动条是显示状态时改变透明度, 值范围 1 到 0
autohidemode: false, //是否隐藏滚动条
bouncescroll:false,//使滚动弹跳在内容结尾作为移动像(仅HW ACCELL)(默认:false)
usetransition:false,
});
$(".yushow").niceScroll(".phone",{
cursorwidth: "5px",// 滚动条的宽度
cursorborderradius: "5px", // 滚动条圆角(像素)
cursoropacitymax: 0.5,// 当滚动条是显示状态时改变透明度, 值范围 1 到 0
autohidemode: false, //是否隐藏滚动条
bouncescroll:false,//使滚动弹跳在内容结尾作为移动像(仅HW ACCELL)(默认:false)
});
$(".editPage").niceScroll(".editScroll",{
cursorwidth: "5px",// 滚动条的宽度
cursorborderradius: "5px", // 滚动条圆角(像素)
cursoropacitymax: 0.5,// 当滚动条是显示状态时改变透明度, 值范围 1 到 0
autohidemode: false, //是否隐藏滚动条
bouncescroll:false,//使滚动弹跳在内容结尾作为移动像(仅HW ACCELL)(默认:false)
usetransition:false,
func_back:"sback",
});
$("body").niceScroll("#topdiv",{
cursorwidth: "5px",// 滚动条的宽度
cursorborderradius: "5px", // 滚动条圆角(像素)
cursoropacitymax: 0.5,// 当滚动条是显示状态时改变透明度, 值范围 1 到 0
autohidemode: false, //是否隐藏滚动条
bouncescroll:false,//使滚动弹跳在内容结尾作为移动像(仅HW ACCELL)(默认:false)
usetransition:false,
});
});
//重置背景色
function bg_reset(){
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
$scope.config.bkcolor="#fff";
//如果想同步到Angular控制器中,则需要调用$apply()方法即可
$scope.$apply();
}
/*--获取no--*/
function get_random(num) {
var random = Math.floor((Math.random() + Math.floor(Math.random() * 9 + 1)) * Math.pow(10, num - 1));
return random;
}
/*--后台数据之间映射到前台--*/
var temdata={$temdata};
var modata={$module};
var tconfig={$config};
var is_mini="{$is_mini}";
if(is_mini=="") is_mini=0;
/*--store_name--*/
var store_name="{$tpshop_shopname}";
var store_img="{:getimg($tpshop_logo,NOIMG);}";
var url="{:url('Ueditor/index',array('savepath'=>'template'))}";
var from_id="{$from_id}";
/*--angular 控制模块--*/
var app=angular.module("app",["ui.sortable",'ui.slider','ng.ueditor','ngSanitize']);
angular.module('app') .filter('to_trusted',
['$sce', function($sce){ return function(text) { return $sce.trustAsHtml(text); }; }]);
app.factory('colorpicker', function() {
function hexFromRGB(r, g, b) {
var hex = [r.toString(16), g.toString(16), b.toString(16)];
angular.forEach(hex, function(value, key) {
if (value.length === 1)
hex[key] = "0" + value;
});
return hex.join('').toUpperCase();
}
return {
refreshSwatch: function(r, g, b) {
var color = '#' + hexFromRGB(r, g, b);
angular.element('#swatch').css('background-color', color);
}
};
});
app.filter('trustHtml', function ($sce) {
return function (input) {
return $sce.trustAsHtml(input);
}
});
app.controller('ctrl', ['$scope','$compile','$http','$timeout',function($scope,$compile,$http,$timeout){
$scope.miframe="<iframe frameborder='0' src='https://v.qq.com/iframe/player.html?vid=n0341nmmg98&tiny=0&auto=0' style='width:100%;height:100%; z-index: 1;'></iframe>";
//富文本
$scope.ueditconfig = {
//这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
toolbars:[['FullScreen',/*全屏*/
'Source', /*源代码*/
'Undo',/*撤销*/
'Redo',/*重做*/
'test',/*文本*/
'insertimage',/*多图上传*/
'link',/*超链接*/
'unlink', /*取消链接*/
'inserttable', /*插入表格*/
'edittable',/*表格属性*/
'blockquote', /*引用*/
'horizontal', /*分隔线*/
'searchreplace', /*查询替换*/
'insertcode', /*代码语言*/
'fontsize', /*字号*/
'Bold',/*加粗*/
'italic', /*斜体*/
'underline', /*下划线*/
'forecolor', /*字体颜色*/
'backcolor', /*背景色*/
'insertorderedlist', /*有序列表*/
'insertunorderedlist', /*无序列表*/
'justifyleft', /*居左对齐*/
'justifyright', /*居右对齐*/
'justifycenter', /*居中对齐*/
'justifyjustify' /*两端对齐*/
]],
//focus时自动清空初始化时的内容
autoClearinitialContent:true,
autoHeightEnabled:false,
//关闭字数统计
wordCount:false,
//关闭elementPath
elementPathEnabled:false,
pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
catchRemoteImageEnable: false //设置是否抓取远程图片
,serverUrl:url
}
/*-------------点击选择编辑--------------*/
$scope.editSlice = function(a,b){
$scope.focus=b;
$scope.content=a.content;
if(a.type==1) {
var ht = $('#ffcustom').html();
$("#control").html($compile(ht)($scope));
}else {
var url0 = "/public/template/html/" + a.ename + "/controlhtm.html";
var ht = "<div ng-include=\"\'" + url0 + "\'\"></div>";
$("#control").html($compile(ht)($scope));
}
}
/*---点击删除元素---*/
$scope.delelem =function (a) {
if($scope.focus==a){
$("#control").html("");
}
$scope.slicedata.splice(a, 1);
$scope.editSlice($scope.slicedata[0],0);
$('.phone_content').niceScroll().resize();
}
//元素{"content":citem,"ename":data.data.eng_name,"name":"","icon":"","type":0};
/*--左侧是模块--*/
$scope.firdata=modata;
$scope.cannotSort = false;
$scope.is_mini = is_mini;
/*---中间预览模块---*/
if(temdata==-1) {
$scope.slicedata = [];
}
else {
$scope.slicedata = temdata;
$scope.editSlice(temdata[0],0);
}
/*---页面的基础信息--*/
if(tconfig==-1)
$scope.config = {"title":"","descr":"","istop":0,"isright":0,"money":0,"bkcolor":"#ffffff"};
else{
$scope.config=tconfig;
$scope.config["isright"]=($scope.config["isright"]==1?true:false);
}
/*---当前控制第几个--*/
$scope.focus=0;
/*-------sortable排序-------*/
$scope.sortableOptions = {
//可以拖动到的对象
connectWith: ".item",
start: function(e, ui) {
$(".ui-sortable-placeholder").css("visibility","visible");
$scope.Clone = ui.item.sortable.sourceModel.slice(); //起始数据源拷贝
$scope.dClone =$scope.slicedata.slice(); //目的数据源拷贝
$scope.ename=$(ui.item).attr("ename");
},
sort:function (e, ui) {
var obj=$(".item").find(".ui-sortable-placeholder");
if(obj.length>0){
$scope.curindex=obj.index();
}
},
// 数据有变化
update: function (e, ui) {},
// 完成拖拽动作
stop: function (e, ui) {
//当有从起始拖到目的时
if ($(e.target).hasClass("first") && ui.item.sortable.droptarget &&e.target != ui.item.sortable.droptarget[0]){
/*--被拖动还原--*/
ui.item.sortable.sourceModel.length = 0;
// clone the original model to restore the removed item
Array.prototype.push.apply(
ui.item.sortable.sourceModel,
$scope.Clone
);
/*--在拖动位置插入元素--*/
var len=ui.item.sortable.sourceModel.length;
var elem;
for(var i=0;i<len;i++){
if(ui.item.sortable.sourceModel[i].ename==$scope.ename){
elem= jQuery.extend(true, {},ui.item.sortable.sourceModel[i]); //深度拷贝
break;
}
}
console.log("elem");
console.log(elem);
$scope.slicedata=$scope.dClone;
$scope.slicedata.splice($scope.curindex, 0,elem);
/*--明确要被控制的对象--*/
$scope.focus=$scope.curindex;
$scope.content=$scope.slicedata[$scope.curindex].content;
if($scope.content.no=="" || $scope.content.no==undefined){
$scope.content.no=get_random(5);
}
if($scope.content.shopname!=undefined && $scope.content.shopname!=null){
$scope.content.shopname=store_name;
}
if($scope.content.logoimg!=undefined && $scope.content.logoimg!=null){
$scope.content.logoimg=store_img;
}
//如果是自定义模板的话
if(elem.type==1){
var ht=$('#ffcustom').html();$("#control").html($compile(ht)($scope));
}else{
/*--右侧控制插入div--*/
var url0 = "/public/template/html/" + elem.ename + "/controlhtm.html";
var ht = "<div ng-include=\"\'" + url0 + "\'\"></div>";
$("#control").html($compile(ht)($scope));
}
$('.phone_content').niceScroll().resize();
}
//当是右侧的拖拽是
else if($(e.target).hasClass("item")){
$timeout(function() {
/*--拖拽完默认第一个被显示--*/
$scope.focus = 0;
$scope.content = $scope.slicedata[0].content;
//console.log($scope.slicedata);
//如果是自定义模板的话
if ($scope.slicedata[0].type == 1) {
var ht = $('#ffcustom').html();
$("#control").html($compile(ht)($scope));
} else {
var url0 = "/public/template/html/" + $scope.slicedata[0].ename + "/controlhtm.html";
var ht = "<div ng-include=\"\'" + url0 + "\'\"></div>";
$("#control").html($compile(ht)($scope));
}
},200);
}
}
}
/*-------------保存模板数据--------------*/
$scope.save = function(){
var len=$scope.slicedata.length;
if(len<=0) {
layer.msg("请拖入要编辑的模块",{icon:2,time:2000});
return;
}
if($scope.config.title==""){
layer.msg("请输入模板标题",{icon:2,time:2000});
$("#ftitle_err").text("请输入模板标题")
return;
}
/*---自定义模块没有选择要报错---*/
var f=true;
for(var i=0;i<len;i++){
var ele= $scope.slicedata[i];
if(ele.type==1 && ele.ename=="") {
layer.msg("请选择自定义模块",{icon:2,time:2000});
f=false;
$scope.editSlice(ele,i);
break;
}
}
if(!f) return;
var isok=1;
for(var i=0;i<len;i++){
var ele=$scope.slicedata[i];
var func=$scope.slicedata[i].content.checkfunc; //自检验函数
if(func!=undefined && func!=null){
isok= eval(func+'(ele)');
if(isok==0) break;
}
}
if(isok==0) return;
var ii=layer.msg('加载中...', {
icon: 16,
shade: [0.5, '#f5f5f5'],
scrollbar: false,
offset: '200px',
time: 100000
});
var postd=[$scope.slicedata,$scope.config];
var id=$("#id").val();
if(id=="") id=0;
/*---post提交数据---*/
$http({
method:'post',
url:'/index.php/admin/weapp/temlatesave_mini/id/'+id+"/from_id/"+from_id,
data:postd
})
.success(function(req){
layer.close(ii);
if(req.code==1){
layer.msg("保存成功",{icon:1,time:2000});
$timeout(function(){
window.location.href="/index.php/admin/Weapp/miniTemplateList";
},1000);
}else{
layer.msg("保存失败",{icon:1,time:2000});
}
})
}
$scope.set_style=function(num){
switch(num){
case 0:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"#81d5f9"
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"#ff8195"
}];
$scope.content.style=0;
break;
case 1:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"#81d5f9"
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"#ff8195"
}];
$scope.content.style=1;
break;
case 2:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"#0065CB"
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"#ff77dd"
}];
$scope.content.style=2;
break;
case 3:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
}];
$scope.content.style=3;
break;
case 4:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"#0065CB"
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
bgcolor:"ff77dd"
}];
$scope.content.style=4;
break;
case 5:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
}];
$scope.content.style=5;
break;
case 6:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
}];
$scope.content.style=6;
break;
case 7:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
}];
$scope.content.style=7;
break;
case 8:
$scope.content.data=[{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
},{
title:"",
src:"",
imgurl:"",
urltitle:"请选择",
wxapp_imgurl:"",
wxapp_url_title:"请选择",
}];
$scope.content.style=8;
break;
}
}
/*---下拉框改变---*/
$scope.changeval = function(x){
$scope.content.ename=x;
var tname="";
$("#ffcustomval").find("div").each(function () {
var ename=$(this).attr('val');
if(ename==x){
tname=$(this).attr('name');
}
});
$scope.content.name=tname;
$(".customName").text(tname);
}
}]);
//---修复图片---
function back_good_img() {
var id=$("#id").val();
var ii=layer.msg('加载中...', {
icon: 16,
shade: [0.5, '#f5f5f5'],
scrollbar: false,
offset: '200px',
time: 0
});
$.ajax({
type: "POST",
url: "/index.php?m=admin&c=template&a=renew_img&id=" + id, //+tab,
async:false,
success: function(data) {
layer.close(ii);
if(data.code==0){
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
$scope.slicedata=data.data;
var list_data=data.data;
//如果想同步到Angular控制器中,则需要调用$apply()方法即可
$scope.$apply();
var ind=$scope.focus;
$scope.editSlice(list_data[ind],ind);
$scope.$apply();
layer.msg('恢复成功', {icon: 1, time: 1000});
}
else{
layer.msg(data.msg, {icon: 2, time: 1000});
}
}
});
}
</script>
</html>