From ba5acc3cdefd33a4845b578015e2aae8b43f80d3 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期三, 04 六月 2025 11:40:29 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 pages/tabbar/video/video.vue |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/pages/tabbar/video/video.vue b/pages/tabbar/video/video.vue
index edab4fc..cc04f4e 100644
--- a/pages/tabbar/video/video.vue
+++ b/pages/tabbar/video/video.vue
@@ -20,7 +20,7 @@
 		</view>
         <view class="video-actions">
           <u-button type="error" size="mini" @click="reUpload">閲嶆柊涓婁紶</u-button>
-          <u-button type="primary" size="mini" @click="chooseCover" v-if="videoInfo.url">閫夋嫨灏侀潰</u-button>
+          <u-button type="primary" size="mini" @click="chooseCover" v-if="videoInfo.url">{{formData.cover ? '鏇存崲灏侀潰' : '璇烽�夋嫨灏侀潰'}}</u-button>
         </view>
       </view>
     </view>
@@ -57,7 +57,7 @@
                 :key="index"
                 :text="tag.tagName"
 				:index="index"
-				type="error"
+				type="success"
                 @close="removeTag(index)"
               />
             </view>
@@ -74,7 +74,7 @@
 		        :key="index"
 		        :text="tag.tagName"
 		  	    :index="index"
-		        type="primary"
+		        type="success"
 		  	  :closeable="false"
 		        @click="selectTopic(index)"
 		      />
@@ -178,8 +178,9 @@
 import UInput from '@/uview-components/uview-ui/components/u-input/u-input.vue';
 import USearch from '@/uview-components/uview-ui/components/u-search/u-search.vue';
 import UPopup from '@/uview-components/uview-ui/components/u-popup/u-popup.vue';
-import MyTag from "@/components/my-tag.vue"
-import { getSTSToken } from "@/api/common.js";
+import MyTag from '@/components/my-tag.vue'
+
+import { getSTSToken, getFilePreviewUrl } from "@/api/common.js";
 import { publish } from "@/api/video.js";
 import { getRecommendTag3 } from "@/api/video-tag.js";
 import { getFileKey } from "@/utils/file.js";
@@ -239,7 +240,7 @@
   },
   computed: {
     canPublish() {
-      return this.formData.videoFileKey && this.formData.title;
+      return this.formData.videoFileKey && this.formData.title && this.formData.cover;
     },
     filteredGoods() {
       if (!this.goodsSearch) return this.goodsList;
@@ -272,7 +273,6 @@
 	  },
 	  // 鍒濆鍖栬吘璁簯cos瀹㈡埛绔�
 	  initCOS() {
-		  console.log("鎵ц浜�");
 		  // 璋冪敤鍚庣鑾峰彇sts涓存椂璁块棶鍑瘉
 		  getSTSToken().then(res => {
 			  const COS = require('@/lib/cos-wx-sdk-v5.js'); // 寮�鍙戞椂浣跨敤
@@ -389,7 +389,30 @@
         sizeType: ['compressed'],
         sourceType: ['album'],
         success: (res) => {
+		  let fileName = res.tempFilePaths[0].substring(res.tempFilePaths[0].lastIndexOf('/') + 1);
+		  // 澶勭悊瀹夊崜鍙兘鐨刄RI缂栫爜
+		  if(fileName.indexOf('%') > -1) {
+				fileName = decodeURIComponent(fileName);
+		  }
+		  const fileKey = getFileKey(fileName);
           this.videoInfo.cover = res.tempFilePaths[0];
+		  this.cosClient.uploadFile({
+		       Bucket: this.bucket,
+		       Region: this.region,
+		       Key: fileKey,
+		       FilePath: res.tempFilePaths[0], 
+		       SliceSize: 1024 * 1024 * 5     /* 瑙﹀彂鍒嗗潡涓婁紶鐨勯槇鍊�,5M */
+		   }, (err, data) => {
+		       if (err) {
+		         console.log('涓婁紶澶辫触', err);
+		       } else {
+		  		 // 鑾峰彇灏侀潰鐨勮闂湴鍧�
+		  		 getFilePreviewUrl(fileKey).then(res => {
+				   this.videoInfo.cover = res.data.data
+				   this.formData.cover = fileKey
+		  		 })
+		       }
+		   });
         }
       });
     },

--
Gitblit v1.8.0