浏览代码

修改文件添加

gujiheimao 1 年之前
父节点
当前提交
12898e8bc0

+ 1 - 23
data/dao/DetailDao.go

@@ -246,31 +246,9 @@ func GetSkuByKey2(key string, pageNum, pageSize int) ([]domain.GoodsSku, int64,
 		}
 		return arr, count, nil
 	}
-	//sql := `SELECT DISTINCT
-	//        s.id,
-	//        s.sku_image,
-	//        s.sku_name,
-	//        s.price,
-	//        s.historical_prices,
-	//        s.inventory_number,
-	//        s.commodity_area_id,
-	//        s.goods_id,
-	//        s.create_by,
-	//        s.create_time
-	//    FROM goods_sku s
-	//    LEFT JOIN goods g ON s.goods_id = g.id
-	//    LEFT JOIN goods_tag t ON FIND_IN_SET(t.id, g.tag_ids)
-	//    WHERE t.tag LIKE ?
-	//       OR g.goods_name LIKE ?
-	//       OR s.sku_name LIKE ?
-	//       OR t.id IS NULL
-	//	ORDER BY s.id DESC
-	//	LIMIT ? OFFSET ?
-	//`
-	//count, err := configs.Engine.SQL(sql, sqlKey, sqlKey, sqlKey, pageSize, (pageNum-1)*pageSize).FindAndCount(&arr)
+
 	count, err := configs.Engine.Table("goods_sku s").
 		Join("left", "goods g", "s.goods_id = g.id").
-		//Join("left", "goods_tag t", "FIND_IN_SET(t.id, g.tag_ids)").Desc("s.id").
 		Join("left", "(SELECT gt.tag as tag,g.id AS goods_id FROM goods g JOIN goods_tag gt ON FIND_IN_SET(gt.id, g.tag_ids)) AS t ", " g.id = t.goods_id").Desc("s.id").
 		Where("t.tag LIKE ? OR g.goods_name LIKE ? OR s.sku_name LIKE ?", sqlKey, sqlKey, sqlKey).
 		Limit(pageSize, (pageNum-1)*pageSize).FindAndCount(&arr)

二进制
file/resources/20240719231923微信图片_20240619220703.jpg


二进制
file/resources/20240726200027微信图片_20240619220703.jpg


二进制
file/resources/20240726201404微信图片_20240619220703.jpg


+ 85 - 1
file/resources/css/detail.css

@@ -1,8 +1,17 @@
+img {
+    max-width: 718px;
+}
+
+div video {
+    max-width: 690px;
+}
+
 .detail {
     padding-top: 80px;
     width: 100%;
     background: #f8f8f8;
 }
+
 .detail .detail-router {
     line-height: 50px;
     text-align: left;
@@ -12,6 +21,7 @@
     height: 50px;
     background: white;
 }
+
 .detail .detail-router .detail-router-list {
     list-style: none;
     margin: 0;
@@ -21,37 +31,45 @@
     font-weight: bold;
     display: flex;
 }
+
 .detail .detail-router .detail-router-list .detail-router-item {
     margin: 0 10px;
 }
+
 .detail .detail-router .detail-router-list .detail-router-item:hover {
     cursor: pointer;
     color: #207cfb;
     text-decoration: underline;
 }
+
 .detail .goods-show {
     background: #cfddd6;
     height: 300px;
     padding-top: 35px;
 }
