sunhao 5 yıl önce
ebeveyn
işleme
4c354c23b2

+ 20 - 8
app/Http/Controllers/Admin/TemplateController.php

@@ -15,6 +15,7 @@ use App\TemplatesSource;
15 15
 use App\TemplatesSourceSalers;
16 16
 use App\AdminRole;
17 17
 use App\TemplatesLog;
18
+use App\TemplatesBackimg;
18 19
 use App\CustDetail;
19 20
 use App\Order;
20 21
 use App\Services\OssServices as oss;
@@ -149,7 +150,7 @@ class TemplateController extends Controller
149 150
      */
150 151
     public function assignSalers(Request $request)
151 152
     {
152
-        $t_id = (int)$request->input('id');
153
+        $s_id = (int)$request->input('id');
153 154
         $salers = $request->input('salers');
154 155
         $assign_type = (int)$request->input('assign_type');
155 156
 
@@ -180,7 +181,7 @@ class TemplateController extends Controller
180 181
         }
181 182
 
182 183
         //如果已经有 ,删除未选中
183
-        TemplatesSalers::where('t_id', $t_id)->whereNotIn('admin_id',$salers)->update(['is_del'=>1]);
184
+        TemplatesSourceSalers::where('s_id', $s_id)->whereNotIn('admin_id',$salers)->update(['is_del'=>1]);
184 185
         foreach( $salers as $k=>$admin_id ){
185 186
             if($assign_type == 1){
186 187
                 $weight = $weight_avg;
@@ -188,10 +189,10 @@ class TemplateController extends Controller
188 189
                 $weight = $weights[$k];
189 190
             }
190 191
 
191
-            TemplatesSalers::updateOrCreate( ['t_id'=>$t_id, 'admin_id'=>$admin_id], ['is_del'=>0, 'weight'=>$weight] );
192
+            TemplatesSourceSalers::updateOrCreate( ['s_id'=>$s_id, 'admin_id'=>$admin_id], ['is_del'=>0, 'weight'=>$weight] );
192 193
         }
193 194
 
194
-        exit('<script>parent.layer.msg("操作成功!",{icon:1,time:1000}); var index=parent.layer.getFrameIndex(window.name); parent.location.href="/admin/template/index";parent.layer.close(index);</script>');
195
+        exit('<script>parent.layer.msg("操作成功!",{icon:1,time:1000}); var index=parent.layer.getFrameIndex(window.name); parent.location.href="/admin/template/sourceindex";parent.layer.close(index);</script>');
195 196
     }
196 197
 
197 198
     /**
@@ -206,7 +207,7 @@ class TemplateController extends Controller
206 207
             $query->whereNotNull('qrcode')->where('qrcode', '<>', '');
207 208
         })->get();
208 209
         $adminList = json_decode(json_encode($adminList), true);
209
-        $assign_admin = TemplatesSalers::where('t_id', $id)->where('is_del', 0)->lists('weight', 'admin_id');
210
+        $assign_admin = TemplatesSourceSalers::where('s_id', $id)->where('is_del', 0)->lists('weight', 'admin_id');
210 211
 
211 212
         $team_info = DB::table('teams')->lists('name', 'id');
212 213
         foreach($adminList as &$admin){
@@ -428,7 +429,7 @@ class TemplateController extends Controller
428 429
 
429 430
         foreach($result as $k=>&$v){
430 431
             # 获取销售
431
-            $salers = TemplatesSourceSalers::select('templates_source_salers.*', 'admin.realname as admin_name')->leftJoin('admin', 'admin.id', '=', 'templates_source_salers.admin_id')->where('templates_source_salers.t_id', $v['id'])->where('templates_source_salers.is_del', 0)->get();
432
+            $salers = TemplatesSourceSalers::select('templates_source_salers.*', 'admin.realname as admin_name')->leftJoin('admin', 'admin.id', '=', 'templates_source_salers.admin_id')->where('templates_source_salers.s_id', $v['id'])->where('templates_source_salers.is_del', 0)->get();
432 433
             $v['salers'] = $salers;            
433 434
             $v['salers_k'] = count($salers); 
434 435
             # 获取模板图
@@ -447,7 +448,9 @@ class TemplateController extends Controller
447 448
      */
448 449
     public function sourcecreate()
449 450
     {
450
-        return view('template/sourcecreate');
451
+        $templates = Templates::where('is_del', 0)->whereNotNull('url')->get();
452
+        $back_imgs = TemplatesBackimg::where('is_del', 0)->whereNotNull('back_img')->lists('back_img');
453
+        return view('template/sourcecreate', ['templates'=>$templates, 'back_imgs'=>$back_imgs]);
451 454
     }
452 455
 
