From 5027240f2bbc9a7f74b8cc661c265eb9d52eb43a Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 19 六月 2025 09:16:57 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
pages/goods-manager/updateSkus/updateSkus.vue | 114 ++
uni_modules/uni-transition/package.json | 117 +
uni_modules/uni-transition/components/uni-transition/uni-transition.vue | 529 ++++++------
pages.json | 25
pages/goods-manager/goodsList/goodsList.vue | 125 ++
api/goods.js | 36
uni_modules/uni-popup/package.json | 193 ++--
pages/tabbar/index/home.vue | 2
uni_modules/uni-transition/changelog.md | 2
/dev/null | 144 ---
pages/video/video-edit.vue | 497 ++++++++---
pages/tabbar/video/video.vue | 30
uni_modules/uni-popup/changelog.md | 3
components/dropdown-menu.vue | 8
uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue | 4
api/video.js | 41 +
pages/video/video-play.vue | 433 ++++++++--
pages/video/home-page.vue | 126 ++
18 files changed, 1,569 insertions(+), 860 deletions(-)
diff --git a/api/goods.js b/api/goods.js
index 260a32d..16a6fd8 100644
--- a/api/goods.js
+++ b/api/goods.js
@@ -316,3 +316,39 @@
})
}
+export function upGoods(params) {
+ return http.request({
+ url: api.store + `/goods/goods/up`,
+ needToken: true,
+ method: Method.PUT,
+ params: params
+ })
+}
+export function lowGoods(params) {
+ return http.request({
+ url: api.store + `/goods/goods/under`,
+ needToken: true,
+ method: Method.PUT,
+ params: params
+ })
+}
+export function getGoodsSkuData(params) {
+ return http.request({
+ url: api.store + '/goods/goods/sku/list',
+ needToken: true,
+ method: Method.GET,
+ params: params
+ })
+}
+
+
+export function updateStocks(params) {
+ return http.request({
+ url: api.store + `/goods/goods/update/stocks`,
+ needToken: true,
+ method: Method.PUT,
+ header: { "content-type": "application/json" },
+ data: params
+ })
+}
+
diff --git a/api/video.js b/api/video.js
index 6c830ed..eaa231d 100644
--- a/api/video.js
+++ b/api/video.js
@@ -156,4 +156,45 @@
method: Method.GET,
needToken: true
});
+}
+
+
+/**
+ * 鍒犻櫎瑙嗛
+ *
+ * @param params
+ */
+ export function delVideo(id) {
+ return http.request({
+ url: "/lmk/video/" + id,
+ method: Method.DELETE,
+ needToken: true
+ });
+}
+
+/**
+ * 淇敼瑙嗛
+ *
+ * @param params
+ */
+ export function updateVideo(data) {
+ return http.request({
+ url: "/lmk/video",
+ method: Method.PUT,
+ needToken: true,
+ data: data
+ });
+}
+
+/**
+ * 鐢ㄦ埛涓嬫灦瑙嗛
+ *
+ * @param params
+ */
+ export function userDownVideo(id) {
+ return http.request({
+ url: "/lmk/video/down/" + id,
+ method: Method.POST,
+ needToken: true
+ });
}
\ No newline at end of file
diff --git a/components/dropdown-menu.vue b/components/dropdown-menu.vue
index 6dee7c9..24b7d60 100644
--- a/components/dropdown-menu.vue
+++ b/components/dropdown-menu.vue
@@ -40,6 +40,10 @@
export default {
name: 'DropdownMenu',
props: {
+ // 涓氬姟鏁版嵁锛岄�変腑鑿滃崟鍚庝竴鍚岃繑鍥�
+ data: {
+ type: Object
+ },
// 閫夐」鍒楄〃
options: {
type: Array,
@@ -103,7 +107,7 @@
// 鏍规嵁閰嶇疆杩斿洖鏁翠釜瀵硅薄鎴杤alue鍊�
const emitValue = typeof item === 'object' ? item[this.valueKey] : item
this.$emit('input', emitValue)
- this.$emit('change', emitValue)
+ this.$emit('change', emitValue, this.data)
}
}
}
@@ -149,7 +153,7 @@
.dropdown-menu {
position: absolute;
- left: 0;
+ left: -50rpx;
display: inline-block;
white-space: nowrap;
background-color: #fff;
diff --git a/pages.json b/pages.json
index 47451d7..aae66b9 100644
--- a/pages.json
+++ b/pages.json
@@ -2,8 +2,8 @@
"easycom": {
"autoscan": true,
"custom": {
- "^u-(.*)": "@/components/uview-components/uview-ui/components/u-$1/u-$1.vue", //uview,
- "^uni-(.*)": "@/uni_modules/uni-$1/components/uni-$1/uni-$1.vue" // uniapp缁勪欢
+ "^u-(.*)": "@/components/uview-components/uview-ui/components/u-$1/u-$1.vue" //uview,
+ // "^uni-(.*)": "@/uni_modules/uni-$1/components/uni-$1/uni-$1.vue" // uniapp缁勪欢
}
},
// "preloadRule": {
@@ -26,12 +26,6 @@
"navigationStyle": "custom" // 闅愯棌椤堕儴瀵艰埅鏍�
}
},
- // {
- // "path": "pages/tabbar/index/home1",
- // "style": {
- // "navigationBarTitleText": ""
- // }
- // },
{
"path": "pages/tabbar/home/index",
"style": {
@@ -254,6 +248,21 @@
}
},
{
+ "path": "pages/goods-manager/updateSkus/updateSkus",
+ "style": {
+ "enablePullDownRefresh": true,
+ "navigationBarTitleText": "璋冩暣搴撳瓨",
+ "componentPlaceholder": {
+ "u-icon": "view",
+ "u-button": "view",
+ "u-form": "view",
+ "u-form-item": "view",
+ "u-input": "view",
+ "u-popup": "view"
+ }
+ }
+ },
+ {
"path": "pages/userPermissions/userPermissions",
"style": {
"navigationBarTitleText": "鐢ㄦ埛鏉冮檺",
diff --git a/pages/goods-manager/goodsList/goodsList.vue b/pages/goods-manager/goodsList/goodsList.vue
index 3e21182..9e62ee5 100644
--- a/pages/goods-manager/goodsList/goodsList.vue
+++ b/pages/goods-manager/goodsList/goodsList.vue
@@ -5,7 +5,7 @@
<!-- 閫氳繃 uni-list--waterfall 绫诲喅瀹氶〉闈㈠竷灞�鏂瑰悜 -->
<!-- to 灞炴�ф惡甯﹀弬鏁拌烦杞鎯呴〉闈紝褰撳墠鍙负鍙傝�� -->
<view :border="!formData.waterfall" class="uni-list-item--waterfall" title="鑷畾涔夊晢鍝佸垪琛�"
- v-for="item in data" :key="item.id" @click="addGoods(item.id)">
+ v-for="item in data" :key="item.id" @click="toggle(item)">
<!-- 閫氳繃header鎻掓Ы瀹氫箟鍒楄〃宸︿晶鍥剧墖 -->
<view class="uni-thumb shop-picture" :class="{ 'shop-picture-column': formData.waterfall }">
@@ -32,9 +32,10 @@
item.buyCount || 0 }}
</view>
<view class="uni-note ellipsis">
- <text class="uni-link">涓婃灦</text>
+ <text :class="item.marketEnable == 'DOWN' ? 'market-down' : 'market-up'">{{
+ item.marketEnable == 'DOWN' ? "宸蹭笅鏋�" : "宸蹭笂鏋�" }}</text>
- <text class="uni-link" style="color:red;">鍒犻櫎</text>
+ <!--<text class="uni-link" style="color:red;">鍒犻櫎</text> -->
</view>
</view>
</view>
@@ -43,6 +44,7 @@
</view>
</view>
+ <view style="height: 80px;"></view>
</view>
<button type="default" class="btn" @click="addGoods('')">
@@ -51,6 +53,18 @@
</button>
<!-- 閫氳繃 loadMore 缁勪欢瀹炵幇涓婃媺鍔犺浇鏁堟灉锛屽闇�鑷畾涔夋樉绀哄唴瀹癸紝鍙弬鑰冿細https://ext.dcloud.net.cn/plugin?id=29 -->
<uni-load-more v-if="loading || formData.status === 'noMore'" :status="formData.status" />
+ <view>
+ <!-- 鏅�氬脊绐� -->
+ <uni-popup ref="popup" background-color="#fff">
+ <view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
+
+ <button type="default" @click="underOrup">{{ selectGoods.marketEnable == 'DOWN' ? '涓婃灦' : "涓嬫灦"
+ }}</button>
+
+ <button type="default" @click="stocks">璋冩暣搴撳瓨</button>
+ </view>
+ </uni-popup>
+ </view>
</view>
</template>
@@ -72,31 +86,11 @@
pageNumber: 1,
pageSize: 10,
},
- data: [
- {
- "id": 122,
- "goods_thumb": "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/83df593e6ba448ddbe6685d928e6fa65.jpg",
- "name": "銆愮垎娆俱�慉pple iPhone 11 (A2223) 64GB 娣辩┖鐏拌壊 绉诲姩鑱旈�氱數淇�4G鎵嬫満",
- "goods_price": "699.00",
- "goods_tip": "鐑崠涓�",
- "tag": [
- "鐑崠涓�",
- ]
- },
- {
- "id": 123,
- "goods_thumb": "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/83df593e6ba448ddbe6685d928e6fa65.jpg",
- "name": "銆愮垎娆俱�慉pple iPhone 11 (A2223) 64GB 娣辩┖鐏拌壊 绉诲姩鑱旈�氱數淇�4G鎵嬫満",
- "goods_price": "699.00",
- "goods_tip": "鐑崠涓�",
- "tag": [
- "鐑崠涓�",
- ]
- }
- ],
+ data: [],
formData: {
status: 'loading', // 鍔犺浇鐘舵��
},
+ selectGoods: {},
tipShow: false // 鏄惁鏄剧ず椤堕儴鎻愮ず妗�
};
},
@@ -108,6 +102,48 @@
}
},
methods: {
+ underOrup() {
+ let params = {
+ goodsId: this.selectGoods.id,
+ };
+ this.$refs.popup.close()
+ if (this.selectGoods.marketEnable == 'DOWN') {
+ API_GOODS.upGoods(params).then((res) => {
+ uni.showLoading({
+ title: '涓婃灦鎴愬姛'
+ });
+
+ setTimeout(function () {
+ uni.hideLoading();
+ }, 2000);
+ this.getGoodsList();
+ })
+ }
+ else {
+ API_GOODS.lowGoods(params).then((res) => {
+ uni.showLoading({
+ title: '涓嬫灦鎴愬姛'
+ });
+
+ setTimeout(function () {
+ uni.hideLoading();
+ }, 2000);
+ this.getGoodsList();
+ })
+ }
+ },
+ stocks() {
+
+ this.$refs.popup.close()
+ var goodsId = this.selectGoods.id
+ uni.navigateTo({
+ url: `/pages/goods-manager/updateSkus/updateSkus${"?goodsId=" + goodsId}`,
+ });
+ },
+ toggle(item) {
+ this.$refs.popup.open('bottom')
+ this.selectGoods = item;
+ },
getGoodsList() {
uni.showLoading();
@@ -255,7 +291,6 @@
// 灏忕▼搴� 缂栬瘧鍚庝細澶氫竴灞傛爣绛撅紝鑰屽叾浠栧钩鍙版病鏈夛紝鎵�浠ラ渶瑕佺壒娈婂鐞嗕竴涓�
/deep/ .uni-list {
/* #endif */
- height: calc(100vh - 100px - 80px - 60px);
display: flex;
flex-direction: row;
flex-wrap: wrap;
@@ -302,4 +337,42 @@
margin-right: 10rpx;
}
}
+
+@mixin flex {
+ /* #ifndef APP-NVUE */
+ display: flex;
+ /* #endif */
+ flex-direction: row;
+}
+
+@mixin height {
+ /* #ifndef APP-NVUE */
+ height: 100%;
+ /* #endif */
+ /* #ifdef APP-NVUE */
+ flex: 1;
+ /* #endif */
+}
+
+.popup-content {
+ @include flex;
+ align-items: center;
+ justify-content: center;
+ padding: 15px;
+ height: 150px;
+ background-color: #fff;
+}
+
+.popup-height {
+ @include height;
+ width: 200px;
+}
+
+.market-down {
+ color: red;
+}
+
+.market-up {
+ color: green;
+}
</style>
\ No newline at end of file
diff --git a/pages/goods-manager/updateSkus/updateSkus.vue b/pages/goods-manager/updateSkus/updateSkus.vue
new file mode 100644
index 0000000..24e74fc
--- /dev/null
+++ b/pages/goods-manager/updateSkus/updateSkus.vue
@@ -0,0 +1,114 @@
+<template>
+ <view>
+ <view class="container">
+ <view class="item" v-for="item in skuList" :key="item.id">
+ <text class="label">{{ item.simpleSpecs }}</text>
+ <input class="input" placeholder="璇疯緭鍏ュ簱瀛樻暟閲�" :value="item.quantity" @input="onInput"
+ :data-id="item.id" />
+ </view>
+ </view>
+ <button type="default" class="btn" @click="updateSkus()">
+ <u-icon name="plus-circle"></u-icon>
+ 鏇存柊
+ </button>
+ </view>
+</template>
+<script>
+
+import * as API_GOODS from "@/api/goods.js";
+export default {
+ data() {
+ return {
+ routerVal: {},
+ skuParams: [],
+ skuList: []
+ }
+ },
+ onShow() {
+ var goodsId = this.routerVal.goodsId
+ let params = {
+ goodsId: goodsId,
+ pageSize: 100
+ };
+ API_GOODS.getGoodsSkuData(params).then((res) => {
+ this.skuList = res.data.result.records
+ res.data.result.records.forEach(item => {
+ this.skuParams.push({ skuId: item.id, quantity: item.quantity })
+ });
+ })
+ },
+ onLoad(option) {
+ uni.showLoading({
+ title: "鍔犺浇涓�",
+ });
+ this.routerVal = option;
+
+ uni.hideLoading();
+ },
+ methods: {
+ onInput(e) {
+ var id = e.currentTarget.dataset.id
+ for (let index = 0; index < this.skuParams.length; index++) {
+ if (this.skuParams[index].skuId == id)
+ this.skuParams[index].quantity = e.detail.value
+ }
+ },
+ updateSkus() {
+ API_GOODS.updateStocks(this.skuParams).then((res) => {
+ if (res.data.code == 200) {
+ uni.showToast({
+ title: "鏇存柊鎴愬姛",
+ icon: "success",
+ duration: 2000,
+ });
+ setTimeout(() => {
+ uni.navigateBack({
+ delta: 1,
+ });
+ })
+ }
+ })
+ }
+ }
+}
+</script>
+<style lang="scss" scoped>
+/* WXSS 鏂囦欢 */
+.container {
+ padding: 20px;
+}
+
+.item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 20px;
+}
+
+.label {
+ width: 80px;
+ text-align: right;
+ margin-right: 15px;
+}
+
+.input {
+ flex: 1;
+ border: 1px solid #ddd;
+ padding: 10px;
+ border-radius: 4px;
+}
+
+.btn {
+ background: $light-color;
+ position: fixed;
+ width: 690rpx;
+ bottom: 60rpx;
+ height: 80rpx;
+ left: 30rpx;
+ font-size: 30rpx;
+ line-height: 80rpx;
+
+ .u-icon {
+ margin-right: 10rpx;
+ }
+}
+</style>
\ No newline at end of file
diff --git a/pages/tabbar/index/home.vue b/pages/tabbar/index/home.vue
index df33ed7..ade53fe 100644
--- a/pages/tabbar/index/home.vue
+++ b/pages/tabbar/index/home.vue
@@ -916,7 +916,7 @@
.video-info {
width: 70%;
position: absolute;
- bottom: 70px;
+ bottom: 20px;
left: 20px;
color: #f8f8f8;
z-index: 10;
diff --git a/pages/tabbar/index/home1.vue b/pages/tabbar/index/home1.vue
deleted file mode 100644
index 1a5edcc..0000000
--- a/pages/tabbar/index/home1.vue
+++ /dev/null
@@ -1,144 +0,0 @@
-<template>
- <!-- 鑷畾涔夋帶鍒舵潯 -->
- <view
- @touchstart="handleTouchStart"
- @touchmove="handleTouchMove"
- @touchend="handleTouchEnd"
- class="container">
- <!-- 杩涘害鏉� - 鏁翠釜鍖哄煙鍙嫋鍔� -->
- <view class="process-warp" :style="{ opacity: showProcess ? 1 : 0 }">
- <!-- 鏄剧ず褰撳墠杩涘害 -->
- <view class="progress-text">{{ hasPlayTime }}/{{formartDuration}}</view>
- <view
- class="progress-bar"
- id="progressBar"
- >
-
- <!-- 宸插~鍏呴儴鍒� -->
- <view class="progress-fill" :style="{ width: progress + '%' }"></view>
- </view>
- </view>
- </view>
-</template>
-
-<script>
-export default {
- data() {
- return {
- startX: 0,
- progress: 0, // 瑙嗛杩涘害
- startProgress : 0, // 寮�濮嬫粦鍔ㄦ椂鐨勮繘搴�
- barLeft: 0, // 杩涘害鏉″乏杈圭晫浣嶇疆
- barWidth: 0, // 杩涘害鏉″搴�
- isDragging: false, // 鏄惁姝e湪鎷栧姩
- processHidenTimer: null, // 杩涘害鏉¢殣钘忓畾鏃跺櫒
- showProcess: false, // 鏄惁鏄剧ず杩涘害鏉�
- };
- },
- mounted() {
- // 鑾峰彇杩涘害鏉$殑灏哄鍜屼綅缃俊鎭�
- this.getBarRect();
- },
- methods: {
- // 鑾峰彇杩涘害鏉$殑浣嶇疆鍜屽昂瀵�
- getBarRect() {
- const query = uni.createSelectorQuery().in(this);
- query.select('#progressBar').boundingClientRect(rect => {
- if (rect) {
- this.barLeft = rect.left;
- this.barWidth = rect.width;
- }
- }).exec();
- },
-
- // 瑙︽懜寮�濮�
- handleTouchStart(e) {
- this.isDragging = true;
- this.showProcess = true;
- this.startProgress = this.progress; // 璁板綍寮�濮嬫椂鐨勮繘搴�
- this.startX = e.touches[0].pageX;
- console.log("璁板綍寮�濮嬫椂鐨勮繘搴�", this.startProgress);
- this.videoContexts[this.currentIndex].pause()
- // this.updateProgress(e);
- },
-
- // 瑙︽懜绉诲姩
- handleTouchMove(e) {
- if (!this.isDragging || !this.barWidth) return;
- clearTimeout(this.processHidenTimer)
- this.videoContexts[this.currentIndex].pause()
- this.updateProgress(e);
- },
-
- // 瑙︽懜缁撴潫
- handleTouchEnd() {
- this.isDragging = false;
- console.log("婊戝姩缁撴潫", this.duration * this.progress);
- this.videoContexts[this.currentIndex].seek(this.duration * this.progress / 100)
- this.videoContexts[this.currentIndex].play()
- this.processHidenTimer = setTimeout(() => {
- this.showProcess = false;
- }, 1000);
- },
-
- // 鏇存柊杩涘害
- updateProgress(e) {
- // 鑾峰彇褰撳墠瑙︽懜鐐筙鍧愭爣
- const currentX = e.touches[0].pageX;
-
- // 璁$畻婊戝姩璺濈(鍍忕礌)
- const deltaX = currentX - this.startX;
-
- // 灏嗗儚绱犺窛绂昏浆鎹负杩涘害澧為噺
- const deltaProgress = (deltaX / this.barWidth) * 100;
- console.log("杩涘害澧為噺", deltaProgress);
- // 璁$畻鏂拌繘搴� = 寮�濮嬫椂鐨勮繘搴� + 婊戝姩澧為噺
- let newProgress = this.startProgress + deltaProgress;
-
- // 闄愬埗鑼冨洿鍦�0-100涔嬮棿
- newProgress = Math.max(0, Math.min(100, newProgress));
-
- this.progress = newProgress;
- }
- }
-};
-</script>
-
-<style>
-.container {
- display: flex;
- flex-direction: column;
- align-items: center;
- position: absolute;
- bottom: 0;
- width: 100%;
- }
-
- .progress-bar {
- position: relative;
- width: 100%;
- height: 16px;
- background-color: #eee;
- overflow: hidden;
- }
-
- .progress-fill {
- position: absolute;
- left: 0;
- top: 0;
- height: 100%;
- background-color: lightgray;
- transition: width 0.1s;
- }
- .process-warp {
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .progress-text {
- margin-top: 10px;
- font-size: 14px;
- color: #666;
- }
-</style>
\ No newline at end of file
diff --git a/pages/tabbar/video/video.vue b/pages/tabbar/video/video.vue
index be52e74..af7dfeb 100644
--- a/pages/tabbar/video/video.vue
+++ b/pages/tabbar/video/video.vue
@@ -132,7 +132,7 @@
<view class="goods-price" style="flex: 1;">楼{{ goods.price }}</view>
<view @click.stop="() => {}" style="flex: 1;display: flex;justify-content: center;align-items: center;">
<view style="width: 90rpx">鏁伴噺锛�</view>
- <uni-number-box v-model="goods.selectNum" :min="0"/>
+ <uni-number-box v-model="goods.goodsNum" :min="0"/>
</view>
</view>
</view>
@@ -451,7 +451,22 @@
},
// 閲嶆柊涓婁紶
reUpload() {
- this.resetData()
+ this.videoInfo = {
+ url: '',
+ fileKey: '',
+ fileType: '',
+ fileSize: 0,
+ originalFileName: '',
+ cover: ''
+ };
+ this.formData.videoFileKey = ''
+ this.formData.cover = ''
+ this.formData.videoFit = 'cover'
+ this.formData.videoDuration = 0
+ this.formData.videoImgs = []
+ this.formData.fileInfo = {}
+ this.formData.videoContentType = 'video'
+ this.videoPreviewImgs = []
this.fileTypeShow = true
},
// 閫夋嫨瑙嗛鍥鹃泦
@@ -527,13 +542,20 @@
// 閫夋嫨鍟嗗搧
chooseGoods() {
+ if(this.selectedGoodsList.length > 0) {
+ const selectedGoodsIds = new Set(this.selectedGoodsList.map(i => i.goodsId));
+ console.log(selectedGoodsIds, "mimade");
+ this.goodsList?.forEach(goods => {
+ this.$set(goods, 'selected', selectedGoodsIds.has(goods.goodsId));
+ });
+ }
this.showGoodsPicker = true;
},
// 閫夋嫨鍏蜂綋鍟嗗搧
selectGoods(goods, index) {
if(! this.selectedGoodsList.some(item => item.id === goods.id)) {
- goods["selectNum"] = 1
+ goods["goodsNum"] = 1
this.selectedGoodsList.push(goods)
this.goodsList[index].selected = true
} else {
@@ -616,7 +638,7 @@
if (valid && this.canPublish) {
this.loading = true;
this.formData.fileInfo = this.videoInfo;
- this.formData["goodsList"] = this.selectedGoodsList.map(item => {return {goodsId: item.goodsId, goodsNum: item.selectNum}});
+ this.formData["goodsList"] = this.selectedGoodsList.map(item => {return {goodsId: item.goodsId, goodsNum: item.goodsNum}});
publish(this.formData).then(res => {
uni.showToast({
title: '瑙嗛宸叉彁浜ゅ鏍竳',
diff --git a/pages/video/home-page.vue b/pages/video/home-page.vue
index 1e29861..5ce3063 100644
--- a/pages/video/home-page.vue
+++ b/pages/video/home-page.vue
@@ -61,20 +61,22 @@
<!-- 瑙嗛鍒楄〃 -->
<scroll-view class="video-list" scroll-y :show-scrollbar="false" @scrolltolower="getPage" v-show="currentTab === 'works' && videoList.length > 0">
+ <view class="video-container">
<view
class="video-item"
v-for="(item, index) in videoList"
:key="item.id"
>
- <image class="video-cover" @click="playAuthorVideo(index)" :src="item.coverUrl" mode="aspectFill"></image>
+ <image class="video-cover" @click="playAuthorVideo(index)" :src="item.videoContentType === 'video' ? item.coverUrl : item.imgs[0]" mode="aspectFill"></image>
<view class="video-info">
<view class="video-stats">
<view class="stat">
<uni-icons type="heart" size="16" color="#fff"></uni-icons>
<text>{{item.collectNum}}</text>
- <view class="more-op">
+ <view class="more-op" v-if="userInfo.self">
<dropdown-menu
:options="item.options"
+ :data="{id: item.id, title: item.title}"
placement="top"
theme-color="#07C160"
@change="handleChange"
@@ -83,6 +85,7 @@
</view>
</view>
</view>
+ </view>
</view>
</scroll-view>
<scroll-view class="video-list" scroll-y :show-scrollbar="false" @scrolltolower="getPage" v-show="currentTab === 'likes' && collectVideoList.length > 0">
@@ -93,7 +96,7 @@
:key="item.id"
@click="playCollectVideo(index)"
>
- <image class="video-cover" :src="item.coverUrl" mode="aspectFill"></image>
+ <image class="video-cover" :src="item.videoContentType === 'video' ? item.coverUrl : item.imgs[0]" mode="aspectFill"></image>
<view class="video-info">
<view class="video-stats">
<view class="stat">
@@ -116,6 +119,18 @@
<!-- <image src="/static/images/empty.png" mode="aspectFit" class="empty-image"></image> -->
<text class="empty-text">杩樻病鏈夌偣璧炰綔鍝佸摝~</text>
</view>
+
+ <!-- 鍒犻櫎瑙嗛鎻愰啋妗� -->
+ <uni-popup ref="delDialog" type="dialog">
+ <uni-popup-dialog type="error" cancelText="鍙栨秷" confirmText="鍒犻櫎" title="鎻愰啋" :content="`鎮ㄦ鍦ㄥ垹闄わ細${opVideo.title}`" @confirm="deleteVideo"
+ @close="dialogClose"></uni-popup-dialog>
+ </uni-popup>
+
+ <!-- 涓嬫灦瑙嗛鎻愰啋妗� -->
+ <uni-popup ref="downDialog" type="dialog">
+ <uni-popup-dialog type="error" cancelText="鍙栨秷" confirmText="涓嬫灦" title="鎻愰啋" :content="`鎮ㄦ鍦ㄤ笅鏋讹細${opVideo.title}`" @confirm="downVideo"
+ @close="dialogClose"></uni-popup-dialog>
+ </uni-popup>
</view>
</template>
@@ -123,16 +138,20 @@
import DropdownMenu from '@/components/dropdown-menu.vue'
import {getAuthorInfo, getAuthorVideoPage, getAuthorCollectVideoPage} from '@/api/user.js'
-import {subscribe, unSubscribe} from '@/api/video.js'
+import {subscribe, unSubscribe, delVideo, updateVideo, userDownVideo} from '@/api/video.js'
export default {
components: {DropdownMenu},
data() {
return {
- options: [
- { command: 1, label: '鍖椾含' },
- { command: 2, label: '涓婃捣' },
- { command: 3, label: '骞垮窞' }
- ],
+ options: [
+ { command: 1, label: '鍖椾含' },
+ { command: 2, label: '涓婃捣' },
+ { command: 3, label: '骞垮窞' }
+ ],
+ opVideo: { // 姝e湪鎿嶄綔鐨勮棰�
+ id: '',
+ title: ''
+ },
currentTab: 'works', // works: 浣滃搧, likes: 鍠滄
authorId: '',
userInfo: {
@@ -172,9 +191,54 @@
this.getAuthorVideoPage();
},
methods: {
- handleChange(value) {
- console.log('閫変腑鍊�:', value)
- },
+ dialogClose() {
+ this.opVideo = {
+ id: '',
+ title: ''
+ }
+ },
+ // 涓嬫灦瑙嗛
+ downVideo() {
+ userDownVideo(this.opVideo.id).then(res => {
+ uni.showToast({
+ title: '涓嬫灦鎴愬姛',
+ duration: 2000
+ });
+ // 鍒锋柊鏁版嵁
+ this.videoList = [];
+ this.videoQuery.pageNumber = 1;
+ this.getAuthorVideoPage();
+ })
+ },
+ // 鍒犻櫎瑙嗛
+ deleteVideo() {
+ delVideo(this.opVideo.id).then(res => {
+ uni.showToast({
+ title: '鍒犻櫎鎴愬姛',
+ duration: 2000
+ });
+ // 鍒锋柊鏁版嵁
+ this.videoList = [];
+ this.videoQuery.pageNumber = 1;
+ this.getAuthorVideoPage();
+ })
+ },
+ // 瑙﹀彂瑙嗛鎿嶄綔
+ handleChange(value, data) {
+ console.log('閫変腑鍊�:', value)
+ this.opVideo.id = data.id;
+ this.opVideo.title = data.title;
+ if (value === 'DELETE') {
+ this.$refs.delDialog.open()
+ } else if (value === 'DOWN') {
+ this.$refs.downDialog.open()
+ } else if (value === 'EDIT') {
+ // 璺宠浆缂栬緫瑙嗛椤甸潰
+ uni.navigateTo({
+ url: `/pages/video/video-edit?id=${this.opVideo.id}`
+ });
+ }
+ },
getPage() {
if(this.currentTab === 'works') {
if(this.nomoreVideo) {
@@ -301,7 +365,7 @@
});
},
// 鎾斁鏀惰棌瑙嗛
- playAuthorVideo(index) {
+ playCollectVideo(index) {
const playInfo = {
videoList: this.collectVideoList,
nomore: this.nomoreCollectVideo,
@@ -460,16 +524,21 @@
}
.video-list {
- width: calc(100% - 20rpx);
- padding: 0 10rpx;
- height: calc(100vh - 554rpx);
- background-color: #fff;
+ width: 100%;
+ padding: 0 10rpx;
+ height: calc(100vh - 554rpx);
+ background-color: #fff;
+}
+
+.video-container {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: space-between;
}
.video-item {
- width: 50%;
- padding: 10rpx;
- box-sizing: border-box;
+ width: 49%;
+ margin-bottom: 20rpx;
position: relative;
}
@@ -481,15 +550,12 @@
}
.video-info {
- display: flex;
- height: 60rpx;
- align-items: center;
- font-size: 24rpx;
- width: 100%;
- padding-right: 20rpx;
- box-sizing: border-box;
position: absolute;
- bottom: 20rpx;
+ bottom: 10rpx;
+ left: 0;
+ right: 0;
+ padding: 0 10rpx;
+ box-sizing: border-box;
}
.video-title {
@@ -569,8 +635,4 @@
}
}
-.video-container {
- display: flex;
- flex-wrap: wrap
-}
</style>
\ No newline at end of file
diff --git a/pages/video/video-edit.vue b/pages/video/video-edit.vue
index f8a3ec2..1b51fe7 100644
--- a/pages/video/video-edit.vue
+++ b/pages/video/video-edit.vue
@@ -1,49 +1,73 @@
<template>
<view class="publish-container">
+ <u-popup v-model="fileTypeShow" mode="bottom" round="20" height="35%">
+ <view style="width: 100%;height:100%;display: flex;flex-direction: column;justify-content: center;align-items: center;">
+ <view>璇烽�夋嫨瑕佸彂甯冪殑绫诲瀷</view>
+ <u-button style="width: 50%;margin-bottom: 30rpx;margin-top: 20rpx;" type="success" @click="chooseVideo">瑙嗛</u-button>
+ <u-button style="width: 50%;" type="success" @click="chooseImgs">鍥剧墖</u-button>
+ </view>
+ </u-popup>
<!-- 瑙嗛涓婁紶鍖哄煙 -->
<view class="upload-section">
- <view class="upload-btn" @click="chooseVideo" v-if="!videoInfo.url">
+ <view class="upload-btn" @click="this.fileTypeShow = true" v-if="!formData.videoFileKey && formData.videoImgs.length < 1">
<u-icon name="plus" size="40" color="#999"></u-icon>
- <text class="upload-text">鐐瑰嚮涓婁紶瑙嗛</text>
- <text class="upload-tips">鏀寔MP4鏍煎紡锛屾渶闀�60绉�</text>
+ <text class="upload-text">鐐瑰嚮涓婁紶</text>
</view>
-
- <view class="video-preview" v-else>
- <video
- :src="videoInfo.url"
+
+ <view class="video-preview" v-else-if="formData.videoContentType === 'video'">
+ <video
+ :src="videoInfo.url"
:object-fit="formData.videoFit"
class="video-player"
:poster="videoInfo.cover || ''"
></video>
- <view class="progress-box">
+ <view class="progress-box" v-if="showUploadProgress">
<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">{{formData.cover ? '鏇存崲灏侀潰' : '璇烽�夋嫨灏侀潰'}}</u-button>
+ <u-button type="primary" size="mini" @click="chooseCover" v-if="formData.videoFileKey">{{formData.cover ? '鏇存崲灏侀潰' : '璇烽�夋嫨灏侀潰'}}</u-button>
</view>
</view>
+
+ <view class="image-list" v-else-if="formData.videoContentType === 'img'">
+ <view
+ v-for="item in videoPreviewImgs"
+ :key="item"
+ class="image-item"
+ :style="{width: itemWidth + 'px', height: itemWidth + 'px'}"
+ >
+ <image
+ :src="item"
+ mode="aspectFill"
+ class="image"
+ />
+ </view>
+ <view class="video-actions">
+ <u-button type="error" size="mini" @click="reUpload">閲嶆柊涓婁紶</u-button>
+ </view>
+ </view>
</view>
-
+
<!-- 瑙嗛淇℃伅琛ㄥ崟 -->
<view class="form-section">
<u-form :model="formData" ref="formRef" labelWidth="80">
<!-- 鏍囬杈撳叆 -->
<u-form-item label="鏍囬" prop="title" borderBottom>
- <u-input
- v-model="formData.title"
+ <u-input
+ v-model="formData.title"
placeholder="璇疯緭鍏ヨ棰戞爣棰�,20瀛椾互鍐�"
maxlength="20"
show-word-limit
clearable
/>
</u-form-item>
-
+
<!-- 璇濋杈撳叆 -->
<u-form-item label="璇濋" prop="tags" borderBottom>
<view class="tags-input-container">
- <u-input
- v-model="tagInput"
+ <u-input
+ v-model="tagInput"
placeholder="杈撳叆璇濋锛屽洖杞︾‘璁�"
clearable
@confirm="addTag"
@@ -52,7 +76,7 @@
></u-input>
<!-- 宸查�夎瘽棰樺睍绀� -->
<view class="tags-display" v-if="formData.tags.length > 0">
- <my-tag
+ <my-tag
v-for="(tag, index) in formData.tags"
:key="index"
:text="tag.tagName"
@@ -69,7 +93,7 @@
<view class="hot-topics" v-if="showTopicRecommendations">
<text class="section-title">{{ tagInput ? '鎺ㄨ崘璇濋' : '鐑棬璇濋' }}</text>
<view class="topic-list">
- <my-tag
+ <my-tag
v-for="(tag, index) in recommendedTags"
:key="index"
:text="tag.tagName"
@@ -81,47 +105,54 @@
</view>
</view>
</u-form-item>
-
-
+
+
<!-- 鍟嗗搧閾炬帴 -->
<u-form-item label="鍟嗗搧" prop="goodsId" borderBottom>
<view class="goods-link-container">
- <u-input
+ <u-input
placeholder="鍙�夋嫨鎺ㄨ崘鍟嗗搧"
clearable
v-if="!selectedGoods"
@click="chooseGoods"
disabled
>
- <u-icon
- slot="right"
- name="search"
- size="24"
+ <u-icon
+ slot="right"
+ name="search"
+ size="24"
@click="chooseGoods"
></u-icon>
</u-input>
- <view class="goods-preview" v-if="selectedGoods">
- <image :src="selectedGoods.image" class="goods-image"></image>
+ <view class="goods-preview" @click="chooseGoods" v-for="goods in selectedGoodsList" :key="goods.id">
+ <image :src="goods.thumbnail" class="goods-image"></image>
<view class="goods-info">
- <text class="goods-name">{{ selectedGoods.name }}</text>
- <text class="goods-price">楼{{ selectedGoods.price }}</text>
+ <text class="goods-name">{{ goods.goodsName }}</text>
+ <view style="display: flex;">
+ <view class="goods-price" style="flex: 1;">楼{{ goods.price }}</view>
+ <view @click.stop="() => {}" style="flex: 1;display: flex;justify-content: center;align-items: center;">
+ <view style="width: 90rpx">鏁伴噺锛�</view>
+ <uni-number-box v-model="goods.goodsNum" :min="0"/>
+ </view>
+ </view>
</view>
- <u-icon
- name="close"
- size="20"
- @click="clearGoods"
+ <u-icon
+ style="position: absolute;right: 8rpx;top: 8rpx"
+ name="close"
+ size="24"
+ @click.stop="clearGoods(goods)"
></u-icon>
</view>
</view>
</u-form-item>
</u-form>
</view>
-
+
<!-- 鍙戝竷鎸夐挳 -->
<view class="publish-btn">
- <u-button
- type="primary"
- shape="circle"
+ <u-button
+ type="success"
+ shape="circle"
:loading="loading"
@click="handlePublish"
:disabled="!canPublish"
@@ -129,7 +160,7 @@
{{ loading ? '鍙戝竷涓�...' : '绔嬪嵆鍙戝竷' }}
</u-button>
</view>
-
+
<!-- 鍟嗗搧閫夋嫨寮圭獥 -->
<u-popup v-model="showGoodsPicker" mode="bottom" round="20" height="70%">
<view class="goods-picker">
@@ -138,34 +169,37 @@
<u-icon name="close" size="24" @click="showGoodsPicker = false"></u-icon>
</view>
<view class="search-bar">
- <u-search
- v-model="goodsSearch"
- placeholder="鎼滅储鍟嗗搧鍚嶇О"
+ <u-search
+ v-model="goodsQuery.keyword"
+ placeholder="鎼滅储鍟嗗搧"
:showAction="false"
+ @change="handlerGoodsSearch"
></u-search>
</view>
- <scroll-view class="goods-list" scroll-y>
- <view
- class="goods-item"
- v-for="goods in filteredGoods"
+ <scroll-view class="goods-list" @scrolltolower="loadMoreGoods" scroll-y :show-scrollbar="false">
+ <view
+ class="goods-item"
+ v-for="(goods, index) in goodsList"
:key="goods.id"
- @click="selectGoods(goods)"
+ @click="selectGoods(goods, index)"
>
- <image :src="goods.image" class="goods-image"></image>
+ <image :src="goods.thumbnail" class="goods-image"></image>
<view class="goods-info">
- <text class="goods-name">{{ goods.name }}</text>
+ <text class="goods-name">{{ goods.goodsName }}</text>
<text class="goods-price">楼{{ goods.price }}</text>
+<!-- <view>{{ goods.sellingPoint }}</view> -->
</view>
- <u-icon
- name="checkmark"
- size="24"
- :color="selectedGoods && selectedGoods.id === goods.id ? '#2979ff' : '#ccc'"
+ <u-icon
+ v-if="goods.selected"
+ name="checkmark"
+ size="36"
+ :color="'#2979ff'"
></u-icon>
</view>
</scroll-view>
</view>
</u-popup>
-
+
<custom-tabbar bgColor="#ffffff" selected="video"></custom-tabbar>
</view>
</template>
@@ -175,21 +209,26 @@
import MyTag from '@/components/my-tag.vue'
import { getSTSToken, getFilePreviewUrl } from "@/api/common.js";
-import { publish, getVideoDetail } from "@/api/video.js";
+import { updateVideo, getVideoDetail } from "@/api/video.js";
import { getRecommendTag3 } from "@/api/video-tag.js";
import { getFileKey } from "@/utils/file.js";
+import { getVideoGoodsList } from "@/api/goods.js";
+
export default {
components: {MyTag},
data() {
return {
+ showUploadProgress: false,
+ fileTypeShow: false,
cosClient: null,
bucket: '',
region: '',
+ endpoint: '',
videoUploadProgress: 0,
loading: false,
showGoodsPicker: false,
- goodsSearch: '',
tagInput: '',
+ videoPreviewImgs: [], // 棰勮鍥剧墖鍦板潃
videoInfo: {
url: '',
fileKey: '',
@@ -197,6 +236,12 @@
fileSize: 0,
originalFileName: '',
cover: ''
+ },
+ goodsQuery: {
+ keyword: '',
+ searchFromSelfStore: false, // 鏄惁鏄煡璇㈣嚜瀹跺簵閾哄晢鍝�
+ pageNumber: 1,
+ pageSize: 5
},
formData: {
id: '',
@@ -206,49 +251,50 @@
videoDuration: 0,
videoFit: 'cover',
goodsId: '',
+ videoContentType: 'video',
+ videoImgs: [],
tags: [],
fileInfo: {}
},
- selectedGoods: null,
- goodsList: [
- {
- id: '1',
- name: '鏂版鏃犵嚎钃濈墮鑰虫満',
- price: '199.00',
- image: 'https://via.placeholder.com/100'
- },
- {
- id: '2',
- name: '鏅鸿兘鎵嬬幆杩愬姩鎵嬭〃',
- price: '299.00',
- image: 'https://via.placeholder.com/100'
- }
- ],
+ selectedGoodsList: [],
+ goodsList: [],
+ noMoreGoods: false, // 娌℃湁鏇村鍟嗗搧浜�
recommendedTags: [],
rules: {
title: [
{ required: true, message: '璇疯緭鍏ヨ棰戞爣棰�', trigger: 'blur' },
{ min: 1, max: 20, message: '鏍囬闀垮害鍦�1鍒�20涓瓧绗�', trigger: 'blur' }
]
- }
+ },
+ screenWidth: 375,
+ gap: 10 // 鍥剧墖闂磋窛
};
},
computed: {
canPublish() {
- return this.formData.videoFileKey && this.formData.title && this.formData.cover;
- },
- filteredGoods() {
- if (!this.goodsSearch) return this.goodsList;
- return this.goodsList.filter(goods =>
- goods.name.toLowerCase().includes(this.goodsSearch.toLowerCase())
- );
+ if(this.formData.videoContentType === 'video') {
+ return this.formData.videoFileKey && this.formData.title && this.formData.cover;
+ } else if(this.formData.videoContentType === 'img') {
+ return this.formData.videoImgs.length > 0 && this.formData.title;
+ }
},
showTopicRecommendations() {
return (this.tagInput === '' || this.recommendedTags.length > 0) && this.formData.tags.length < 5;
- }
+ },
+ // 璁$畻姣忎釜鍥剧墖椤圭殑瀹藉害锛堣�冭檻闂磋窛锛�
+ itemWidth() {
+ return (this.screenWidth - (this.gap * 4) - 20) / 3
+ }
},
onLoad(option) {
- this.getVideoDetail(option.id)
+ this.getVDetail(option.id)
+ // 鑾峰彇灞忓箷瀹藉害
+ const systemInfo = uni.getSystemInfoSync()
+ this.screenWidth = systemInfo.windowWidth
+ this.goodsQuery.pageNumber = 1
+ this.goodsQuery.pageSize = 10
+ this.getVideoGoodsByEs()
+
},
onShow() {
this.initCOS()
@@ -256,23 +302,57 @@
this.getRecommendTags()
},
methods: {
- getVideoDetail(id) {
- getVideoDetail(id).then(res => {
- this.fileInfo.cover = res.data.data.coverUrl
- this.fileInfo.url = res.data.data.videoUrl
- this.formData.cover = res.data.data.coverFileKey
- this.formData.id = res.data.data.id
- this.formData.title = res.data.data.title
- this.formData.videoFileKey = res.data.data.videoFileKey
- this.formData.videoFit = res.data.data.videoFit
- this.formData.videoDuration = res.data.data.videoDuration
- this.formData.goodsId = res.data.data.goodsId
- this.formData.tags = res.data.data.tags
- }).catch(() => {
- uni.navigateBack({
- delta: 1
- });
- })
+ getVDetail(id) {
+ getVideoDetail(id).then(res => {
+ this.videoInfo.cover = res.data.data.coverUrl
+ this.videoInfo.url = res.data.data.videoUrl
+ this.formData.videoImgs = res.data.data.imgs
+ this.formData.videoContentType = res.data.data.videoContentType
+ this.formData.cover = res.data.data.coverFileKey
+ this.formData.id = res.data.data.id
+ this.formData.title = res.data.data.title
+ this.formData.videoFileKey = res.data.data.videoFileKey
+ this.formData.videoFit = res.data.data.videoFit
+ this.formData.videoDuration = res.data.data.videoDuration
+ this.selectedGoodsList = res.data.data.goodsList
+ this.formData.tags = res.data.data.tags
+ this.showUploadProgress = false
+ console.log("瑙嗛璇︽儏", this.formData);
+ })
+ },
+ // 鍔犺浇鏇村鍟嗗搧
+ loadMoreGoods() {
+ if(this.noMoreGoods) {
+ return
+ }
+ this.goodsQuery.pageNumber += 1;
+ this.goodsQuery.pageSize = 5;
+ this.getVideoGoodsByEs()
+ },
+ // 澶勭悊鍟嗗搧鎼滅储鍊�
+ handlerGoodsSearch() {
+ this.goodsQuery.pageNumber = 1
+ this.goodsQuery.pageSize = 10
+ this.getVideoGoodsByEs()
+ },
+ // 鑾峰彇鍟嗗搧鍒嗛〉
+ async getVideoGoodsByEs() {
+ getVideoGoodsList(this.goodsQuery).then(res => {
+
+ if(this.goodsQuery.pageNumber === 1) {
+ this.goodsList = res.data.data
+ } else {
+ this.goodsList = [
+ ...this.goodsList,
+ ...res.data.data.filter(
+ (newItem) => !this.goodsList.some((oldItem) => oldItem.id === newItem.id)
+ ),
+ ];
+ }
+ if(res.data.data.length < this.goodsQuery.pageSize) {
+ this.noMoreGoods = true;
+ }
+ })
},
// 鑾峰彇鎺ㄨ崘鏍囩
async getRecommendTags(type) {
@@ -290,7 +370,7 @@
getSTSToken().then(res => {
const COS = require('@/lib/cos-wx-sdk-v5.js'); // 寮�鍙戞椂浣跨敤
// const COS = require('./lib/cos-wx-sdk-v5.min.js'); // 涓婄嚎鏃朵娇鐢ㄥ帇缂╁寘
-
+
// console.log(COS.version); sdk 鐗堟湰闇�瑕佷笉浣庝簬 1.7.2
this.cosClient = new COS({
SecretId: res.data.data.tmpSecretId, // sts 鏈嶅姟涓嬪彂鐨勪复鏃� secretId
@@ -302,21 +382,28 @@
});
this.bucket = res.data.data.bucket
this.region = res.data.data.region
+ this.endpoint = res.data.data.endpoint
})
-
+
},
// 閫夋嫨瑙嗛
chooseVideo() {
+ this.fileTypeShow = false;
+ // 娓呯┖閫夋嫨鐨勫浘鐗�
+ this.videoPreviewImgs = [];
+ this.formData.videoImgs = [];
+ this.formData.videoContentType = 'video'
uni.chooseVideo({
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: 'back',
success: (res) => {
this.videoUploadProgress = 0
+
// 鑾峰彇鏂囦欢鍚�
const tempPath = res.tempFilePath;
let fileName = tempPath.substring(tempPath.lastIndexOf('/') + 1);
-
+
// 澶勭悊瀹夊崜鍙兘鐨刄RI缂栫爜
if(fileName.indexOf('%') > -1) {
fileName = decodeURIComponent(fileName);
@@ -334,12 +421,12 @@
this.formData.videoDuration = res.duration;
// 鍒ゆ柇瑙嗛鐨勫~鍏呮ā寮�
this.formData.videoFit = this.calculateVideoFit(res.width, res.height)
-
+ this.showUploadProgress = true
this.cosClient.uploadFile({
Bucket: this.bucket,
Region: this.region,
Key: fileKey,
- FilePath: res.tempFilePath,
+ FilePath: res.tempFilePath,
SliceSize: 1024 * 1024 * 5, /* 瑙﹀彂鍒嗗潡涓婁紶鐨勯槇鍊�,5M */
onProgress: (progressData) => {
console.log(progressData.percent);
@@ -357,7 +444,7 @@
cover: ''
}
} else {
- console.log(this.videoInfo);
+
}
});
},
@@ -374,27 +461,75 @@
calculateVideoFit(width, height) {
const viewportRatio = uni.getSystemInfoSync().windowWidth / uni.getSystemInfoSync().windowHeight;
const videoRatio = width / height;
-
+
// 瑙勫垯1锛氳秴瀹借棰戯紙濡傜數褰�21:9锛�
if (videoRatio > 2) return 'contain';
-
+
// 瑙勫垯2锛氱珫灞忚棰戯紙濡�9:16锛�
if (videoRatio < 0.8) return 'cover';
-
+
// 瑙勫垯3锛氭帴杩戝睆骞曟瘮渚嬬殑妯睆瑙嗛
return Math.abs(videoRatio - viewportRatio) > 0.3 ? 'contain' : 'cover';
},
// 閲嶆柊涓婁紶
reUpload() {
this.videoInfo = {
- url: '',
- cover: '',
- duration: 0,
- size: 0
+ url: '',
+ fileKey: '',
+ fileType: '',
+ fileSize: 0,
+ originalFileName: '',
+ cover: ''
};
- this.chooseVideo();
+ this.formData.videoFileKey = ''
+ this.formData.cover = ''
+ this.formData.videoFit = 'cover'
+ this.formData.videoDuration = 0
+ this.formData.videoImgs = []
+ this.formData.fileInfo = {}
+ this.formData.videoContentType = 'video'
+ this.videoPreviewImgs = []
+ this.fileTypeShow = true
},
-
+ // 閫夋嫨瑙嗛鍥鹃泦
+ chooseImgs() {
+ this.fileTypeShow = false
+ // 娓呯┖閫夋嫨鐨勮棰�
+ this.formData.videoFileKey = '';
+ this.formData.cover = '';
+ this.formData.videoContentType = 'img'
+ uni.chooseImage({
+ count: 9,
+ sizeType: ['compressed'],
+ sourceType: ['album'],
+ success: (res) => {
+ res.tempFilePaths.forEach(tmpImg => {
+ let fileName = tmpImg.substring(tmpImg.lastIndexOf('/') + 1);
+ // 澶勭悊瀹夊崜鍙兘鐨刄RI缂栫爜
+ if(fileName.indexOf('%') > -1) {
+ fileName = decodeURIComponent(fileName);
+ }
+ const fileKey = getFileKey(fileName);
+ this.cosClient.uploadFile({
+ Bucket: this.bucket,
+ Region: this.region,
+ Key: fileKey,
+ FilePath: tmpImg,
+ SliceSize: 1024 * 1024 * 5 /* 瑙﹀彂鍒嗗潡涓婁紶鐨勯槇鍊�,5M */
+ }, (err, data) => {
+ if (err) {
+ console.log('涓婁紶澶辫触', err);
+ } else {
+ // 鑾峰彇灏侀潰鐨勮闂湴鍧�
+ this.videoPreviewImgs.push(this.endpoint + '/' + fileKey);
+ this.formData.videoImgs.push(fileKey);
+ }
+ });
+ })
+
+ }
+ });
+ },
// 閫夋嫨灏侀潰
chooseCover() {
uni.chooseImage({
@@ -413,41 +548,54 @@
Bucket: this.bucket,
Region: this.region,
Key: fileKey,
- FilePath: res.tempFilePaths[0],
+ 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
- })
+ this.videoInfo.cover = this.endpoint + '/' + fileKey
+ this.formData.cover = fileKey
}
});
}
});
},
-
+
// 閫夋嫨鍟嗗搧
chooseGoods() {
+ if(this.selectedGoodsList.length > 0) {
+ const selectedGoodsIds = new Set(this.selectedGoodsList.map(i => i.goodsId));
+ console.log(selectedGoodsIds, "mimade");
+ this.goodsList?.forEach(goods => {
+ this.$set(goods, 'selected', selectedGoodsIds.has(goods.goodsId));
+ });
+ }
this.showGoodsPicker = true;
},
-
+
// 閫夋嫨鍏蜂綋鍟嗗搧
- selectGoods(goods) {
- this.selectedGoods = goods;
- this.formData.goodsId = goods.id;
- this.showGoodsPicker = false;
+ selectGoods(goods, index) {
+ if(! this.selectedGoodsList.some(item => item.id === goods.id)) {
+ goods["goodsNum"] = 1
+ this.selectedGoodsList.push(goods)
+ this.goodsList[index].selected = true
+ } else {
+ this.goodsList[index].selected = false
+ this.selectedGoodsList = this.selectedGoodsList.filter(item => item.id !== goods.id);
+ }
},
-
+
// 娓呴櫎鍟嗗搧
- clearGoods() {
- this.selectedGoods = null;
- this.formData.goodsId = '';
+ clearGoods(goods) {
+ this.selectedGoodsList = this.selectedGoodsList.filter(item => item.id !== goods.id);
+ this.goodsList.forEach(item => {
+ if(item.id === goods.id) {
+ item.selected = false
+ }
+ })
},
-
+
// 鎼滅储鐑棬璇濋
searchTags() {
if (this.tagInput.trim() !== '') {
@@ -478,7 +626,7 @@
});
}
},
-
+
// 閫夋嫨鎺ㄨ崘璇濋
selectTopic(index) {
const tag = this.recommendedTags[index]
@@ -489,7 +637,7 @@
});
return;
}
-
+
if (this.formData.tags.filter(item => item.tagName === tag.tagName).length < 1) {
this.formData.tags.push(tag);
this.tagInput = '';
@@ -500,49 +648,31 @@
});
}
},
-
+
// 绉婚櫎鏍囩
removeTag(index) {
this.formData.tags.splice(index, 1);
},
-
+
// 澶勭悊鍙戝竷
handlePublish() {
this.$refs.formRef.validate(valid => {
if (valid && this.canPublish) {
this.loading = true;
this.formData.fileInfo = this.videoInfo;
- console.log(this.formData);
- publish(this.formData).then(res => {
+ this.formData["goodsList"] = this.selectedGoodsList.map(item => {return {goodsId: item.goodsId, goodsNum: item.goodsNum}});
+ updateVideo(this.formData).then(res => {
uni.showToast({
title: '瑙嗛宸叉彁浜ゅ鏍竳',
icon: 'success'
});
this.loading = false
// 閲嶇疆琛ㄥ崟
- this.videoInfo = {
- url: '',
- fileKey: '',
- fileType: '',
- fileSize: 0,
- originalFileName: '',
- cover: ''
- };
- this.formData = {
- id: '',
- title: '',
- videoFileKey: '',
- cover: '',
- videoFit: 'cover',
- videoDuration: 0,
- goodsId: '',
- tags: [],
- fileInfo: {}
- };
+ this.resetData();
this.selectedGoods = null;
this.tagInput = '';
this.recommendedTags = [];
-
+
// TODO 鍏堣烦棣栭〉,鍚庨潰璺虫垜鐨勮棰戦〉闈�
setTimeout(() => {
uni.switchTab({
@@ -557,21 +687,46 @@
});
}
});
- }
+ },
+ resetData() {
+ // 閲嶇疆琛ㄥ崟
+ this.videoInfo = {
+ url: '',
+ fileKey: '',
+ fileType: '',
+ fileSize: 0,
+ originalFileName: '',
+ cover: ''
+ };
+ this.formData = {
+ id: '',
+ title: '',
+ videoFileKey: '',
+ cover: '',
+ videoFit: 'cover',
+ videoDuration: 0,
+ goodsId: '',
+ videoContentType: 'video',
+ videoImgs: [],
+ tags: [],
+ fileInfo: {}
+ };
+ this.videoPreviewImgs = []
+ this.selectedGoodsList = []
+ }
}
};
</script>
<style scoped>
.publish-container {
- padding: 20rpx;
+ padding: 10px;
padding-bottom: 120rpx;
}
.upload-section {
background-color: #f8f8f8;
border-radius: 16rpx;
- padding: 40rpx;
margin-bottom: 30rpx;
display: flex;
justify-content: center;
@@ -611,9 +766,11 @@
}
.video-actions {
+ width: 100%;
margin-top: 20rpx;
display: flex;
justify-content: center;
+ align-items: center;
gap: 20rpx;
}
@@ -634,6 +791,7 @@
background-color: #f9f9f9;
border-radius: 8rpx;
margin-top: 15rpx;
+ position: relative;
}
.goods-preview .goods-image {
@@ -705,10 +863,11 @@
}
.publish-btn {
- position: fixed;
+ /* position: fixed;
bottom: 100rpx;
left: 20rpx;
- right: 20rpx;
+ right: 20rpx; */
+ margin-top: 40rpx;
}
.goods-picker {
@@ -779,4 +938,22 @@
height: 25px;
margin-top: 10px;
}
-</style>
\ No newline at end of file
+
+.image-list {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: flex-start;
+}
+
+.image-item {
+ margin: 5px;
+ overflow: hidden;
+ border-radius: 8px;
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
+}
+
+.image {
+ width: 100%;
+ height: 100%;
+}
+</style>
diff --git a/pages/video/video-play.vue b/pages/video/video-play.vue
index d98f74e..4cf61c2 100644
--- a/pages/video/video-play.vue
+++ b/pages/video/video-play.vue
@@ -9,89 +9,141 @@
@change="onSwiperChange"
>
<swiper-item v-for="(item, index) in videoList" :key="item.id">
- <!-- 鎾斁鎸夐挳锛堜粎褰撹棰戞殏鍋滄椂鏄剧ず锛� -->
- <view
- class="play-icon"
- @click="togglePlay(index)"
- v-if="!currentVideoIsPlaying"
- >
- <image src="/static/video/play.png" style="width: 45px;height: 45px" mode="aspectFit"></image>
- </view>
- <video
- :id="'video'+index"
- :ref="'video'+index"
- :src="item.videoUrl"
- :autoplay="currentIndex === index"
- :controls="false"
- :loop="true"
- :object-fit="item.objectFit"
- class="video-item"
- @play="onPlay(item.id, index)"
- @pause="onPause(index)"
- @ended="onEnded(index)"
- @click="togglePlay(index)"
- @timeupdate="onTimeUpdate($event)"
- ></video>
-
- <!-- 鎮寕鍟嗗搧閾炬帴灞� -->
- <view class="goods-link-warp">
- <view class="goods-link">
- <view class="goods-container">
- <!-- 鍟嗗搧鍥剧墖 -->
- <image class="goods-image" :src="item.goods.imageUrl" mode="aspectFill"></image>
-
- <!-- 鍟嗗搧淇℃伅 -->
- <view class="goods-info">
- <text class="goods-name">{{item.goods.name}}</text>
- <view class="price-section">
- <text class="current-price">楼{{item.goods.price}}</text>
- <text class="original-price" v-if="item.goods.originalPrice">楼{{item.goods.originalPrice}}</text>
- </view>
- <text class="sales-count">{{item.goods.saleNum}}浜哄凡璐�</text>
- </view>
-
- <!-- 璐拱鎸夐挳 -->
- <view class="buy-button">
- <text>璐拱</text>
- </view>
- </view>
- </view>
- </view>
-
-
- <!-- 瑙嗛淇℃伅灞� -->
- <view class="video-info">
- <view>
- <text class="video-author">@{{item.authorName}}</text>
- </view>
- <view style="width: 100%;word-wrap: break-word;white-space: normal;overflow-wrap: break-word;">
- <text class="video-title">{{item.title}}</text>
- <text class="video-tag" v-for="(tag, index) in item.tagList" :key="tag.id">#{{tag.tagName}}</text>
- </view>
- </view>
-
- <!-- 鍙充晶浜掑姩鎸夐挳 -->
- <view class="action-buttons">
- <view class="avatar-container">
- <image class="avatar" @click="jumpToHomePage(item.authorId)" :src="item.authorAvatar" mode="aspectFill"></image>
- <!-- 鍏虫敞鍥炬爣 - 浣跨敤缁濆瀹氫綅 -->
- <view v-if="!item.subscribeThisAuthor" class="follow-icon" @click="subscribeAuth(index, item.authorId)">
- <text class="iconfont"></text>
- </view>
- </view>
- <view class="action-item" @click="toggleCollect(item, index)">
- <text class="iconfont" v-if="item.collected"></text>
- <text class="iconfont" v-else></text>
- <text style="font-size: 10px;font-weight: lighter;">{{item.collectNum}}</text>
+ <view style="width: 100%;height: 100%;" v-if="item.videoContentType === 'video'">
+ <!-- 鎾斁鎸夐挳锛堜粎褰撹棰戞殏鍋滄椂鏄剧ず锛� -->
+ <view
+ class="play-icon"
+ @click="togglePlay(index)"
+ v-if="!currentVideoIsPlaying"
+ >
+ <image src="/static/video/play.png" style="width: 45px;height: 45px" mode="aspectFit"></image>
+ </view>
+ <video
+ :id="'video'+index"
+ :ref="'video'+index"
+ :src="item.videoUrl"
+ :autoplay="currentIndex === index"
+ :controls="false"
+ :loop="true"
+ :object-fit="item.objectFit"
+ :enable-progress-gesture="false"
+ class="video-item"
+ @play="onPlay(item.id, index)"
+ @pause="onPause(index)"
+ @ended="onEnded(index)"
+ @click="togglePlay(index)"
+ @timeupdate="onTimeUpdate($event)"
+ @loadedmetadata="onLoadedMetadata($event)"
+
+ ></video>
+ <!-- 鑷畾涔夋帶鍒舵潯 -->
+ <view
+ @touchstart="handleTouchStart"
+ @touchmove="handleTouchMove"
+ @touchend="handleTouchEnd"
+ class="container">
+ <!-- 杩涘害鏉� - 鏁翠釜鍖哄煙鍙嫋鍔� -->
+ <view class="process-warp" :style="{ opacity: showProcess ? 1 : 0 }">
+ <!-- 鏄剧ず褰撳墠杩涘害 -->
+ <view class="progress-text">{{ hasPlayTime }}/{{formartDuration}}</view>
+ <view
+ class="progress-bar"
+ id="progressBar"
+ >
+
+ <!-- 宸插~鍏呴儴鍒� -->
+ <view class="progress-fill" :style="{ width: progress + '%' }"></view>
+ </view>
+ </view>
+ </view>
+ </view>
+ <view style="width: 100%; height: 100%;" v-else-if="item.videoContentType === 'img'">
+ <uni-swiper-dot
+ :info="item.imgs"
+ :current="currentImgIndex"
+ mode="round"
+ style="width: 100%;height: 100%;display: flex;justify-content: center;align-items: center;"
+ :dots-styles="{width: 24, bottom: 24,selectedBackgroundColor: 'green', backgroundColor: 'gray'}"
+ >
+ <swiper class="swiper-box" @change="imgChange" :autoplay="true" :interval="3000">
+ <swiper-item v-for="img in item.imgs" :key="img">
+ <view class="swiper-item">
+ <!-- 璋冩暣 image 鏍峰紡锛屼娇鍏跺眳涓笖鎸夋瘮渚嬬缉鏀� -->
+ <image
+ :src="img"
+ mode="aspectFit"
+ style="width: 100%; height: 100%; display: block; margin: 0 auto;"
+ ></image>
+ </view>
+ </swiper-item>
+ </swiper>
+ </uni-swiper-dot>
+ </view>
+
+
+ <!-- 鎮寕鍟嗗搧閾炬帴灞� -->
+ <view class="goods-link-warp" v-if="item.goodsList.length > 0">
+ <view class="goods-link">
+ <swiper @change="goodsChange" :autoplay="true" :interval="4000" style="height: 120rpx;">
+ <swiper-item v-for="goods in item.goodsList" :key="goods.goodsId">
+ <view class="goods-container" @click="jumpToPay(item.id)">
+ <!-- 鍟嗗搧鍥剧墖 -->
+ <image class="goods-image" :src="goods.thumbnail" mode="aspectFill"></image>
+
+ <!-- 鍟嗗搧淇℃伅 -->
+ <view class="goods-info">
+ <text class="goods-name">{{goods.goodsName}}</text>
+ <view class="price-section">
+ <text class="current-price">楼{{goods.price}}</text>
+ <text class="original-price" v-if="goods.originalPrice">楼{{goods.originalPrice}}</text>
+ </view>
+ </view>
+ </view>
+ </swiper-item>
+ </swiper>
+ </view>
+ </view>
+
+
+ <!-- 瑙嗛淇℃伅灞� -->
+ <view class="video-info">
+ <view>
+ <text class="video-author">@{{item.authorName}}</text>
+ </view>
+ <view style="width: 100%;word-wrap: break-word;white-space: normal;overflow-wrap: break-word;">
+ <text class="video-title">{{item.title}}</text>
+ <text class="video-tag" v-for="(tag, index) in item.tagList" :key="tag.id">#{{tag.tagName}}</text>
+ </view>
</view>
- <view class="action-item" @click="showComments(item)">
- <text class="iconfont"></text>
- <text style="font-size: 10px;font-weight: lighter;">{{item.commentNum}}</text>
+
+ <!-- 鍙充晶浜掑姩鎸夐挳 -->
+ <view class="action-buttons">
+ <view class="avatar-container">
+ <image class="avatar" @click="jumpToHomePage(item.authorId)" :src="item.authorAvatar" mode="aspectFill"></image>
+ <!-- 鍏虫敞鍥炬爣 - 浣跨敤缁濆瀹氫綅 -->
+ <view v-if="!item.subscribeThisAuthor" class="follow-icon" @click="subscribeAuth(index, item.authorId)">
+ <text class="iconfont"></text>
+ </view>
+ </view>
+ <view class="action-item" @click="toggleCollect(item, index)">
+ <text class="iconfont" v-if="item.collected"></text>
+ <text class="iconfont" v-else></text>
+ <text style="font-size: 10px;font-weight: lighter;">{{item.collectNum}}</text>
+ </view>
+ <view class="action-item" @click="showComments(item)">
+ <text class="iconfont"></text>
+ <text style="font-size: 10px;font-weight: lighter;">{{item.commentNum}}</text>
+ </view>
+ <view class="action-item">
+ <button open-type="share" class="custom-share-btn" :data-obj="item">
+ <text class="iconfont"></text>
+ </button>
+
+ </view>
</view>
- </view>
-
- </swiper-item>
- </swiper>
+
+ </swiper-item>
+ </swiper>
<!-- 璇勮寮圭獥 -->
<uni-popup ref="commentPopup" type="bottom" :is-mask-click="true" @maskClick="closeCommentPopup">
@@ -178,9 +230,29 @@
<script>
import { getRecommendVideos, savePlayRecord, subscribe, getVideoComments, addVideoComment, thubmsUpComment, cancelThubmsUpComment } from "@/api/video.js";
import { changeCollect } from "@/api/collect.js";
+import { saveShare } from "@/api/share.js";
+import storage from "@/utils/storage.js";
export default {
+ computed: {
+ hasPlayTime() {
+ return this.sliderFormatTime(this.progress > 0 ? this.duration * this.progress / 100 : 0);
+ }
+ },
data() {
return {
+ currentImgIndex: 0, // 鎾斁鍒扮鍑犲紶鍥�--绱㈠紩
+ currentGoodsIndex: 0, // 鎾斁鍒扮鍑犱釜鍟嗗搧--绱㈠紩
+ currentTime: 0,
+ formartDuration: '',
+ duration: 0,
+ startX: 0,
+ progress: 0, // 瑙嗛杩涘害
+ startProgress : 0, // 寮�濮嬫粦鍔ㄦ椂鐨勮繘搴�
+ barLeft: 0, // 杩涘害鏉″乏杈圭晫浣嶇疆
+ barWidth: 0, // 杩涘害鏉″搴�
+ isDragging: false, // 鏄惁姝e湪鎷栧姩
+ processHidenTimer: null, // 杩涘害鏉¢殣钘忓畾鏃跺櫒
+ showProcess: false, // 鏄惁鏄剧ず杩涘害鏉�
videoNoMore: false, // 鏄惁杩樻湁鏇村瑙嗛
commentNoMore: false, // 鏄惁杩樻湁鏇村璇勮
commentQuery: {
@@ -253,6 +325,7 @@
const playInfo = uni.getStorageSync("playInfo", playInfo);
if(playInfo) {
this.videoList = playInfo.videoList;
+ console.log("鎷垮埌鏁版嵁浜�",playInfo);
this.videoQuery.pageNumber = playInfo.pageNumber;
this.videoNoMore = playInfo.nomore;
this.videoQuery.authorId = option.authorId;
@@ -267,7 +340,51 @@
// 鍒濆鍖栬棰戜笂涓嬫枃
this.initVideoContexts();
},
+ onShareAppMessage(e) {
+ const userInfo = storage.getUserInfo();
+ if(!userInfo) {
+ console.log("鏈櫥褰曚笉鑳藉垎浜�");
+ return
+ }
+ const videoInfo = e.target.dataset.obj;
+ // 淇濆瓨鍒嗕韩璁板綍
+ const data = {
+ shareType: 'video',
+ refId: videoInfo.id,
+ shareUser: userInfo.id
+ }
+ saveShare(data)
+ return {
+ title: videoInfo.title,
+ path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}`,
+ imageUrl: videoInfo.coverUrl
+ }
+ },
methods: {
+ // 鐐瑰嚮鍟嗗搧璺宠浆
+ jumpToPay(videoId) {
+ uni.navigateTo({
+ url: '/pages/video/video-goods-detail?videoId=' + videoId
+ });
+ },
+ // 杞挱鍥惧彉鍖�
+ imgChange(e) {
+ this.currentImgIndex = e.detail.current;
+ },
+ // 鍟嗗搧杞挱鍥惧彉鍖�
+ goodsChange(e) {
+ this.currentGoodsIndex = e.detail.current;
+ },
+ // 鑾峰彇杩涘害鏉$殑浣嶇疆鍜屽昂瀵�
+ getBarRect() {
+ const query = uni.createSelectorQuery().in(this);
+ query.select('#progressBar').boundingClientRect(rect => {
+ if (rect) {
+ this.barLeft = rect.left;
+ this.barWidth = rect.width;
+ }
+ }).exec();
+ },
// 璺宠浆涓汉涓婚〉
jumpToHomePage(authorId) {
uni.navigateTo({
@@ -364,6 +481,12 @@
const input = this.$refs.commentInput;
if (input) input.focus();
});
+ },
+ // 杩涘害鏉℃椂闂存牸寮忓寲 (00:00)
+ sliderFormatTime(seconds) {
+ const mins = Math.floor(seconds / 60);
+ const secs = Math.floor(seconds % 60);
+ return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
},
// 鏍煎紡鍖栨椂闂�
formatTime(time) {
@@ -561,6 +684,67 @@
this.videoContexts[this.currentIndex].play();
}
},
+
+ // 鑾峰彇杩涘害鏉$殑浣嶇疆鍜屽昂瀵�
+ getBarRect() {
+ const query = uni.createSelectorQuery().in(this);
+ query.select('#progressBar').boundingClientRect(rect => {
+ if (rect) {
+ this.barLeft = rect.left;
+ this.barWidth = rect.width;
+ }
+ }).exec();
+ },
+
+ // 瑙︽懜寮�濮�
+ handleTouchStart(e) {
+ this.isDragging = true;
+ this.showProcess = true;
+ this.startProgress = this.progress; // 璁板綍寮�濮嬫椂鐨勮繘搴�
+ this.startX = e.touches[0].pageX;
+ console.log("璁板綍寮�濮嬫椂鐨勮繘搴�", this.startProgress);
+ this.videoContexts[this.currentIndex].pause()
+ // this.updateProgress(e);
+ },
+
+ // 瑙︽懜绉诲姩
+ handleTouchMove(e) {
+ if (!this.isDragging || !this.barWidth) return;
+ clearTimeout(this.processHidenTimer)
+ this.videoContexts[this.currentIndex].pause()
+ this.updateProgress(e);
+ },
+
+ // 瑙︽懜缁撴潫
+ handleTouchEnd() {
+ this.isDragging = false;
+ console.log("婊戝姩缁撴潫", this.duration * this.progress);
+ this.videoContexts[this.currentIndex].seek(this.duration * this.progress / 100)
+ this.videoContexts[this.currentIndex].play()
+ this.processHidenTimer = setTimeout(() => {
+ this.showProcess = false;
+ }, 1000);
+ },
+
+ // 鏇存柊杩涘害
+ updateProgress(e) {
+ // 鑾峰彇褰撳墠瑙︽懜鐐筙鍧愭爣
+ const currentX = e.touches[0].pageX;
+
+ // 璁$畻婊戝姩璺濈(鍍忕礌)
+ const deltaX = currentX - this.startX;
+
+ // 灏嗗儚绱犺窛绂昏浆鎹负杩涘害澧為噺
+ const deltaProgress = (deltaX / this.barWidth) * 100;
+ console.log("杩涘害澧為噺", deltaProgress);
+ // 璁$畻鏂拌繘搴� = 寮�濮嬫椂鐨勮繘搴� + 婊戝姩澧為噺
+ let newProgress = this.startProgress + deltaProgress;
+
+ // 闄愬埗鑼冨洿鍦�0-100涔嬮棿
+ newProgress = Math.max(0, Math.min(100, newProgress));
+
+ this.progress = newProgress;
+ },
// 鏀惰棌/鍙栨秷鏀惰棌
toggleCollect(item, index) {
@@ -594,9 +778,15 @@
},
// 瑙嗛鎾斁浜嬩欢
onPlay(id, index) {
- console.log(id, index, "瑙﹀彂鎾斁");
+ this.getBarRect()
+ this.progress = 0
if(index === this.currentIndex) {
this.currentVideoIsPlaying = true;
+ if(! this.duration) {
+ // 璁剧疆褰撳墠鎾斁瑙嗛鐨勬�绘椂闀�
+ this.duration = this.videoList[this.currentIndex].videoDuration;
+ this.formartDuration = this.sliderFormatTime(this.duration);
+ }
} else {
this.currentVideoIsPlaying = false;
return
@@ -632,8 +822,15 @@
// 璁板綍鎾斁鏃堕暱
onTimeUpdate(e) {
this.playRecord.playAt = e.detail.currentTime
+ this.currentTime = e.detail.currentTime;
+ this.progress = (e.detail.currentTime / this.duration) * 100
},
-
+ // 鑾峰彇瑙嗛鎬绘椂闀�
+ onLoadedMetadata(e) {
+ // this.duration = e.detail.duration;
+ // this.formartDuration = this.sliderFormatTime(this.duration);
+ // console.log("瑙嗛鎬绘椂闀�", this.duration);
+ },
// 淇濆瓨鎾斁璁板綍
async savePlayRecord() {
console.log(Date.now(), this.playRecord.startPlayTime, this.totalHidenTime);
@@ -669,7 +866,7 @@
.video-swiper {
width: 100%;
- height: 100%;
+ height: calc(100% - 20rpx);
}
.video-item {
@@ -691,7 +888,7 @@
.video-info {
width: 70%;
position: absolute;
- bottom: 70px;
+ bottom: 20px;
left: 20px;
color: #f8f8f8;
z-index: 10;
@@ -765,6 +962,7 @@
}
.goods-link {
position: relative;
+ width: 450rpx;
margin: 20rpx 0;
padding: 12rpx;
background-color: rgba(255, 255, 255, 0.9);
@@ -773,6 +971,7 @@
}
.goods-container {
+ width: 100%;
display: flex;
align-items: center;
}
@@ -795,11 +994,13 @@
font-size: 28rpx;
color: #333;
font-weight: bold;
- display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
- overflow: hidden;
margin-bottom: 8rpx;
+ width: 280rpx; /* 闇�瑕佹寚瀹氬搴� */
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
}
.price-section {
@@ -1025,4 +1226,62 @@
.thumbs-num {
margin-left: 4rpx;
}
+ .container {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ }
+
+ .progress-bar {
+ position: relative;
+ width: 100%;
+ height: 16px;
+ background-color: #eee;
+ overflow: hidden;
+ }
+
+ .progress-fill {
+ position: absolute;
+ left: 0;
+ top: 0;
+ height: 100%;
+ background-color: lightgray;
+ transition: width 0.1s;
+ }
+ .process-warp {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ }
+ .progress-text {
+ margin-top: 10px;
+ font-size: 14px;
+ color: #666;
+ }
+ .swiper-box {
+ width: 100%;
+ height: 1200rpx;
+ }
+ .swiper-item {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 100%;
+ height: 100%;
+ }
+ .custom-share-btn {
+ font-size: unset;
+ background: none;
+ padding: 0;
+ margin: 0;
+ line-height: normal;
+ border: none;
+ }
+ .custom-share-btn::after {
+ border: none;
+ }
</style>
\ No newline at end of file
diff --git a/uni_modules/uni-popup/changelog.md b/uni_modules/uni-popup/changelog.md
index 013272a..f28b928 100644
--- a/uni_modules/uni-popup/changelog.md
+++ b/uni_modules/uni-popup/changelog.md
@@ -1,3 +1,6 @@
+## 1.9.9锛�2025-06-11锛�
+- 淇 uni-popup-dialog 涓� setVal 鏂规硶鎶ラ敊鐨勯棶棰�
+- 淇 uni-popup-dialog 鏁版嵁鍙屽悜缁戝畾闂銆�
## 1.9.8锛�2025-04-16锛�
- 淇 鏇存柊缁勪欢绀轰緥 锛岃В鍐虫洿鏂版暟鎹垨淇濆瓨椤圭洰瀵艰嚧寮圭獥娑堝け鐨勯棶棰�
## 1.9.7锛�2025-04-14锛�
diff --git a/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue b/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
index f5731d5..12ce2c9 100644
--- a/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
+++ b/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
@@ -156,11 +156,11 @@
}
},
value(val) {
- setVal(val)
+ this.setVal(val)
},
// #ifdef VUE3
modelValue(val) {
- setVal(val)
+ this.setVal(val)
},
// #endif
val(val) {
diff --git a/uni_modules/uni-popup/package.json b/uni_modules/uni-popup/package.json
index d8bfb9f..7be6c66 100644
--- a/uni_modules/uni-popup/package.json
+++ b/uni_modules/uni-popup/package.json
@@ -1,90 +1,107 @@
{
- "id": "uni-popup",
- "displayName": "uni-popup 寮瑰嚭灞�",
- "version": "1.9.8",
- "description": " Popup 缁勪欢锛屾彁渚涘父鐢ㄧ殑寮瑰眰",
- "keywords": [
- "uni-ui",
- "寮瑰嚭灞�",
- "寮圭獥",
- "popup",
- "寮规"
+ "id": "uni-popup",
+ "displayName": "uni-popup 寮瑰嚭灞�",
+ "version": "1.9.9",
+ "description": " Popup 缁勪欢锛屾彁渚涘父鐢ㄧ殑寮瑰眰",
+ "keywords": [
+ "uni-ui",
+ "寮瑰嚭灞�",
+ "寮圭獥",
+ "popup",
+ "寮规"
+],
+ "repository": "https://github.com/dcloudio/uni-ui",
+ "engines": {
+ "HBuilderX": "",
+ "uni-app": "^4.01",
+ "uni-app-x": ""
+ },
+ "directories": {
+ "example": "../../temps/example_temps"
+ },
+ "dcloudext": {
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "鏃�",
+ "data": "鏃�",
+ "permissions": "鏃�"
+ },
+ "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
+ "type": "component-vue",
+ "darkmode": "x",
+ "i18n": "x",
+ "widescreen": "x"
+ },
+ "uni_modules": {
+ "dependencies": [
+ "uni-scss",
+ "uni-transition"
],
- "repository": "https://github.com/dcloudio/uni-ui",
- "engines": {
- "HBuilderX": ""
- },
- "directories": {
- "example": "../../temps/example_temps"
- },
- "dcloudext": {
- "sale": {
- "regular": {
- "price": "0.00"
- },
- "sourcecode": {
- "price": "0.00"
- }
- },
- "contact": {
- "qq": ""
- },
- "declaration": {
- "ads": "鏃�",
- "data": "鏃�",
- "permissions": "鏃�"
- },
- "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
- "type": "component-vue"
- },
- "uni_modules": {
- "dependencies": [
- "uni-scss",
- "uni-transition"
- ],
- "encrypt": [],
- "platforms": {
- "cloud": {
- "tcb": "y",
- "aliyun": "y",
- "alipay": "n"
- },
- "client": {
- "App": {
- "app-vue": "y",
- "app-nvue": "y",
- "app-harmony": "u",
- "app-uvue": "u"
- },
- "H5-mobile": {
- "Safari": "y",
- "Android Browser": "y",
- "寰俊娴忚鍣�(Android)": "y",
- "QQ娴忚鍣�(Android)": "y"
- },
- "H5-pc": {
- "Chrome": "y",
- "IE": "y",
- "Edge": "y",
- "Firefox": "y",
- "Safari": "y"
- },
- "灏忕▼搴�": {
- "寰俊": "y",
- "闃块噷": "y",
- "鐧惧害": "y",
- "瀛楄妭璺冲姩": "y",
- "QQ": "y"
- },
- "蹇簲鐢�": {
- "鍗庝负": "u",
- "鑱旂洘": "u"
- },
- "Vue": {
- "vue2": "y",
- "vue3": "y"
- }
- }
- }
- }
-}
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "x",
+ "aliyun": "x",
+ "alipay": "x"
+ },
+ "client": {
+ "uni-app": {
+ "vue": {
+ "vue2": "鈭�",
+ "vue3": "鈭�"
+ },
+ "web": {
+ "safari": "鈭�",
+ "chrome": "鈭�"
+ },
+ "app": {
+ "vue": "鈭�",
+ "nvue": "鈭�",
+ "android": "鈭�",
+ "ios": "鈭�",
+ "harmony": "x"
+ },
+ "mp": {
+ "weixin": "鈭�",
+ "alipay": "鈭�",
+ "toutiao": "鈭�",
+ "baidu": "鈭�",
+ "kuaishou": "鈭�",
+ "jd": "鈭�",
+ "harmony": "鈭�",
+ "qq": "鈭�",
+ "lark": "鈭�"
+ },
+ "quickapp": {
+ "huawei": "-",
+ "union": "-"
+ }
+ },
+ "uni-app-x": {
+ "web": {
+ "safari": "-",
+ "chrome": "-"
+ },
+ "app": {
+ "android": "-",
+ "ios": "-",
+ "harmony": "-"
+ },
+ "mp": {
+ "weixin": "-"
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/uni-transition/changelog.md b/uni_modules/uni-transition/changelog.md
index 2f2b10d..1e500ab 100644
--- a/uni_modules/uni-transition/changelog.md
+++ b/uni_modules/uni-transition/changelog.md
@@ -1,3 +1,5 @@
+## 1.3.5锛�2025-06-11锛�
+- 淇 绗竴娆℃墽琛屼笉鏄剧ず鍔ㄧ敾鐨勯棶棰�
## 1.3.4锛�2025-04-16锛�
- 淇 椤甸潰鏁版嵁鏇存柊鍒板簳鍔ㄧ敾澶嶅師鐨勯棶棰�
- 淇 绀轰緥椤甸潰鎵撳紑鎶ラ敊鐨勯棶棰�
diff --git a/uni_modules/uni-transition/components/uni-transition/uni-transition.vue b/uni_modules/uni-transition/components/uni-transition/uni-transition.vue
index 8772572..cce8538 100644
--- a/uni_modules/uni-transition/components/uni-transition/uni-transition.vue
+++ b/uni_modules/uni-transition/components/uni-transition/uni-transition.vue
@@ -1,289 +1,286 @@
<template>
- <!-- #ifndef APP-NVUE -->
- <view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view>
- <!-- #endif -->
- <!-- #ifdef APP-NVUE -->
- <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"><slot></slot></view>
- <!-- #endif -->
+ <!-- #ifndef APP-NVUE -->
+ <view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
+ <slot></slot>
+ </view>
+ <!-- #endif -->
+ <!-- #ifdef APP-NVUE -->
+ <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
+ <slot></slot>
+ </view>
+ <!-- #endif -->
</template>
<script>
-import { createAnimation } from './createAnimation'
+ import { createAnimation } from './createAnimation'
-/**
- * Transition 杩囨浮鍔ㄧ敾
- * @description 绠�鍗曡繃娓″姩鐢荤粍浠�
- * @tutorial https://ext.dcloud.net.cn/plugin?id=985
- * @property {Boolean} show = [false|true] 鎺у埗缁勪欢鏄剧ず鎴栭殣钘�
- * @property {Array|String} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 杩囨浮鍔ㄧ敾绫诲瀷
- * @value fade 娓愰殣娓愬嚭杩囨浮
- * @value slide-top 鐢变笂鑷充笅杩囨浮
- * @value slide-right 鐢卞彸鑷冲乏杩囨浮
- * @value slide-bottom 鐢变笅鑷充笂杩囨浮
- * @value slide-left 鐢卞乏鑷冲彸杩囨浮
- * @value zoom-in 鐢卞皬鍒板ぇ杩囨浮
- * @value zoom-out 鐢卞ぇ鍒板皬杩囨浮
- * @property {Number} duration 杩囨浮鍔ㄧ敾鎸佺画鏃堕棿
- * @property {Object} styles 缁勪欢鏍峰紡锛屽悓 css 鏍峰紡锛屾敞鎰忓甫鈥�-鈥樿繛鎺ョ鐨勫睘鎬ч渶瑕佷娇鐢ㄥ皬椹煎嘲鍐欐硶濡傦細`backgroundColor:red`
- */
-export default {
- name: 'uniTransition',
- emits:['click','change'],
- props: {
- show: {
- type: Boolean,
- default: false
- },
- modeClass: {
- type: [Array, String],
- default() {
- return 'fade'
- }
- },
- duration: {
- type: Number,
- default: 300
- },
- styles: {
- type: Object,
- default() {
- return {}
- }
- },
- customClass:{
- type: String,
- default: ''
- },
- onceRender:{
- type:Boolean,
- default:false
- },
- },
- data() {
- return {
- isShow: false,
- transform: '',
- opacity: 1,
- animationData: {},
- durationTime: 300,
- config: {}
- }
- },
- watch: {
- show: {
- handler(newVal) {
- if (newVal) {
- this.open()
- } else {
- // 閬垮厤涓婃潵灏辨墽琛� close,瀵艰嚧鍔ㄧ敾閿欎贡
- if (this.isShow) {
- this.close()
- }
+ /**
+ * Transition 杩囨浮鍔ㄧ敾
+ * @description 绠�鍗曡繃娓″姩鐢荤粍浠�
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=985
+ * @property {Boolean} show = [false|true] 鎺у埗缁勪欢鏄剧ず鎴栭殣钘�
+ * @property {Array|String} modeClass = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 杩囨浮鍔ㄧ敾绫诲瀷
+ * @value fade 娓愰殣娓愬嚭杩囨浮
+ * @value slide-top 鐢变笂鑷充笅杩囨浮
+ * @value slide-right 鐢卞彸鑷冲乏杩囨浮
+ * @value slide-bottom 鐢变笅鑷充笂杩囨浮
+ * @value slide-left 鐢卞乏鑷冲彸杩囨浮
+ * @value zoom-in 鐢卞皬鍒板ぇ杩囨浮
+ * @value zoom-out 鐢卞ぇ鍒板皬杩囨浮
+ * @property {Number} duration 杩囨浮鍔ㄧ敾鎸佺画鏃堕棿
+ * @property {Object} styles 缁勪欢鏍峰紡锛屽悓 css 鏍峰紡锛屾敞鎰忓甫鈥�-鈥樿繛鎺ョ鐨勫睘鎬ч渶瑕佷娇鐢ㄥ皬椹煎嘲鍐欐硶濡傦細`backgroundColor:red`
+ */
+ export default {
+ name: 'uniTransition',
+ emits: ['click', 'change'],
+ props: {
+ show: {
+ type: Boolean,
+ default: false
+ },
+ modeClass: {
+ type: [Array, String],
+ default () {
+ return 'fade'
}
},
- immediate: true
- }
- },
- computed: {
- // 鐢熸垚鏍峰紡鏁版嵁
- stylesObject() {
- let styles = {
- ...this.styles,
- 'transition-duration': this.duration / 1000 + 's'
- }
- let transform = ''
- for (let i in styles) {
- let line = this.toLine(i)
- transform += line + ':' + styles[i] + ';'
- }
- return transform
- },
- // 鍒濆鍖栧姩鐢绘潯浠�
- transformStyles() {
- return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject
- }
- },
- created() {
- // 鍔ㄧ敾榛樿閰嶇疆
- this.config = {
- duration: this.duration,
- timingFunction: 'ease',
- transformOrigin: '50% 50%',
- delay: 0
- }
- this.durationTime = this.duration
- },
- methods: {
- /**
- * ref 瑙﹀彂 鍒濆鍖栧姩鐢�
- */
- init(obj = {}) {
- if (obj.duration) {
- this.durationTime = obj.duration
- }
- this.animation = createAnimation(Object.assign(this.config, obj),this)
- },
- /**
- * 鐐瑰嚮缁勪欢瑙﹀彂鍥炶皟
- */
- onClick() {
- this.$emit('click', {
- detail: this.isShow
- })
- },
- /**
- * ref 瑙﹀彂 鍔ㄧ敾鍒嗙粍
- * @param {Object} obj
- */
- step(obj, config = {}) {
- if (!this.animation) return
- for (let i in obj) {
- try {
- if(typeof obj[i] === 'object'){
- this.animation[i](...obj[i])
- }else{
- this.animation[i](obj[i])
- }
- } catch (e) {
- console.error(`鏂规硶 ${i} 涓嶅瓨鍦╜)
+ duration: {
+ type: Number,
+ default: 300
+ },
+ styles: {
+ type: Object,
+ default () {
+ return {}
}
+ },
+ customClass: {
+ type: String,
+ default: ''
+ },
+ onceRender: {
+ type: Boolean,
+ default: false
+ },
+ },
+ data() {
+ return {
+ isShow: false,
+ transform: '',
+ opacity: 0,
+ animationData: {},
+ durationTime: 300,
+ config: {}
}
- this.animation.step(config)
- return this
},
- /**
- * ref 瑙﹀彂 鎵ц鍔ㄧ敾
- */
- run(fn) {
- if (!this.animation) return
- this.animation.run(fn)
- },
- // 寮�濮嬭繃搴﹀姩鐢�
- open() {
- clearTimeout(this.timer)
- this.transform = ''
- this.isShow = true
- let { opacity, transform } = this.styleInit(false)
- if (typeof opacity !== 'undefined') {
- this.opacity = opacity
+ watch: {
+ show: {
+ handler(newVal) {
+ if (newVal) {
+ this.open()
+ } else {
+ // 閬垮厤涓婃潵灏辨墽琛� close,瀵艰嚧鍔ㄧ敾閿欎贡
+ if (this.isShow) {
+ this.close()
+ }
+ }
+ },
+ immediate: true
}
- this.transform = transform
- // 纭繚鍔ㄦ�佹牱寮忓凡缁忕敓鏁堝悗锛屾墽琛屽姩鐢伙紝濡傛灉涓嶅姞 nextTick 锛屼細瀵艰嚧 wx 鍔ㄧ敾鎵ц寮傚父
- this.$nextTick(() => {
- // TODO 瀹氭椂鍣ㄤ繚璇佸姩鐢诲畬鍏ㄦ墽琛岋紝鐩墠鏈変簺闂锛屽悗闈細鍙栨秷瀹氭椂鍣�
- this.timer = setTimeout(() => {
- this.animation = createAnimation(this.config, this)
- this.tranfromInit(false).step()
- this.animation.run(() => {
- this.transform = ''
- this.opacity = opacity || 1
- })
- this.$emit('change', {
- detail: this.isShow
- })
- }, 20)
- })
},
- // 鍏抽棴杩囧害鍔ㄧ敾
- close(type) {
- if (!this.animation) return
- this.tranfromInit(true)
- .step()
- .run(() => {
- this.isShow = false
- this.animationData = null
- this.animation = null
- let { opacity, transform } = this.styleInit(false)
- this.opacity = opacity || 1
- this.transform = transform
- this.$emit('change', {
- detail: this.isShow
- })
- })
- },
- // 澶勭悊鍔ㄧ敾寮�濮嬪墠鐨勯粯璁ゆ牱寮�
- styleInit(type) {
- let styles = {
- transform: ''
- }
- let buildStyle = (type, mode) => {
- if (mode === 'fade') {
- styles.opacity = this.animationType(type)[mode]
- } else {
- styles.transform += this.animationType(type)[mode] + ' '
+ computed: {
+ // 鐢熸垚鏍峰紡鏁版嵁
+ stylesObject() {
+ let styles = {
+ ...this.styles,
+ 'transition-duration': this.duration / 1000 + 's'
}
- }
- if (typeof this.modeClass === 'string') {
- buildStyle(type, this.modeClass)
- } else {
- this.modeClass.forEach(mode => {
- buildStyle(type, mode)
- })
- }
- return styles
- },
- // 澶勭悊鍐呯疆缁勫悎鍔ㄧ敾
- tranfromInit(type) {
- let buildTranfrom = (type, mode) => {
- let aniNum = null
- if (mode === 'fade') {
- aniNum = type ? 0 : 1
- } else {
- aniNum = type ? '-100%' : '0'
- if (mode === 'zoom-in') {
- aniNum = type ? 0.8 : 1
- }
- if (mode === 'zoom-out') {
- aniNum = type ? 1.2 : 1
- }
- if (mode === 'slide-right') {
- aniNum = type ? '100%' : '0'
- }
- if (mode === 'slide-bottom') {
- aniNum = type ? '100%' : '0'
- }
+ let transform = ''
+ for (let i in styles) {
+ let line = this.toLine(i)
+ transform += line + ':' + styles[i] + ';'
}
- this.animation[this.animationMode()[mode]](aniNum)
+ return transform
+ },
+ // 鍒濆鍖栧姩鐢绘潯浠�
+ transformStyles() {
+ return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject
}
- if (typeof this.modeClass === 'string') {
- buildTranfrom(type, this.modeClass)
- } else {
- this.modeClass.forEach(mode => {
- buildTranfrom(type, mode)
+ },
+ created() {
+ // 鍔ㄧ敾榛樿閰嶇疆
+ this.config = {
+ duration: this.duration,
+ timingFunction: 'ease',
+ transformOrigin: '50% 50%',
+ delay: 0
+ }
+ this.durationTime = this.duration
+ },
+ methods: {
+ /**
+ * ref 瑙﹀彂 鍒濆鍖栧姩鐢�
+ */
+ init(obj = {}) {
+ if (obj.duration) {
+ this.durationTime = obj.duration
+ }
+ this.animation = createAnimation(Object.assign(this.config, obj), this)
+ },
+ /**
+ * 鐐瑰嚮缁勪欢瑙﹀彂鍥炶皟
+ */
+ onClick() {
+ this.$emit('click', {
+ detail: this.isShow
})
- }
+ },
+ /**
+ * ref 瑙﹀彂 鍔ㄧ敾鍒嗙粍
+ * @param {Object} obj
+ */
+ step(obj, config = {}) {
+ if (!this.animation) return this
+ Object.keys(obj).forEach(key => {
+ const value = obj[key]
+ if (typeof this.animation[key] === 'function') {
+ Array.isArray(value) ?
+ this.animation[key](...value) :
+ this.animation[key](value)
+ }
+ })
+ this.animation.step(config)
+ return this
+ },
+ /**
+ * ref 瑙﹀彂 鎵ц鍔ㄧ敾
+ */
+ run(fn) {
+ if (!this.animation) return
+ this.animation.run(fn)
+ },
+ // 寮�濮嬭繃搴﹀姩鐢�
+ open() {
+ clearTimeout(this.timer)
+ this.isShow = true
+ // 鏂板鍒濆鐘舵�侀噸缃�昏緫锛堝叧閿級
+ this.transform = this.styleInit(false).transform || ''
+ this.opacity = this.styleInit(false).opacity || 0
- return this.animation
- },
- animationType(type) {
- return {
- fade: type ? 0 : 1,
- 'slide-top': `translateY(${type ? '0' : '-100%'})`,
- 'slide-right': `translateX(${type ? '0' : '100%'})`,
- 'slide-bottom': `translateY(${type ? '0' : '100%'})`,
- 'slide-left': `translateX(${type ? '0' : '-100%'})`,
- 'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
- 'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
+ // 纭繚鍔ㄦ�佹牱寮忓凡缁忕敓鏁堝悗锛屾墽琛屽姩鐢伙紝濡傛灉涓嶅姞 nextTick 锛屼細瀵艰嚧 wx 鍔ㄧ敾鎵ц寮傚父
+ this.$nextTick(() => {
+ // TODO 瀹氭椂鍣ㄤ繚璇佸姩鐢诲畬鍏ㄦ墽琛岋紝鐩墠鏈変簺闂锛屽悗闈細鍙栨秷瀹氭椂鍣�
+ this.timer = setTimeout(() => {
+ this.animation = createAnimation(this.config, this)
+ this.tranfromInit(false).step()
+ this.animation.run(() => {
+ this.transform = ''
+ this.opacity = this.styleInit(false).opacity || 1
+ this.$emit('change', {
+ detail: this.isShow
+ })
+ })
+ }, 80)
+ })
+ },
+ // 鍏抽棴杩囧害鍔ㄧ敾
+ close(type) {
+ if (!this.animation) return
+ this.tranfromInit(true)
+ .step()
+ .run(() => {
+ this.isShow = false
+ this.animationData = null
+ this.animation = null
+ let { opacity, transform } = this.styleInit(false)
+ this.opacity = opacity || 1
+ this.transform = transform
+ this.$emit('change', {
+ detail: this.isShow
+ })
+ })
+ },
+ // 澶勭悊鍔ㄧ敾寮�濮嬪墠鐨勯粯璁ゆ牱寮�
+ styleInit(type) {
+ let styles = { transform: '', opacity: 1 }
+ const buildStyle = (type, mode) => {
+ const value = this.animationType(type)[mode] // 鐩存帴浣跨敤 type 鎺у埗鐘舵��
+ if (mode.startsWith('fade')) {
+ styles.opacity = value
+ } else {
+ styles.transform += value + ' '
+ }
+ }
+
+ if (typeof this.modeClass === 'string') {
+ buildStyle(type, this.modeClass)
+ } else {
+ this.modeClass.forEach(mode => buildStyle(type, mode))
+ }
+ return styles
+ },
+ // 澶勭悊鍐呯疆缁勫悎鍔ㄧ敾
+ tranfromInit(type) {
+ let buildTranfrom = (type, mode) => {
+ let aniNum = null
+ if (mode === 'fade') {
+ aniNum = type ? 0 : 1
+ } else {
+ aniNum = type ? '-100%' : '0'
+ if (mode === 'zoom-in') {
+ aniNum = type ? 0.8 : 1
+ }
+ if (mode === 'zoom-out') {
+ aniNum = type ? 1.2 : 1
+ }
+ if (mode === 'slide-right') {
+ aniNum = type ? '100%' : '0'
+ }
+ if (mode === 'slide-bottom') {
+ aniNum = type ? '100%' : '0'
+ }
+ }
+ this.animation[this.animationMode()[mode]](aniNum)
+ }
+ if (typeof this.modeClass === 'string') {
+ buildTranfrom(type, this.modeClass)
+ } else {
+ this.modeClass.forEach(mode => {
+ buildTranfrom(type, mode)
+ })
+ }
+
+ return this.animation
+ },
+ animationType(type) {
+ return {
+ fade: type ? 1 : 0,
+ 'slide-top': `translateY(${type ? '0' : '-100%'})`,
+ 'slide-right': `translateX(${type ? '0' : '100%'})`,
+ 'slide-bottom': `translateY(${type ? '0' : '100%'})`,
+ 'slide-left': `translateX(${type ? '0' : '-100%'})`,
+ 'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
+ 'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
+ }
+ },
+ // 鍐呯疆鍔ㄧ敾绫诲瀷涓庡疄闄呭姩鐢诲搴斿瓧鍏�
+ animationMode() {
+ return {
+ fade: 'opacity',
+ 'slide-top': 'translateY',
+ 'slide-right': 'translateX',
+ 'slide-bottom': 'translateY',
+ 'slide-left': 'translateX',
+ 'zoom-in': 'scale',
+ 'zoom-out': 'scale'
+ }
+ },
+ // 椹煎嘲杞腑妯嚎
+ toLine(name) {
+ return name.replace(/([A-Z])/g, '-$1').toLowerCase()
}
- },
- // 鍐呯疆鍔ㄧ敾绫诲瀷涓庡疄闄呭姩鐢诲搴斿瓧鍏�
- animationMode() {
- return {
- fade: 'opacity',
- 'slide-top': 'translateY',
- 'slide-right': 'translateX',
- 'slide-bottom': 'translateY',
- 'slide-left': 'translateX',
- 'zoom-in': 'scale',
- 'zoom-out': 'scale'
- }
- },
- // 椹煎嘲杞腑妯嚎
- toLine(name) {
- return name.replace(/([A-Z])/g, '-$1').toLowerCase()
}
}
-}
</script>
<style></style>
diff --git a/uni_modules/uni-transition/package.json b/uni_modules/uni-transition/package.json
index b76a3ab..5e5136a 100644
--- a/uni_modules/uni-transition/package.json
+++ b/uni_modules/uni-transition/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-transition",
"displayName": "uni-transition 杩囨浮鍔ㄧ敾",
- "version": "1.3.4",
+ "version": "1.3.5",
"description": "鍏冪礌鐨勭畝鍗曡繃娓″姩鐢�",
"keywords": [
"uni-ui",
@@ -12,12 +12,14 @@
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
- "HBuilderX": ""
+ "HBuilderX": "",
+ "uni-app": "^4.01",
+ "uni-app-x": ""
},
"directories": {
"example": "../../temps/example_temps"
},
-"dcloudext": {
+ "dcloudext": {
"sale": {
"regular": {
"price": "0.00"
@@ -35,51 +37,86 @@
"permissions": "鏃�"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
- "type": "component-vue"
+ "type": "component-vue",
+ "darkmode": "x",
+ "i18n": "x",
+ "widescreen": "x"
},
"uni_modules": {
- "dependencies": ["uni-scss"],
+ "dependencies": [
+ "uni-scss"
+ ],
"encrypt": [],
"platforms": {
"cloud": {
- "tcb": "y",
- "aliyun": "y",
- "alipay": "n"
+ "tcb": "鈭�",
+ "aliyun": "鈭�",
+ "alipay": "x"
},
"client": {
- "App": {
- "app-vue": "y",
- "app-nvue": "y",
- "app-harmony": "u",
- "app-uvue": "n"
+ "uni-app": {
+ "vue": {
+ "vue2": "鈭�",
+ "vue3": "鈭�"
+ },
+ "web": {
+ "safari": "鈭�",
+ "chrome": "鈭�"
+ },
+ "app": {
+ "vue": "鈭�",
+ "nvue": "鈭�",
+ "android": "鈭�",
+ "ios": "鈭�",
+ "harmony": "-"
+ },
+ "mp": {
+ "weixin": {
+ "extVersion": "1.0.2",
+ "minVersion": ""
+ },
+ "alipay": {
+ "extVersion": "1.0.2",
+ "minVersion": ""
+ },
+ "toutiao": {
+ "extVersion": "1.0.2",
+ "minVersion": ""
+ },
+ "baidu": {
+ "extVersion": "1.0.2",
+ "minVersion": ""
+ },
+ "kuaishou": {
+ "extVersion": "1.1.0",
+ "minVersion": ""
+ },
+ "jd": {
+ "extVersion": "1.0.2",
+ "minVersion": ""
+ },
+ "harmony": "x",
+ "qq": "-",
+ "lark": "-"
+ },
+ "quickapp": {
+ "huawei": "-",
+ "union": "-"
+ }
},
- "H5-mobile": {
- "Safari": "y",
- "Android Browser": "y",
- "寰俊娴忚鍣�(Android)": "y",
- "QQ娴忚鍣�(Android)": "y"
- },
- "H5-pc": {
- "Chrome": "y",
- "IE": "y",
- "Edge": "y",
- "Firefox": "y",
- "Safari": "y"
- },
- "灏忕▼搴�": {
- "寰俊": "y",
- "闃块噷": "y",
- "鐧惧害": "y",
- "瀛楄妭璺冲姩": "y",
- "QQ": "y"
- },
- "蹇簲鐢�": {
- "鍗庝负": "u",
- "鑱旂洘": "u"
- },
- "Vue": {
- "vue2": "y",
- "vue3": "y"
+ "uni-app-x": {
+ "web": {
+ "safari": "-",
+ "chrome": "-"
+ },
+ "app": {
+ "android": "-",
+ "ios": "-",
+ "harmony": "-"
+ },
+ "mp": {
+ "weixin": "-"
+ }
}
}
}
--
Gitblit v1.8.0