Browse Source

http request change

jihuaqiang 2 years ago
parent
commit
b4abfb44a2
2 changed files with 35 additions and 20 deletions
  1. 11 1
      components/MobileLandPage.vue
  2. 24 19
      pages/course/index.vue

+ 11 - 1
components/MobileLandPage.vue

@@ -73,6 +73,8 @@ import { getStorage, setStorage, removeStorage, storageKey, getOauthUrl, createW
 import { postRequest } from '../http';
 import { postRequest } from '../http';
 import FontZoom from './FontZoom';
 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 overTimePic = require('../static/img/icon-h5-denet.svg');
 const giveawayPic = require('../static/img/icon-h5-giveaway.svg');
 const giveawayPic = require('../static/img/icon-h5-giveaway.svg');
 const redpackPic = require('../static/img/icon-h5-redpack.svg');
 const redpackPic = require('../static/img/icon-h5-redpack.svg');
@@ -185,7 +187,8 @@ export default {
 		toLogin() {
 		toLogin() {
 			let userInfo = getStorage(storageKey.userInfo);
 			let userInfo = getStorage(storageKey.userInfo);
 			if (userInfo) {
 			if (userInfo) {
-				location.href = `/course?useful=${this.useFul ? '0' : '1'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
+				setStorage(TO_LOGIN_KEY, 1);
+				location.href = `/course?useful=${this.useFul ? '1' : '0'}&playType=${this.playType}&rewardType=${this.rewardType}&postId=${this.postId}`;
 			} else {
 			} else {
 				this.twitterAuth();
 				this.twitterAuth();
 			}
 			}
@@ -229,6 +232,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 },
 	components: { FontZoom },
 };
 };
 </script>
 </script>

+ 24 - 19
pages/course/index.vue

@@ -14,15 +14,15 @@
 		<div class="course-page-btns">
 		<div class="course-page-btns">
 			<div v-if="active > 0" class="course-page-btns-btn back" @click="back">Back</div>
 			<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 - 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>
 	</div>
 	</div>
 </template>
 </template>
 
 
 <script>
 <script>
-import { postRequest } from '../../http';
 import { PlayType } from '../../types';
 import { PlayType } from '../../types';
-import { getQueryString } from '../../utils/help';
+import axios from 'axios';
+import { getQueryString, baseURL, appVersionCode } from '../../utils/help';
 
 
 export default {
 export default {
 	name: 'course',
 	name: 'course',
@@ -45,8 +45,8 @@ export default {
 		isTreasureCpd() {
 		isTreasureCpd() {
 			return this.playType === PlayType.Treasure;
 			return this.playType === PlayType.Treasure;
 		},
 		},
-		isTimeExpiredCpd() {
-			return this.useful === '0';
+		isUsefulCpd() {
+			return getQueryString('useful') === '1';
 		},
 		},
 		tipTextCpd() {
 		tipTextCpd() {
 			if (this.isLottaryCpd) {
 			if (this.isLottaryCpd) {
@@ -59,18 +59,6 @@ export default {
 		},
 		},
 	},
 	},
 	methods: {
 	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() {
 		next() {
 			if (this.active < this.course.length - 1) {
 			if (this.active < this.course.length - 1) {
 				this.active++;
 				this.active++;
@@ -85,9 +73,22 @@ export default {
 			window.open(`https://twitter.com/intent/retweet?tweet_id=${this.postId}`);
 			window.open(`https://twitter.com/intent/retweet?tweet_id=${this.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) {
+			console.log('detail', data.data, route);
+			return {
+				course: route.query.useful === '1' ? data.data.withRewardGuideImages : data.data.withoutRewardGuideImages,
+			};
+		}
+	},
 	mounted() {
 	mounted() {
-		this.getCource();
-		this.useful = getQueryString('useful');
 		this.playType = getQueryString('playType');
 		this.playType = getQueryString('playType');
 		this.rewardType = getQueryString('rewardType');
 		this.rewardType = getQueryString('rewardType');
 		this.postId = getQueryString('postId');
 		this.postId = getQueryString('postId');
@@ -119,6 +120,10 @@ body {
 		font-size: 16px;
 		font-size: 16px;
 		line-height: 22px;
 		line-height: 22px;
 		color: #fff;
 		color: #fff;
+		position: fixed;
+		top: 0;
+		left: 0;
+		z-index: 1;
 		.tip-icon {
 		.tip-icon {
 			width: 36px;
 			width: 36px;
 			margin-right: 20px;
 			margin-right: 20px;