From 882c2a5c9d7b6df827d006b5ae261c199d116f1e Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期一, 09 六月 2025 11:11:02 +0800 Subject: [PATCH] 客户管理 加载更多 --- pages/tabbar/video/video.vue | 80 ++++++++++++++++++++++++++++------------ 1 files changed, 56 insertions(+), 24 deletions(-) diff --git a/pages/tabbar/video/video.vue b/pages/tabbar/video/video.vue index 24539f4..cc04f4e 100644 --- a/pages/tabbar/video/video.vue +++ b/pages/tabbar/video/video.vue @@ -16,11 +16,11 @@ :poster="videoInfo.cover || ''" ></video> <view class="progress-box"> - <progress style="width: 100%;" :percent="videoUploadProgress" show-info stroke-width="6" :active="true" active-color="#ff573e" /> + <progress style="width: 100%;" :percent="videoUploadProgress" active-mode="forwards" show-info stroke-width="6" :active="true" active-color="#ff573e" /> </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)" /> @@ -171,13 +171,21 @@ </template> <script> -import MyTag from "@/components/my-tag.vue" -import { getSTSToken } from "@/api/common.js"; +import UIcon from '@/uview-components/uview-ui/components/u-icon/u-icon.vue'; +import UButton from '@/uview-components/uview-ui/components/u-button/u-button.vue'; +import UForm from '@/uview-components/uview-ui/components/u-form/u-form.vue'; +import UFormItem from '@/uview-components/uview-ui/components/u-form-item/u-form-item.vue'; +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, getFilePreviewUrl } from "@/api/common.js"; import { publish } from "@/api/video.js"; import { getRecommendTag3 } from "@/api/video-tag.js"; import { getFileKey } from "@/utils/file.js"; export default { - components: {MyTag}, + components: {MyTag,UIcon,UButton,UForm,UFormItem,UInput,USearch,UPopup}, data() { return { cosClient: null, @@ -200,6 +208,7 @@ id: '', title: '', videoFileKey: '', + videoDuration: 0, videoFit: 'cover', goodsId: '', tags: [], @@ -231,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; @@ -253,7 +262,7 @@ }, methods: { // 鑾峰彇鎺ㄨ崘鏍囩 - getRecommendTags(type) { + async getRecommendTags(type) { const params = { tagName: this.tagInput.trim(), searchType: type @@ -264,10 +273,8 @@ }, // 鍒濆鍖栬吘璁簯cos瀹㈡埛绔� initCOS() { - console.log("鎵ц浜�"); // 璋冪敤鍚庣鑾峰彇sts涓存椂璁块棶鍑瘉 getSTSToken().then(res => { - console.log(res, "sts缁撴瀯"); const COS = require('@/lib/cos-wx-sdk-v5.js'); // 寮�鍙戞椂浣跨敤 // const COS = require('./lib/cos-wx-sdk-v5.min.js'); // 涓婄嚎鏃朵娇鐢ㄥ帇缂╁寘 @@ -301,20 +308,21 @@ if(fileName.indexOf('%') > -1) { fileName = decodeURIComponent(fileName); } - const fileKey = getFileKey(fileName); - this.videoInfo = { - url: res.tempFilePath, - fileKey: fileKey, - fileType: fileKey.split('/')[0], - fileSize: res.size, - originalFileName: fileName, - cover: '' - }; - this.formData.videoFileKey = fileKey; - // 鍒ゆ柇瑙嗛鐨勫~鍏呮ā寮� - this.formData.videoFit = this.calculateVideoFit(res.width, res.height) + const fileKey = getFileKey(fileName); + this.videoInfo = { + url: res.tempFilePath, + fileKey: fileKey, + fileType: fileKey.split('/')[0], + fileSize: res.size, + originalFileName: fileName, + cover: '' + }; + this.formData.videoFileKey = fileKey; + this.formData.videoDuration = res.duration; + // 鍒ゆ柇瑙嗛鐨勫~鍏呮ā寮� + this.formData.videoFit = this.calculateVideoFit(res.width, res.height) - this.cosClient.uploadFile({ + this.cosClient.uploadFile({ Bucket: this.bucket, Region: this.region, Key: fileKey, @@ -381,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 + }) + } + }); } }); }, @@ -489,6 +520,7 @@ title: '', videoFileKey: '', videoFit: 'cover', + videoDuration: 0, goodsId: '', tags: [], fileInfo: {} -- Gitblit v1.8.0