index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div
  3. class="finance2023"
  4. :style="'font-size:' + font_size + 'px'"
  5. @touchend.once="init"
  6. >
  7. <!-- 播放键 -->
  8. <svg
  9. class="imgbtn"
  10. @click="play"
  11. :style="{
  12. 'animation-play-state': play_stats ? 'running' : 'paused',
  13. }"
  14. viewBox="0 0 1024 1024"
  15. version="1.1"
  16. xmlns="http://www.w3.org/2000/svg"
  17. p-id="899"
  18. width="32"
  19. height="32"
  20. >
  21. <path
  22. d="M512 17.066667c273.339733 0 494.933333 221.5936 494.933333 494.933333S785.339733 1006.933333 512 1006.933333 17.066667 785.339733 17.066667 512 238.660267 17.066667 512 17.066667z"
  23. opacity=".502"
  24. p-id="900"
  25. ></path>
  26. <path
  27. d="M512 1024C229.2224 1024 0 794.7776 0 512 0 229.2224 229.2224 0 512 0c282.7776 0 512 229.2224 512 512 0 282.7776-229.2224 512-512 512z m0-972.8C257.501867 51.2 51.2 257.501867 51.2 512s206.301867 460.8 460.8 460.8 460.8-206.301867 460.8-460.8S766.498133 51.2 512 51.2z"
  28. fill="#FFFFFF"
  29. p-id="901"
  30. ></path>
  31. <path
  32. d="M530.568533 170.666667c4.8128 34.1504 5.495467 77.2096 41.2672 120.2688 27.4944 32.802133 58.453333 62.173867 79.7696 88.832C679.799467 414.6176 699.733333 458.359467 699.733333 502.784c0 71.0656-34.372267 141.431467-57.770666 180.394667h-10.990934c16.503467-36.898133 49.5104-97.723733 46.7456-162.628267-1.365333-36.232533-15.121067-75.178667-38.485333-103.867733-26.146133-33.501867-70.161067-60.142933-108.663467-62.8736v387.447466c0 30.754133-18.568533 58.7776-45.380266 79.274667C459.0592 841.028267 424.669867 853.333333 394.410667 853.333333c-19.2512 0-37.137067-6.144-49.5104-16.401066-13.073067-10.257067-20.6336-25.275733-20.6336-43.042134 0-28.023467 19.2512-56.046933 45.380266-76.544 26.146133-21.179733 59.136-34.850133 86.647467-34.850133 24.081067 0 44.6976 3.413333 57.088 15.035733V170.666667h17.186133z"
  33. fill="#FFFFFF"
  34. p-id="902"
  35. ></path>
  36. </svg>
  37. <img src="./img/bg2023.jpg" style="width: 100%" />
  38. <p class="users">
  39. 已有<span class="user_num" v-text="totalUser"></span>人参与
  40. </p>
  41. <div
  42. class="main"
  43. :style="{
  44. height: look_more ? 'auto' : '400px',
  45. }"
  46. >
  47. <img src="./img/mainbg.png" style="width: 100%" />
  48. <div
  49. class="inset"
  50. :style="{
  51. background: !look_more
  52. ? 'linear-gradient(#f8eac300, #f8eac3 45%)'
  53. : '#f8eac300',
  54. }"
  55. >
  56. <div class="bottom_set">
  57. <p class="line_title" v-if="!look_more" @click="look_more = true">
  58. <span style="vertical-align: middle">阅读全文</span>
  59. <svg
  60. viewBox="0 0 1024 1024"
  61. version="1.1"
  62. style="display: inline-block; vertical-align: middle"
  63. xmlns="http://www.w3.org/2000/svg"
  64. width="16"
  65. height="16"
  66. >
  67. <path
  68. fill="#986c3d"
  69. d="M486.4 537.6C492.8 544 505.6 544 512 544s19.2 0 25.6-6.4l224-224c12.8-12.8 12.8-32 0-44.8s-32-12.8-44.8 0L512 467.2 313.6 262.4C300.8 256 275.2 256 262.4 262.4S256 300.8 262.4 313.6L486.4 537.6z"
  70. ></path>
  71. <path
  72. fill="#986c3d"
  73. d="M710.4 486.4 512 691.2 313.6 486.4c-12.8-12.8-32-12.8-44.8 0S256 524.8 262.4 537.6l224 224C492.8 768 505.6 768 512 768s19.2 0 25.6-6.4l224-224c12.8-12.8 12.8-32 0-44.8S723.2 480 710.4 486.4z"
  74. ></path>
  75. </svg>
  76. </p>
  77. <p v-if="look_more" @click="look_more = false" class="line_title">
  78. <span style="vertical-align: middle">收起</span>
  79. <svg
  80. viewBox="0 0 1024 1024"
  81. version="1.1"
  82. style="
  83. display: inline-block;
  84. vertical-align: middle;
  85. transform: rotate(180deg);
  86. "
  87. xmlns="http://www.w3.org/2000/svg"
  88. width="16"
  89. height="16"
  90. >
  91. <path
  92. fill="#986c3d"
  93. d="M486.4 537.6C492.8 544 505.6 544 512 544s19.2 0 25.6-6.4l224-224c12.8-12.8 12.8-32 0-44.8s-32-12.8-44.8 0L512 467.2 313.6 262.4C300.8 256 275.2 256 262.4 262.4S256 300.8 262.4 313.6L486.4 537.6z"
  94. ></path>
  95. <path
  96. fill="#986c3d"
  97. d="M710.4 486.4 512 691.2 313.6 486.4c-12.8-12.8-32-12.8-44.8 0S256 524.8 262.4 537.6l224 224C492.8 768 505.6 768 512 768s19.2 0 25.6-6.4l224-224c12.8-12.8 12.8-32 0-44.8S723.2 480 710.4 486.4z"
  98. ></path>
  99. </svg>
  100. </p>
  101. <div @click="createhb" class="btn">
  102. <div class="inset_btn">
  103. {{ img_local ? '查看海报' : '输入姓名' }}
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. <van-dialog
  110. v-model:show="show"
  111. title=" "
  112. show-cancel-button
  113. :beforeClose="onSubmit"
  114. >
  115. <van-form>
  116. <van-cell-group inset>
  117. <van-field
  118. v-model="username"
  119. name="昵称"
  120. label="昵称"
  121. placeholder="请输入昵称"
  122. :rules="[{ required: true, message: '请填写昵称' }]"
  123. />
  124. </van-cell-group>
  125. </van-form>
  126. </van-dialog>
  127. </div>
  128. </template>
  129. <script setup>
  130. import { getTotal, saveUser } from '@/api/2023.js';
  131. import { ref } from 'vue';
  132. import { showImagePreview, showToast } from 'vant';
  133. // import { onMounted, reactive } from "vue";
  134. // import { isIpad, isIpod, isIphone } from "../../utils/isTerminal";
  135. /**
  136. * window.$originData.orginParames.title 页面标题
  137. * window.$originData.orginParames.parameters 固定参数值
  138. * window.$originData.urlParames url参数
  139. */
  140. let s = window.$originData.orginParames.availWidth / 25;
  141. s > 40 ? (s = 40) : '';
  142. const totalUser = ref(0);
  143. const font_size = ref();
  144. const play_stats = ref(false);
  145. const canvas = document.createElement('canvas');
  146. const show = ref(false);
  147. const username = ref('');
  148. let img_local = ref(localStorage.getItem('hb20230712'));
  149. let d2 = undefined;
  150. let isInitAudio = true;
  151. canvas.width = 750;
  152. canvas.height = 1334;
  153. const audio = new Audio('https://cxzx.smcic.net/topic/tool/media/bgm.mp3');
  154. audio.loop = true; // 循环播放
  155. audio.autoplay = 'autoplay';
  156. audio.oncanplay = () => {
  157. let t = setTimeout(() => {
  158. window.WeixinJSBridge &&
  159. window.WeixinJSBridge.invoke(
  160. 'getNetworkType',
  161. {},
  162. () => {
  163. audio.play();
  164. },
  165. false
  166. );
  167. clearTimeout(t);
  168. }, 500);
  169. };
  170. audio.onplaying = () => (play_stats.value = !audio.paused);
  171. audio.onpause = () => (play_stats.value = !audio.paused);
  172. const play = () => {
  173. if (audio.paused) {
  174. // 播放
  175. audio.play();
  176. } else {
  177. // 暂停
  178. audio.pause();
  179. }
  180. };
  181. const init = () => {
  182. if (!isInitAudio || !audio.paused) return;
  183. isInitAudio = false;
  184. play();
  185. };
  186. const look_more = ref(false);
  187. const createhb = () => {
  188. if (img_local.value) showImagePreview([img_local.value]);
  189. else show.value = true;
  190. };
  191. const canvas_init = (uname, num) => {
  192. return new Promise(resolve => {
  193. const img = new Image();
  194. img.crossOrigin = '';
  195. // 增加随机数选择图片
  196. img.src = 'https://cxzx.smcic.net/topic/tool/img/hb.jpg';
  197. if (!d2) d2 = canvas.getContext('2d');
  198. img.onload = () => {
  199. d2.drawImage(img, 0, 0, 750, 1334);
  200. let line1 = [100, 250];
  201. let fontsize = '30px';
  202. d2.font = fontsize + ' 微软雅黑';
  203. d2.fillStyle = '#ffffff';
  204. d2.fillText('您是第', line1[0], line1[1]);
  205. d2.font = '50px 微软雅黑';
  206. d2.fillStyle = '#ffffff';
  207. d2.fillText(uname, line1[0], 190);
  208. d2.font = '50px 微软雅黑';
  209. d2.fillStyle = '#ffffff';
  210. d2.fillText(num, 200, line1[1]);
  211. d2.font = fontsize + ' 微软雅黑';
  212. d2.fillStyle = '#ffffff';
  213. d2.fillText(
  214. '个参与本次活动的人',
  215. line1[0] + 114 + num.toString().length * 30,
  216. line1[1]
  217. );
  218. resolve();
  219. };
  220. });
  221. };
  222. const onSubmit = e => {
  223. if (e === 'cancel') return true;
  224. if (username.value.length > 10) return showToast('昵称字数不得超过5个');
  225. if (!username.value) {
  226. showToast('请输入昵称');
  227. return false;
  228. }
  229. saveUser({
  230. userName: username.value,
  231. }).then(r => {
  232. show.value = false;
  233. canvas_init(r.userName, r.userOrder + r.userOrderUnreal).then(() => {
  234. const imgs = canvas.toDataURL('image/png');
  235. showImagePreview([imgs]);
  236. img_local.value = imgs;
  237. localStorage.setItem('hb20230712', imgs);
  238. });
  239. });
  240. };
  241. const getTotalFunc = () => {
  242. getTotal().then(r => {
  243. totalUser.value = r.order;
  244. });
  245. };
  246. getTotalFunc();
  247. setInterval(() => {
  248. getTotalFunc();
  249. }, 5000);
  250. </script>
  251. <style>
  252. /* 按钮动画 */
  253. @-webkit-keyframes rotating {
  254. 0% {
  255. transform: rotate(0deg);
  256. }
  257. to {
  258. transform: rotate(1turn);
  259. }
  260. }
  261. @-moz-keyframes rotating {
  262. 0% {
  263. transform: rotate(0deg);
  264. }
  265. to {
  266. transform: rotate(1turn);
  267. }
  268. }
  269. @-o-keyframes rotating {
  270. 0% {
  271. transform: rotate(0deg);
  272. }
  273. to {
  274. transform: rotate(1turn);
  275. }
  276. }
  277. @keyframes rotating {
  278. 0% {
  279. transform: rotate(0deg);
  280. }
  281. to {
  282. transform: rotate(1turn);
  283. }
  284. }
  285. .finance2023 {
  286. width: 100vw;
  287. height: 100vh;
  288. overflow: auto;
  289. font-weight: 400;
  290. padding-bottom: 1em;
  291. background-color: #e8bd88;
  292. }
  293. .finance2023 .imgbtn {
  294. position: absolute;
  295. top: 16px;
  296. right: 16px;
  297. z-index: 10;
  298. transform-origin: center;
  299. -webkit-animation: rotating 1.2s linear infinite;
  300. -moz-animation: rotating 1.2s linear infinite;
  301. -o-animation: rotating 1.2s linear infinite;
  302. animation: rotating 1.2s linear infinite;
  303. }
  304. .finance2023 .main {
  305. width: 100%;
  306. overflow: hidden;
  307. margin: 0 auto;
  308. color: #626262;
  309. border-radius: 10px;
  310. padding: 1em 1em 55px 1em;
  311. /* background-color: #f8eac3; */
  312. background-repeat: no-repeat;
  313. background-size: 100% 100%;
  314. position: relative;
  315. }
  316. .finance2023 .main .inset {
  317. position: absolute;
  318. bottom: 0;
  319. width: 92%;
  320. left: 50%;
  321. transform: translateX(-50%);
  322. display: flex;
  323. flex-direction: column-reverse;
  324. height: 150px;
  325. background: -webkit-linear-gradient(#ffffff00, #ffffff 45%);
  326. background: -o-linear-gradient(#ffffff00, #ffffff 45%);
  327. background: -moz-linear-gradient(#ffffff00, #ffffff 45%);
  328. background: linear-gradient(#ffffff00, #ffffff 45%);
  329. }
  330. .finance2023 .main .inset .bottom_set {
  331. width: 100%;
  332. height: 75px;
  333. background-color: #ebc77d;
  334. box-shadow: inset 0 5px 5px #ebc77d;
  335. border-bottom-left-radius: 10px;
  336. border-bottom-right-radius: 10px;
  337. position: relative;
  338. }
  339. .finance2023 .main .inset .bottom_set .btn {
  340. position: absolute;
  341. top: 50%;
  342. left: 50%;
  343. transform: translate(-50%, -50%);
  344. width: 7rem;
  345. height: 2rem;
  346. color: #666;
  347. text-align: center;
  348. line-height: calc(2rem - 8px);
  349. background-color: #eeac65;
  350. border-radius: 5px;
  351. padding: 3px;
  352. box-shadow: 0 0 5px;
  353. }
  354. .finance2023 .main .inset .bottom_set .btn .inset_btn {
  355. border-radius: 5px;
  356. border: 1px dashed #fff;
  357. }
  358. .finance2023 .main .line_title {
  359. margin-top: -2em;
  360. text-align: center;
  361. color: #986c3d;
  362. }
  363. .finance2023 .users {
  364. text-align: center;
  365. color: #986c3d;
  366. margin-top: -2em;
  367. }
  368. .finance2023 .users .user_num {
  369. color: #fb0301;
  370. font-size: 1.5em;
  371. }
  372. </style>