index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!--
  2. 每月挑战
  3. http://localhost:5173/card/#/pages/mytz/index
  4. https://oss-mbh5.colormaprun.com/card/#/pages/mytz/index
  5. -->
  6. <template>
  7. <view class="body body-radius">
  8. <view class="content uni-column" :class="contentBg" @click="btnClick">
  9. <view class="main uni-column">
  10. <image mode="aspectFit" class="logo" :src="logoSrc"></image>
  11. <text class="type">{{ecName}}</text>
  12. <text class="name">{{name}}</text>
  13. <button class="button button-txtcolor">{{btnText}}</button>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import tools from '../../common/tools';
  20. import {
  21. ossUrl,
  22. token,
  23. apiCardBaseQuery,
  24. } from '../../common/api';
  25. export default {
  26. data() {
  27. return {
  28. queryString: "",
  29. token: "",
  30. ecId: 0, // 卡片id
  31. ecName: '', // 卡片名称
  32. ecDesc: '', // 卡片简介
  33. beginSecond: null, // 卡片开始时间戳,单位秒
  34. endSecond: null, // 卡片结束时间戳,单位秒
  35. contentBg: "",
  36. logoSrc: "",
  37. type: "",
  38. name: "",
  39. btnText: "",
  40. }
  41. },
  42. computed: {
  43. curYearMonth() {
  44. var currentDate = new Date();
  45. var currentYear = currentDate.getFullYear();
  46. var currentMonth = currentDate.getMonth() + 1; // 月份从0开始,所以要加1
  47. return `${currentYear}年${currentMonth}月`;
  48. }
  49. },
  50. onLoad(event) { // 类型非必填,可自动推导
  51. // console.log(event);
  52. this.queryString = tools.objectToQueryString(event);
  53. // console.log(queryString);
  54. this.token = event["token"] ?? token;
  55. this.ecId = event["id"] ?? 0;
  56. this.contentBg = "content-bg-" + (event["bg"] ?? "blue");
  57. this.logoSrc = "/static/logo/" + (event["logo"] ?? "mytz") + '.png';
  58. // this.type = event["type"] ?? "每月挑战";
  59. this.name = event["name"] ?? this.curYearMonth;
  60. this.btnText = event["btnText"] ?? "开始挑战";
  61. this.getCardBaseQuery();
  62. },
  63. onUnload() {
  64. },
  65. methods: {
  66. // 卡片基本信息查询
  67. getCardBaseQuery() {
  68. uni.request({
  69. url: apiCardBaseQuery,
  70. header: {
  71. "Content-Type": "application/x-www-form-urlencoded",
  72. "token": this.token,
  73. },
  74. method: "POST",
  75. data: {
  76. ecId: this.ecId
  77. },
  78. success: (res) => {
  79. // console.log("getCardBaseQuery", res)
  80. const data = res.data.data;
  81. this.ecName = data.ecName;
  82. this.ecDesc = data.ecDesc;
  83. this.beginSecond = data.beginSecond;
  84. this.endSecond = data.endSecond;
  85. },
  86. fail: (err) => {
  87. console.log("getCardBaseQuery err", err)
  88. },
  89. });
  90. },
  91. btnClick() {
  92. window.location.href = `${ossUrl}#/pages/mytz/detail?${this.queryString}`;
  93. }
  94. }
  95. }
  96. </script>
  97. <style>
  98. .content {
  99. width: 100vw;
  100. height: 100vh;
  101. justify-content: center;
  102. }
  103. .content-bg-blue {
  104. background: linear-gradient(180deg,#178bff 0%,#004d9b 100%);
  105. }
  106. .content-bg-green {
  107. background: linear-gradient(180deg,#7aedff 0%,#047200 100%);
  108. }
  109. .content-bg-brown {
  110. background: linear-gradient(180deg,#ad4301 0%,#8d2219 100%);
  111. }
  112. .main {
  113. width: 100%;
  114. height: 700rpx;
  115. /* margin-top: 20rpx; */
  116. justify-content: space-evenly;
  117. }
  118. .logo {
  119. /* width: 230rpx; */
  120. height: 230rpx;
  121. }
  122. .type {
  123. opacity: 60%;
  124. /* line-height: 25px; */
  125. font-family: Roboto;
  126. color: #ffffff;
  127. font-size: 36rpx;
  128. text-align: center;
  129. }
  130. .name {
  131. font-family: Roboto;
  132. color: #ffffff;
  133. font-size: 46rpx;
  134. text-align: center;
  135. }
  136. .button {
  137. width: 320rpx;
  138. height: 86rpx;
  139. background: #ffffff;
  140. border-radius: 56rpx;
  141. font-size: 46rpx;
  142. line-height: 80rpx;
  143. }
  144. .button-txtcolor {
  145. color: #0458ad;
  146. }
  147. </style>