index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <div class="SilkRoadShanShiPinList">
  3. <img src="../../assets/img/siluchunwanlist.jpg" style="width: 100%" />
  4. <div class="guize" @click="showGuize">投票规则</div>
  5. <div class="guize" style="top: 5em" @click="paiming">查看排名</div>
  6. <van-cell-group title="团队组" style="padding: 8px">
  7. <van-row gutter="8">
  8. <van-col
  9. span="12"
  10. v-for="item in list"
  11. :key="item.id"
  12. @click="() => clickShowVideo(item)"
  13. >
  14. <van-image
  15. :width="width"
  16. :height="height"
  17. fit="cover"
  18. position="left"
  19. :src="
  20. item.file + '?x-oss-process=video/snapshot,t_100,f_jpg,m_fast'
  21. "
  22. />
  23. <van-row>
  24. <van-col :span="config.times ? 18 : 24">{{ item.name }}</van-col>
  25. <van-col span="6" v-if="config.times">
  26. <van-button
  27. type="primary"
  28. size="mini"
  29. @click="() => toupiao(item)"
  30. >投票</van-button
  31. >
  32. </van-col>
  33. </van-row>
  34. <br />
  35. </van-col>
  36. </van-row>
  37. </van-cell-group>
  38. <van-cell-group title="个人组" style="padding: 8px">
  39. <van-row gutter="8">
  40. <van-col
  41. span="12"
  42. v-for="item in listSelf"
  43. :key="item.id"
  44. @click="() => clickShowVideo(item)"
  45. >
  46. <van-image
  47. :width="width"
  48. :height="height"
  49. fit="cover"
  50. position="left"
  51. :src="
  52. item.file + '?x-oss-process=video/snapshot,t_100,f_jpg,m_fast'
  53. "
  54. />
  55. <van-row>
  56. <van-col :span="config.times ? 18 : 24">{{ item.name }}</van-col>
  57. <van-col span="6" v-if="config.times">
  58. <van-button
  59. type="primary"
  60. size="mini"
  61. @click="() => toupiao(item)"
  62. >投票</van-button
  63. >
  64. </van-col>
  65. </van-row>
  66. <br />
  67. </van-col>
  68. </van-row>
  69. </van-cell-group>
  70. <Shanshipin />
  71. <van-dialog v-model:show="showPaihang" confirm-button-text="关闭">
  72. <div style="height: 50vh">
  73. <van-tabs>
  74. <van-tab title="个人">
  75. <div class="SilkList">
  76. <van-cell-group inset>
  77. <van-cell title="名称" value="投票量"></van-cell>
  78. <van-cell
  79. v-for="item in listSelf"
  80. :key="item + 'self'"
  81. :title="item.name"
  82. :value="formmate(item.votes)"
  83. />
  84. </van-cell-group>
  85. </div>
  86. </van-tab>
  87. <van-tab title="团队">
  88. <div class="SilkList">
  89. <van-cell-group inset>
  90. <van-cell title="名称" value="投票量"></van-cell>
  91. <van-cell
  92. v-for="item in list"
  93. :key="item.id + 'team'"
  94. :title="item.name"
  95. :value="formmate(item.votes)"
  96. />
  97. </van-cell-group>
  98. </div>
  99. </van-tab>
  100. </van-tabs>
  101. </div>
  102. </van-dialog>
  103. <van-overlay z-index="20" :show="showVideo" @click="showVideo = false">
  104. <van-icon @click="() => clickShowVideo()" size="25" name="close" class="close" />
  105. <div class="video" v-if="showVideo" @click.stop>
  106. <div class="videoText" v-text="video.introduction"></div>
  107. </div>
  108. </van-overlay>
  109. <video
  110. muted
  111. v-show="showVideo"
  112. loop
  113. x5-video-player-type="h5"
  114. preload="metadata"
  115. autoplay
  116. playsinline="true"
  117. webkit-playsinline="true"
  118. x-webkit-airplay="true"
  119. x5-video-orientation="portraint"
  120. x5-video-player-fullscreen="true"
  121. :src="video.file || ''"
  122. class="videoEle"
  123. ></video>
  124. </div>
  125. </template>
  126. <script setup>
  127. import { ref, reactive } from "vue";
  128. import { showDialog, showConfirmDialog, showToast } from "vant";
  129. // import { onMounted, reactive } from "vue";
  130. // import { isIpad, isIpod, isIphone } from "../../utils/isTerminal";
  131. import { getEnrollList, getVote, getTimes } from "@/api/SilkRoadSpringGala.js";
  132. import Shanshipin from "@/components/shanshipin.vue";
  133. /**
  134. * window.$originData.orginParames.title 页面标题
  135. * window.$originData.orginParames.parameters 固定参数值
  136. * window.$originData.urlParames url参数
  137. */
  138. const getList = call => {
  139. Promise.all([
  140. getEnrollList({
  141. type: "团队",
  142. operateId: 2,
  143. }),
  144. getEnrollList({
  145. type: "个人",
  146. operateId: 2,
  147. }),
  148. ]).then(resList => {
  149. list.value = resList[0] || [];
  150. listSelf.value = resList[1] || [];
  151. call && call();
  152. });
  153. };
  154. const w = window.$originData.orginParames.availWidth || 0;
  155. const width = ref((w - 16) / 2);
  156. const height = ref(width.value * 0.57);
  157. const showPaihang = ref(false);
  158. const list = ref([]);
  159. const listSelf = ref([]);
  160. const showVideo = ref(false);
  161. const video = ref({});
  162. const config = reactive({
  163. times: -1,
  164. isShanShiPin: window.$shanshipin.UserId,
  165. });
  166. const t = config.isShanShiPin ? 5 : 1;
  167. const login = reactive({
  168. name: localStorage.getItem("SilkRoadShanShiPinName") || "",
  169. phone:
  170. window.$shanshipin.Phone ||
  171. localStorage.getItem("SilkRoadShanShiPinPhone") ||
  172. "",
  173. });
  174. getList();
  175. if (!login.phone) {
  176. showDialog({
  177. title: "登录",
  178. message: () => {
  179. return (
  180. <van-cell-group inset>
  181. <van-field
  182. v-model={login.name}
  183. required
  184. label="姓名"
  185. placeholder="请输入姓名"
  186. />
  187. <van-field
  188. v-model={login.phone}
  189. required
  190. type="tel"
  191. label="手机号"
  192. placeholder="请输入手机号"
  193. />
  194. </van-cell-group>
  195. );
  196. },
  197. theme: "round-button",
  198. beforeClose: () => {
  199. console.log(login);
  200. if (!login.phone || !login.name) return false;
  201. localStorage.setItem("SilkRoadShanShiPinPhone", login.phone);
  202. localStorage.setItem("SilkRoadShanShiPinName", login.name);
  203. return true;
  204. },
  205. });
  206. } else {
  207. getTimes({
  208. phone: login.phone,
  209. }).then(r => (config.times = r.times - t >= 0));
  210. }
  211. const toupiao = function (item) {
  212. showConfirmDialog({
  213. message: "确定投票给" + item.name + "么?",
  214. beforeClose: type => {
  215. console.log(type);
  216. if (type !== "confirm") return true;
  217. return new Promise(resolve => {
  218. getVote({
  219. target: item.phone,
  220. source: login.phone,
  221. client: config.isShanShiPin ? "闪视频" : "其他",
  222. operateId: 2,
  223. })
  224. .then(r => {
  225. console.log("----------->", r);
  226. showToast("投票成功!");
  227. resolve(true);
  228. })
  229. .catch(() => {
  230. console.log("----------->");
  231. resolve(true);
  232. });
  233. });
  234. },
  235. });
  236. };
  237. const showGuize = () => {
  238. showDialog({
  239. title: "活动规则",
  240. messageAlign: "left",
  241. confirmButtonText: "关闭",
  242. message: () => (
  243. <div class="art">
  244. <p>
  245. 1、 活动主题:“ 大美中国· 多彩丝路”《 2023 丝路嘉年华· 丝路春晚》
  246. 之我要上丝路春晚。
  247. </p>
  248. <p>
  249. 2、 活动时间: 即日起至12月20日海选报名 + 节目征集, 12 月21日 - 22
  250. 日线上海选, 12 月23日 - 26 日网络投票。
  251. </p>
  252. <p>
  253. 3、 征集范围: 各群体组织及社会民间文艺团体、 凡有才艺者,
  254. 且创作内容符合节目要求的团体和个人。
  255. </p>
  256. <p>
  257. 4、 内容形式: 节目内容以“ 大美中国· 多彩丝路” 为主题, 健康、
  258. 积极向上, 具备中国文化特色的创意表演, 节目形式包括但不限于情景歌舞、
  259. 演唱等, 以及其他适合舞台表演和电视呈现的艺术形式。
  260. </p>
  261. <p>
  262. 5、 上传规则: 参与报名的团体、
  263. 个人将录制好的高清视频作品上传至闪视频APP, 个人节目不超过3分钟,
  264. 团体节目不超过5分钟。
  265. </p>
  266. </div>
  267. ),
  268. });
  269. };
  270. const paiming = () => {
  271. if (!config.isShanShiPin) return showToast("下载闪视频查看投票结果。");
  272. getList(() => {
  273. showPaihang.value = true;
  274. });
  275. };
  276. const formmate = num => {
  277. if (num === 0) return num;
  278. let N = num || 0;
  279. switch (true) {
  280. case N >= 10000:
  281. N = (N / 10000).toFixed(2) - 0 + "万";
  282. break;
  283. case N >= 100000000:
  284. N = (N / 100000000).toFixed(2) - 0 + "亿";
  285. break;
  286. }
  287. return N;
  288. };
  289. let videoEleHTML = undefined;
  290. const clickShowVideo = item => {
  291. showVideo.value = !showVideo.value;
  292. if (!item) return;
  293. video.value = item || {};
  294. if (!videoEleHTML) videoEleHTML = document.querySelector("video");
  295. videoEleHTML.currentTime = 0;
  296. videoEleHTML.play();
  297. };
  298. </script>
  299. <style lang="scss">
  300. .SilkRoadShanShiPinList {
  301. width: 100vw;
  302. padding-bottom: 80px;
  303. .guize {
  304. background-color: #ff2c2c;
  305. position: fixed;
  306. right: 0;
  307. top: 2em;
  308. color: #fff;
  309. font-weight: 400;
  310. font-size: 16px;
  311. padding: 3px 5px 3px 15px;
  312. border-top-left-radius: 1em;
  313. border-bottom-left-radius: 1em;
  314. z-index: 2;
  315. }
  316. .SilkList {
  317. height: calc(50vh - 60px);
  318. overflow-y: auto;
  319. }
  320. .videoEle {
  321. width: 100vw;
  322. position: absolute;
  323. background-color: #000;
  324. top: 50%;
  325. z-index: 21;
  326. transform: translateY(-50%);
  327. }
  328. .van-overlay {
  329. .video {
  330. width: 100vw;
  331. height: 100vh;
  332. top: 0;
  333. position: fixed;
  334. .videoText {
  335. color: #fff;
  336. position: absolute;
  337. bottom: 0;
  338. padding: 0.5em;
  339. text-indent: 2em;
  340. }
  341. }
  342. .close {
  343. position: absolute;
  344. top: 10px;
  345. right: 10px;
  346. z-index: 11;
  347. color: #fff;
  348. font-size: 20px;
  349. }
  350. }
  351. }
  352. </style>