index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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-contail">
  9. <div class="course-page-pics-contail-wrap" :style="{ transform: translastCpd }">
  10. <img class="pic" v-for="(item, index) in course" :key="index" :src="item" />
  11. </div>
  12. </div>
  13. <div class="course-page-pagination">
  14. <div class="spon" v-for="(item, index) in course" :key="index" :class="active === index ? 'active' : ''"></div>
  15. </div>
  16. <div class="course-page-btns">
  17. <div v-if="active > 0" class="course-page-btns-btn back" @click="back">Back</div>
  18. <div v-if="active < this.course.length - 1" class="course-page-btns-btn next" @click="next">Next</div>
  19. <div v-if="active === this.course.length - 1 && isUsefulCpd && (isLottaryCpd || isTreasureCpd || isCommonCpd)" @click="retweer" class="course-page-btns-btn retweer">Retweet</div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { PlayType, UsefulType } from '../../types';
  25. import Report from '../../log-center/log';
  26. import { getQueryString, baseURL, getMid, getStorage, removeStorage, getDetailSSR } from '../../utils/help';
  27. export default {
  28. name: 'course',
  29. data() {
  30. return {
  31. active: 0,
  32. useful: '',
  33. course: [],
  34. };
  35. },
  36. computed: {
  37. translastCpd() {
  38. return `translateX(${-this.active * 100}vw)`;
  39. },
  40. isLottaryCpd() {
  41. return +this.playType === PlayType.lottery;
  42. },
  43. isCommonCpd() {
  44. return +this.playType === PlayType.common;
  45. },
  46. isTreasureCpd() {
  47. return +this.playType === PlayType.Treasure;
  48. },
  49. isNFTCpd() {
  50. return +this.playType === PlayType.NFT;
  51. },
  52. isUsefulCpd() {
  53. return this.useful === '1';
  54. },
  55. tipTextCpd() {
  56. if (!this.isUsefulCpd) {
  57. return 'How to install Denet Chrome Extension';
  58. } else if (this.isCommonCpd) {
  59. return 'Install DeNet chrome extension to claim your prize';
  60. } else if (this.isLottaryCpd || this.isTreasureCpd) {
  61. return 'Install Denet Chrome Extension to complete the quest';
  62. } else {
  63. return 'How to install Denet Chrome Extension';
  64. }
  65. },
  66. },
  67. methods: {
  68. next() {
  69. this.active++;
  70. this.reportLog();
  71. },
  72. back() {
  73. this.active--;
  74. this.reportLog();
  75. },
  76. retweer() {
  77. let logData = {
  78. baseInfo: {
  79. mid: getMid(),
  80. pageSource: Report.pageSource.tutorialPage,
  81. machineCode: getMid(),
  82. },
  83. params: {
  84. eventData: {
  85. businessType: Report.businessType.buttonClick,
  86. objectType: Report.objectType.rtButton,
  87. postId: getQueryString('postId'),
  88. },
  89. },
  90. };
  91. Report.reportLog(logData);
  92. if (getQueryString('srcContentId')) {
  93. window.location.href = `https://twitter.com/intent/retweet?tweet_id=${getQueryString('srcContentId')}`;
  94. }
  95. },
  96. reportLog() {
  97. let logData = {
  98. baseInfo: {
  99. mid: getMid(),
  100. pageSource: Report.pageSource.tutorialPage,
  101. machineCode: getMid(),
  102. },
  103. params: {
  104. eventData: {
  105. businessType: Report.businessType.pageView,
  106. postId: getQueryString('postId'),
  107. },
  108. extParams: {
  109. pageindex: this.active + 1,
  110. },
  111. },
  112. };
  113. if (this.isNFTCpd) {
  114. delete logData.params.eventData.postId;
  115. logData.params.eventData.nftProjectId = getQueryString('nftProjectId');
  116. }
  117. Report.reportLog(logData);
  118. },
  119. },
  120. async asyncData(context) {
  121. let { route, error } = context;
  122. let result = await getDetailSSR({
  123. context,
  124. url: `${baseURL}/denet/base/guide/getAllMobilePageGuide`,
  125. });
  126. if (result.code == 0) {
  127. return {
  128. useful: route.query.useful,
  129. playType: route.query.playType,
  130. course: route.query.useful === UsefulType.unUseful || route.query.playType === PlayType.NFT ? result.data.withoutRewardGuideImages : result.data.withRewardGuideImages,
  131. };
  132. } else {
  133. return error({
  134. message: result.msg,
  135. statusCode: 301,
  136. });
  137. }
  138. },
  139. mounted() {
  140. this.reportLog();
  141. const landPageLog = getStorage('land-page-log');
  142. if (landPageLog) {
  143. Report.reportLog(JSON.parse(landPageLog));
  144. removeStorage('land-page-log');
  145. }
  146. },
  147. };
  148. </script>
  149. <style lang="scss">
  150. html,
  151. body,
  152. #__nuxt,
  153. #__layout {
  154. width: 100%;
  155. height: 100%;
  156. padding: 0;
  157. margin: 0;
  158. }
  159. </style>
  160. <style lang="scss" scoped>
  161. body {
  162. background-color: #f5f5f5;
  163. }
  164. .course-page {
  165. min-height: 100%;
  166. max-height: 100%;
  167. overflow: hidden;
  168. display: flex;
  169. flex-direction: column;
  170. align-items: center;
  171. justify-content: space-between;
  172. &-tips {
  173. width: 100%;
  174. height: 80px;
  175. background: #94a7b6;
  176. display: flex;
  177. padding: 0 20px;
  178. align-items: center;
  179. font-weight: 600;
  180. font-size: 16px;
  181. line-height: 22px;
  182. color: #fff;
  183. z-index: 1;
  184. .tip-icon {
  185. width: 36px;
  186. margin-right: 20px;
  187. }
  188. }
  189. &-pics-contail {
  190. flex: 1;
  191. overflow: hidden;
  192. &-wrap {
  193. display: flex;
  194. transition: all 0.5s;
  195. .pic {
  196. width: 100%;
  197. }
  198. }
  199. }
  200. &-pagination {
  201. display: flex;
  202. justify-content: center;
  203. align-items: center;
  204. margin: 16px 0;
  205. .spon {
  206. width: 8px;
  207. height: 8px;
  208. background: #d9d9d9;
  209. margin: 0 3px;
  210. border-radius: 50%;
  211. }
  212. .active {
  213. background: #1d9bf0;
  214. }
  215. }
  216. &-btns {
  217. width: 100%;
  218. display: flex;
  219. padding: 0 8px 30px;
  220. &-btn {
  221. flex: 1;
  222. margin: 0 8px;
  223. height: 54px;
  224. line-height: 54px;
  225. text-align: center;
  226. border-radius: 60px;
  227. }
  228. &-btn:active {
  229. -webkit-tap-highlight-color: transparent;
  230. }
  231. .back {
  232. background: rgba(29, 155, 240, 0.01);
  233. border: 1px solid #e8e8e8;
  234. color: #3d3d3d;
  235. }
  236. .next {
  237. background: rgba(0, 0, 0, 0.01);
  238. border: 1px solid #b5e1ff;
  239. color: #1d9bf0;
  240. }
  241. .retweer {
  242. background: #1d9bf0;
  243. border: 1px solid #1d9bf0;
  244. color: #fff;
  245. }
  246. }
  247. }
  248. </style>