index.vue 12 KB

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