Browse Source

Merge branch 'dev_1.1.7_lint' of https://git.yishihui.com/DeNet/de-net-official into dev_1.1.7_lint

wenliming 2 years ago
parent
commit
37f7836d99
3 changed files with 46 additions and 39 deletions
  1. 1 1
      README.md
  2. 15 5
      components/MobileLandPage.vue
  3. 30 33
      pages/course/index.vue

+ 1 - 1
README.md

@@ -95,4 +95,4 @@ pm2 list (pm2常用命令 https://zhuanlan.zhihu.com/p/395339261
 
 停止守护进程: pm2 stop "de-net-official"
 
-删除守护进程: pm2 delete "de-net-official"
+删除守护进程: pm2 delete "de-net-official"

+ 15 - 5
components/MobileLandPage.vue

@@ -60,7 +60,7 @@
 		<FontZoom width="330">
 			<div class="mobile-land-page-tip">{{ tipCpd }}</div>
 		</FontZoom>
-		<div class="mobile-land-page-login-twitter" @click="toLogin">Login Twitter</div>
+		<div class="mobile-land-page-login-twitter" @click="toLogin">{{ isLoginCpd ? 'Claim Prize' : 'Login Twitter' }}</div>
 	</div>
 </template>
 <script>
@@ -69,6 +69,8 @@ import { getStorage, setStorage, removeStorage, storageKey, getOauthUrl, createW
 import { postRequest } from '../http';
 import FontZoom from './FontZoom';
 
+const TO_LOGIN_KEY = 'twitter-login-from-denet-mobile-h5-landpage';
+
 const overTimePic = require('../static/img/icon-h5-denet.svg');
 const giveawayPic = require('../static/img/icon-h5-giveaway.svg');
 const redpackPic = require('../static/img/icon-h5-redpack.svg');
@@ -176,13 +178,17 @@ export default {
 				return 'login Twitter to install DeNet Chrome Extension';
 			}
 		},
+		isLoginCpd() {
+			return !!getStorage(storageKey.userInfo);
+		},
 	},
 	methods: {
 		toLogin() {
 			let userInfo = getStorage(storageKey.userInfo);
 			if (userInfo) {
-				location.href = `/course?useful=${this.useFul ? '0' : '1'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
+				location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
 			} else {
+				setStorage(TO_LOGIN_KEY, 1);
 				this.twitterAuth();
 			}
 		},
@@ -193,9 +199,7 @@ export default {
 				},
 			}).then(({ code, data }) => {
 				if (code == 0) {
-					console.log('%c [ data ]-78', 'font-size:13px; background:pink; color:#bf2c9f;', data);
 					let url = getOauthUrl(data.authToken);
-
 					let win = createWindow(url);
 					this.timer.value = setInterval(() => {
 						if (win && win.closed) {
@@ -217,7 +221,6 @@ export default {
 					},
 				}).then(({ code, data }) => {
 					if (code == 0) {
-						console.log('%c [ data ]-100', 'font-size:13px; background:pink; color:#bf2c9f;', data);
 						setStorage(storageKey.userInfo, data);
 						removeStorage(storageKey.verifier);
 					}
@@ -225,6 +228,13 @@ export default {
 			}
 		},
 	},
+	mounted() {
+		const fromTwitterLoginPage = getStorage(TO_LOGIN_KEY);
+		if (fromTwitterLoginPage) {
+			removeStorage(TO_LOGIN_KEY);
+			location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
+		}
+	},
 	components: { FontZoom },
 };
 </script>

+ 30 - 33
pages/course/index.vue

@@ -14,15 +14,15 @@
 		<div class="course-page-btns">
 			<div v-if="active > 0" class="course-page-btns-btn back" @click="back">Back</div>
 			<div v-if="active < this.course.length - 1" class="course-page-btns-btn next" @click="next">Next</div>
-			<div v-if="active < this.course.length && (isLottaryCpd || isTreasureCpd || isCommonCpd)" @click="retweer" class="course-page-btns-btn retweer">Retweet</div>
+			<div v-if="active === this.course.length - 1 && isUsefulCpd && (isLottaryCpd || isTreasureCpd || isCommonCpd)" @click="retweer" class="course-page-btns-btn retweer">Retweet</div>
 		</div>
 	</div>
 </template>
 
 <script>
-import { postRequest } from '../../http';
 import { PlayType } from '../../types';
-import { getQueryString } from '../../utils/help';
+import axios from 'axios';
+import { getQueryString, baseURL, appVersionCode } from '../../utils/help';
 
 export default {
 	name: 'course',
@@ -37,21 +37,21 @@ export default {
 			return `translateX(${-this.active * 100}vw)`;
 		},
 		isLottaryCpd() {
-			return this.playType === PlayType.lottery;
+			return +getQueryString('playType') === PlayType.lottery;
 		},
 		isCommonCpd() {
-			return this.playType === PlayType.common;
+			return +getQueryString('playType') === PlayType.common;
 		},
 		isTreasureCpd() {
-			return this.playType === PlayType.Treasure;
+			return +getQueryString('playType') === PlayType.Treasure;
 		},
-		isTimeExpiredCpd() {
-			return this.useful === '0';
+		isUsefulCpd() {
+			return getQueryString('useful') === '1';
 		},
 		tipTextCpd() {
 			if (this.isLottaryCpd) {
 				return 'Install DeNet chrome extension to claim your prize';
-			} else if (this.isCommonCpd || this.is) {
+			} else if (this.isCommonCpd || this.isTreasureCpd) {
 				return 'Install Denet Chrome Extension to complete the quest';
 			} else {
 				return 'How to install Denet Chrome Extension';
@@ -59,38 +59,31 @@ export default {
 		},
 	},
 	methods: {
-		getCource() {
-			postRequest(`/base/guide/getAllMobilePageGuide`, {}).then(({ code, data }) => {
-				if (code == 0) {
-					console.log('%c [ data ]-78', 'font-size:13px; background:pink; color:#bf2c9f;', data);
-					if (this.useful === 1) {
-						this.course = data.withRewardGuideImages;
-					} else {
-						this.course = data.withoutRewardGuideImages;
-					}
-				}
-			});
-		},
 		next() {
-			if (this.active < this.course.length - 1) {
-				this.active++;
-			} else {
-				window.location.replace(`https://twitter.com/intent/retweet?tweet_id=${this.postId}`);
-			}
+			this.active++;
 		},
 		back() {
 			this.active--;
 		},
 		retweer() {
-			window.open(`https://twitter.com/intent/retweet?tweet_id=${this.postId}`);
+			if (getQueryString('postId')) {
+				window.open(`https://twitter.com/intent/retweet?tweet_id=${getQueryString('postId')}`);
+			}
 		},
 	},
-	mounted() {
-		this.getCource();
-		this.useful = getQueryString('useful');
-		this.playType = getQueryString('playType');
-		this.rewardType = getQueryString('rewardType');
-		this.postId = getQueryString('postId');
+	async asyncData(params) {
+		let { route } = params;
+		let { data } = await axios.post(`${baseURL}/denet/base/guide/getAllMobilePageGuide`, {
+			baseInfo: {
+				appVersionCode: appVersionCode,
+				mid: '00000000-0000-0000-0000-000000000000',
+			},
+		});
+		if (data.code == 0) {
+			return {
+				course: route.query.useful === '1' ? data.data.withRewardGuideImages : data.data.withoutRewardGuideImages,
+			};
+		}
 	},
 };
 </script>
@@ -119,6 +112,10 @@ body {
 		font-size: 16px;
 		line-height: 22px;
 		color: #fff;
+		position: fixed;
+		top: 0;
+		left: 0;
+		z-index: 1;
 		.tip-icon {
 			width: 36px;
 			margin-right: 20px;