+
 .detail .goods-show .goods-show-info {
     width: 1180px;
     margin: 0 auto;
     display: flex;
     justify-content: space-between;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body {
     display: flex;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-img {
     perspective: 300px;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-img img {
     transform-origin: left center;
     transform: rotateY(10deg) rotateX(5deg);
     box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
     border-radius: 20px;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text {
     padding-top: 20px;
     padding-left: 30px;
@@ -59,12 +77,14 @@
     width: 600px;
     text-align: left;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-title {
     line-height: 35px;
     font-size: 30px;
     font-weight: bold;
     color: #777;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages {
     margin-top: 15px;
     color: #888;
@@ -72,15 +92,19 @@
     justify-content: left;
     flex-wrap: wrap;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage-not-icon {
     width: 85px;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage-icon {
     width: 110px;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage-icon .goods-show-tag {
     padding-left: 0px;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage {
     padding: 5px;
     margin-bottom: 5px;
@@ -93,23 +117,28 @@
     user-select: none;
     text-align: center;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage img {
     width: 25px;
     height: 25px;
     border-radius: 50%;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage .goods-show-tag {
     width: 100%;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage .goods-show-name {
     font-size: 16px;
     line-height: 20px;
     color: #666666;
     font-weight: bold;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-text .goods-show-advantages .goods-show-advantage .goods-show-desc {
     font-size: 12px;
 }
+
 .detail .goods-show .goods-show-info .goods-show-body .goods-show-des {
     margin-top: 30px;
     color: #aaa;
@@ -118,10 +147,12 @@
     text-overflow: ellipsis;
     overflow: hidden;
 }
+
 .detail .goods-show .goods-show-info .goods-show-count {
     display: flex;
     width: 150px;
 }
+
 .detail .goods-show .goods-show-info .goods-show-count .goods-show-price-text {
     font-size: 12px;
     width: 150px;
@@ -131,9 +162,11 @@
     height: 34px;
     background: rgba(255, 255, 255, 0.3);
 }
+
 .detail .goods-show .goods-show-info .goods-show-count .goods-show-price-text span:nth-child(1) {
     color: #999;
 }
+
 .detail .goods-info {
     width: 1180px;
     display: flex;
@@ -141,9 +174,11 @@
     justify-content: space-between;
     margin: 20px auto 0 auto;
 }
+
 .detail .goods-info .info-left {
     width: 760px;
 }
+
 .detail .goods-info .info-left .info-left-select-btns {
     padding: 15px;
     width: 730px;
@@ -155,6 +190,7 @@
     flex-wrap: wrap;
     background: white;
 }
+
 .detail .goods-info .info-left .info-left-select-btns .info-left-select-btn {
     margin: 0 10px 20px 0;
     height: 35px;
@@ -168,14 +204,17 @@
     transition: background-color 0.2s ease;
     user-select: none;
 }
+
 .detail .goods-info .info-left .info-left-select-btns .info-left-select-btn:hover {
     background: #888888;
     color: white;
 }
+
 .detail .goods-info .info-left .info-left-select-btns .info-left-select-btn:active {
     background: #dddddd;
     color: #888888;
 }
+
 .detail .goods-info .info-left .info-left-select-param {
     padding: 15px;
     border-radius: 0 0 5px 5px;
@@ -187,6 +226,7 @@
     justify-content: space-between;
     flex-wrap: wrap;
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn {
     user-select: none;
     width: 300px;
@@ -201,6 +241,7 @@
     font-size: 12px;
     margin-bottom: 10px;
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn .ilspb-selector {
     line-height: 35px;
     width: 20px;
@@ -213,13 +254,16 @@
     align-items: center;
     justify-content: center;
 }
-.detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn .ilspb-selector svg{
+
+.detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn .ilspb-selector svg {
     width: 15px;
     height: 15px;
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn span {
     margin-left: 10px;
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn .ilspb-tag {
     margin-top: -15px;
     margin-left: 0;
@@ -233,20 +277,25 @@
     color: rgba(223, 30, 28);
     border: rgba(223, 30, 28) 1px solid;
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn:hover .ilspb-tag {
     background: rgba(248, 217, 209, 0.3);
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn .it {
     margin: -15px 0 0 180px;
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn:hover {
     background: #aaa;
     color: white;
 }
+
 .detail .goods-info .info-left .info-left-select-param .info-left-select-param-btn:active {
     background: #dddddd;
     color: #aaa;
 }
+
 .detail .goods-info .info-left .info-left-des {
     margin-top: 30px;
     border-radius: 5px;
@@ -255,32 +304,39 @@
     border: #dddddd 1px solid;
     background: white;
 }
+
 .detail .goods-info .info-left .info-left-des .des-tags {
     display: flex;
     flex-wrap: wrap;
     font-size: 16px;
     border-bottom: #dddddd 1px solid;
 }
+
 .detail .goods-info .info-left .info-left-des .des-tags .des-tag {
     padding: 15px 5px;
     transition: font-size 0.2s ease;
     line-height: 30px;
     cursor: pointer;
 }
+
 .detail .goods-info .info-left .info-left-des .des-tags .des-select-tag {
     font-weight: bold;
     font-size: 20px;
 }
+
 .detail .goods-info .info-left .info-left-des .info-introduction {
     text-align: left;
     text-indent: 2em;
     height: auto;
 }
+
 .detail .goods-info .info-right {
     width: 380px;
 }
+
 .detail .goods-info .info-right .info-right-price-calc {
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count {
     display: flex;
     justify-content: space-between;
@@ -290,11 +346,13 @@
     border: solid #dddddd;
     border-width: 1px 1px 0 1px;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-font {
     font-size: 14px;
     line-height: 36px;
     text-align: left;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button {
     width: 120px;
     border-radius: 15px;
@@ -303,6 +361,7 @@
     display: grid;
     grid-template-columns: 1fr 1fr 1fr;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button .irpc-count-button-minus,
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button .irpc-count-button-add {
     text-align: center;
@@ -315,18 +374,22 @@
     user-select: none;
     border-radius: 0 15px 15px 0;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button .irpc-count-button-minus:nth-child(1) {
     border-radius: 15px 0 0 15px;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button .irpc-count-button-minus:hover,
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button .irpc-count-button-add:hover {
     background: #eaeaea;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button .irpc-count-button-input {
     text-align: center;
     line-height: 36px;
     width: 40px;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-purchase-count .irpc-count-button .irpc-count-button-input input {
     color: #666666;
     font-size: 14px;
@@ -336,6 +399,7 @@
     background: transparent;
     border: transparent;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price {
     border: solid #dddddd;
     border-width: 0 1px 1px 1px;
@@ -345,6 +409,7 @@
     padding: 10px 30px 10px 30px;
     background: white;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .price-name {
     justify-content: left;
     text-align: left;
@@ -352,16 +417,19 @@
     font-weight: bold;
     display: inline-block;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .price {
     display: flex;
     vertical-align: bottom;
     justify-content: space-between;
     margin: 10px 5px 0 5px;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .price .price-number {
     display: flex;
     justify-content: right;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .price .price-number .price-original {
     padding-top: 13px;
     display: block;
@@ -373,9 +441,11 @@
     font-size: 14px;
     text-align: right;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .price .price-number .price-original:before {
     content: "¥";
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .price .price-number .price-value {
     font-weight: bold;
     font-size: 26px;
@@ -383,9 +453,11 @@
     text-align: right;
     letter-spacing: -1.5px;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .price .price-number .price-value:before {
     content: "¥";
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .purchase-button {
     border-top: 1px solid #dddddd;
     width: 320px;
@@ -394,6 +466,7 @@
     color: white;
     text-align: center;
 }
+
 .detail .goods-info .info-right .info-right-price-calc .info-right-total-purchase-price .purchase-button .purchase-button-btn {
     margin-top: 20px;
     background: #207cfb;
@@ -402,6 +475,7 @@
     user-select: none;
     cursor: pointer;
 }
+
 .detail .goods-info .info-right .info-recommend {
     margin-top: 40px;
     margin-bottom: 20px;
@@ -410,6 +484,7 @@
     border-radius: 5px;
     border: 1px solid #dddddd;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-title {
     font-size: 24px;
     font-weight: bold;
@@ -418,6 +493,7 @@
     margin-bottom: 15px;
     border-bottom: 1px solid #dddddd;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items {
     width: 320px;
     padding: 10px 30px;
@@ -426,22 +502,26 @@
     flex-wrap: wrap;
     display: flex;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items .info-recommend-item {
     cursor: pointer;
     margin: 0 10px 20px 10px;
     max-width: 150px;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items .info-recommend-item .recommend-item-img {
     width: 110px;
     height: 143px;
     margin-bottom: 12px;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items .info-recommend-item .recommend-item-img img {
     border-radius: 15px;
     width: 110px;
     height: 143px;
     z-index: 1;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items .info-recommend-item .recommend-item-img:after {
     transition: all 5.3s ease;
     margin: -148px 0 0 0;
@@ -454,12 +534,15 @@
     background-color: rgba(255, 255, 255, 0.1);
     border-radius: 15px;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items .info-recommend-item .recommend-item-img:hover:after {
     display: block;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items .info-recommend-item:hover .recommend-item-img img {
     box-shadow: #333 0 0 8px;
 }
+
 .detail .goods-info .info-right .info-recommend .info-recommend-items .info-recommend-item .recommend-item-name {
     width: 110px;
     height: 38px;
@@ -477,6 +560,7 @@
 .content img {
     max-width: 680px;
 }
+
 /*//todo order*/
 .order-buy-curtain {
     position: fixed;

+ 66 - 0
router/FileRouter.go

@@ -23,6 +23,7 @@ func FileRouter(engine *gin.RouterGroup) {
 		//文章上传
 		//user.POST("/upload", uploadHandler)
 		PushRouter(user, "POST", "/upload", uploadHandler)
+		PushRouter(user, "POST", "/upload/type", UploadHandlerByType)
 		PushRouter(user, "PUT", "", DeleteFile)
 	}
 }
@@ -57,6 +58,71 @@ func uploadHandler(c *gin.Context) {
 		"url": "/api/static/" + header.Filename,
 	}))
 }
+func UploadHandlerByType(c *gin.Context) {
+	header, _ := c.FormFile("file")
+	if header != nil {
+		uploadHandler(c)
+		return
+	}
+	header, _ = c.FormFile("image")
+	if header != nil {
+		//大于2M
+		if header.Size > 1024*1024*2 {
+			c.JSON(200, CreateResultError(400, "图片大小不能超过2M"))
+			return
+		}
+		l := len(header.Filename)
+		if strings.LastIndex(header.Filename, ".png") == l-4 ||
+			strings.LastIndex(header.Filename, ".jpg") == l-4 ||
+			strings.LastIndex(header.Filename, ".jpeg") == l-5 ||
+			strings.LastIndex(header.Filename, ".gif") == l-4 {
+
+			header.Filename = fmt.Sprintf("%s%s", time.Now().Format("20060102150405"), header.Filename) // 文件名格式 自己可以改 建议保证唯一性
+			path := filepath + "image/" + header.Filename                                               //路径+文件名上传
+
+			// 上传文件到指定的目录
+			err := c.SaveUploadedFile(header, path)
+			if err != nil {
+				err = errors.New(fmt.Sprintf("上传失败,%v", err))
+				return
+			}
+			data := CreateResultData(map[string]interface{}{
+				"url": "/api/static/image/" + header.Filename,
+			})
+			data["errno"] = 0
+			c.JSON(200, data)
+		} else {
+			c.JSON(200, CreateResultError(400, "图片格式错误"))
+		}
+		return
+	}
+	header, _ = c.FormFile("video")
+	if header != nil {
+		if header.Size > 1024*1024*40 {
+			c.JSON(200, CreateResultError(400, "视频大小不能超过40M"))
+			return
+		}
+		l := len(header.Filename)
+		if strings.LastIndex(header.Filename, ".mp4") == l-4 {
+			header.Filename = fmt.Sprintf("%s%s", time.Now().Format("20060102150405"), header.Filename) // 文件名格式 自己可以改 建议保证唯一性
+			path := filepath + "video/" + header.Filename                                               //路径+文件名上传
+			// 上传文件到指定的目录
+			err := c.SaveUploadedFile(header, path)
+			if err != nil {
+				err = errors.New(fmt.Sprintf("上传失败,%v", err))
+				return
+			}
+			data := CreateResultData(map[string]interface{}{
+				"url": "/api/static/video/" + header.Filename,
+			})
+			data["errno"] = 0
+			c.JSON(200, data)
+		} else {
+			c.JSON(200, CreateResultError(400, "视频格式错误"))
+		}
+		return
+	}
+}
 
 // DeleteFile 文件上传
 func DeleteFile(c *gin.Context) {

+ 0 - 3
router/TestRouter.go

@@ -167,7 +167,6 @@ func SearchPage(c *gin.Context) {
 	pageNum := c.Query("pageNum")
 	pageSize := c.Query("pageSize")
 
-	fmt.Println("key:", key, "num:", pageNum, "size:", pageSize)
 	m := make(map[string]interface{})
 	arr, count, err := dao.GetSkuByKey2(key, cast.ToInt(pageNum), cast.ToInt(pageSize))
 	if err != nil {
@@ -178,11 +177,9 @@ func SearchPage(c *gin.Context) {
 		"list": arr,
 	}
 	list, err := json.Marshal(arrM)
-	fmt.Println("list:", string(list))
 	json.Unmarshal(list, &m)
 	m["count"] = count
 	m["key"] = key
-	fmt.Println("map:", m)
 	c.HTML(http.StatusOK, "search.html", m)
 }