index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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" @upWay="upWay" />
  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 upWay() {
  140. getMatch({
  141. phone: from.phone,
  142. }).then(r=>{
  143. formmateMatch(r || []);
  144. });
  145. }
  146. function formmateBanner(r) {
  147. Videos.value = r.videos || [];
  148. Banner.value = r.banner || [];
  149. }
  150. function formmateMatch(matchList) {
  151. const isForeast = !!matchList[14].winner;
  152. for (let i = 0; i < matchList.length; i++) {
  153. const v = matchList[i];
  154. if (v.rounds === "1/8决赛") setRow(0, v, isForeast); // 16进8
  155. else if (v.rounds === "1/4决赛") setRow(1, v, isForeast); // 8进4
  156. else if (v.rounds === "半决赛") setRow(2, v); // 4进2
  157. else if (v.rounds === "决赛") {
  158. // 2进1
  159. team[3] = [
  160. {
  161. isForeast,
  162. team: v.home,
  163. isWinner: v.winner === v.home,
  164. teamlogo: v.homeLogo,
  165. isED: !!v.winner,
  166. isHome: true,
  167. selectId: v.id,
  168. pSelectId: v.homePid,
  169. },
  170. ];
  171. team[5] = [
  172. {
  173. isForeast,
  174. team: v.away,
  175. isWinner: v.winner === v.away,
  176. teamlogo: v.awayLogo,
  177. isED: !!v.winner,
  178. isHome: true,
  179. selectId: v.id,
  180. pSelectId: v.awayPid,
  181. },
  182. ];
  183. team[Math.ceil((maxcol.length - 1) / 2)] = [
  184. {
  185. team: v.winner || "",
  186. isWinner: true,
  187. teamlogo:
  188. v.winner === v.home
  189. ? v.homeLogo
  190. : v.winner === v.away
  191. ? v.awayLogo
  192. : "",
  193. isHome: true,
  194. isForeast,
  195. isED: !!v.winner,
  196. selectId: v.id,
  197. pSelectId: -1,
  198. },
  199. ];
  200. }
  201. }
  202. }
  203. function playVideo(item) {
  204. play.value = item;
  205. }
  206. function setRow(index, v) {
  207. const max = maxcol[index];
  208. if (team[index] && team[index].length == max) {
  209. // 放到图像下部
  210. setTeam(maxcol.length - index - 1, v);
  211. } else {
  212. // 放到图像上部
  213. setTeam(index, v);
  214. }
  215. }
  216. function setTeam(teamIndex, item, isForeast) {
  217. if (!team[teamIndex]) team[teamIndex] = [];
  218. team[teamIndex].push({
  219. team: item.home || "",
  220. isWinner: item.winner === item.home,
  221. teamlogo: item.homeLogo || "",
  222. isED: !!item.winner,
  223. isForeast,
  224. isHome: true,
  225. selectId: item.id,
  226. pSelectId: item.homePid,
  227. });
  228. team[teamIndex].push({
  229. team: item.away || "",
  230. isWinner: item.winner === item.away,
  231. teamlogo: item.awayLogo || "",
  232. isED: !!item.winner,
  233. isForeast,
  234. isHome: false,
  235. selectId: item.id,
  236. pSelectId: item.awayPid,
  237. });
  238. }
  239. function login(next) {
  240. Dialog.alert({
  241. title: "",
  242. messageAlign: "left",
  243. theme: "round-button",
  244. confirmButtonText: "登录",
  245. message: () => (
  246. <div>
  247. <van-field
  248. required
  249. v-model={from.name}
  250. label="姓名"
  251. placeholder="请输入用户名"
  252. />
  253. <van-field
  254. required
  255. v-model={from.phone}
  256. label="联系方式"
  257. type="tel"
  258. placeholder="请输入手机号"
  259. />
  260. </div>
  261. ),
  262. }).then(() => {
  263. if(!from.phone) return Toast("登录后才能看到自己的作品哦~")
  264. setStorage();
  265. next && next();
  266. });
  267. }
  268. function verification() {
  269. if (!from.phone) return login(() => toNewPage("./WorldCupDetail.html"));
  270. toNewPage("./WorldCupDetail.html");
  271. }
  272. function toNewPage(url) {
  273. if (!url) return;
  274. let U = url || "";
  275. if (window.$shanshipin.Phone) U += "?phone=" + window.$shanshipin.Phone;
  276. location.href = U;
  277. }
  278. function saveVote() {
  279. if (!from.phone) return login(vote);
  280. else vote();
  281. }
  282. function vote() {
  283. votpSave({
  284. target: play.value.phone,
  285. source: from.phone,
  286. client: p,
  287. }).then(r => {
  288. console.log(r);
  289. Toast("感谢您的支持!");
  290. });
  291. }
  292. </script>
  293. <style lang="scss">
  294. .WorldCup {
  295. $fontSize: calc(100% / 10);
  296. width: 100%;
  297. max-width: 1440px;
  298. min-height: 100vh;
  299. margin: 0 auto;
  300. overflow-y: auto;
  301. overflow-x: hidden;
  302. background-image: url(../../assets/img/bg.jpg);
  303. background-size: 100% 100%;
  304. .video {
  305. background: #000;
  306. width: 100%;
  307. }
  308. .activityTitle {
  309. width: 51.1%;
  310. display: block;
  311. margin: 0 auto;
  312. }
  313. .up {
  314. padding-top: 38.8vw;
  315. position: relative;
  316. .Banner {
  317. font-size: 0;
  318. position: relative;
  319. img {
  320. width: 100%;
  321. }
  322. .play {
  323. position: absolute;
  324. font-size: 40px;
  325. color: #fff;
  326. top: 50%;
  327. left: 50%;
  328. transform: translate(-50%, -50%);
  329. z-index: 1;
  330. }
  331. }
  332. .upbg {
  333. position: absolute;
  334. top: 0;
  335. z-index: 0;
  336. width: 100%;
  337. }
  338. .video {
  339. position: relative;
  340. z-index: 1;
  341. width: calc(100% - 26px);
  342. height: 160px;
  343. margin: 13px;
  344. }
  345. .activity {
  346. background-image: url(../../assets/img/kuang.png);
  347. background-size: 100% 100%;
  348. margin: 17px 10px 19px 10px;
  349. min-height: 315px;
  350. color: #fff;
  351. font-size: 14px;
  352. font-weight: 400;
  353. padding: 15px;
  354. line-height: 1.8em;
  355. p {
  356. text-indent: 2em;
  357. border: 1px solid #fbd204;
  358. border-radius: 1em;
  359. padding: 5px;
  360. }
  361. .nextDuan {
  362. margin-top: 20px;
  363. }
  364. }
  365. .btns {
  366. display: flex;
  367. justify-content: space-between;
  368. padding: 0 10px 32px 10px;
  369. .userInput {
  370. display: inline-block;
  371. width: 56.3vw;
  372. max-width: 211px;
  373. height: 64px;
  374. }
  375. .my {
  376. width: 35.5vw;
  377. max-width: 133px;
  378. margin-left: 11px;
  379. }
  380. }
  381. }
  382. .down {
  383. background-image: linear-gradient(
  384. to bottom,
  385. rgba(0, 0, 0, 0.2),
  386. rgba(0, 0, 0, 0.4)
  387. );
  388. .videobg {
  389. background-image: url(../../assets/img/videobg.jpg);
  390. background-size: 100% 100%;
  391. padding: 28px 13px;
  392. .title {
  393. height: 25px;
  394. font-size: 28px;
  395. font-family: Baiwuchangtidecard;
  396. color: #ffffff;
  397. line-height: 42px;
  398. -webkit-text-stroke: 1px #0b37ab;
  399. text-stroke: 1px #0b37ab;
  400. text-align: center;
  401. margin-bottom: 25px;
  402. }
  403. .video {
  404. position: relative;
  405. font-size: 0;
  406. img {
  407. width: calc(50vw - 13px);
  408. }
  409. .play {
  410. position: absolute;
  411. font-size: 40px;
  412. color: #fff;
  413. top: 50%;
  414. left: 50%;
  415. transform: translate(-50%, -50%);
  416. z-index: 1;
  417. }
  418. }
  419. }
  420. }
  421. .playVideo {
  422. position: fixed;
  423. top: 0;
  424. left: 0;
  425. right: 0;
  426. bottom: 0;
  427. background: rgba(0, 0, 0, 1);
  428. z-index: 10;
  429. video {
  430. position: absolute;
  431. top: 50%;
  432. transform: translate(0, -50%);
  433. width: 100%;
  434. background: rgb(0, 0, 0);
  435. }
  436. .close {
  437. position: absolute;
  438. top: 10px;
  439. right: 10px;
  440. z-index: 11;
  441. color: #fff;
  442. font-size: 20px;
  443. }
  444. .btn {
  445. width: 50vw;
  446. position: absolute;
  447. left: 50%;
  448. bottom: 5vh;
  449. transform: translate(-50%, 0);
  450. }
  451. }
  452. }
  453. </style>