index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <div class="WorldCup" :style="'font-size: ' + fontSize + 'px'">
  3. <div class="up">
  4. <img class="upbg" :src="require('../../assets/img/upbg.jpg')" />
  5. <van-swipe class="Banner video" :autoplay="3000" indicator-color="white">
  6. <van-swipe-item
  7. v-for="item in Banner"
  8. :key="item.url"
  9. @click="() => playVideo(item)"
  10. >
  11. <van-icon name="play-circle-o" class="play" />
  12. <img
  13. :src="item.url + '?x-oss-process=video/snapshot,t_100,f_jpg,m_fast'"
  14. alt=""
  15. />
  16. </van-swipe-item>
  17. </van-swipe>
  18. <img class="activityTitle" :src="require('../../assets/img/T.png')" />
  19. <div class="activity">
  20. <p>
  21. 尽管曾经的比赛已成过眼云烟,但总有些经典瞬间无法忘却。那些年的世界杯名场面、那些与挚友一同熬夜看比赛的日子,那些因为足球而欣喜、落寞、激动、感伤的时刻,会永远铭记心中。
  22. </p>
  23. <p class="nextDuan">
  24. 用户可在下方“我要投稿”上传自己与足球相关的视频,题材包含:足球技巧展示、喜爱的球队/球星、球衣收藏、印象深刻的比赛等各种足球、世界杯相关的视频,并点击“我的投稿”分享邀请好友助威。
  25. </p>
  26. </div>
  27. <div class="btns">
  28. <img
  29. class="userInput"
  30. @click="() => toNewPage('./WorldContribution.html')"
  31. :src="require('../../assets/img/userInput.png')"
  32. />
  33. <img
  34. class="userInput my"
  35. @click="verification"
  36. :src="require('../../assets/img/my.png')"
  37. />
  38. </div>
  39. </div>
  40. <div class="down">
  41. <div class="videobg">
  42. <div class="title">精彩视频</div>
  43. <van-row gutter="18">
  44. <van-col
  45. class="video"
  46. span="12"
  47. v-for="i in Videos"
  48. :key="i.url"
  49. @click="() => playVideo(i)"
  50. >
  51. <van-icon name="play-circle-o" class="play" />
  52. <img
  53. width="100%"
  54. :src="i.url + '?x-oss-process=video/snapshot,t_100,f_jpg,m_fast'"
  55. alt=""
  56. />
  57. </van-col>
  58. </van-row>
  59. </div>
  60. <div class="vote">
  61. <ranking />
  62. <chat @toLogin="login" />
  63. </div>
  64. <match v-if="team.length" />
  65. </div>
  66. <div class="playVideo" v-if="play.phone">
  67. <van-icon @click="() => playVideo({})" name="close" class="close" />
  68. <video :src="play.url" controls></video>
  69. <van-button
  70. round
  71. class="btn"
  72. block
  73. @click="saveVote"
  74. color="linear-gradient(to right, #ff6034, #ee0a24)"
  75. >
  76. 投票
  77. </van-button>
  78. </div>
  79. <Shanshipin />
  80. </div>
  81. </template>
  82. <script setup>
  83. import Shanshipin from "@/components/shanshipin.vue";
  84. // import { ElCarouselItem, ElCarousel } from "element-plus";
  85. // import "element-plus/theme-chalk/base.css";
  86. // import "element-plus/theme-chalk/el-carousel.css";
  87. // import "element-plus/theme-chalk/el-carousel-item.css";
  88. import { isShanshipin, isWechat } from "@/utils/isTerminal";
  89. import { ref, provide, reactive } from "vue";
  90. import chat from "./components/chat.vue";
  91. import ranking from "./components/ranking.vue";
  92. import match from "./components/match.vue";
  93. import { Toast, Dialog } from "vant";
  94. import { getMatch, getBannerAndVideo, votpSave } from "@/api/worldCup.js";
  95. const availWidth =
  96. window.$originData.orginParames.availWidth > 1440
  97. ? 1440
  98. : window.$originData.orginParames.availWidth;
  99. const fontSize = ref(availWidth / 10);
  100. const Banner = ref([]);
  101. const Videos = ref([]);
  102. const play = ref({});
  103. const maxcol = [8, 4, 2, 1, 1, 1, 2, 4, 8];
  104. let team = reactive([]);
  105. const shanshipin = window.$shanshipin || {};
  106. const from = reactive({
  107. name: shanshipin.UserName || localStorage.getItem("worldCupName") || "",
  108. phone: shanshipin.Phone || localStorage.getItem("worldCupPhone") || "",
  109. });
  110. provide("fontSize", fontSize); // 配置全域参数
  111. provide("availWidth", availWidth); // 配置全域参数
  112. provide("maxcol", maxcol); // 配置全域参数
  113. provide("team", team); // 配置全域参数
  114. provide("user", from); // 配置全域参数
  115. // import { onMounted, reactive } from "vue";
  116. // import { isIpad, isIpod, isIphone } from "../../utils/isTerminal";
  117. /**
  118. * window.$originData.orginParames.title 页面标题
  119. * window.$originData.orginParames.parameters 固定参数值
  120. * window.$originData.urlParames url参数
  121. */
  122. const p = isWechat ? "微信" : isShanshipin ? "闪视频" : "其它";
  123. function setStorage() {
  124. localStorage.setItem("worldCupPhone", from.phone || "");
  125. localStorage.setItem("worldCupName", from.name || "");
  126. }
  127. /**
  128. * getMatch 获得赛事日程;
  129. */
  130. Promise.all([
  131. getMatch({
  132. phone: from.phone,
  133. }),
  134. getBannerAndVideo(),
  135. ]).then(li => {
  136. formmateMatch(li[0] || []);
  137. formmateBanner(li[1] || {});
  138. });
  139. function formmateBanner(r) {
  140. Videos.value = r.videos || [];
  141. Banner.value = r.banner || [];
  142. }
  143. function formmateMatch(matchList) {
  144. const isForeast = !!matchList[14].isWinner;
  145. for (let i = 0; i < matchList.length; i++) {
  146. const v = matchList[i];
  147. if (v.rounds === "1/8决赛") setRow(0, v, isForeast); // 16进8
  148. else if (v.rounds === "1/4决赛") setRow(1, v, isForeast); // 8进4
  149. else if (v.rounds === "半决赛") setRow(2, v); // 4进2
  150. else if (v.rounds === "决赛") {
  151. // 2进1
  152. team[3] = [
  153. {
  154. isForeast,
  155. team: v.home,
  156. isWinner: v.winner === v.home,
  157. teamlogo: v.homeLogo,
  158. isED: !!v.winner,
  159. isHome: true,
  160. selectId: v.id,
  161. pSelectId: v.pid,
  162. },
  163. ];
  164. team[5] = [
  165. {
  166. isForeast,
  167. team: v.away,
  168. isWinner: v.winner === v.away,
  169. teamlogo: v.awayLogo,
  170. isED: !!v.winner,
  171. isHome: true,
  172. selectId: v.id,
  173. pSelectId: v.pid,
  174. },
  175. ];
  176. team[Math.ceil((maxcol.length - 1) / 2)] = [
  177. {
  178. team: v.winner || "",
  179. isWinner: true,
  180. teamlogo:
  181. v.winner === v.home
  182. ? v.homeLogo
  183. : v.winner === v.away
  184. ? v.awayLogo
  185. : "",
  186. isHome: true,
  187. isForeast,
  188. isED: !!v.winner,
  189. selectId: v.id,
  190. pSelectId: v.pid,
  191. },
  192. ];
  193. }
  194. }
  195. }
  196. function playVideo(item) {
  197. play.value = item;
  198. }
  199. function setRow(index, v) {
  200. const max = maxcol[index];
  201. if (team[index] && team[index].length == max) {
  202. // 放到图像下部
  203. setTeam(maxcol.length - index - 1, v);
  204. } else {
  205. // 放到图像上部
  206. setTeam(index, v);
  207. }
  208. }
  209. function setTeam(teamIndex, item, isForeast) {
  210. if (!team[teamIndex]) team[teamIndex] = [];
  211. team[teamIndex].push({
  212. team: item.home || "",
  213. isWinner: item.winner === item.home,
  214. teamlogo: item.homeLogo || "",
  215. isED: !!item.winner,
  216. isForeast,
  217. isHome: true,
  218. selectId: item.id,
  219. pSelectId: item.pid,
  220. });
  221. team[teamIndex].push({
  222. team: item.away || "",
  223. isWinner: item.winner === item.away,
  224. teamlogo: item.awayLogo || "",
  225. isED: !!item.winner,
  226. isForeast,
  227. isHome: false,
  228. selectId: item.id,
  229. pSelectId: item.pid,
  230. });
  231. }
  232. function login(next) {
  233. Dialog.alert({
  234. title: "",
  235. messageAlign: "left",
  236. theme: "round-button",
  237. confirmButtonText: "登录",
  238. message: () => (
  239. <div>
  240. <van-field
  241. required
  242. v-model={from.name}
  243. label="姓名"
  244. placeholder="请输入用户名"
  245. />
  246. <van-field
  247. required
  248. v-model={from.phone}
  249. label="联系方式"
  250. type="tel"
  251. placeholder="请输入手机号"
  252. />
  253. </div>
  254. ),
  255. }).then(() => {
  256. setStorage();
  257. next && next();
  258. });
  259. }
  260. function verification() {
  261. if (!from.phone) return login(() => toNewPage("./WorldCupDetail.html"));
  262. toNewPage("./WorldCupDetail.html");
  263. }
  264. function toNewPage(url) {
  265. if (!url) return;
  266. let U = url || "";
  267. if (window.$shanshipin.Phone) U += "?phone=" + window.$shanshipin.Phone;
  268. location.href = U;
  269. }
  270. function saveVote() {
  271. if (!from.phone) return login(vote);
  272. else vote();
  273. }
  274. function vote() {
  275. votpSave({
  276. target: play.value.phone,
  277. source: from.phone,
  278. client: p,
  279. }).then(r => {
  280. console.log(r);
  281. Toast("感谢您的支持!");
  282. });
  283. }
  284. </script>
  285. <style lang="scss">
  286. .WorldCup {
  287. $fontSize: calc(100% / 10);
  288. width: 100%;
  289. max-width: 1440px;
  290. min-height: 100vh;
  291. margin: 0 auto;
  292. overflow-y: auto;
  293. overflow-x: hidden;
  294. background-image: url(../../assets/img/bg.jpg);
  295. background-size: 100% 100%;
  296. .video {
  297. background: #000;
  298. width: 100%;
  299. }
  300. .activityTitle {
  301. width: 51.1%;
  302. display: block;
  303. margin: 0 auto;
  304. }
  305. .up {
  306. padding-top: 38.8vw;
  307. position: relative;
  308. .Banner {
  309. font-size: 0;
  310. position: relative;
  311. img {
  312. width: 100%;
  313. }
  314. .play {
  315. position: absolute;
  316. font-size: 40px;
  317. color: #fff;
  318. top: 50%;
  319. left: 50%;
  320. transform: translate(-50%, -50%);
  321. z-index: 1;
  322. }
  323. }
  324. .upbg {
  325. position: absolute;
  326. top: 0;
  327. z-index: 0;
  328. width: 100%;
  329. }
  330. .video {
  331. position: relative;
  332. z-index: 1;
  333. width: calc(100% - 26px);
  334. height: 160px;
  335. margin: 13px;
  336. }
  337. .activity {
  338. background-image: url(../../assets/img/kuang.png);
  339. background-size: 100% 100%;
  340. margin: 17px 10px 19px 10px;
  341. min-height: 315px;
  342. color: #fff;
  343. font-size: 14px;
  344. font-weight: 400;
  345. padding: 15px;
  346. line-height: 1.8em;
  347. p {
  348. text-indent: 2em;
  349. border: 1px solid #fbd204;
  350. border-radius: 1em;
  351. padding: 5px;
  352. }
  353. .nextDuan {
  354. margin-top: 20px;
  355. }
  356. }
  357. .btns {
  358. display: flex;
  359. justify-content: space-between;
  360. padding: 0 10px 32px 10px;
  361. .userInput {
  362. display: inline-block;
  363. width: 56.3vw;
  364. max-width: 211px;
  365. height: 64px;
  366. }
  367. .my {
  368. width: 35.5vw;
  369. max-width: 133px;
  370. margin-left: 11px;
  371. }
  372. }
  373. }
  374. .down {
  375. background-image: linear-gradient(
  376. to bottom,
  377. rgba(0, 0, 0, 0.2),
  378. rgba(0, 0, 0, 0.4)
  379. );
  380. .videobg {
  381. background-image: url(../../assets/img/videobg.jpg);
  382. background-size: 100% 100%;
  383. padding: 28px 13px;
  384. .title {
  385. height: 25px;
  386. font-size: 28px;
  387. font-family: Baiwuchangtidecard;
  388. color: #ffffff;
  389. line-height: 42px;
  390. -webkit-text-stroke: 1px #0b37ab;
  391. text-stroke: 1px #0b37ab;
  392. text-align: center;
  393. margin-bottom: 25px;
  394. }
  395. .video {
  396. position: relative;
  397. font-size: 0;
  398. img {
  399. width: calc(50vw - 13px);
  400. }
  401. .play {
  402. position: absolute;
  403. font-size: 40px;
  404. color: #fff;
  405. top: 50%;
  406. left: 50%;
  407. transform: translate(-50%, -50%);
  408. z-index: 1;
  409. }
  410. }
  411. }
  412. }
  413. .playVideo {
  414. position: fixed;
  415. top: 0;
  416. left: 0;
  417. right: 0;
  418. bottom: 0;
  419. background: rgba(0, 0, 0, 1);
  420. z-index: 10;
  421. video {
  422. position: absolute;
  423. top: 50%;
  424. transform: translate(0, -50%);
  425. width: 100%;
  426. background: rgb(0, 0, 0);
  427. }
  428. .close {
  429. position: absolute;
  430. top: 10px;
  431. right: 10px;
  432. z-index: 11;
  433. color: #fff;
  434. font-size: 20px;
  435. }
  436. .btn {
  437. width: 50vw;
  438. position: absolute;
  439. left: 50%;
  440. bottom: 5vh;
  441. transform: translate(-50%, 0);
  442. }
  443. }
  444. }
  445. </style>