453 456
     /**
@@ -491,8 +494,9 @@ class TemplateController extends Controller
491 494
      */
492 495
     public function sourceedit($id)
493 496
     {
497
+        $templates = Templates::where('is_del', 0)->whereNotNull('url')->get();
494 498
         $template = TemplatesSource::findOrFail($id);
495
-        return view('template/sourceedit', ['template' => $template, 'id'=>$id]);
499
+        return view('template/sourceedit', ['template' => $template, 'id'=>$id, 'templates' => $templates]);
496 500
     }
497 501
 
498 502
     /**
@@ -532,6 +536,14 @@ class TemplateController extends Controller
532 536
         return redirect('/admin/template/sourceindex')->with('info', '修改成功');
533 537
     }
534 538
 
539
+    public function createSourceUrl($t_id, $id){
540
+        $url = Templates::where('id', $t_id)->pluck('url');
541
+        if($url){
542
+            return $url . '?id='.$id;
543
+        }
544
+        return false;
545
+    }
546
+
535 547
 
536 548
 }
537 549
  

+ 17 - 0
app/TemplatesBackimg.php

@@ -0,0 +1,17 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: Administrator
5
+ * Date: 2017/12/5
6
+ * Time: 15:07
7
+ */
8
+
9
+namespace App;
10
+use Illuminate\Database\Eloquent\Model;
11
+
12
+class TemplatesBackimg extends Model
13
+{
14
+    public $timestamps = false;
15
+    protected $table = "templates_backimg";
16
+   
17
+}

+ 17 - 0
app/TemplatesSource.php

@@ -0,0 +1,17 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: Administrator
5
+ * Date: 2017/12/5
6
+ * Time: 15:07
7
+ */
8
+
9
+namespace App;
10
+use Illuminate\Database\Eloquent\Model;
11
+
12
+class TemplatesSource extends Model
13
+{
14
+    public $timestamps = false;
15
+    protected $table = "templates_source";
16
+   
17
+}

+ 18 - 0
app/TemplatesSourceSalers.php

@@ -0,0 +1,18 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: Administrator
5
+ * Date: 2017/12/5
6
+ * Time: 15:07
7
+ */
8
+
9
+namespace App;
10
+use Illuminate\Database\Eloquent\Model;
11
+
12
+class TemplatesSourceSalers extends Model
13
+{
14
+    public $timestamps = false;
15
+    protected $table = "templates_source_salers";
16
+    protected $fillable = ['t_id', 'admin_id', 'weight', 'is_del', 's_id'];
17
+   
18
+}

+ 1 - 0
resources/views/admin/index.blade.php

@@ -41,6 +41,7 @@
41 41
                 <dd>
42 42
                     <ul>
