Browse Source

新闻管理

huangyan 10 months ago
parent
commit
dbe56f6c09

+ 0 - 2
controllers/index.go

@@ -2,7 +2,6 @@ package controllers
 
 import (
 	"cc-officialweb/service"
-	"fmt"
 	beego "github.com/beego/beego/v2/server/web"
 )
 
@@ -36,7 +35,6 @@ func (c *MainController) Get() {
 	data, err := service.GetDataModel()
 	if err == nil {
 		c.Data["Datas"] = data
-		fmt.Print(data, "    =========")
 	} else {
 		c.Data["Datas"] = "未获得数据"
 	}

+ 158 - 2
controllers/new.go

@@ -1,8 +1,16 @@
 package controllers
 
 import (
+	"cc-officialweb/models"
 	"cc-officialweb/service"
+	"cc-officialweb/unity"
+	"cc-officialweb/utils"
+	"encoding/json"
 	beego "github.com/beego/beego/v2/server/web"
+	"github.com/go-playground/validator/v10"
+	"html/template"
+	"strconv"
+	"time"
 )
 
 type NewController struct {
@@ -10,8 +18,156 @@ type NewController struct {
 }
 
 func (n *NewController) Get() {
-	news := service.GetNews()
-
+	types := n.GetString("types")
+	news := service.GetNews(types)
 	n.Data["News"] = news
 	n.TplName = "news.html"
 }
+
+// NewDetail 根据id获取对应新闻详情
+func (n *NewController) NewDetail() {
+	var success []string
+	param := n.Ctx.Input.Param(":id")
+	atoi, _ := strconv.Atoi(param)
+	id, err := unity.GetById(atoi, &models.News{})
+	if err == nil {
+		n.Data["detail"] = id
+	}
+	exams := service.GetResource("example")
+	for _, v := range exams {
+		success = append(success, v.Url)
+	}
+	n.Data["example"] = success
+	n.TplName = "news-detail.html"
+}
+
+// GetAllNew 获得所有新闻消息
+func (n *NewController) GetAllNew() {
+	var page unity.PageParams
+	err := json.Unmarshal(n.Ctx.Input.RequestBody, &page)
+	if err != nil {
+		n.Data["json"] = &JSON{Code: 101, Msg: "参数错误"}
+		n.ServeJSON()
+		return
+	}
+	result, total, current, err := unity.Paginate(page, models.News{})
+	if err != nil {
+		n.Data["json"] = &JSON{Code: 101, Msg: "查询失败"}
+		n.ServeJSON()
+		return
+	} else {
+		n.Data["json"] = &JSON{Code: 200, Msg: "查询成功", Data: &JSONS{
+			Current: current,
+			Size:    total,
+			Data:    result,
+		}}
+		n.ServeJSON()
+		return
+	}
+}
+
+//GetNewDetail 获得详细新闻
+func (n *NewController) GetNewDetail() {
+	getString := n.GetString("id")
+	id, _ := strconv.Atoi(getString)
+	validate := validator.New()
+	err2 := validate.Var(id, "required")
+	if err2 != nil {
+		n.Data["json"] = &JSON{Code: 103, Msg: "id不能为空"}
+		n.ServeJSON()
+		return
+	}
+	result, err := unity.GetById(id, &models.News{})
+	if err != nil {
+		n.Data["json"] = &JSON{Code: 101, Msg: "获取失败"}
+		n.ServeJSON()
+		return
+	} else {
+		n.Data["json"] = &JSON{Code: 200, Msg: "获取成功", Data: result}
+		n.ServeJSON()
+		return
+	}
+}
+
+// GetNewsType 获取新闻类型
+func (n *NewController) GetNewsType() {
+	var news []models.News
+	tx := utils.DB.Find(&news)
+	if tx.RowsAffected > 0 {
+		n.Data["json"] = &JSON{Code: 200, Msg: "获取成功", Data: news}
+		n.ServeJSON()
+		return
+	} else {
+		n.Data["json"] = &JSON{Code: 101, Msg: "获取失败"}
+		n.ServeJSON()
+		return
+	}
+}
+
+// UpdateNews 修改新闻
+func (n *NewController) UpdateNews() {
+	var newsdto models.NewsDto
+	var news models.News
+	err := json.Unmarshal(n.Ctx.Input.RequestBody, &newsdto)
+	if err != nil {
+		n.Data["json"] = &JSON{Code: 101, Msg: "json解析失败"}
+		n.ServeJSON()
+		return
+	}
+	news.Title = newsdto.Title
+	news.Detail = newsdto.Detail
+	news.Image = newsdto.Image
+	news.Synopsis = newsdto.Synopsis
+	news.IsActive = newsdto.IsActive
+	news.Types = newsdto.Types
+	_, err = unity.UpdateById(newsdto.ID, &news)
+	if err != nil {
+		n.Data["json"] = &JSON{Code: 102, Msg: err.Error()}
+		n.ServeJSON()
+		return
+	} else {
+		n.Data["json"] = &JSON{Code: 200, Msg: "修改成功"}
+		n.ServeJSON()
+	}
+}
+
+// DeleteNewsById 根据id删除新闻
+func (n *NewController) DeleteNewsById() {
+	id := n.GetString("id")
+	atoi, _ := strconv.Atoi(id)
+	validate := validator.New()
+	err2 := validate.Var(atoi, "required")
+	if err2 != nil {
+		n.Data["json"] = &JSON{Code: 103, Msg: "id不能为空"}
+		n.ServeJSON()
+		return
+	}
+	_, err := unity.DeleteById(atoi, models.News{})
+	if err != nil {
+		n.Data["json"] = map[string]interface{}{"code": 101, "msg": "删除失败"}
+		n.ServeJSON()
+		return
+	} else {
+		n.Data["json"] = map[string]interface{}{"code": 200, "msg": "删除成功"}
+		n.ServeJSON()
+	}
+}
+
+// AddNews 添加新闻
+func (n *NewController) AddNews() {
+	var newsDto models.NewsDto
+	err := json.Unmarshal(n.Ctx.Input.RequestBody, &newsDto)
+	if err != nil {
+		n.Data["json"] = &JSON{Code: 101, Msg: "json解析失败"}
+		n.ServeJSON()
+		return
+	}
+	if service.AddNews(newsDto) {
+		n.Data["json"] = &JSON{Code: 200, Msg: "添加成功"}
+		n.ServeJSON()
+	} else {
+		n.Data["json"] = &JSON{Code: 102, Msg: "添加失败"}
+		n.ServeJSON()
+		return
+	}
+}

+ 0 - 1
controllers/product-detail.go

@@ -11,7 +11,6 @@ type DetailController struct {
 }
 
 func (d *DetailController) Get() {
-	d.Data["IsDetail"] = true
 	id := d.Ctx.Input.Param(":id")
 	atoi, err := strconv.Atoi(id)
 	if err != nil {

+ 7 - 0
controllers/product.go

@@ -24,6 +24,13 @@ func (s *ProductController) Get() {
 	for _, v := range exams {
 		success = append(success, v.Url)
 	}
+	//数据大屏展示
+	data, err := service.GetDataModel()
+	if err == nil {
+		s.Data["Datas"] = data
+	} else {
+		s.Data["Datas"] = "未获得数据"
+	}
 	s.Data["Products"] = product
 	s.Data["example"] = success
 	s.TplName = "product.html"

+ 9 - 1
models/news.go

@@ -12,6 +12,14 @@ type News struct {
 	Detail   template.HTML `json:"detail"`
 	Types    string        `json:"types"`
 	IsActive bool          `json:"is_active"` // 是否激活
-	IsIndex  bool          `json:"is_index"`  // 是否首页
+	Image    string        `json:"image"`
+}
+type NewsDto struct {
+	ID       uint          `json:"id"`
+	Title    string        `json:"title"`
+	Synopsis template.HTML `json:"synopsis"`
+	Detail   template.HTML `json:"detail"`
+	Types    string        `json:"types"`
+	IsActive bool          `json:"is_active"` // 是否激活
 	Image    string        `json:"image"`
 }

+ 14 - 6
routers/router.go

@@ -7,6 +7,7 @@ import (
 )
 
 func init() {
+	//前台官网
 	beego.Router("/", &controllers.MainController{})
 	beego.Router("/about", &controllers.AboutController{})
 	beego.Router("/services", &controllers.ServicesController{})
@@ -21,39 +22,46 @@ func init() {
 	beego.Router("/product/:id/accessories", &controllers.DetailController{})
 	beego.Router("/portfolio", &controllers.MainController{})
 	beego.Router("/contact", &controllers.ContactController{})
-
+	//新闻管理
 	beego.Router("/news", &controllers.NewController{})
+	beego.Router("/news/:id", &controllers.NewController{}, "get:NewDetail")
+	beego.Router("/api/news", &controllers.NewController{}, "post:GetAllNew")
+	beego.Router("/api/news", &controllers.NewController{}, "get:GetNewDetail")
+	beego.Router("/api/addnews", &controllers.NewController{}, "post:AddNews")
+	beego.Router("/api/news", &controllers.NewController{}, "delete:DeleteNewsById")
+	beego.Router("/api/news", &controllers.NewController{}, "put:UpdateNews")
+	beego.Router("/api/newstype", &controllers.NewController{}, "get:GetNewsType")
 
 	beego.Router("/admin", &admin.LoginController{})
 	beego.Router("/login", &admin.LoginController{})
 	beego.Router("/api/logon", &admin.LoginController{}, "post:Login")
 	beego.Router("/admin/index", &admin.IndexController{})
-
+	//资源管理
 	beego.Router("/api/upload", &controllers.UploadImageController{})
 	beego.Router("/api/updateResource", &controllers.UploadImageController{}, "put:UpdateResource")
 	beego.Router("/api/resource", &controllers.UploadImageController{}, "delete:DeleteResourceById")
 	beego.Router("/api/resource", &controllers.UploadImageController{}, "post:GetResource")
 	beego.Router("/api/resource", &controllers.UploadImageController{}, "get:GetResourceById")
-
+	//产品管理
 	beego.Router("/api/product", &controllers.ProductController{}, "post:AddProduct")
 	beego.Router("/api/product", &controllers.ProductController{}, "delete:DeleteProductById")
 	beego.Router("/api/productAll", &controllers.ProductController{}, "post:GetAllProduct")
 	beego.Router("/api/product", &controllers.ProductController{}, "put:UpdateProductById")
 	beego.Router("/api/product", &controllers.ProductController{}, "get:GetProduct")
-
+	//服务管理
 	beego.Router("/api/service", &controllers.ServicesDetailController{}, "post:AddServices")
 	beego.Router("/api/service", &controllers.ServicesDetailController{}, "put:UpdateServices")
 	beego.Router("/api/service", &controllers.ServicesDetailController{}, "delete:DeleteServices")
 	beego.Router("/api/allservice", &controllers.ServicesDetailController{}, "post:GetAllServices")
 	beego.Router("/api/service", &controllers.ServicesDetailController{}, "get:GetServices")
 	beego.Router("/api/getservice", &controllers.ServicesDetailController{}, "get:GetServe")
-
+	//招募管理
 	beego.Router("/api/recruit", &controllers.RecruitController{}, "post:AddRecruit")
 	beego.Router("/api/recruit", &controllers.RecruitController{}, "put:UpdateRecruit")
 	beego.Router("/api/recruit", &controllers.RecruitController{}, "delete:DeleteRecruit")
 	beego.Router("/api/allrecruit", &controllers.RecruitController{}, "post:GetAllRecruit")
 	beego.Router("/api/recruit", &controllers.RecruitController{}, "get:GetRecruit")
-
+	//数据展示
 	beego.Router("/api/data", &controllers.DataModelController{}, "get:GetData")
 	beego.Router("/api/data", &controllers.DataModelController{}, "put:UpdataModel")
 	beego.Router("/api/data", &controllers.DataModelController{}, "delete:DeleteDataModel")

+ 17 - 10
service/news.go

@@ -6,12 +6,12 @@ import (
 )
 
 // GetNews 获取新闻列表,按时间排序获取最近时间的新闻
-func GetNews() (new []models.News) {
-	tx := utils.DB.Order("created_at DESC").Find(&new)
-	if tx.Error != nil {
-		return nil
+func GetNews(types string) (new []models.News) {
+	tx := utils.DB.Where("types=?", types).Order("created_at DESC").Find(&new)
+	if tx.RowsAffected > 0 {
+		return new
 	}
-	return new
+	return
 }
 
 // GetNewsById 根据ID获得新闻
@@ -23,13 +23,20 @@ func GetNewsById(id int) (new models.News) {
 	return models.News{}
 }
 
-// GetNewsByTypes 根据类型获取新闻
-func GetNewsByTypes(types string) (new models.News) {
-	tx := utils.DB.Where("types = ?", types).First(&new)
+func AddNews(newsdto models.NewsDto) bool {
+	news := models.News{
+		Title:    newsdto.Title,
+		Synopsis: newsdto.Synopsis,
+		Detail:   newsdto.Detail,
+		Types:    newsdto.Types,
+		IsActive: newsdto.IsActive,
+		Image:    newsdto.Image,
+	}
+	tx := utils.DB.Create(&news)
 	if tx.RowsAffected > 0 {
-		return new
+		return true
 	}
-	return models.News{}
+	return false
 }
 
 // UpdateNews 修改新闻

+ 83 - 51
static/css/style.css

@@ -82,7 +82,7 @@ h1, h2, h3, h4, h5, h6 {
   padding: 4px 4px 0 0;
 }
 .contact-info.float-left {
-    color: #acacac;
+  color: #acacac;
 }
 #topbar .contact-info .fa-phone {
   padding-left: 20px;
@@ -494,30 +494,30 @@ body.mobile-nav-active #mobile-nav-toggle {
 /*-------------------------------------------------
 Inner Banner
 ---------------------------------------------------*/
-#innerBanner{
-	background: linear-gradient(45deg, #00b1e4 -132%, #0c2e8a 100%);
-	padding: 40px 0;
-	text-align:center;
-	background: #00b1e4;
-}
-#innerBanner h2{
-	color:#fff;
-	text-align:center;
-	font-weight:normal;
-	font-size:18px;
-	margin:0px;
-}
-#innerBanner h2 span{
-	color:#fff;
-	font-weight:bold;
-	font-size:38px;
-	text-align:center;
-}
-.svgImg{
-	
-}
-.svgImg img{
-	width:120px;
+#innerBanner {
+  background: linear-gradient(45deg, #00b1e4 -132%, #0c2e8a 100%);
+  padding: 40px 0;
+  text-align: center;
+  background: #00b1e4;
+}
+#innerBanner h2 {
+  color: #fff;
+  text-align: center;
+  font-weight: normal;
+  font-size: 18px;
+  margin: 0px;
+}
+#innerBanner h2 span {
+  color: #fff;
+  font-weight: bold;
+  font-size: 38px;
+  text-align: center;
+}
+.svgImg {
+
+}
+.svgImg img {
+  width: 120px;
 }
 /*--------------------------------------------------------------
 # Sections
@@ -865,11 +865,11 @@ Inner Banner
   padding: 25px;
   /* background: linear-gradient(45deg, #00b1e457 0%, #405ece91 100%); */
 }
-#portfolio .portfolio-item h2{
-  opacity:0;
+#portfolio .portfolio-item h2 {
+  opacity: 0;
 }
-#portfolio .portfolio-item:hover h2{
-opacity:1;
+#portfolio .portfolio-item:hover h2 {
+  opacity: 1;
 }
 #portfolio .portfolio-item img {
   -webkit-transition: all ease-in-out 0.4s;
@@ -980,22 +980,22 @@ opacity:1;
 #testimonials .owl-dot.active {
   background-color: #00b1e4;
 }
-.map{
-	
-margin: 80px auto 40px;
+.map {
+
+  margin: 80px auto 40px;
 }
 p.help-block,
-p.help-block ul{
-    float: left; 
-    margin: 0;
-    padding: 0;
+p.help-block ul {
+  float: left;
+  margin: 0;
+  padding: 0;
 }
 p.help-block li {
-    float: left; 
-    margin: 10px 0 0 0;
-    padding: 0;
-    list-style:none;
-    color:red;
+  float: left;
+  margin: 10px 0 0 0;
+  padding: 0;
+  list-style: none;
+  color: red;
 }
 /* Call To Action Section
 --------------------------------*/
@@ -1100,7 +1100,7 @@ p.help-block li {
   background: #eaeaea;
   padding: 4px;
 }
-#team .member .social a:hover{
+#team .member .social a:hover {
   color: #081e5b;
   margin: 2px 6px;
   border: 1px solid #081e5b;
@@ -1268,15 +1268,15 @@ p.help-block li {
   color: #00b1e4;
 }
 .owl-carousel .owl-item img {
-    display: block;
-    width: auto;
-    height: 70px;
-    margin: 0 auto;
+  display: block;
+  width: auto;
+  height: 70px;
+  margin: 0 auto;
 }
 #carousel-img-height {
-   height: 400px;
-   object-fit: cover; /* 保持图片宽高比并填充容器 */
- }
+  height: 400px;
+  object-fit: cover; /* 保持图片宽高比并填充容器 */
+}
 .carousel-container {
   position: relative; /* 使得绝对定位的子元素参照此元素定位 */
 }
@@ -1331,8 +1331,12 @@ p.help-block li {
   grid-row-gap: 0px;
 }
 
-.div1 { grid-area: 2 / 1 / 3 / 2; }
-.div2 { grid-area: 2 / 2 / 3 / 3; }
+.div1 {
+  grid-area: 2 / 1 / 3 / 2;
+}
+.div2 {
+  grid-area: 2 / 2 / 3 / 3;
+}
 .btn-group {
   display: flex;
   justify-content: center;
@@ -1348,3 +1352,31 @@ p.help-block li {
   overflow: hidden;
   min-height: 200px; /* 根据需要调整高度 */
 }
+.count-up .count-item .count-icon i {
+  font-size: 2.5rem;
+  color: #6e45e2;
+}
+
+.count-up .count-item .count-content {
+  margin: 10px 0;
+}
+
+.count-up .count-item .count-content .count-number {
+  font-size: 4rem;
+  font-weight: bold;
+  color: #ff9624;
+}
+
+.count-up .count-item p {
+  font-size: 1.25rem;
+  font-weight: 700;
+}
+.feature-data .count-up {
+  color: #333;
+  font-size: 70px;
+}
+
+.feature-data .text-muted {
+  color: #666;
+  font-size: 90px;
+}

+ 53 - 18
views/index.html

@@ -51,10 +51,10 @@
                 <li class="menu-active"><a href="/">首页</a></li>
                 <li><a href="/about">关于我们</a></li>
                 <li><a href="/services/1">服务介绍</a></li>
-                <li class="menu-has-children"><a href="/news">新闻</a>
+                <li class="menu-has-children"><a href="/news?types=industry">新闻</a>
                     <ul>
-                        <li><a href="#">公司新闻</a></li>
-                        <li><a href="#">行业新闻</a></li>
+                        <li><a href="/news?types=firm">公司新闻</a></li>
+                        <li><a href="/news?types=industry">行业新闻</a></li>
                     </ul>
                 </li>
                 <li><a href="/product?ptype=hardware">产品介绍</a>
@@ -75,14 +75,6 @@
   banner
 ============================-->
 <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
-    <!--<div class="carousel-indicators">-->
-    <!--    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active"-->
-    <!--            aria-current="true" aria-label="Slide 1"></button>-->
-    <!--    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"-->
-    <!--            aria-label="Slide 2"></button>-->
-    <!--    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"-->
-    <!--            aria-label="Slide 3"></button>-->
-    <!--</div>-->
     <div class="carousel-inner">
         {{range $index,$item:=.banner}}
         <div class="float-buttons">
@@ -107,13 +99,34 @@
 </div><!-- #intro -->
 
 <main id="main">
-    <!--数据展示-->
-    <section class="features">
-        <div class="container" data-aos="fade-up">
-            <div class="row">
-                <div class="div1 col-3">
-                    <h4><a href="services/{{.ID}}">sss</a></h4>
-                    <p>{{.Datas}}</p>
+    <section class="features" data-aos="fade-up">
+        <div class="container">
+            <div class="section-header">
+                <h2>部分合作案例</h2>
+                <div class="row">
+                    <div class="row feature-item" style="background-color: #b3d7ff">
+                        <div class="col-md-4">
+                            <div class="d-flex flex-column justify-content-between h-100 feature-data">
+                                <div class="count-up" data-target="{{.Datas.Provinces}}"
+                                     style="font-size: 35px; color: #0b0b0b">0
+                                </div>
+                                <span class="text-muted" style="color: #d4d4d4; font-size: 15px;">省区</span>
+                            </div>
+                        </div>
+                        <div class="col-md-4">
+                            <div class="d-flex flex-column justify-content-between h-100 feature-data">
+                                <div class="count-up" data-target="{{.Datas.Prefecture}}" style="font-size: 35px">0
+                                </div>
+                                <span class="text-muted" style="color: #d4d4d4; font-size: 15px;">地州</span>
+                            </div>
+                        </div>
+                        <div class="col-md-4">
+                            <div class="d-flex flex-column justify-content-between h-100 feature-data">
+                                <div class="count-up" data-target="{{.Datas.Counties}}" style="font-size: 35px">0</div>
+                                <span class="text-muted" style="color: #d4d4d4; font-size: 15px;">县份</span>
+                            </div>
+                        </div>
+                    </div>
                 </div>
             </div>
     </section>
@@ -266,5 +279,27 @@
 <script src="../static/js/main.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
+<script>
+    document.addEventListener('DOMContentLoaded', function () {
+        // 获取所有带有data-target属性的元素
+        var countUpElements = document.querySelectorAll('.count-up');
+        countUpElements.forEach(function (element) {
+            var target = parseInt(element.getAttribute('data-target')); // 获取目标数值
+            var start = 0; // 初始值
+            var duration = 2000; // 动画持续时间,单位毫秒
+            var increment = Math.ceil(target / (duration / 16)); // 计算每16ms增加的值
+
+            var timer = setInterval(function () {
+                start += increment;
+                element.textContent = start; // 更新显示的数值
+
+                if (start > target) {
+                    clearInterval(timer); // 达到或超过目标值时停止
+                    element.textContent = target;
+                }
+            }, 100); // 每16ms执行一次,大约60帧/秒
+        });
+    });
+</script>
 </body>
 </html>

+ 126 - 0
views/news-detail.html

@@ -0,0 +1,126 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>宝智达冷链官网</title>
+    <meta content="width=device-width, initial-scale=1.0" name="viewport">
+    <meta content="" name="keywords">
+    <meta content="" name="description">
+    <meta content="Author" name="WebThemez">
+    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
+    <!-- Favicons -->
+    <link href="../static/img/favicon.png" rel="icon">
+    <link href="../static/img/apple-touch-icon.png" rel="apple-touch-icon">
+
+    <!--字体 -->
+    <link
+        href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700"
+        rel="stylesheet">
+
+    <!-- Bootstrap CSS File -->
+    <link href="../static/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
+
+    <script src="https://unpkg.com/naive-ui"></script>
+    <!-- Libraries CSS Files -->
+    <link href="../static/lib/font-awesome/css/font-awesome.min.css" rel="stylesheet">
+    <link href="../static/lib/animate/animate.min.css" rel="stylesheet">
+    <link href="../static/lib/ionicons/css/ionicons.min.css" rel="stylesheet">
+    <link href="../static/lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">
+    <link href="../static/lib/magnific-popup/magnific-popup.css" rel="stylesheet">
+    <link href="../static/lib/ionicons/css/ionicons.min.css" rel="stylesheet">
+
+    <link href="../static/css/style.css" rel="stylesheet">
+</head>
+
+<body id="body">
+<header id="header">
+    <div class="container">
+
+        <div id="logo" class="pull-left">
+            <h1><a href="#body" class="scrollto"><span>宝</span>智达冷链</a></h1>
+            <!-- <a href="#body"><img src="img/logo.png" alt="" title="" /></a>-->
+        </div>
+
+        <nav id="nav-menu-container">
+            <ul class="nav-menu">
+                <li class="menu-active"><a href="/">首页</a></li>
+                <li><a href="/about">关于我们</a></li>
+                <li><a href="/services/1">服务介绍</a></li>
+                <li><a href="/product?ptype=hardware">产品介绍</a>
+                    <ul>
+                        <li><a href="/product?ptype=software">软件</a></li>
+                        <li><a href="/product?ptype=hardware">硬件</a></li>
+                    </ul>
+                </li>
+                <li><a href="/recruit">全国代理招募</a></li>
+                <li class="menu-has-children"><a href="">新闻</a>
+                    <ul>
+                        <li><a href="#">公司新闻</a></li>
+                        <li><a href="#">行业新闻</a></li>
+                    </ul>
+                </li>
+                <li><a href="/contact">联系我们</a></li>
+            </ul>
+        </nav><!-- #nav-menu-container -->
+    </div>
+</header>
+
+
+<!--==========================
+    Page Banner Section
+  ============================-->
+<section id="innerBanner" style="background-color: #00a3d1">
+    <div class="inner-content">
+        <h2><span>{{.detail.Title}}</span></h2>
+        <div>
+        </div>
+    </div>
+</section><!-- #Page Banner -->
+
+<main id="main" style="display: flex; justify-content: center; align-items: center;">
+    <div>{{.detail.Detail}}</div>
+
+</main>
+<section id="clients" class="wow fadeInUp">
+    <div class="container">
+        <div class="section-header">
+            <h2>部分合作案例</h2>
+        </div>
+        <div class="owl-carousel clients-carousel">
+            {{range $index,$exam:=.example}}
+            <img src="{{$exam}}" alt="..." style="max-width: 100%; height: auto">
+            {{end}}
+        </div>
+    </div>
+</section><!-- #clients -->
+<!--==========================
+  Footer
+============================-->
+<footer id="footer">
+    <div class="container">
+        <div class="copyright">
+            Copyright &copy; 2018.Company name All rights reserved.<a target="_blank"
+                                                                      href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a>
+        </div>
+        <div class="credits">
+        </div>
+    </div>
+</footer><!-- #footer -->
+
+<a href="#" class="back-to-top"><i class="fa fa-chevron-up"></i></a>
+
+<!-- JavaScript  -->
+<script src="../static/lib/jquery/jquery.min.js"></script>
+<script src="../static/lib/jquery/jquery-migrate.min.js"></script>
+<script src="../static/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
+<script src="../static/lib/easing/easing.min.js"></script>
+<script src="../static/lib/superfish/hoverIntent.js"></script>
+<script src="../static/lib/superfish/superfish.min.js"></script>
+<script src="../static/lib/wow/wow.min.js"></script>
+<script src="../static/lib/owlcarousel/owl.carousel.min.js"></script>
+<script src="../static/lib/magnific-popup/magnific-popup.min.js"></script>
+<script src="../static/lib/sticky/sticky.js"></script>
+<script src="../static/js/main.js"></script>
+
+</body>
+</html>

+ 39 - 19
views/news.html

@@ -13,13 +13,11 @@
     <link href="../static/img/apple-touch-icon.png" rel="apple-touch-icon">
 
     <!--字体 -->
-    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700"
-          rel="stylesheet">
-
+    <link
+        href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700"
+        rel="stylesheet">
     <!-- Bootstrap CSS File -->
     <link href="../static/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
-
-
     <!-- Libraries CSS Files -->
     <link href="../static/lib/font-awesome/css/font-awesome.min.css" rel="stylesheet">
     <link href="../static/lib/animate/animate.min.css" rel="stylesheet">
@@ -27,7 +25,6 @@
     <link href="../static/lib/owlcarousel/assets/owl.carousel.min.css" rel="stylesheet">
     <link href="../static/lib/magnific-popup/magnific-popup.css" rel="stylesheet">
     <link href="../static/lib/ionicons/css/ionicons.min.css" rel="stylesheet">
-
     <!-- Main Stylesheet File -->
     <link href="../static/css/style.css" rel="stylesheet">
 </head>
@@ -43,7 +40,6 @@
             <h1><a href="#body" class="scrollto"><span>宝</span>智达冷链</a></h1>
             <!-- <a href="#body"><img src="img/logo.png" alt="" title="" /></a>-->
         </div>
-
         <nav id="nav-menu-container">
             <ul class="nav-menu">
                 <li class="menu-active"><a href="/">首页</a></li>
@@ -78,25 +74,47 @@
         </div>
     </div>
 </section><!-- #Page Banner -->
+<main id="main" class="container-fluid">
 
-<main id="main" style="display: flex; justify-content: center; align-items: center;">
-
-    <section id="news" class="wow fadeInUp">
+    <div class="btn-group btn-group-lg" role="group" aria-label="Large button group" style="margin-top: 10px">
+        <button type="button" class="btn btn-outline-primary" onclick="location.href='news?types=industry'">行业新闻
+        </button>
+        <button type="button" class="btn btn-outline-primary" onclick="location.href='news?types=firm'">公司新闻
+        </button>
+    </div>
+    <section id="news" class="row wow fadeInUp" style="margin-top: 20px;">
         {{range .News}}
-        <div class="row">
-            <div class="container">
-                {{.Title}}
+        <div class="col-md-4 col-sm-6 mb-4">
+            <div class="card shadow-sm">
+                <img src="{{.Image}}" class="card-img-top img-fluid" alt="{{.Title}}">
+                <div class="card-body">
+                    <h5 class="card-title"><a href="/news/{{.ID}}">{{.Title}}</a></h5>
+                    <!-- 如果有更多内容(如简介、日期等),可以在这里添加 -->
+                </div>
+                <div class="card-footer text-right text-muted">
+                    <small>发布时间:{{.UpdatedAt}}</small> <!-- 假设.PublishDate是发布时间 -->
+                </div>
             </div>
-            <img src="{{.Image}}">
         </div>
         {{end}}
     </section>
-
 </main>
-<!-- #clients -->
-<!--==========================
-  Footer
-============================-->
+<section id="call-to-action" class="wow fadeInUp">
+    <div class="container">
+        <div class="row">
+            <div class="col-lg-9 text-center text-lg-left">
+                <h3 class="cta-title">获取我们的服务</h3>
+                <p class="cta-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolores quae porro
+                    consequatur aliquam, incidunt fugiat culpa esse aute nulla cupidatat non proident, sunt in culpa
+                    qui officia deserunt mollit anim id est laborum.</p>
+            </div>
+            <div class="col-lg-3 cta-btn-container text-center">
+                <a class="cta-btn align-middle" href="#contact">联系我们</a>
+            </div>
+        </div>
+
+    </div>
+</section>
 <footer id="footer">
     <div class="container">
         <div class="copyright">
@@ -122,6 +140,8 @@
 <script src="../static/lib/magnific-popup/magnific-popup.min.js"></script>
 <script src="../static/lib/sticky/sticky.js"></script>
 <script src="../static/js/main.js"></script>
+<script>
 
+</script>
 </body>
 </html>

+ 54 - 3
views/product.html

@@ -13,8 +13,9 @@
     <link href="../static/img/apple-touch-icon.png" rel="apple-touch-icon">
 
     <!--字体 -->
-    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700"
-          rel="stylesheet">
+    <link
+        href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700"
+        rel="stylesheet">
 
     <!-- Bootstrap CSS File -->
     <link href="../static/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
@@ -99,7 +100,35 @@
 </section><!-- #Page Banner -->
 
 <main id="main">
-
+    <section class="features" data-aos="fade-up">
+        <div class="container">
+            <div class="row">
+                <div class="col-md-3 feature-item" style="background-color: #8fdf82">
+                    <span>管理效率使用</span>
+                    <ul>
+                        <li><strong>3D可视化平台</strong>
+                            <div class="count-up" data-target="{{.Datas.DvisualizationPlatform}}"></div>
+                        </li>
+                        <li><strong>大数据管理平台</strong>
+                            <div class="count-up" data-target="{{.Datas.BigDataManagementPlatform}}"></div>
+                        </li>
+                        <li><strong>冷链系列培训</strong>
+                            <div class="count-up" data-target="{{.Datas.ColdChainTraining}}"></div>
+                        </li>
+                        <li><strong>保温箱安全平台</strong>
+                            <div class="count-up" data-target="{{.Datas.IncubatorSafetyPlatform}}"></div>
+                        </li>
+                        <li><strong>冷藏车安全平台</strong>
+                            <div class="count-up" data-target="{{.Datas.SafetyPlatformForRefrigeratedTrucks}}"></div>
+                        </li>
+                        <li><strong>售后预警服务</strong>
+                            <div class="count-up" data-target="{{.Datas.AfterSalesEarlyWarningService}}"></div>
+                        </li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </section>
     <!--==========================
       Services Section
     ============================-->
@@ -201,5 +230,27 @@
 <script src="../static/js/main.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
+<script>
+    document.addEventListener('DOMContentLoaded', function () {
+        // 获取所有带有data-target属性的元素
+        var countUpElements = document.querySelectorAll('.count-up');
+        countUpElements.forEach(function (element) {
+            var target = parseInt(element.getAttribute('data-target')); // 获取目标数值
+            var start = 0; // 初始值
+            var duration = 2000; // 动画持续时间,单位毫秒
+            var increment = Math.ceil(target / (duration / 16)); // 计算每16ms增加的值
+
+            var timer = setInterval(function () {
+                start += increment;
+                element.textContent = start; // 更新显示的数值
+
+                if (start > target) {
+                    clearInterval(timer); // 达到或超过目标值时停止
+                    element.textContent = target;
+                }
+            }, 16); // 每16ms执行一次,大约60帧/秒
+        });
+    });
+</script>
 </body>
 </html>