rabin 7 years ago
parent
commit
d82a438fac

+ 1 - 1
cron.py

@@ -47,7 +47,7 @@ def timeSync():
 def handle():
 	gevent.joinall([
 		gevent.spawn(device),
-		gevent.spawn(savePic),
+		#gevent.spawn(savePic),
 		gevent.spawn(timeSync),
 	])
 

+ 23 - 2
front/api/upload.py

@@ -9,6 +9,7 @@ from __load__ import *
 from datetime import *
 import os
 import uuid
+from PIL import Image
 
 class index_path(Load):
 	"""
@@ -35,7 +36,7 @@ class index_path(Load):
 	def post(self, *args, **kwargs):
 		url = self.request.protocol + "://" + self.request.host
 		file_metas = self.request.files["file"]
-
+		type = self.input('type', 1)
 		# print(file_metas)
 		day = str(date.today())
 		day = day.split('-')
@@ -46,4 +47,24 @@ class index_path(Load):
 			file_path = File.mkdirs(os.path.join(Demeter.path, 'runtime','upload', file_path)) + '/' + Demeter.md5(file_name) + '.jpg'
 			with open(file_path, 'wb') as up:
 				up.write(meta['body'])
-		self.out('yes', {'src':url + file_path.replace(Demeter.path + 'runtime', '')})
+
+		if type:
+			#裁图类型,暂时居中裁图
+			file_path = self.crop(file_path)
+		self.out('yes', {'src':url + file_path.replace(Demeter.path + 'runtime', '')})
+
+	def crop(file):
+		img = Image.open(file) #打开图片句柄    
+		width = img.size[0]
+		height = img.size[1]
+		size = 0
+		if width < height:
+			size = width
+		else:
+			size = height
+		#img.thumbnail((500, 500))
+		left = width/4
+		crop = img.crop((left, 0, size+left, size))
+		file = file + '_crop_center.jpg'
+		crop.save(file)
+		return file

File diff suppressed because it is too large
+ 0 - 0
web/static/lib/player/video-js.min.css


File diff suppressed because it is too large
+ 11 - 0
web/static/lib/player/video.min.js


File diff suppressed because it is too large
+ 0 - 0
web/static/lib/player/videojs-contrib-hls.min.js


+ 42 - 20
web/templates/index.html

@@ -2,47 +2,69 @@
 <html>
 <head>
     {%include 'inc/header.html'%}
-    <link href="{{static_url('css/index.css')}}" rel="stylesheet"></head>
+    <link href="{{static_url('css/index.css')}}" rel="stylesheet">
+    <link href="{{static_url('lib/player/video-js.min.css')}}" rel="stylesheet">
+    </head>
 <body>
     {%include 'inc/menu.html'%}
     <div class="wrapper">
         <div class="swiper-container">
-	        <div class="swiper-wrapper">
-	            <div class="swiper-slide"><a href="#"><img src="{{static_url('images/1da7fa89.banner.jpg')}}" width="100%"><i class="btn-play"></i></a></div>
-	        </div>
-	    </div>
+            <div class="swiper-wrapper">
+                <div class="swiper-slide">
+                    <video id="player-1" width="1000" height="450" class="player video-js vjs-default-skin vjs-big-play-centered" controls>
+                      <source
+                         src="{{data['setting']['web']['video']}}"
+                         type="video/mp4">
+                    </video>   
+                </div>
+            </div>
+        </div>
         {% if data['function'] %}
-	    <div class="block product">
-	    	<h2 class="block-title">产品功能</h2>
-	    	<ul>
+        <div class="block product">
+            <h2 class="block-title">产品功能</h2>
+            <ul>
                 {%set i=1 %}
                 {% for v in data['function'] %}
-	    		<li><a href="{{v['link']}}"><i class="icon icon{{i}}"></i><p>{{v['name']}}</p></a></li>
+                <li><a href="{{v['link']}}"><i class="icon icon{{i}}"></i><p>{{v['name']}}</p></a></li>
                 {%set i=i+1 %}
-	    		{% end %}
-	    	</ul>
-	    </div>
+                {% end %}
+            </ul>
+        </div>
         {% end %}
-	    <div class="block wechat">
-	    	<h2 class="block-title">微信管理</h2>
-	    	<img src="{{data['setting']['web']['wx_pic']}}" width="559" height="220">
+        <div class="block wechat">
+            <h2 class="block-title">微信管理</h2>
+            <img src="{{data['setting']['web']['wx_pic']}}" width="559" height="220">
             <div class="msg">
                 {% raw data['setting']['web']['wx_text'] %}
                 <a href="{{data['setting']['web']['wx_link']}}" target="_blank">查看详细操作说明</a>
             </div>
-	    </div>
+        </div>
         {% if data['demo'] %}
-	    <div class="block custom">
-	    	<h2 class="block-title">客户案例</h2>
-	    	<ul>
+        <div class="block custom">
+            <h2 class="block-title">客户案例</h2>
+            <ul>
                 {% for v in data['demo'] %}
                 <li><a href="{{v['link']}}"><img src="{{v['pic']}}" width="100%"><p>{{v['name']}}</p></a></li>
                 {% end %}
             </ul>
-	    </div>
+        </div>
         {% end %}
     </div>
     {%include 'inc/footer.html'%}
     {%include 'inc/script.html'%}
+    <script type="text/javascript" src="{{static_url('lib/player/video.min.js')}}"></script>
+    <script type="text/javascript" src="{{static_url('lib/player/videojs-contrib-hls.min.js')}}"></script>
+    <script>
+    $(".player").each(function()
+    {
+        var self = $(this);
+        var id = self.attr('id');
+        var url = self.attr('data-url');
+        var player = videojs(id, { fluid: false }, function()
+        {
+            //this.play();
+        });
+    });
+    </script>
     </body>
 </html>

Some files were not shown because too many files changed in this diff