index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="page">
  3. <div class="page-top"></div>
  4. <div class="page-content">
  5. <div class="content"></div>
  6. <div class="entry">
  7. <div class="title">活动入口</div>
  8. <div class="list">
  9. <div class="cover" @click="toDetail">
  10. <span class="status" :class="activity.type">{{
  11. activity.text
  12. }}</span>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import { mapGetters } from 'vuex'
  21. export default {
  22. layout: 'app-ross',
  23. data() {
  24. return {
  25. activityState: 0,
  26. }
  27. },
  28. computed: {
  29. ...mapGetters(['routePrefix', 'authUserId']),
  30. activity() {
  31. const result = {
  32. 2: { type: 'end', text: '已结束' },
  33. 1: { type: 'start', text: '进行中' },
  34. 0: { type: 'wait', text: '未开始' },
  35. }
  36. return result[this.activityState]
  37. },
  38. },
  39. created() {
  40. this.fetchActivityStatus()
  41. },
  42. methods: {
  43. toDetail() {
  44. if (this.activityState !== 1) {
  45. this.$toast(`活动${this.activity.text}`)
  46. return
  47. }
  48. const url = `${this.routePrefix}/activity/challenge/list`
  49. this.$router.push(url)
  50. },
  51. async fetchActivityStatus() {
  52. try {
  53. const res = await this.$http.api.fetchActivityStatus({
  54. authUserId: this.authUserId,
  55. })
  56. if (!res.data) return
  57. this.activityState = res.data.activityState
  58. } catch (error) {
  59. console.log(error)
  60. }
  61. },
  62. },
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. @media screen and (min-width: 768px) {
  67. .page {
  68. padding-bottom: 269px;
  69. .page-top {
  70. width: 100%;
  71. height: 530px;
  72. background-position: center;
  73. background: #ddd;
  74. }
  75. .page-content {
  76. width: 1200px;
  77. margin: 0 auto;
  78. margin-top: 16px;
  79. .content {
  80. min-height: 1170px;
  81. background: #fff5e8;
  82. }
  83. .entry {
  84. .title {
  85. font-size: 24px;
  86. text-align: center;
  87. font-weight: bold;
  88. color: #282828;
  89. margin: 85px 0 48px;
  90. }
  91. .cover {
  92. position: relative;
  93. width: 856px;
  94. height: 340px;
  95. margin: 0 auto;
  96. background: pink;
  97. cursor: pointer;
  98. .status {
  99. position: absolute;
  100. left: 0;
  101. top: 0;
  102. width: 72px;
  103. height: 32px;
  104. line-height: 32px;
  105. border-radius: 8px 0 8px 0;
  106. color: #fff;
  107. text-align: center;
  108. &.wait {
  109. background: #f94b4b;
  110. }
  111. &.start {
  112. background: #f3920d;
  113. }
  114. &.end {
  115. background: rgba(0, 0, 0, 0.3);
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. @media screen and (max-width: 768px) {
  124. .page {
  125. padding-bottom: 10vw;
  126. .page-top {
  127. width: 100%;
  128. height: 100vw;
  129. background-position: center;
  130. background: #ddd;
  131. }
  132. .page-content {
  133. width: 85.6vw;
  134. margin: 0 auto;
  135. margin-top: 3.2vw;
  136. .content {
  137. min-height: 116.3vw;
  138. background: #fff5e8;
  139. }
  140. .entry {
  141. .title {
  142. font-size: 4.2vw;
  143. text-align: center;
  144. font-weight: bold;
  145. color: #282828;
  146. margin: 7.2vw 0 4.3vw;
  147. }
  148. .cover {
  149. position: relative;
  150. width: 85.6vw;
  151. height: 34vw;
  152. margin: 0 auto;
  153. background: pink;
  154. cursor: pointer;
  155. .status {
  156. position: absolute;
  157. left: 0;
  158. top: 0;
  159. width: 12.8vw;
  160. height: 5.6vw;
  161. line-height: 5.6vw;
  162. border-radius: 0.8vw 0 0.8vw 0;
  163. color: #fff;
  164. text-align: center;
  165. font-size: 3vw;
  166. &.wait {
  167. background: #f94b4b;
  168. }
  169. &.start {
  170. background: #f3920d;
  171. }
  172. &.end {
  173. background: rgba(0, 0, 0, 0.3);
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. </style>