nieyuge 2 anos atrás
pai
commit
20d6e35a00
1 arquivos alterados com 27 adições e 23 exclusões
  1. 27 23
      pages/nft.vue

+ 27 - 23
pages/nft.vue

@@ -38,13 +38,14 @@ const page = {
 }
 const jumpUrl = page[process.env.NUXT_ENV.MODE] + '/'
 const baseURL = api[process.env.NUXT_ENV.MODE]
+const appVersionCode = 6;
 
 export default {
     name: 'ntf',
     data() {
         return {
             isLoading: true,
-            appVersionCode: 3,
+            appVersionCode: appVersionCode,
             jumpUrl: jumpUrl,
             detail: {},
             config: {},
@@ -56,7 +57,7 @@ export default {
 		return {
 			type: '',
 			title: this.title,
-			appVersionCode: 3,
+			appVersionCode: appVersionCode,
 			meta: [
 				// facebook 
 				{
@@ -91,31 +92,34 @@ export default {
 			]
 		}
 	},
+    async asyncData(params) {
+        let { route } = params;
+		let { data } = await axios.post(`${baseURL}/denet/nft/project/getNftProjectInfo`, {
+			baseInfo: {
+				appVersionCode: appVersionCode,
+				mid: function () {
+					return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
+						var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
+						return v.toString(16);
+					});
+				}()
+			},
+			params: {
+				nftProjectId: route.params.id || ''
+			}
+		})
+		if (data.code == 0 && data.data !== null) {
+            return {
+                detail: data.data,
+                isLoading: false
+            }
+		}
+    },
     created() {
         this.setCookieMid();
         this.getConfig();
-        this.getData();
     },
     methods: {
-        getData() {
-            if (this.$route.params && this.$route.params.id) {
-                axios.post(`${baseURL}/denet/nft/project/getNftProjectInfo`, {
-                    baseInfo: {
-                        appVersionCode: this.appVersionCode,
-                        mid: this.mid
-                    },
-                    params: {
-                        nftProjectId: this.$route.params.id || ''
-                    }
-                }).then(res => {
-                    let { code, data } = res.data;
-                    if (code === 0) {
-                        this.detail = data;
-                        this.isLoading = false;
-                    }
-                })
-            }
-        },
         guid() {
 			return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
 				var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
@@ -138,7 +142,7 @@ export default {
         async getConfig() {
 			let { data } = await axios.post(`${baseURL}/denet/base/config/getFrontConfig`, {
 				baseInfo: {
-					appVersionCode: this.appVersionCode,
+					appVersionCode: appVersionCode,
 					mid: this.mid
 				},
 				params: {}