index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <view class="container">
  3. <view v-if="showPlayIcon" class="wx-play-mask" @click="handlePlay">
  4. <image class="wx-play-mask__icon" src="../../static/play.png" />
  5. </view>
  6. <view class="loading" v-if="loadingState" :class="[loadingOutAnime?'loadingOut':'']">
  7. <view class="loadingBox" v-if="loadPointState">
  8. <span class="span1"></span>
  9. <span class="span2"></span>
  10. <span class="span3"></span>
  11. <span class="span4"></span>
  12. <span class="span5"></span>
  13. <span class="span6"></span>
  14. </view>
  15. <image class="loadingText" @load="loadImgEnd" :src="loadingText" mode="aspectFit"></image>
  16. </view>
  17. <view class="changeAudio" :class="[audioState?'changeAudioPlay':'']" @click="changeAudio">
  18. <image :src="audioImgA" v-show="audioState" mode="aspectFit"></image>
  19. <image :src="audioImgB" v-show="!audioState" mode="aspectFit"></image>
  20. </view>
  21. <view class="videoContent">
  22. <video id="myVideoBg" :src="videoBgPath" :loop="true" :controls="false" :muted="true" objectFit='cover'
  23. :show-progress='false' :enable-progress-gesture='false' :show-play-btn='false'
  24. :show-fullscreen-btn='false' x5-playsinline="true"
  25. playsinline="true"
  26. webkit-playsinline="true"
  27. x-webkit-airplay="true"
  28. x5-video-player-type="h5"
  29. @loadedmetadata="videoLoadingEnd"></video>
  30. </view>
  31. <view class="tips" v-show="tipsState">
  32. <image :src="tips" mode="aspectFit"></image>
  33. </view>
  34. <view class="imgLayer">
  35. <view class="imgMask" v-if="imgShowIndex!='close'">
  36. </view>
  37. <view class="imgItem" v-for="(item,index) in personList" :key="item.name"
  38. :style="{width:item.width,height:item.height,left:item.x,top:item.y}" v-show="imgShowIndex==item.name">
  39. <image :src="item.url" mode="aspectFill"></image>
  40. </view>
  41. </view>
  42. <view class="clickLayer">
  43. <view class="clickItem clickItem1" @click="openImg('person1')">
  44. </view>
  45. <view class="clickItem clickItem2" @click="openImg('person2')">
  46. </view>
  47. <view class="clickItem clickItem3" @click="openImg('person3')">
  48. </view>
  49. <view class="clickItem clickItem4" @click="openImg('person4')">
  50. </view>
  51. <view class="clickItem clickItem5" @click="openImg('person5')">
  52. </view>
  53. </view>
  54. <view class="textLayer">
  55. <view class="textItem" v-for="(item,index) in textList" :key="item.name" v-show="imgShowIndex==item.name">
  56. <image :src="item.url" mode="aspectFill"></image>
  57. </view>
  58. </view>
  59. <view class="closeBtn" v-show="imgShowIndex!='close'" @click="closeContent">
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. const ua = window.navigator.userAgent.toLowerCase()
  65. export default {
  66. data() {
  67. return {
  68. showPlayIcon: ua.match(/MicroMessenger/i) == 'micromessenger',
  69. loadPointState: false,
  70. logoImg: "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/logo.png",
  71. loadingState: true,
  72. loadingOutAnime: false, //加载退场动画
  73. videoCtx: "",
  74. tipsState: true,
  75. tips: "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/tips.png",
  76. audioImgA: "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/audioOn.png",
  77. audioImgB: "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/audioOff.png",
  78. loadingText: "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/loading.jpg",
  79. audioUrl: "",
  80. webUrl: "https://dadu.oss-cn-hangzhou.aliyuncs.com/api/getHtml",
  81. audioState: false,
  82. innerAudioContext: "",
  83. imgShowIndex: "close",
  84. videoBgPath: "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/video/bg.mp4",
  85. personList: [{
  86. "name": "person1",
  87. "width": "180rpx",
  88. "height": "461rpx",
  89. "x": "-10rpx",
  90. "y": "980rpx",
  91. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/person/1.png"
  92. },
  93. {
  94. "name": "person2",
  95. "width": "192rpx",
  96. "height": "466rpx",
  97. "x": "130rpx",
  98. "y": "980rpx",
  99. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/person/2.png"
  100. },
  101. {
  102. "name": "person3",
  103. "width": "246rpx",
  104. "height": "474rpx",
  105. "x": "278rpx",
  106. "y": "950rpx",
  107. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/person/3.png"
  108. },
  109. {
  110. "name": "person4",
  111. "width": "179rpx",
  112. "height": "466rpx",
  113. "x": "485rpx",
  114. "y": "972rpx",
  115. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/person/4.png"
  116. },
  117. {
  118. "name": "person5",
  119. "width": "148rpx",
  120. "height": "458rpx",
  121. "x": "610rpx",
  122. "y": "980rpx",
  123. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/person/5.png"
  124. }
  125. ],
  126. textList: [{
  127. "name": "person1",
  128. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/text1A.png"
  129. },
  130. {
  131. "name": "person2",
  132. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/text2A.png"
  133. },
  134. {
  135. "name": "person3",
  136. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/text3A.png"
  137. },
  138. {
  139. "name": "person4",
  140. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/text4A.png"
  141. },
  142. {
  143. "name": "person5",
  144. "url": "https://dadu.oss-cn-hangzhou.aliyuncs.com/static/zhongduxiu/img/text5A.png"
  145. }
  146. ]
  147. }
  148. },
  149. methods: {
  150. loadImgEnd(e) {
  151. this.loadPointState = true
  152. },
  153. createAudio() {
  154. this.innerAudioContext = uni.createInnerAudioContext()
  155. this.innerAudioContext.loop = true
  156. this.innerAudioContext.src = `${this.$g.baseUrl}/static/zhongduxiu/audio/audio.mp3`
  157. this.innerAudioContext.play()
  158. },
  159. changeAudio() {
  160. if (this.audioState) {
  161. this.innerAudioContext.pause()
  162. } else {
  163. this.innerAudioContext.play()
  164. }
  165. this.audioState = !this.audioState
  166. },
  167. videoLoadingEnd() {
  168. this.loadingOutAnime = true
  169. this.videoCtx.play()
  170. let t = setTimeout(() => {
  171. this.loadingState = false
  172. clearTimeout(t)
  173. }, 600)
  174. },
  175. openImg(index) {
  176. this.imgShowIndex = index
  177. this.tipsState = false
  178. },
  179. closeContent() {
  180. this.imgShowIndex = 'close'
  181. },
  182. handlePlay() {
  183. this.videoCtx.play()
  184. this.changeAudio()
  185. this.showPlayIcon = false
  186. }
  187. },
  188. onLoad() {
  189. // #ifdef MP-WEIXIN
  190. uni.hideHomeButton()
  191. // #endif
  192. this.videoCtx = uni.createVideoContext('myVideoBg')
  193. this.createAudio()
  194. },
  195. onHide() {
  196. this.audioState = false
  197. },
  198. onShow() {
  199. if (this.showPlayIcon) return
  200. this.audioState = true
  201. if (this.innerAudioContext) {
  202. this.innerAudioContext.play()
  203. }
  204. },
  205. onUnload() {
  206. this.innerAudioContext.stop()
  207. this.innerAudioContext.destroy()
  208. }
  209. }
  210. </script>
  211. <style scoped>
  212. .container {
  213. position: relative;
  214. width: 100vw;
  215. height: 100vh;
  216. overflow: hidden;
  217. }
  218. .wx-play-mask {
  219. position: absolute;
  220. top: 0;
  221. left: 0;
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. width: 750rpx;
  226. height: 1624rpx;
  227. background: rgba(0, 0, 0, 0.6);
  228. z-index: 9999;
  229. }
  230. .wx-play-mask__icon {
  231. width: 128upx;
  232. height: 128upx;
  233. }
  234. @media screen and (max-height: 750px) {
  235. .container {
  236. overflow: visible !important;
  237. }
  238. .container .tips {
  239. top: 1300rpx;
  240. }
  241. }
  242. .container .loading {
  243. position: absolute;
  244. top: 0;
  245. left: 0;
  246. width: 100vw;
  247. height: 100vh;
  248. z-index: 9998;
  249. background: #4c4c4c;
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. }
  254. .container .loading .loadingBox {
  255. position: absolute;
  256. width: 105rpx;
  257. height: 41rpx;
  258. display: flex;
  259. top: 345rpx;
  260. left: 459rpx;
  261. z-index: 1;
  262. opacity: 0;
  263. justify-content: space-around;
  264. align-items: center;
  265. animation: 0.8s loadingBoxAnime 0.5s linear forwards;
  266. }
  267. @keyframes loadingBoxAnime {
  268. from {
  269. opacity: 0;
  270. }
  271. to {
  272. opacity: 1;
  273. }
  274. }
  275. .container .loading .loadingBox span {
  276. width: 8rpx;
  277. height: 8rpx;
  278. background: #c8841a;
  279. border-radius: 50%;
  280. }
  281. .container .loading .loadingBox .span1 {
  282. animation: 0.8s spanAnime 0.2s alternate infinite;
  283. }
  284. .container .loading .loadingBox .span2 {
  285. animation: 0.8s spanAnime 0.4s alternate infinite;
  286. }
  287. .container .loading .loadingBox .span3 {
  288. animation: 0.8s spanAnime 0.6s alternate infinite;
  289. }
  290. .container .loading .loadingBox .span4 {
  291. animation: 0.8s spanAnime 0.8s alternate infinite;
  292. }
  293. .container .loading .loadingBox .span5 {
  294. animation: 0.8s spanAnime 1s alternate infinite;
  295. }
  296. .container .loading .loadingBox .span6 {
  297. animation: 0.8s spanAnime 1.2s alternate infinite;
  298. }
  299. @keyframes spanAnime {
  300. from {
  301. transform: scale(1.5);
  302. }
  303. to {
  304. transform: scale(0.7);
  305. }
  306. }
  307. .container .loading .loadingBox .loadingRotate {
  308. animation: 1s loadingRotateAnime linear infinite;
  309. }
  310. .container .loading .loadingText {
  311. position: absolute;
  312. top: 0%;
  313. left: 0%;
  314. width: 750rpx;
  315. height: 1624rpx;
  316. will-change: transform;
  317. }
  318. @keyframes loadingRotateAnime {
  319. from {
  320. transform: rotate(0deg);
  321. }
  322. to {
  323. transform: rotate(360deg);
  324. }
  325. }
  326. .container .loadingOut {
  327. animation: 1s loadingOutAnime linear forwards;
  328. }
  329. @keyframes loadingOutAnime {
  330. from {
  331. opacity: 1;
  332. }
  333. to {
  334. opacity: 0;
  335. }
  336. }
  337. .container .tips {
  338. position: absolute;
  339. width: 750rpx;
  340. height: 318rpx;
  341. /* top: 1300rpx; */
  342. bottom: 0;
  343. left: 0;
  344. opacity: 0;
  345. animation: 3s tipsAnime 1s linear alternate infinite;
  346. }
  347. .container .tips image {
  348. width: 100%;
  349. height: 100%;
  350. }
  351. @keyframes tipsAnime {
  352. from {
  353. opacity: 0.5;
  354. }
  355. to {
  356. opacity: 1;
  357. }
  358. }
  359. .container .changeAudio {
  360. position: absolute;
  361. right: 45rpx;
  362. top: 45rpx;
  363. width: 47rpx;
  364. height: 47rpx;
  365. z-index: 999999;
  366. }
  367. .container .changeAudio image {
  368. width: 100%;
  369. height: 100%;
  370. }
  371. .container .changeAudioPlay {
  372. animation: 1s changeAudioAnime linear infinite;
  373. }
  374. @keyframes changeAudioAnime {
  375. from {
  376. transform: rotate(0deg);
  377. }
  378. to {
  379. transform: rotate(360deg);
  380. }
  381. }
  382. .videoContent {
  383. width: 750rpx;
  384. height: 1624rpx;
  385. position: absolute;
  386. top: 0;
  387. left: 0;
  388. }
  389. .videoContent video {
  390. width: 100%;
  391. height: 100%;
  392. }
  393. .imgLayer {
  394. width: 100vw;
  395. height: 100vh;
  396. position: absolute;
  397. top: 0;
  398. left: 0;
  399. z-index: 99;
  400. }
  401. .imgLayer .imgMask {
  402. width: 750rpx;
  403. height: 1624rpx;
  404. background: rgba(0, 0, 0, 0.6);
  405. opacity: 0;
  406. animation: 1s imgMaskAnime linear forwards;
  407. }
  408. @keyframes imgMaskAnime {
  409. from {
  410. opacity: 0;
  411. }
  412. to {
  413. opacity: 1;
  414. }
  415. }
  416. .imgLayer .imgItem {
  417. position: absolute;
  418. animation: 0.5s imgItemAnime linear forwards;
  419. }
  420. @keyframes imgItemAnime {
  421. from {
  422. transform: scale(1);
  423. }
  424. to {
  425. transform: scale(1.05);
  426. }
  427. }
  428. .imgLayer .imgItem image {
  429. width: 100%;
  430. height: 100%;
  431. }
  432. .clickLayer {
  433. width: 100vw;
  434. height: 100vh;
  435. position: absolute;
  436. top: 0;
  437. left: 0;
  438. z-index: 99999;
  439. }
  440. .clickLayer .clickItem {
  441. width: 200rpx;
  442. height: 150rpx;
  443. position: absolute;
  444. /* background: pink; */
  445. z-index: 9999;
  446. }
  447. .clickLayer .clickItem1 {
  448. width: 150rpx;
  449. height: 460rpx;
  450. left: 0rpx;
  451. top: 970rpx;
  452. }
  453. .clickLayer .clickItem2 {
  454. width: 160rpx;
  455. height: 460rpx;
  456. left: 152rpx;
  457. top: 970rpx;
  458. }
  459. .clickLayer .clickItem3 {
  460. width: 170rpx;
  461. height: 460rpx;
  462. left: 315rpx;
  463. top: 970rpx;
  464. }
  465. .clickLayer .clickItem4 {
  466. width: 140rpx;
  467. height: 460rpx;
  468. left: 486rpx;
  469. top: 970rpx;
  470. }
  471. .clickLayer .clickItem5 {
  472. width: 123rpx;
  473. height: 460rpx;
  474. left: 628rpx;
  475. top: 970rpx;
  476. }
  477. .textLayer {
  478. position: absolute;
  479. top: 0;
  480. left: 0;
  481. width: 750rpx;
  482. height: 1624rpx;
  483. z-index: 999;
  484. }
  485. .textLayer .textItem {
  486. position: absolute;
  487. width: 643rpx;
  488. height: 372rpx;
  489. top: 525rpx;
  490. left: 50%;
  491. opacity: 0;
  492. transform: translateX(-50%);
  493. animation: 0.5s textItemAnime 1s linear forwards;
  494. }
  495. @keyframes textItemAnime {
  496. from {
  497. opacity: 0;
  498. }
  499. to {
  500. opacity: 1;
  501. }
  502. }
  503. .textLayer .textItem image {
  504. width: 100%;
  505. height: 100%;
  506. }
  507. .closeBtn {
  508. position: absolute;
  509. z-index: 99999;
  510. top: 525rpx;
  511. left: 635rpx;
  512. width: 60rpx;
  513. height: 60rpx;
  514. opacity: 0;
  515. animation: 0.5s textItemAnime linear 1s forwards;
  516. }
  517. </style>