43 43
                         <li @if(!isset($res['template/manage'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/template/index')}}" data-title="模板列表" href="javascript:void(0)">模板列表</a></li>
44
+                        <li @if(!isset($res['template/manage'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/template/sourceindex')}}" data-title="渠道列表" href="javascript:void(0)">渠道列表</a></li>
44 45
                         <li @if(!isset($res['template/manage'])) style="display:none;list-style-type:none;" @endif><a data-href="{{url('admin/template/logindex')}}" data-title="模板点击日志" href="javascript:void(0)">模板点击日志</a></li>                      
45 46
                         
46 47
                     </ul>

+ 17 - 8
resources/views/template/sourcecreate.blade.php

@@ -9,18 +9,27 @@
9 9
         </div>
10 10
     @endif
11 11
     <div class="page-container">
12
-        <form action="/admin/template/store" method="post" class="form form-horizontal" enctype="multipart/form-data">
12
+        <form action="/admin/template/sourcestore" method="post" class="form form-horizontal" enctype="multipart/form-data">
13 13
             <input type="hidden" name="_token" value="{{ csrf_token() }}" />
14 14
             <div class="row cl">
15 15
                 <label class="form-label col-xs-4 col-sm-2">
16
-                    模板连接:</label>
16
+                    选择模板:</label>
17 17
                 <div class="formControls col-xs-6 col-sm-6">
18
-                    <input type="text" class="input-text" value="{{old('url')}}" placeholder="" name="url">
18
+                    @if($templates)
19
+                    <ul>
20
+                        @foreach($templates as $item)
21
+                        <li>
22
+                            <img  style="width:100px;" src="{{$item['img']}}"/>
23
+                            <input type="radio" class="input-text" value="{{$item['id']}}" @if(old('t_id') == $item['id']) checked @endif name="t_id">{{$item['note']}}
24
+                        </li>
25
+                        @endforeach
26
+                    </ul>
27
+                    @endif
19 28
                 </div>
20 29
             </div>
21
-            <div class="row cl">
30
+            <!--div class="row cl">
22 31
                 <label class="form-label col-xs-4 col-sm-2">
23
-                    模板图片:</label>
32
+                    背景图片:</label>
24 33
                 <div class="formControls col-xs-6 col-sm-6">
25 34
                         <span class="btn-upload">
26 35
                           <input class="input-text upload-url radius" type="text" name="uploadfile-1" id="uploadfile-1" readonly><a href="javascript:void();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe642;</i> 上传图片</a>
@@ -28,10 +37,10 @@
28 37
                         </span><br>
29 38
                     文件类型支持:jpg ,png ,ico ,文件大小不能超过1M
30 39
                 </div>
31
-            </div>
40
+            </div-->
32 41
             <div class="row cl">
33 42
                 <label class="form-label col-xs-4 col-sm-2">
34
-                    模板描述:</label>
43
+                    渠道描述:</label>
35 44
                 <div class="formControls col-xs-6 col-sm-6">
36 45
                     <input type="text" class="input-text" value="{{old('note')}}" placeholder="" name="note">
37 46
                 </div>
@@ -60,7 +69,7 @@
60 69
         });
61 70
         /*返回*/
62 71
         function return_index(){
63
-            location.href='/admin/template/index';
72
+            location.href='/admin/template/sourceindex';
64 73
         }
65 74
     </script>
66 75
     </body>

+ 17 - 9
resources/views/template/sourceedit.blade.php

@@ -9,31 +9,39 @@
9 9
         </div>
10 10
     @endif
11 11
     <div class="page-container">
12
-        <form action="/admin/template/update" method="post" class="form form-horizontal" enctype="multipart/form-data">
12
+        <form action="/admin/template/sourceupdate" method="post" class="form form-horizontal" enctype="multipart/form-data">
13 13
             <input type="hidden" name="_token" value="{{ csrf_token() }}" />
14 14
             <input type="hidden" name="id" value="{{$id}}" />
15 15
             <div class="row cl">
16 16
                 <label class="form-label col-xs-4 col-sm-2">
17
-                    模板链接:</label>
17
+                    选择模板:</label>
18 18
                 <div class="formControls col-xs-6 col-sm-6">
19
-                    <input type="text" class="input-text" value="{{$template['url']}}" placeholder="" name="url">
19
+                    @if($templates)
20
+                    <ul>
21
+                        @foreach($templates as $item)
22
+                        <li>
23
+                            <img  style="width:100px;" src="{{$item['img']}}"/>
24
+                            <input type="radio" class="input-text" value="{{$item['id']}}" @if($template['t_id'] == $item['id']) checked @endif name="t_id">{{$item['note']}}
25
+                        </li>
26
+                        @endforeach
27
+                    </ul>
28
+                    @endif
20 29
                 </div>
21 30
             </div>
22
-            <div class="row cl">
31
+            <!--div class="row cl">
23 32
                 <label class="form-label col-xs-4 col-sm-2">
24
-                    模板样式图:</label>
33
+                    背景图片:</label>
25 34
                 <div class="formControls col-xs-6 col-sm-6">
26
-                    <div><img width="100" src="{{$template['img']?$template['img']:'/empty.png'}}"/></div><br>
27 35
                         <span class="btn-upload">
28 36
                           <input class="input-text upload-url radius" type="text" name="uploadfile-1" id="uploadfile-1" readonly><a href="javascript:void();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe642;</i> 上传图片</a>
29 37
                           <input type="file" multiple name="img" class="input-file">
30 38
                         </span><br>
31 39
                     文件类型支持:jpg ,png ,ico ,文件大小不能超过1M
32 40
                 </div>
33
-            </div>
41
+            </div-->
34 42
             <div class="row cl">
35 43
                 <label class="form-label col-xs-4 col-sm-2">
36
-                    模板描述:</label>
44
+                    渠道描述:</label>
37 45
                 <div class="formControls col-xs-6 col-sm-6">
38 46
                     <input type="text" class="input-text" value="{{$template['note']}}" placeholder="" name="note">
39 47
                 </div>
@@ -62,7 +70,7 @@
62 70
         });
63 71
         /*返回*/
64 72
         function return_index(){
65
-            location.href='/admin/template/index';
73
+            location.href='/admin/template/sourceindex';
66 74
         }
67 75
        
68 76
     </script>

+ 1 - 1
resources/views/template/sourceindex.blade.php

@@ -109,7 +109,7 @@
109 109
             totalPage: {{$pages}},
110 110
             totalSize: {{$count}},
111 111
             callback: function(num) {
112
-                location.href='index?page='+num;
112
+                location.href='sourceindex?page='+num;
113 113
             }
114 114
         })
115 115