weixianghui 5 жил өмнө
parent
commit
88bd514dea

+ 2 - 2
core/src/qfw/manage/course.go

@@ -529,7 +529,7 @@ func (this *CourseManage) CreateOnLineApi() {
 			courseDate == "" || endTime == "" {
 			courseDate == "" || endTime == "" {
 			return &FuncResult{false, errors.New("参数不完整"), nil}
 			return &FuncResult{false, errors.New("参数不完整"), nil}
 		}
 		}
-		if picUrl != "" {
+		/*if picUrl != "" {
 			//生成访问地址
 			//生成访问地址
 			b, _, m := cutil.FileRedis(picUrl,"img")
 			b, _, m := cutil.FileRedis(picUrl,"img")
 			if b == false{
 			if b == false{
@@ -549,7 +549,7 @@ func (this *CourseManage) CreateOnLineApi() {
 			if b == false{
 			if b == false{
 				return &FuncResult{false, errors.New(fmt.Sprintf("%s", m)), nil}
 				return &FuncResult{false, errors.New(fmt.Sprintf("%s", m)), nil}
 			}
 			}
-		}
+		}*/
 
 
 		publishtime, err := time.ParseInLocation(qutil.Date_Full_Layout, s_publishtime, time.Local)
 		publishtime, err := time.ParseInLocation(qutil.Date_Full_Layout, s_publishtime, time.Local)
 		if err != nil {
 		if err != nil {

+ 52 - 15
core/src/web/templates/manage/course/onLineContent.html

@@ -16,6 +16,7 @@
     <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/My97DatePicker/WdatePicker.js"></script>
     <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/My97DatePicker/WdatePicker.js"></script>
     <script type="text/javascript" src="{{Msg "seo" "cdn"}}/layui/layui.js"></script>
     <script type="text/javascript" src="{{Msg "seo" "cdn"}}/layui/layui.js"></script>
     <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/issue.js"></script>
     <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/issue.js"></script>
+    <script type="text/javascript" src="{{Msg "seo" "cdn"}}/js/upload.js"></script>
     <style type="text/css">
     <style type="text/css">
         .widget-content {
         .widget-content {
             table-layout: fixed;
             table-layout: fixed;
@@ -131,7 +132,8 @@
                                 头图:
                                 头图:
                             </div>
                             </div>
                             <div class="items-right">
                             <div class="items-right">
-                                <input id="picUrl" type="text" placeholder="请输入图片地址" value="{{.T.picUrl}}">
+                                <input id="picUrl"  style="width: 25%;" type="text" placeholder="请输入图片地址" value="{{.T.picUrl}}">
+                                <button type="button"  class="btn btn-primary" onClick="upload(this, 'img')" style="color: #4E5051;margin-top: -4px;height: 36px;">上传</button>
                             </div>
                             </div>
                         </div>
                         </div>
                         <div class="items">
                         <div class="items">
@@ -155,7 +157,8 @@
                                 课件:
                                 课件:
                             </div>
                             </div>
                             <div class="items-right">
                             <div class="items-right">
-                                <input id="fileUrl" type="text" placeholder="请输入课件地址" value="{{.T.fileUrl}}">
+                                <input id="fileUrl" type="text" style="width: 25%" placeholder="请输入课件地址" value="{{.T.fileUrl}}">
+                                <button type="button"  class="btn btn-primary" onClick="upload(this, 'file')" style="color: #4E5051;margin-top: -4px;height: 36px;">上传</button>
                             </div>
                             </div>
                         </div>
                         </div>
                         <div class="items">
                         <div class="items">
@@ -258,6 +261,7 @@
 
 
     </div>
     </div>
 </div>
 </div>
+<div id="upload" style="display: none;"></div>
 {{include "/common/bottom.html"}}
 {{include "/common/bottom.html"}}
 <script type="text/javascript" src="/js/bootbox.js"></script>
 <script type="text/javascript" src="/js/bootbox.js"></script>
 <script>
 <script>
@@ -299,10 +303,12 @@
         });
         });
         editor.html(content);
         editor.html(content);
         var glkcLi = "";
         var glkcLi = "";
-        for (var i = 0; i < associatedCourses.length; i++){
-            glkcLi = glkcLi + "<li id="+associatedCourses[i]._id+">"+associatedCourses[i].s_name+"</li>"
+        if(associatedCourses != null){
+            for (var i = 0; i < associatedCourses.length; i++){
+                glkcLi = glkcLi + "<li id="+associatedCourses[i]._id+">"+associatedCourses[i].s_name+"</li>"
+            }
+            $('.courser').html(glkcLi);
         }
         }
-        $('.courser').html(glkcLi);
     });
     });
 
 
     //提交
     //提交
@@ -402,16 +408,6 @@
         $($Obj).removeAttr("disabled");
         $($Obj).removeAttr("disabled");
     }
     }
 
 
-    //预览
-    function preview(flag) {
-        if (flag === 0) {
-            window.open("/manage/course/preview/pc/" + id)
-        } else (flag === 1)
-        {
-            window.open("/manage/course/preview/mobile/" + id)
-        }
-    }
-
     var dateFormat = function (timestamp, formats) {
     var dateFormat = function (timestamp, formats) {
         // formats格式包括
         // formats格式包括
         // 1. Y-m-d
         // 1. Y-m-d
@@ -448,6 +444,47 @@
             })[matches];
             })[matches];
         });
         });
     };
     };
+
+    //上传按钮
+    function initUpload(flag,obj,type){
+        var option={
+            name:"onLineUpload",
+            btnname:"上传",
+            action:"/filemanage/upload",
+            btnClass:"",
+            afterError:function(data,e){
+                alert("上传失败,请重新上传。");
+            },
+            afterUpload:function(data){ //此处可以重写,上传后的处理
+                if(data.flag == true){
+                    if (type == "img"){
+                        $("#picUrl").val(data.url)
+                    }
+                    if (type == "file"){
+                        $("#fileUrl").val(data.url)
+                    }
+                    bootbox.alert("上传成功");
+                }else{
+                    bootbox.alert(data.msg);
+                }
+            }
+        };
+        try{
+            $("#upload").upload(option,"",flag);
+        }catch(e){}
+    }
+    //上传图片
+    function upload(obj,type){
+        $("#upload").upload("reset");
+        initUpload(1,obj,type);
+        if (type == "img"){
+            $("#upload input[type='file']").attr("accept",".jpg,.png,.jpeg").trigger("click");
+        }
+        if (type == "file"){
+            $("#upload input[type='file']").attr("accept",".zip,.ppt,.pptx,.pdf,.doc,.docx").trigger("click");
+        }
+    }
+
 </script>
 </script>
 </body>
 </body>
 </html>
 </html>