1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
| <template> <div class="video-container"> <mTikTok ref="mTikTokRef" :video-list="state.videoList" @loadMore="loadMore" @change="change" > <template v-slot="data"> <view class="video-side-right" :class="{ active: state.cutVideo.id === data.item.id }" > <view class="action-item action-item-user"> <image class="shop-logo" src="https://examples-1251000004.cos.ap-shanghai.myqcloud.com/sample.jpeg?imageMogr2/crop/180x180/gravity/center" /> <view class="action-btn"> <text class="iconfont">+</text> </view> <text class="action-item-text"></text> </view> <view class="action-item"> <text class="iconfont icon-star11beifen">❤</text> <text class="action-item-text">{{ data.item.fav }}</text> </view> <view class="action-item"> <text class="iconfont icon-share">☝</text> <text class="action-item-text">分享</text> </view> </view> <view class="video-bottom-area" :class="{ active: state.cutVideo.id === data.item.id }" > <view class="shop-name"> @{{ data.item.name }} </view> <view class="shop-card">{{ data.item.desc }}</view> </view> </template> </mTikTok> </div> </template> <script lang="ts" setup> import { onMounted, reactive, ref } from "vue"; // 导入组件 import mTikTok from "@/components/mTikTok.vue";
const mTikTokRef = ref<InstanceType<typeof mTikTok>>();
const state = reactive({ cutVideo: {} as AnyObject, videoList: [ { src: "https://sns-video-hw.xhscdn.com/stream/1/110/258/01e8dda817e899370103700199a1dfa9b2_258.mp4", id: "1", name: "开玩笑的鸡毛", fav: 154, desc: "这里是简介内容", }, { src: "https://sns-video-hw.xhscdn.com/stream/79/110/258/01e8ef3a5e7fd48f4f03700199e67c96fa_258.mp4", id: "2", name: "开玩笑的鸡毛", fav: 1544, desc: "这里是简介内容", }, { src: "https://sns-video-hw.xhscdn.com/stream/79/110/258/01e8e5fa652aa89b4f03700199c25a5e16_258.mp4", id: "3", name: "开玩笑的鸡毛", fav: 457, desc: "这里是简介内容", }, { src: "https://sns-video-hw.xhscdn.com/stream/1/110/258/01e8ec727be8bc9a0103700199dba00279_258.mp4", id: "4", name: "开玩笑的鸡毛", fav: 44, desc: "这里是简介内容", }, { src: "https://sns-video-hw.xhscdn.com/stream/79/110/258/01e8dca9ade7eb494f037001999df7cd33_258.mp4", id: "5", name: "开玩笑的鸡毛", fav: 4154, desc: "这里是简介内容", }, { src: "https://sns-video-hw.xhscdn.com/stream/1/110/258/01e8e24eace7c4880103700199b4049ff4_258.mp4", id: "6", name: "开玩笑的鸡毛", fav: 1054, desc: "这里是简介内容", }, { src: "https://sns-video-hw.xhscdn.com/stream/79/110/258/01e8de25bddb4b714f03700199a3c3a989_258.mp4", id: "7", name: "开玩笑的鸡毛", fav: 8154, desc: "这里是简介内容", }, ], });
const loadMore = () => { // 触发加载更多 console.log("加载更多"); };
const change = (e: any) => { state.cutVideo = e.detail; console.log("🚀 ~ file: index.vue:53 ~ change ~ data:", e); };
// 播放第几个 const playIndex = (index: number) => { mTikTokRef.value?.initSwiperData(index); };
onMounted(() => { // 直接播放第3个 // playIndex(3); }); </script> <style lang="scss"> $zIndex: 99;
.video-layer { position: absolute; right: 12px; bottom: 120px; color: #fff; }
.video-bottom-area { position: absolute; left: 20px; bottom: 40px; opacity: 0; transition: all 250ms; z-index: 0;
&.active { opacity: 1; z-index: $zIndex; transition-delay: 200ms; }
.shop-name { color: #fff; margin-bottom: 6px; }
.shop-card { width: 160px; height: 80px; background-color: rgba(255, 255, 255, 0.5); border-radius: 4px; } }
.video-side-right { position: absolute; right: 12px; bottom: 120px; color: #fff; opacity: 0; transition: all 250ms; z-index: 0;
&.active { opacity: 1; z-index: $zIndex; transition-delay: 200ms; }
.action-item { position: relative; margin-bottom: 20px; text-align: center;
.shop-logo { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; }
.iconfont { display: block; font-size: 28px; }
.action-item-text { display: block; font-size: 12px; }
.action-btn { position: absolute; left: 50%; transform: translateX(-50%); bottom: -8px; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background-color: #f60;
.iconfont { font-size: 16px; } } }
.action-item-user { margin-bottom: 40px; } } </style>
|