index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!-- 移动端 教程页面 -->
  2. <template>
  3. <div class="course-page">
  4. <div class="course-page-tips">
  5. <img class="tip-icon" src="./../../static/img/icon-h5-topc.png" />
  6. <span class="tip-text">{{ tipTextCpd }}</span>
  7. </div>
  8. <div class="course-page-pics-wrap" :style="{ transform: translastCpd }">
  9. <img class="pic" v-for="(item, index) in course" :key="index" :src="item" />
  10. </div>
  11. <div class="course-page-pagination">
  12. <div class="spon" v-for="(item, index) in course" :key="index" :class="active === index ? 'active' : ''"></div>
  13. </div>
  14. <div class="course-page-btns">
  15. <div v-if="active > 0" class="course-page-btns-btn back" @click="back">Back</div>
  16. <div v-if="active < this.course.length - 1" class="course-page-btns-btn next" @click="next">Next</div>
  17. <div v-if="active === this.course.length - 1 && isUsefulCpd && (isLottaryCpd || isTreasureCpd || isCommonCpd)" @click="retweer" class="course-page-btns-btn retweer">Retweet</div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import { PlayType } from '../../types';
  23. import axios from 'axios';
  24. import { getQueryString, baseURL, appVersionCode } from '../../utils/help';
  25. export default {
  26. name: 'course',
  27. data() {
  28. return {
  29. active: 0,
  30. course: [],
  31. };
  32. },
  33. computed: {
  34. translastCpd() {
  35. return `translateX(${-this.active * 100}vw)`;
  36. },
  37. isLottaryCpd() {
  38. return this.playType === PlayType.lottery;
  39. },
  40. isCommonCpd() {
  41. return this.playType === PlayType.common;
  42. },
  43. isTreasureCpd() {
  44. return this.playType === PlayType.Treasure;
  45. },
  46. isUsefulCpd() {
  47. return getQueryString('useful') === '1';
  48. },
  49. tipTextCpd() {
  50. if (this.isLottaryCpd) {
  51. return 'Install DeNet chrome extension to claim your prize';
  52. } else if (this.isCommonCpd || this.is) {
  53. return 'Install Denet Chrome Extension to complete the quest';
  54. } else {
  55. return 'How to install Denet Chrome Extension';
  56. }
  57. },
  58. },
  59. methods: {
  60. next() {
  61. if (this.active < this.course.length - 1) {
  62. this.active++;
  63. } else {
  64. window.location.replace(`https://twitter.com/intent/retweet?tweet_id=${this.postId}`);
  65. }
  66. },
  67. back() {
  68. this.active--;
  69. },
  70. retweer() {
  71. window.open(`https://twitter.com/intent/retweet?tweet_id=${this.postId}`);
  72. },
  73. },
  74. async asyncData(params) {
  75. let { route } = params;
  76. let { data } = await axios.post(`${baseURL}/denet/base/guide/getAllMobilePageGuide`, {
  77. baseInfo: {
  78. appVersionCode: appVersionCode,
  79. mid: '00000000-0000-0000-0000-000000000000',
  80. },
  81. });
  82. if (data.code == 0) {
  83. console.log('detail', data.data, route);
  84. return {
  85. course: route.query.useful === '1' ? data.data.withRewardGuideImages : data.data.withoutRewardGuideImages,
  86. };
  87. }
  88. },
  89. mounted() {
  90. this.playType = getQueryString('playType');
  91. this.rewardType = getQueryString('rewardType');
  92. this.postId = getQueryString('postId');
  93. },
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. body {
  98. background-color: #f5f5f5;
  99. }
  100. .course-page {
  101. min-height: 100vh;
  102. max-height: 100vh;
  103. overflow: hidden;
  104. display: flex;
  105. flex-direction: column;
  106. align-items: center;
  107. justify-content: space-between;
  108. &-tips {
  109. width: 100%;
  110. height: 80px;
  111. background: #94a7b6;
  112. display: flex;
  113. padding: 0 20px;
  114. align-items: center;
  115. font-weight: 600;
  116. font-size: 16px;
  117. line-height: 22px;
  118. color: #fff;
  119. position: fixed;
  120. top: 0;
  121. left: 0;
  122. z-index: 1;
  123. .tip-icon {
  124. width: 36px;
  125. margin-right: 20px;
  126. }
  127. }
  128. &-pics-wrap {
  129. display: flex;
  130. transition: all 0.5s;
  131. .pic {
  132. width: 100%;
  133. }
  134. }
  135. &-pagination {
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. .spon {
  140. width: 8px;
  141. height: 8px;
  142. background: #d9d9d9;
  143. margin: 0 3px;
  144. border-radius: 50%;
  145. }
  146. .active {
  147. background: #1d9bf0;
  148. }
  149. }
  150. &-btns {
  151. width: 100%;
  152. display: flex;
  153. padding: 0 8px 30px;
  154. &-btn {
  155. flex: 1;
  156. margin: 0 8px;
  157. height: 54px;
  158. line-height: 54px;
  159. text-align: center;
  160. border-radius: 60px;
  161. }
  162. &-btn:active {
  163. -webkit-tap-highlight-color: transparent;
  164. }
  165. .back {
  166. background: rgba(29, 155, 240, 0.01);
  167. border: 1px solid #e8e8e8;
  168. color: #3d3d3d;
  169. }
  170. .next {
  171. background: rgba(0, 0, 0, 0.01);
  172. border: 1px solid #b5e1ff;
  173. color: #1d9bf0;
  174. }
  175. .retweer {
  176. background: #1d9bf0;
  177. border: 1px solid #1d9bf0;
  178. color: #fff;
  179. }
  180. }
  181. }
  182. </style>