Browse Source

login in course page

jihuaqiang 2 years ago
parent
commit
db6327b651
2 changed files with 13 additions and 20 deletions
  1. 5 5
      components/MobileLandPage.vue
  2. 8 15
      pages/course/index.vue

+ 5 - 5
components/MobileLandPage.vue

@@ -64,7 +64,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>
@@ -182,14 +182,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) {
-				setStorage(TO_LOGIN_KEY, 1);
 				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();
 			}
 		},
@@ -200,9 +203,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) {
@@ -224,7 +225,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);
 					}

+ 8 - 15
pages/course/index.vue

@@ -37,13 +37,13 @@ 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;
 		},
 		isUsefulCpd() {
 			return getQueryString('useful') === '1';
@@ -51,7 +51,7 @@ export default {
 		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';
@@ -60,17 +60,15 @@ export default {
 	},
 	methods: {
 		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')}`);
+			}
 		},
 	},
 	async asyncData(params) {
@@ -88,11 +86,6 @@ export default {
 			};
 		}
 	},
-	mounted() {
-		this.playType = getQueryString('playType');
-		this.rewardType = getQueryString('rewardType');
-		this.postId = getQueryString('postId');
-	},
 };
 </script>