VideoPlayer.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385
  1. <template>
  2. <section class="space-y-6">
  3. <!-- 返回按钮 -->
  4. <div class="flex items-center justify-between">
  5. <div class="flex items-center gap-3">
  6. <button
  7. @click="goBack"
  8. class="flex items-center gap-2 text-white/80 hover:text-white transition"
  9. >
  10. <svg
  11. class="w-5 h-5"
  12. fill="none"
  13. stroke="currentColor"
  14. viewBox="0 0 24 24"
  15. >
  16. <path
  17. stroke-linecap="round"
  18. stroke-linejoin="round"
  19. stroke-width="2"
  20. d="M15 19l-7-7 7-7"
  21. />
  22. </svg>
  23. <span class="text-sm">返回</span>
  24. </button>
  25. <div class="relative">
  26. <button
  27. @click="toggleShare"
  28. class="p-2 rounded-lg bg-white/5 border border-white/10 text-white/70 hover:bg-white/10 hover:text-white transition"
  29. >
  30. <svg
  31. class="w-5 h-5"
  32. fill="none"
  33. stroke="currentColor"
  34. viewBox="0 0 24 24"
  35. >
  36. <path
  37. stroke-linecap="round"
  38. stroke-linejoin="round"
  39. stroke-width="2"
  40. d="M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.367 2.684 3 3 0 00-5.367-2.684z"
  41. />
  42. </svg>
  43. </button>
  44. <!-- 分享提示弹窗 -->
  45. <div
  46. v-if="showShareModal"
  47. class="absolute top-0 left-full ml-2 z-50 bg-emerald-500 text-white px-3 py-1.5 rounded-lg shadow-lg flex items-center gap-1.5 whitespace-nowrap"
  48. >
  49. <svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20">
  50. <path
  51. fill-rule="evenodd"
  52. d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1-0 011.414 0z"
  53. clip-rule="evenodd"
  54. />
  55. </svg>
  56. <span class="text-xs font-medium">已复制</span>
  57. </div>
  58. </div>
  59. </div>
  60. <!-- 购买按钮区域 -->
  61. <div
  62. v-if="!isSinglePurchased && !isVip"
  63. class="flex items-center gap-1.5"
  64. >
  65. <!-- 游客和免费用户显示试看时间信息 -->
  66. <div v-if="isGuestOrFree" class="text-xs text-white/60 px-2 py-1">
  67. 试看 {{ trialDuration }} 秒
  68. </div>
  69. <!-- 只有非游客用户才显示购买会员按钮 -->
  70. <button
  71. v-if="!isGuest"
  72. @click="handleMembershipClick"
  73. class="px-2 py-1 rounded-md bg-brand text-slate-900 text-xs font-medium hover:bg-brand/90 transition whitespace-nowrap min-w-fit"
  74. >
  75. 开通会员
  76. </button>
  77. <button
  78. @click="handleSinglePurchaseClick"
  79. class="px-3 py-2 rounded-lg bg-blue-500 text-white text-sm font-semibold hover:bg-blue-600 transition shadow-lg hover:shadow-xl flash-animation glow-animation hover:animate-none whitespace-nowrap min-w-fit"
  80. >
  81. 单片购买
  82. </button>
  83. </div>
  84. </div>
  85. <!-- 视频播放器区域 -->
  86. <div class="relative rounded-2xl overflow-hidden bg-black">
  87. <div class="aspect-video video-container">
  88. <VideoProcessor
  89. ref="videoProcessorRef"
  90. :cover-url="videoInfo.cover"
  91. :m3u8-url="videoInfo.m3u8"
  92. :alt="videoInfo.name"
  93. :auto-play="false"
  94. :hide-error="false"
  95. :enable-retry="true"
  96. cover-class="w-full h-full object-cover"
  97. video-class="w-full h-full object-contain"
  98. @cover-loaded="onCoverLoaded"
  99. @video-loaded="onVideoLoaded"
  100. @error="onVideoProcessorError"
  101. @retry="onVideoProcessorRetry"
  102. @play="onVideoPlay"
  103. @timeupdate="onVideoTimeUpdate"
  104. @seeking="onVideoSeeking"
  105. />
  106. <!-- 试看提示 -->
  107. <div
  108. v-if="isTrialMode"
  109. class="absolute top-4 right-4 text-white px-3 py-1.5 text-sm font-medium"
  110. >
  111. 试看中
  112. </div>
  113. <!-- 试看结束遮罩 -->
  114. <div
  115. v-if="showTrialEndModal && !isSinglePurchased && !isVip"
  116. class="absolute inset-0 bg-black/80 flex items-center justify-center z-50"
  117. >
  118. <div
  119. class="bg-white/10 backdrop-blur-sm rounded-2xl p-6 max-w-sm mx-4 text-center"
  120. >
  121. <div class="text-white text-lg font-semibold mb-4">
  122. 试看时间已结束
  123. </div>
  124. <div class="text-white/70 text-sm mb-6">
  125. <span v-if="!isGuest">购买会员或单独购买本片继续观看</span>
  126. <span v-else>单独购买本片继续观看</span>
  127. </div>
  128. <div class="space-y-3">
  129. <!-- 只有非游客用户才显示购买会员按钮 -->
  130. <button
  131. v-if="!isGuest"
  132. @click="purchaseMembership"
  133. class="w-full bg-brand hover:bg-brand/90 text-slate-900 py-3 px-4 rounded-lg font-medium transition whitespace-nowrap"
  134. >
  135. 开通会员
  136. </button>
  137. <button
  138. @click="purchaseVideo"
  139. class="w-full bg-blue-500 hover:bg-blue-600 text-white py-3 px-4 rounded-lg font-semibold transition shadow-lg hover:shadow-xl flash-animation glow-animation hover:animate-none whitespace-nowrap"
  140. >
  141. 单独购买本片
  142. </button>
  143. <button
  144. @click="showTrialEndModal = false"
  145. class="w-full text-white/60 hover:text-white/80 py-2 text-sm transition"
  146. >
  147. 取消
  148. </button>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <!-- 单片购买确认弹窗 -->
  155. <div
  156. v-if="showSinglePurchaseModal"
  157. class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
  158. @click.self="showSinglePurchaseModal = false"
  159. >
  160. <div
  161. class="bg-surface border border-white/10 rounded-2xl p-6 w-full max-w-sm mx-4 text-center"
  162. >
  163. <h3 class="text-lg font-semibold text-white/90 mb-2">确认购买</h3>
  164. <p class="text-sm text-white/70 mb-4">
  165. 确定要购买当前视频吗?<br />
  166. 购买后即可观看完整内容
  167. </p>
  168. <div class="text-lg font-semibold text-brand mb-6">
  169. ¥{{ priceStore.getSinglePrice() }}
  170. </div>
  171. <div class="space-y-3">
  172. <button
  173. @click="purchaseVideo"
  174. class="w-full bg-blue-500 hover:bg-blue-600 text-white py-3 px-4 rounded-lg font-semibold transition shadow-lg hover:shadow-xl flash-animation glow-animation hover:animate-none whitespace-nowrap"
  175. >
  176. 确认购买
  177. </button>
  178. <button
  179. @click="showSinglePurchaseModal = false"
  180. class="w-full text-white/60 hover:text-white/80 py-2 text-sm transition"
  181. >
  182. 取消
  183. </button>
  184. </div>
  185. </div>
  186. </div>
  187. <!-- 会员购买弹窗 -->
  188. <div
  189. v-if="showMembershipPurchaseModal"
  190. class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
  191. @click.self="showMembershipPurchaseModal = false"
  192. >
  193. <div
  194. class="bg-surface border border-white/10 rounded-2xl p-4 w-full max-w-sm mx-4"
  195. >
  196. <h3 class="text-lg font-semibold text-white/90 mb-4 text-center">
  197. 开通会员
  198. </h3>
  199. <!-- 会员套餐选择 -->
  200. <div class="space-y-2 mb-3">
  201. <h4 class="text-sm font-medium text-white/70 mb-2">选择套餐</h4>
  202. <div class="space-y-2">
  203. <label
  204. v-for="plan in membershipPlans"
  205. :key="plan.key"
  206. class="relative cursor-pointer"
  207. >
  208. <input
  209. v-model="selectedPlan"
  210. :value="plan.key"
  211. type="radio"
  212. name="membership-plan"
  213. class="sr-only"
  214. />
  215. <div
  216. class="border-2 rounded-lg p-2 transition-all"
  217. :class="
  218. selectedPlan === plan.key
  219. ? 'border-brand bg-brand/10'
  220. : 'border-white/20 hover:border-white/30'
  221. "
  222. >
  223. <div class="flex justify-between items-center">
  224. <div
  225. class="font-medium text-white/90 text-sm whitespace-nowrap"
  226. >
  227. {{ plan.label }} - {{ plan.duration }}
  228. </div>
  229. <div class="font-semibold text-white/90 text-sm">
  230. {{ plan.price }}
  231. </div>
  232. </div>
  233. </div>
  234. </label>
  235. </div>
  236. </div>
  237. <!-- 支付方式选择 -->
  238. <div class="mb-3">
  239. <h4 class="text-sm font-medium text-white/70 mb-2">支付方式</h4>
  240. <label
  241. class="flex items-center p-2 border border-white/20 rounded-lg cursor-pointer hover:bg-white/5"
  242. >
  243. <input
  244. v-model="selectedPayment"
  245. value="alipay"
  246. type="radio"
  247. name="payment-method"
  248. class="sr-only"
  249. />
  250. <div class="flex items-center">
  251. <div
  252. class="w-6 h-6 bg-blue-500 rounded flex items-center justify-center mr-3"
  253. >
  254. <span class="text-white text-sm font-bold">支</span>
  255. </div>
  256. <span class="text-white/90 text-sm">支付宝</span>
  257. </div>
  258. </label>
  259. </div>
  260. <!-- 操作按钮 -->
  261. <div class="flex gap-2 pt-3 border-t border-white/10">
  262. <button
  263. type="button"
  264. @click="showMembershipPurchaseModal = false"
  265. class="flex-1 px-3 py-2 border border-white/20 text-white/70 rounded-lg hover:bg-white/5 transition text-sm"
  266. >
  267. 取消
  268. </button>
  269. <button
  270. @click="handleMembershipPurchase"
  271. :disabled="!selectedPlan || isPaymentLoading"
  272. class="flex-1 px-3 py-2 bg-brand text-slate-900 rounded-lg hover:bg-brand/90 transition disabled:opacity-50 disabled:cursor-not-allowed text-sm"
  273. >
  274. {{ isPaymentLoading ? "处理中..." : "立即购买" }}
  275. </button>
  276. </div>
  277. </div>
  278. </div>
  279. <!-- 支付等待弹窗 -->
  280. <div
  281. v-if="showPaymentWaitingDialog"
  282. class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
  283. >
  284. <div
  285. class="bg-surface border border-white/10 rounded-2xl p-8 w-full max-w-sm mx-4 text-center"
  286. >
  287. <!-- 加载动画 -->
  288. <div class="mb-6">
  289. <div
  290. class="w-16 h-16 mx-auto border-4 border-white/20 border-t-brand rounded-full animate-spin"
  291. ></div>
  292. </div>
  293. <!-- 等待文字 -->
  294. <h3 class="text-lg font-semibold text-white/90 mb-2">
  295. 正在拉起支付页面,等待支付...
  296. </h3>
  297. <p class="text-sm text-white/60 mb-6">
  298. 请在支付页面完成支付<br />
  299. 支付完成后点击已完成支付
  300. </p>
  301. <!-- 操作按钮 -->
  302. <div class="flex gap-3">
  303. <button
  304. @click="showPaymentWaitingDialog = false"
  305. class="flex-1 px-4 py-2 border border-white/20 text-white/70 rounded-lg hover:bg-white/5 transition"
  306. >
  307. 取消支付
  308. </button>
  309. <button
  310. @click="handleQueryOrder"
  311. class="flex-1 px-4 py-2 bg-brand text-slate-900 rounded-lg hover:bg-brand/90 transition"
  312. >
  313. 已完成支付
  314. </button>
  315. </div>
  316. </div>
  317. </div>
  318. <!-- 单片购买支付等待弹窗 -->
  319. <div
  320. v-if="showSinglePaymentWaitingDialog"
  321. class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
  322. >
  323. <div
  324. class="bg-surface border border-white/10 rounded-2xl p-8 w-full max-w-sm mx-4 text-center"
  325. >
  326. <!-- 加载动画 -->
  327. <div class="mb-6">
  328. <div
  329. class="w-16 h-16 mx-auto border-4 border-white/20 border-t-brand rounded-full animate-spin"
  330. ></div>
  331. </div>
  332. <!-- 等待文字 -->
  333. <h3 class="text-lg font-semibold text-white/90 mb-2">
  334. 正在拉起支付页面,等待支付...
  335. </h3>
  336. <p class="text-sm text-white/60 mb-6">
  337. 请在支付页面完成支付<br />
  338. 支付完成后点击已完成支付
  339. </p>
  340. <!-- 操作按钮 -->
  341. <div class="flex gap-3">
  342. <button
  343. @click="showSinglePaymentWaitingDialog = false"
  344. class="flex-1 px-4 py-2 border border-white/20 text-white/70 rounded-lg hover:bg-white/5 transition"
  345. >
  346. 取消支付
  347. </button>
  348. <button
  349. @click="handleSingleQueryOrder"
  350. class="flex-1 px-4 py-2 bg-brand text-slate-900 rounded-lg hover:bg-brand/90 transition"
  351. >
  352. 已完成支付
  353. </button>
  354. </div>
  355. </div>
  356. </div>
  357. <!-- 错误提示弹窗 -->
  358. <div
  359. v-if="showErrorDialog"
  360. class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
  361. @click.self="showErrorDialog = false"
  362. >
  363. <div
  364. class="bg-surface border border-white/10 rounded-2xl p-6 w-full max-w-sm mx-4 text-center"
  365. >
  366. <!-- 错误图标 -->
  367. <div class="mb-4">
  368. <div
  369. class="w-12 h-12 mx-auto bg-red-500/20 rounded-full flex items-center justify-center"
  370. >
  371. <svg
  372. class="w-6 h-6 text-red-400"
  373. fill="none"
  374. stroke="currentColor"
  375. viewBox="0 0 24 24"
  376. >
  377. <path
  378. stroke-linecap="round"
  379. stroke-linejoin="round"
  380. stroke-width="2"
  381. d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"
  382. />
  383. </svg>
  384. </div>
  385. </div>
  386. <!-- 错误信息 -->
  387. <h3 class="text-lg font-semibold text-white/90 mb-2">操作失败</h3>
  388. <p class="text-sm text-white/70 mb-6">
  389. {{ errorMessage }}
  390. </p>
  391. <!-- 确认按钮 -->
  392. <button
  393. @click="showErrorDialog = false"
  394. class="w-full px-4 py-2 bg-brand text-slate-900 rounded-lg hover:bg-brand/90 transition"
  395. >
  396. 确定
  397. </button>
  398. </div>
  399. </div>
  400. <!-- 成功提示弹窗 -->
  401. <div
  402. v-if="showSuccessDialog"
  403. class="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
  404. @click.self="showSuccessDialog = false"
  405. >
  406. <div
  407. class="bg-surface border border-white/10 rounded-2xl p-6 w-full max-w-sm mx-4 text-center"
  408. >
  409. <!-- 成功图标 -->
  410. <div class="mb-4">
  411. <div
  412. class="w-12 h-12 mx-auto bg-green-500/20 rounded-full flex items-center justify-center"
  413. >
  414. <svg
  415. class="w-6 h-6 text-green-400"
  416. fill="none"
  417. stroke="currentColor"
  418. viewBox="0 0 24 24"
  419. >
  420. <path
  421. stroke-linecap="round"
  422. stroke-linejoin="round"
  423. stroke-width="2"
  424. d="M5 13l4 4L19 7"
  425. />
  426. </svg>
  427. </div>
  428. </div>
  429. <!-- 成功信息 -->
  430. <h3 class="text-lg font-semibold text-white/90 mb-2">操作成功</h3>
  431. <p class="text-sm text-white/70 mb-6">
  432. {{ successMessage }}
  433. </p>
  434. <!-- 确认按钮 -->
  435. <button
  436. @click="showSuccessDialog = false"
  437. class="w-full px-4 py-2 bg-brand text-slate-900 rounded-lg hover:bg-brand/90 transition"
  438. >
  439. 确定
  440. </button>
  441. </div>
  442. </div>
  443. <!-- 视频信息区域 -->
  444. <div class="space-y-6">
  445. <!-- 视频标题和基本信息 -->
  446. <div class="space-y-3">
  447. <h1 class="text-xl font-semibold text-white leading-tight">
  448. {{ videoInfo.name || "视频标题" }}
  449. </h1>
  450. <div class="flex items-center gap-4 text-sm text-white/60">
  451. <div class="flex items-center gap-1">
  452. <svg
  453. class="w-4 h-4"
  454. fill="none"
  455. stroke="currentColor"
  456. viewBox="0 0 24 24"
  457. >
  458. <path
  459. stroke-linecap="round"
  460. stroke-linejoin="round"
  461. stroke-width="2"
  462. d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
  463. />
  464. </svg>
  465. <span>{{ formatDuration(videoInfo.duration) }}</span>
  466. </div>
  467. <div class="flex items-center gap-1">
  468. <svg
  469. class="w-4 h-4"
  470. fill="none"
  471. stroke="currentColor"
  472. viewBox="0 0 24 24"
  473. >
  474. <path
  475. stroke-linecap="round"
  476. stroke-linejoin="round"
  477. stroke-width="2"
  478. d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
  479. />
  480. <path
  481. stroke-linecap="round"
  482. stroke-linejoin="round"
  483. stroke-width="2"
  484. d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
  485. />
  486. </svg>
  487. <span>{{ formatNumber(videoInfo.view) }} 次观看</span>
  488. </div>
  489. <div class="flex items-center gap-1">
  490. <svg
  491. class="w-4 h-4"
  492. fill="none"
  493. stroke="currentColor"
  494. viewBox="0 0 24 24"
  495. >
  496. <path
  497. stroke-linecap="round"
  498. stroke-linejoin="round"
  499. stroke-width="2"
  500. d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
  501. />
  502. </svg>
  503. <span>{{ formatNumber(videoInfo.like) }} 点赞</span>
  504. </div>
  505. </div>
  506. </div>
  507. <!-- 标签信息 -->
  508. <!-- <div
  509. v-if="videoInfo.taginfo && videoInfo.taginfo.length > 0"
  510. class="space-y-3"
  511. >
  512. <h3 class="text-sm font-medium text-white/80">标签</h3>
  513. <div class="flex flex-wrap gap-2">
  514. <span
  515. v-for="tag in videoInfo.taginfo"
  516. :key="tag.hash"
  517. class="px-3 py-1.5 rounded-full bg-white/5 border border-white/10 text-xs text-white/70 hover:bg-white/10 hover:text-white transition"
  518. >
  519. {{ tag.name }}
  520. </span>
  521. </div>
  522. </div> -->
  523. <!-- 相关推荐 -->
  524. <div v-if="relatedVideos.length > 0" class="space-y-4">
  525. <h3 class="text-sm font-medium text-white/80">相关推荐</h3>
  526. <div class="grid grid-cols-2 gap-3">
  527. <article
  528. v-for="video in relatedVideos.slice(0, 12)"
  529. :key="video.id"
  530. @click="playVideo(video)"
  531. class="group rounded-xl overflow-hidden bg-white/5 border border-white/10 cursor-pointer hover:bg-white/10 transition"
  532. >
  533. <!-- 横屏封面 -->
  534. <div class="aspect-[16/9] relative">
  535. <VideoProcessor
  536. :cover-url="video.cover"
  537. :alt="video.name"
  538. cover-class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"
  539. />
  540. <div
  541. class="absolute bottom-2 right-2 bg-black/70 text-white text-xs px-2 py-1 rounded"
  542. >
  543. {{ formatDuration(video.duration) }}
  544. </div>
  545. </div>
  546. <!-- 视频信息 -->
  547. <div class="p-3">
  548. <h4 class="text-sm font-medium text-white/90 line-clamp-2 mb-1">
  549. {{ video.name }}
  550. </h4>
  551. <p class="text-xs text-white/50 truncate">
  552. {{ formatNumber(video.view) }} 次观看 ·
  553. {{ formatNumber(video.like) }} 点赞
  554. </p>
  555. <!-- 标签信息(移动端隐藏) -->
  556. <div
  557. v-if="video.taginfo && video.taginfo.length > 0"
  558. class="hidden sm:flex flex-wrap gap-1 mt-2"
  559. >
  560. <span
  561. v-for="tag in video.taginfo.slice(0, 2)"
  562. :key="tag.hash"
  563. class="px-2 py-0.5 rounded-full bg-white/5 border border-white/10 text-xs text-white/70"
  564. >
  565. {{ tag.name }}
  566. </span>
  567. <span
  568. v-if="video.taginfo.length > 2"
  569. class="px-2 py-0.5 rounded-full bg-white/5 border border-white/10 text-xs text-white/50"
  570. >
  571. +{{ video.taginfo.length - 2 }}
  572. </span>
  573. </div>
  574. </div>
  575. </article>
  576. </div>
  577. </div>
  578. </div>
  579. </section>
  580. </template>
  581. <script setup lang="ts">
  582. import { ref, onMounted, onUnmounted, computed, watch } from "vue";
  583. import { useRoute, useRouter } from "vue-router";
  584. import {
  585. searchVideoByTags,
  586. getVideoDetail,
  587. purchaseSingle,
  588. purchaseMember,
  589. userQueryOrder,
  590. checkSinglePurchase,
  591. } from "@/services/api";
  592. import VideoProcessor from "@/components/VideoProcessor.vue";
  593. import { useUserStore } from "@/store/user";
  594. import { usePriceStore } from "@/store/price";
  595. import { VipLevel, canWatchFullVideo, getTrialDuration } from "@/types/vip";
  596. // 路由相关
  597. const route = useRoute();
  598. const router = useRouter();
  599. // 用户状态
  600. const userStore = useUserStore();
  601. const priceStore = usePriceStore();
  602. // 视频播放器引用(现在由 VideoProcessor 组件管理)
  603. const videoPlayer = ref<HTMLVideoElement>();
  604. const videoProcessorRef = ref<any>();
  605. // 视频信息
  606. const videoInfo = ref<any>({
  607. id: "",
  608. name: "",
  609. cover: "",
  610. m3u8: "",
  611. duration: 0,
  612. view: 0,
  613. like: 0,
  614. time: 0,
  615. taginfo: [],
  616. });
  617. // 相关视频
  618. const relatedVideos = ref<any[]>([]);
  619. // 状态管理
  620. const showShareModal = ref(false);
  621. const showTrialEndModal = ref(false);
  622. const showMembershipPurchaseModal = ref(false);
  623. const showSinglePurchaseModal = ref(false);
  624. const isTrialMode = ref(false);
  625. // 单片购买状态
  626. const isSinglePurchased = ref(false);
  627. // 使用动态价格配置
  628. const membershipPlans = computed(() => priceStore.getMembershipPlans);
  629. const selectedPlan = ref("");
  630. const selectedPayment = ref("alipay");
  631. const isPaymentLoading = ref(false);
  632. // 支付等待相关
  633. const showPaymentWaitingDialog = ref(false);
  634. const currentOrderNo = ref("");
  635. // 提示弹窗相关
  636. const showSuccessDialog = ref(false);
  637. const showErrorDialog = ref(false);
  638. const successMessage = ref("");
  639. const errorMessage = ref("");
  640. // 单片购买支付等待相关
  641. const showSinglePaymentWaitingDialog = ref(false);
  642. const singleCurrentOrderNo = ref("");
  643. // 检测是否为夸克浏览器
  644. const isQuarkBrowser = () => {
  645. const ua = navigator.userAgent.toLowerCase();
  646. return ua.includes('quark');
  647. };
  648. // 显示成功/错误提示的函数
  649. const showSuccess = (message: string) => {
  650. successMessage.value = message;
  651. showSuccessDialog.value = true;
  652. // 夸克浏览器自动滚动到底部
  653. if (isQuarkBrowser()) {
  654. setTimeout(() => {
  655. window.scrollTo({
  656. top: document.documentElement.scrollHeight,
  657. behavior: 'smooth'
  658. });
  659. }, 100);
  660. }
  661. };
  662. const showError = (message: string) => {
  663. errorMessage.value = message;
  664. showErrorDialog.value = true;
  665. // 夸克浏览器自动滚动到底部
  666. if (isQuarkBrowser()) {
  667. setTimeout(() => {
  668. window.scrollTo({
  669. top: document.documentElement.scrollHeight,
  670. behavior: 'smooth'
  671. });
  672. }, 100);
  673. }
  674. };
  675. // 生成设备标识
  676. const generateMacAddress = (): string => {
  677. const hex = "0123456789ABCDEF";
  678. let mac = "";
  679. for (let i = 0; i < 6; i++) {
  680. if (i > 0) mac += ":";
  681. mac += hex[Math.floor(Math.random() * 16)];
  682. mac += hex[Math.floor(Math.random() * 16)];
  683. }
  684. return mac;
  685. };
  686. const device = generateMacAddress();
  687. // Safari兼容性处理:打开支付页面
  688. const openPaymentPage = (url: string) => {
  689. // 检测是否为Safari浏览器
  690. const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  691. if (isSafari) {
  692. // Safari浏览器
  693. setTimeout(() => window.open(url, "_blank"));
  694. // window.location.href = url;
  695. } else {
  696. // 其他浏览器:正常使用window.open
  697. window.open(url, "_blank");
  698. }
  699. };
  700. // 计算属性
  701. const currentVipLevel = computed(() => userStore.getVipLevel());
  702. const isGuestOrFree = computed(() => !canWatchFullVideo(currentVipLevel.value));
  703. const trialDuration = computed(() => getTrialDuration(priceStore));
  704. // 参考Account.vue的用户类型判断
  705. const isGuest = computed(() => {
  706. return userStore.userInfo?.vipLevel === "guest";
  707. });
  708. const isVip = computed(() => {
  709. const level = userStore.userInfo?.vipLevel;
  710. return level && level !== VipLevel.GUEST && level !== VipLevel.FREE;
  711. });
  712. // VideoProcessor 事件处理
  713. const onCoverLoaded = (url: string) => {
  714. // 封面加载完成
  715. };
  716. const onVideoLoaded = (url: string) => {
  717. // 视频加载完成
  718. };
  719. const onVideoProcessorError = (error: string) => {
  720. console.error("VideoProcessor 错误:", error);
  721. };
  722. const onVideoProcessorRetry = () => {
  723. // VideoProcessor 重试
  724. };
  725. const onVideoPlay = () => {
  726. // 如果是guest或free用户且还没有开始试看,且未购买当前视频,则开始试看
  727. if (isGuestOrFree.value && !isTrialMode.value && !isSinglePurchased.value) {
  728. startTrial();
  729. }
  730. };
  731. // 监听视频播放进度
  732. const onVideoTimeUpdate = () => {
  733. if (isGuestOrFree.value && isTrialMode.value) {
  734. const video = document.querySelector("video");
  735. if (video && video.currentTime > trialDuration.value) {
  736. // 超过试看时间,停止播放并显示购买弹窗
  737. video.pause();
  738. // 将视频时间重置到试看结束时间
  739. video.currentTime = trialDuration.value;
  740. // 停止HLS加载
  741. if (videoProcessorRef.value) {
  742. videoProcessorRef.value.stopHlsLoading();
  743. }
  744. showTrialEndModal.value = true;
  745. }
  746. }
  747. };
  748. // 监听视频时间变化(包括拖拽进度条)
  749. const onVideoSeeking = () => {
  750. if (isGuestOrFree.value && isTrialMode.value) {
  751. const video = document.querySelector("video");
  752. if (video && video.currentTime > trialDuration.value) {
  753. // 如果拖拽到超过试看时间,强制回到试看结束时间
  754. video.currentTime = trialDuration.value;
  755. }
  756. }
  757. };
  758. // 格式化时长
  759. const formatDuration = (duration: string | number): string => {
  760. const seconds = parseInt(String(duration));
  761. const minutes = Math.floor(seconds / 60);
  762. const remainingSeconds = seconds % 60;
  763. return `${minutes}:${remainingSeconds.toString().padStart(2, "0")}`;
  764. };
  765. // 格式化数字
  766. const formatNumber = (num: string | number): string => {
  767. const n = parseInt(String(num));
  768. if (n >= 10000) {
  769. return `${(n / 10000).toFixed(1)}万`;
  770. }
  771. return n.toString();
  772. };
  773. // 返回上一页
  774. const goBack = () => {
  775. router.back();
  776. };
  777. // 分享视频(直接复制链接并显示提示)
  778. const toggleShare = async () => {
  779. try {
  780. const videoUrl = window.location.href;
  781. await navigator.clipboard.writeText(videoUrl);
  782. showShareModal.value = true;
  783. // 1秒后自动隐藏提示
  784. setTimeout(() => {
  785. showShareModal.value = false;
  786. }, 1000);
  787. } catch (error) {
  788. console.error("复制链接失败:", error);
  789. }
  790. };
  791. // 播放视频
  792. const playVideo = (video: any) => {
  793. const vipLevel = userStore.getVipLevel();
  794. if (vipLevel === VipLevel.GUEST || vipLevel === VipLevel.FREE) {
  795. // guest和free用户通过URL参数传递cover和m3u8,同时包含视频ID
  796. router.push({
  797. name: "VideoPlayer",
  798. params: { id: video.id },
  799. query: {
  800. cover: video.cover,
  801. m3u8: video.m3u8,
  802. name: video.name,
  803. duration: video.duration,
  804. view: video.view,
  805. like: video.like,
  806. },
  807. });
  808. } else {
  809. // 其他VIP用户正常调用详情接口
  810. router.push({
  811. name: "VideoPlayer",
  812. params: { id: video.id },
  813. });
  814. }
  815. // 滚动到页面顶端
  816. window.scrollTo({
  817. top: 0,
  818. behavior: "smooth",
  819. });
  820. };
  821. // 开始试看
  822. const startTrial = () => {
  823. isTrialMode.value = true;
  824. };
  825. // 处理顶部会员购买按钮点击
  826. const handleMembershipClick = () => {
  827. showMembershipPurchaseModal.value = true;
  828. // 夸克浏览器自动滚动到底部
  829. if (isQuarkBrowser()) {
  830. setTimeout(() => {
  831. window.scrollTo({
  832. top: document.documentElement.scrollHeight,
  833. behavior: 'smooth'
  834. });
  835. }, 100);
  836. }
  837. };
  838. // 处理顶部单片购买按钮点击
  839. const handleSinglePurchaseClick = () => {
  840. showSinglePurchaseModal.value = true;
  841. // 夸克浏览器自动滚动到底部
  842. if (isQuarkBrowser()) {
  843. setTimeout(() => {
  844. window.scrollTo({
  845. top: document.documentElement.scrollHeight,
  846. behavior: 'smooth'
  847. });
  848. }, 100);
  849. }
  850. };
  851. // 购买会员
  852. const purchaseMembership = () => {
  853. // 关闭试看结束弹窗
  854. showTrialEndModal.value = false;
  855. // 打开会员购买弹窗
  856. showMembershipPurchaseModal.value = true;
  857. // 夸克浏览器自动滚动到底部
  858. if (isQuarkBrowser()) {
  859. setTimeout(() => {
  860. window.scrollTo({
  861. top: document.documentElement.scrollHeight,
  862. behavior: 'smooth'
  863. });
  864. }, 100);
  865. }
  866. };
  867. // 处理会员购买
  868. const handleMembershipPurchase = async () => {
  869. if (!selectedPlan.value) {
  870. showError("请选择会员套餐");
  871. return;
  872. }
  873. isPaymentLoading.value = true;
  874. try {
  875. const response = await purchaseMember(
  876. userStore.userInfo.id,
  877. selectedPlan.value
  878. );
  879. if (response.code === 1) {
  880. // 保存订单号
  881. currentOrderNo.value = response.out_trade_no;
  882. // 关闭购买弹窗
  883. showMembershipPurchaseModal.value = false;
  884. // Safari兼容性处理:使用多种方式打开支付页面
  885. // openPaymentPage(response.code_url);
  886. setTimeout(() => window.open(response.code_url, "_blank"));
  887. // 显示支付等待弹窗
  888. showPaymentWaitingDialog.value = true;
  889. // 重置选择
  890. selectedPlan.value = "";
  891. } else {
  892. showError(`支付失败: ${response.msg || "未知错误"}`);
  893. }
  894. } catch (error) {
  895. console.error("购买会员失败", error);
  896. showError("购买失败,请重试");
  897. } finally {
  898. isPaymentLoading.value = false;
  899. }
  900. };
  901. // 查询订单状态
  902. const handleQueryOrder = async () => {
  903. if (!currentOrderNo.value) {
  904. showError("没有找到订单信息");
  905. return;
  906. }
  907. try {
  908. const response = await userQueryOrder(currentOrderNo.value);
  909. if (response.status === 1) {
  910. // 支付成功
  911. await userStore.sync();
  912. showPaymentWaitingDialog.value = false;
  913. showSuccess("会员购买成功!");
  914. currentOrderNo.value = "";
  915. } else {
  916. showError(response.msg || "会员购买失败");
  917. }
  918. } catch (error) {
  919. console.error("查询订单状态失败:", error);
  920. showError("会员购买失败,请重试");
  921. }
  922. };
  923. // 查询单片购买订单状态
  924. const handleSingleQueryOrder = async () => {
  925. if (!singleCurrentOrderNo.value) {
  926. showError("没有找到订单信息");
  927. return;
  928. }
  929. try {
  930. // 使用视频信息的真实ID查询订单
  931. const response = await userQueryOrder(
  932. singleCurrentOrderNo.value,
  933. videoInfo.value.id
  934. );
  935. if (response.status === 1) {
  936. // 支付成功
  937. await userStore.sync();
  938. showSinglePaymentWaitingDialog.value = false;
  939. showSuccess("视频购买成功!");
  940. singleCurrentOrderNo.value = "";
  941. // 重新检查购买状态(已完成支付时的检查)
  942. await checkVideoPurchaseStatus();
  943. } else {
  944. showError(response.msg || "视频购买失败");
  945. }
  946. } catch (error) {
  947. console.error("查询单片购买订单状态失败:", error);
  948. showError("视频购买失败,请重试");
  949. }
  950. };
  951. // 单独购买本片
  952. const purchaseVideo = async () => {
  953. // 夸克浏览器自动滚动到底部
  954. if (isQuarkBrowser()) {
  955. setTimeout(() => {
  956. window.scrollTo({
  957. top: document.documentElement.scrollHeight,
  958. behavior: 'smooth'
  959. });
  960. }, 100);
  961. }
  962. try {
  963. // 使用视频信息的真实ID
  964. if (!videoInfo.value.id || videoInfo.value.id === "unknown") {
  965. showError("未找到视频资源ID");
  966. return;
  967. }
  968. const response = await purchaseSingle(
  969. userStore.userInfo.id,
  970. videoInfo.value.id
  971. );
  972. if (response.code === 1) {
  973. // 保存订单号
  974. singleCurrentOrderNo.value = response.out_trade_no;
  975. // 关闭弹窗
  976. showTrialEndModal.value = false;
  977. showSinglePurchaseModal.value = false;
  978. // Safari兼容性处理:使用多种方式打开支付页面
  979. // openPaymentPage(response.code_url);
  980. setTimeout(() => window.open(response.code_url, "_blank"));
  981. // 显示支付等待弹窗
  982. showSinglePaymentWaitingDialog.value = true;
  983. console.log("单片购买订单创建成功:", response.out_trade_no);
  984. } else {
  985. console.error("单片购买失败:", response.msg);
  986. showError(`购买失败: ${response.msg || "未知错误"}`);
  987. }
  988. } catch (error) {
  989. console.error("单片购买异常:", error);
  990. showError("购买失败,请重试");
  991. }
  992. };
  993. // 检查用户是否已购买当前视频
  994. const checkVideoPurchaseStatus = async () => {
  995. if (!videoInfo.value.id || videoInfo.value.id === "unknown") {
  996. return;
  997. }
  998. try {
  999. const response = await checkSinglePurchase(videoInfo.value.id);
  1000. isSinglePurchased.value = response === true;
  1001. } catch (error) {
  1002. console.error("检查视频购买状态失败:", error);
  1003. isSinglePurchased.value = false;
  1004. }
  1005. };
  1006. // 加载视频信息
  1007. const loadVideoInfo = async () => {
  1008. const vipLevel = userStore.getVipLevel();
  1009. // 获取视频ID(无论什么用户类型都使用相同的获取方式)
  1010. const videoId = route.params.id || route.query.id;
  1011. // 如果是guest或free用户,从query参数获取视频信息
  1012. if (vipLevel === VipLevel.GUEST || vipLevel === VipLevel.FREE) {
  1013. const { cover, m3u8, name, duration, view, like } = route.query;
  1014. if (cover && m3u8) {
  1015. videoInfo.value = {
  1016. id: videoId || "unknown",
  1017. name: name || "试看视频",
  1018. cover: cover as string,
  1019. m3u8: m3u8 as string,
  1020. duration: parseInt(duration as string) || 0,
  1021. view: parseInt(view as string) || 0,
  1022. like: parseInt(like as string) || 0,
  1023. time: 0,
  1024. taginfo: [],
  1025. };
  1026. // 设置页面标题
  1027. document.title = `${videoInfo.value.name} - 试看`;
  1028. return;
  1029. }
  1030. }
  1031. // 其他情况,通过API获取视频详情
  1032. if (videoId) {
  1033. try {
  1034. // 通过API获取视频详情
  1035. const response = await getVideoDetail(device, String(videoId));
  1036. if (response.status === 0 && response.data) {
  1037. const data = response.data;
  1038. videoInfo.value = {
  1039. id: data.id || videoId,
  1040. name: data.name || `视频 ${videoId}`,
  1041. cover: data.cover || "",
  1042. m3u8: data.m3u8 || "",
  1043. duration: data.duration || 0,
  1044. view: data.view || 0,
  1045. like: data.like || 0,
  1046. time: data.time || 0,
  1047. taginfo: data.tags
  1048. ? data.tags
  1049. .split(",")
  1050. .map((tag: string) => ({ name: tag.trim(), hash: tag.trim() }))
  1051. : [],
  1052. };
  1053. // 设置页面标题
  1054. document.title = `${videoInfo.value.name} - 视频播放`;
  1055. } else {
  1056. console.error("获取视频详情失败-1:", response.msg);
  1057. // 设置默认值
  1058. videoInfo.value = {
  1059. id: videoId,
  1060. name: `视频 ${videoId}`,
  1061. cover: "",
  1062. m3u8: "",
  1063. duration: 0,
  1064. view: 0,
  1065. like: 0,
  1066. time: 0,
  1067. taginfo: [],
  1068. };
  1069. }
  1070. } catch (error) {
  1071. console.error("获取视频详情失败-2:", error);
  1072. // 设置默认值
  1073. videoInfo.value = {
  1074. id: videoId,
  1075. name: `视频 ${videoId}`,
  1076. cover: "",
  1077. m3u8: "",
  1078. duration: 0,
  1079. view: 0,
  1080. like: 0,
  1081. time: 0,
  1082. taginfo: [],
  1083. };
  1084. }
  1085. } else {
  1086. console.error("未找到视频ID");
  1087. }
  1088. };
  1089. // 加载相关视频
  1090. const loadRelatedVideos = async () => {
  1091. try {
  1092. // 获取当前视频的标签
  1093. const currentVideoTags = videoInfo.value.taginfo || [];
  1094. if (currentVideoTags.length > 0) {
  1095. // 随机选择一个标签
  1096. const randomTag =
  1097. currentVideoTags[Math.floor(Math.random() * currentVideoTags.length)];
  1098. // 生成1-10之间的随机页码
  1099. const randomPage = Math.floor(Math.random() * 10) + 1;
  1100. // 获取12个该标签下的最热视频
  1101. const response = await searchVideoByTags(
  1102. device,
  1103. randomPage,
  1104. 12,
  1105. randomTag.hash,
  1106. "long",
  1107. "view"
  1108. );
  1109. if (response.status === 0 && response.data?.list) {
  1110. // 过滤掉当前视频
  1111. relatedVideos.value = response.data.list
  1112. .filter((video: any) => video.id !== videoInfo.value.id)
  1113. .slice(0, 12);
  1114. }
  1115. } else {
  1116. // 如果没有标签,则获取全局最热视频
  1117. const randomPage = Math.floor(Math.random() * 10) + 1;
  1118. const response = await searchVideoByTags(
  1119. device,
  1120. randomPage,
  1121. 12,
  1122. undefined,
  1123. "long",
  1124. "view"
  1125. );
  1126. if (response.status === 0 && response.data?.list) {
  1127. relatedVideos.value = response.data.list
  1128. .filter((video: any) => video.id !== videoInfo.value.id)
  1129. .slice(0, 12);
  1130. }
  1131. }
  1132. } catch (error) {
  1133. console.error("加载相关视频失败:", error);
  1134. }
  1135. };
  1136. // 监听路由参数变化
  1137. watch(
  1138. () => route.params.id,
  1139. async (newId, oldId) => {
  1140. if (newId && newId !== oldId) {
  1141. // 停止当前视频播放
  1142. if (videoProcessorRef.value) {
  1143. videoProcessorRef.value.stopVideo();
  1144. }
  1145. // 重置购买状态
  1146. isSinglePurchased.value = false;
  1147. await loadVideoInfo();
  1148. await loadRelatedVideos();
  1149. // 检查购买状态(首页点击进入视频时的检查)
  1150. const vipLevel = userStore.getVipLevel();
  1151. if (
  1152. vipLevel !== VipLevel.GUEST &&
  1153. videoInfo.value.id &&
  1154. videoInfo.value.id !== "unknown"
  1155. ) {
  1156. await checkVideoPurchaseStatus();
  1157. }
  1158. } else if (oldId === undefined && newId) {
  1159. await loadVideoInfo();
  1160. await loadRelatedVideos();
  1161. const vipLevel = userStore.getVipLevel();
  1162. if (
  1163. vipLevel !== VipLevel.GUEST &&
  1164. videoInfo.value.id &&
  1165. videoInfo.value.id !== "unknown"
  1166. ) {
  1167. await checkVideoPurchaseStatus();
  1168. }
  1169. }
  1170. },
  1171. { immediate: true }
  1172. );
  1173. onMounted(async () => {
  1174. // 加载价格配置
  1175. if (!priceStore.isPriceConfigLoaded) {
  1176. await priceStore.fetchPriceConfig();
  1177. }
  1178. });
  1179. onUnmounted(() => {
  1180. // 组件卸载时的清理工作
  1181. });
  1182. </script>
  1183. <style scoped>
  1184. /* 视频容器样式 */
  1185. .video-container {
  1186. position: relative;
  1187. }
  1188. /* 自定义闪烁动画 */
  1189. @keyframes flash {
  1190. 0%,
  1191. 50%,
  1192. 100% {
  1193. opacity: 1;
  1194. transform: scale(1);
  1195. }
  1196. 25%,
  1197. 75% {
  1198. opacity: 0.8;
  1199. transform: scale(1.05);
  1200. }
  1201. }
  1202. @keyframes glow {
  1203. 0%,
  1204. 100% {
  1205. box-shadow: 0 0 5px rgba(59, 130, 246, 0.5),
  1206. 0 0 10px rgba(59, 130, 246, 0.3);
  1207. }
  1208. 50% {
  1209. box-shadow: 0 0 20px rgba(59, 130, 246, 0.8),
  1210. 0 0 30px rgba(59, 130, 246, 0.6);
  1211. }
  1212. }
  1213. .flash-animation {
  1214. animation: flash 2s ease-in-out infinite;
  1215. }
  1216. .glow-animation {
  1217. animation: glow 2s ease-in-out infinite;
  1218. }
  1219. /* 移动端全屏样式 */
  1220. @media screen and (max-width: 768px) {
  1221. video {
  1222. /* 强制横屏全屏 */
  1223. object-fit: contain;
  1224. }
  1225. /* 全屏时的样式 */
  1226. video:fullscreen {
  1227. width: 100vw;
  1228. height: 100vh;
  1229. object-fit: contain;
  1230. background: black;
  1231. }
  1232. /* WebKit全屏样式 */
  1233. video:-webkit-full-screen {
  1234. width: 100vw;
  1235. height: 100vh;
  1236. object-fit: contain;
  1237. background: black;
  1238. }
  1239. /* Mozilla全屏样式 */
  1240. video:-moz-full-screen {
  1241. width: 100vw;
  1242. height: 100vh;
  1243. object-fit: contain;
  1244. background: black;
  1245. }
  1246. /* MS全屏样式 */
  1247. video:-ms-fullscreen {
  1248. width: 100vw;
  1249. height: 100vh;
  1250. object-fit: contain;
  1251. background: black;
  1252. }
  1253. }
  1254. </style>