index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <!--
  2. 锦标赛
  3. http://localhost:5173/card/#/pages/jbs/index
  4. https://oss-mbh5.colormaprun.com/card/#/pages/jbs/index
  5. -->
  6. <template>
  7. <view class="body body-radius">
  8. <view class="content" :class="cssContentBg" @click="btnClick">
  9. <view class="top uni-row">
  10. <view class="top-right uni-row">
  11. <image mode="aspectFit" class="clock" src="/static/default/clock.png"></image>
  12. <view class="countdown">{{countdown}}</view>
  13. </view>
  14. </view>
  15. <view class="main uni-column">
  16. <view :class="cssLogo"></view>
  17. <text class="type">{{type}}</text>
  18. <text class="name">{{ecName}}</text>
  19. <button class="button button-txtcolor">{{btnText}}</button>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import tools from '../../common/tools';
  26. import {
  27. token,
  28. ossUrl,
  29. apiCardBaseQuery,
  30. apiCardConfigQuery,
  31. apiCardDetailQuery
  32. } from '../../common/api';
  33. export default {
  34. data() {
  35. return {
  36. pageName: "index",
  37. queryString: "",
  38. token: "",
  39. ecId: 0, // 卡片id
  40. ecName: '', // 卡片名称
  41. ecDesc: '', // 卡片简介
  42. beginSecond: null, // 卡片开始时间戳,单位秒
  43. endSecond: null, // 卡片结束时间戳,单位秒
  44. // mcId: 0, // 赛事id
  45. // mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
  46. // mcName: "", // 赛事名称
  47. countdown: "", // 倒计时
  48. interval: null,
  49. cssContentBg: "",
  50. cssLogo: "",
  51. type: "",
  52. btnText: "",
  53. }
  54. },
  55. computed: {},
  56. onLoad(event) { // 类型非必填,可自动推导
  57. // console.log(event);
  58. this.queryString = tools.objectToQueryString(event);
  59. // console.log(queryString);
  60. this.token = event["token"] ?? token;
  61. this.ecId = event["id"] ?? 0;
  62. this.type = event["type"] ?? "锦标赛";
  63. this.btnText = event["btnText"] ?? "开始比赛";
  64. tools.removeCssCode();
  65. this.getCardBaseQuery();
  66. this.getCardConfigQuery();
  67. },
  68. onUnload() {
  69. this.clear();
  70. },
  71. methods: {
  72. clear() {
  73. if (this.interval != null) {
  74. clearInterval(this.interval);
  75. this.interval = null;
  76. }
  77. },
  78. loadConfig(config) {
  79. // console.log("config", config);
  80. const css = config.css;
  81. if (css != undefined && css.length > 0) {
  82. tools.loadCssCode(css);
  83. if (css.indexOf(".content-bg{") >= 0) {
  84. this.cssContentBg = "content-bg";
  85. }
  86. if (css.indexOf(".logo{") >= 0) {
  87. this.cssLogo = "logo";
  88. }
  89. }
  90. if (this.cssContentBg == "") {
  91. this.cssContentBg = "content-bg-default";
  92. }
  93. if (this.cssLogo == "") {
  94. this.cssLogo = "logo-default";
  95. }
  96. console.log("[loadConfig] cssContentBg:", this.cssContentBg);
  97. console.log("[loadConfig] cssLogo:", this.cssLogo);
  98. },
  99. // 获取倒计时
  100. getCountdown() {
  101. // console.log(this.endSecond)
  102. if (this.endSecond > 0) {
  103. const now = Date.now() / 1000;
  104. const dif = this.endSecond - now;
  105. // const dif = 3600*24 - 60;
  106. if (dif > 0) {
  107. this.countdown = tools.convertSecondsToDHM(dif);
  108. } else {
  109. this.countdown = "已结束";
  110. }
  111. // this.countdown = tools.convertSecondsToHMS(dif);
  112. } else {
  113. this.countdown = "--天--小时";
  114. }
  115. },
  116. // 卡片基本信息查询
  117. getCardBaseQuery() {
  118. uni.request({
  119. url: apiCardBaseQuery,
  120. header: {
  121. "Content-Type": "application/x-www-form-urlencoded",
  122. "token": this.token,
  123. },
  124. method: "POST",
  125. data: {
  126. ecId: this.ecId
  127. },
  128. success: (res) => {
  129. console.log("getCardBaseQuery", res)
  130. const data = res.data.data;
  131. this.ecName = data.ecName;
  132. this.ecDesc = data.ecDesc;
  133. this.beginSecond = data.beginSecond;
  134. this.endSecond = data.endSecond;
  135. this.getCountdown();
  136. this.clear();
  137. this.interval = setInterval(this.getCountdown, 60000);
  138. },
  139. fail: (err) => {
  140. console.log("getCardBaseQuery err", err)
  141. },
  142. });
  143. },
  144. // 卡片配置信息查询
  145. getCardConfigQuery() {
  146. uni.request({
  147. url: apiCardConfigQuery,
  148. header: {
  149. "Content-Type": "application/x-www-form-urlencoded",
  150. "token": this.token,
  151. },
  152. method: "POST",
  153. data: {
  154. ecId: this.ecId,
  155. pageName: this.pageName
  156. },
  157. success: (res) => {
  158. // console.log("getCardConfigQuery", res)
  159. const data = res.data.data;
  160. const config = data.configJson != "" ? JSON.parse(data.configJson) : "";
  161. // console.log("configJson", config);
  162. /* const config = {
  163. "css": `
  164. .content-bg{
  165. background: url('static/cardbg/xfl.png') no-repeat;
  166. background-size: cover;
  167. }
  168. .logo{
  169. width: 50vw;
  170. height: 50vw;
  171. background: url('static/logo/xfl.png') no-repeat;
  172. background-size: contain;
  173. }
  174. `
  175. }; */
  176. this.loadConfig(config);
  177. },
  178. fail: (err) => {
  179. console.log("getCardConfigQuery err", err)
  180. },
  181. });
  182. },
  183. // 卡片信息查询
  184. // getCardDetailQuery() {
  185. // uni.request({
  186. // url: apiCardDetailQuery,
  187. // header: {
  188. // "Content-Type": "application/x-www-form-urlencoded",
  189. // "token": this.token,
  190. // },
  191. // method: "POST",
  192. // data: {
  193. // ecId: this.ecId
  194. // },
  195. // success: (res) => {
  196. // console.log("getCardDetailQuery", res)
  197. // const data = res.data.data;
  198. // this.mcType = data.mcType;
  199. // this.mcId = data.mcId;
  200. // this.mcName = data.mcName;
  201. // this.endSecond = data.endSecond;
  202. // this.getCountdown();
  203. // this.clear();
  204. // this.interval = setInterval(this.getCountdown, 60000);
  205. // },
  206. // fail: (err) => {
  207. // console.log("getCardDetailQuery err", err)
  208. // },
  209. // });
  210. // },
  211. btnClick() {
  212. // uni.reLaunch({
  213. // uni.navigateTo({
  214. // url: '/pages/default/rankList?' + this.queryString
  215. // });
  216. // window.location.href = `https://oss-mbh5.colormaprun.com/card/#/pages/default/rankList?${this.queryString}`;
  217. window.location.href = `${ossUrl}#/pages/jbs/rankList?${this.queryString}`;
  218. }
  219. }
  220. }
  221. </script>
  222. <style scoped>
  223. .content {
  224. width: 100vw;
  225. height: 100vh;
  226. }
  227. .content-bg-default {
  228. background: linear-gradient(180deg, #7aedff 0%, #047200 100%);
  229. /* background: linear-gradient(180deg, #178bff 0%, #004d9b 100%); */
  230. /* background: linear-gradient(180deg, #7aedff 0%, #8d2219 100%); */
  231. }
  232. .top {
  233. width: 100%;
  234. justify-content: flex-end;
  235. }
  236. .top-right {
  237. min-width: 180rpx;
  238. height: 80rpx;
  239. margin-top: 30rpx;
  240. margin-right: 30rpx;
  241. padding-left: 16rpx;
  242. padding-right: 16rpx;
  243. background-color: rgba(0, 0, 0, 0.3);
  244. border-radius: 12px;
  245. }
  246. .clock {
  247. width: 50rpx;
  248. height: 50rpx;
  249. margin-right: 12rpx;
  250. }
  251. .countdown {
  252. min-width: 120rpx;
  253. text-align: center;
  254. font-family: Roboto;
  255. color: #ffffff;
  256. font-size: 46rpx;
  257. /* letter-spacing: 2rpx; */
  258. }
  259. .main {
  260. width: 100%;
  261. height: 700rpx;
  262. margin-top: 20rpx;
  263. justify-content: space-evenly;
  264. }
  265. .logo-default {
  266. width: 50vw;
  267. height: 50vw;
  268. background-image: url('/static/logo/jbs.png');
  269. background-repeat: no-repeat;
  270. background-position-x: center;
  271. background-position-y: center;
  272. background-size: contain;
  273. }
  274. .type {
  275. opacity: 60%;
  276. /* line-height: 25px; */
  277. font-family: Roboto;
  278. color: #ffffff;
  279. font-size: 40rpx;
  280. text-align: center;
  281. }
  282. .name {
  283. font-family: Roboto;
  284. color: #ffffff;
  285. font-size: 50rpx;
  286. text-align: center;
  287. }
  288. .button {
  289. width: 320rpx;
  290. height: 86rpx;
  291. margin-top: 30rpx;
  292. background: #ffffff;
  293. border-radius: 56rpx;
  294. font-size: 46rpx;
  295. line-height: 80rpx;
  296. }
  297. .button-txtcolor {
  298. color: #000000;
  299. }
  300. </style>