Authored by zhangwenxue

商品详情: 使用SSR

... ... @@ -200,6 +200,11 @@ export default {
showSizeRequestSheet: 'onSizeRequestHidden',
};
},
asyncData({store, router}) {
const productId = parseInt(router.params.productId, 10);
return store.dispatch('product/fetchProductInfo', {productId});
},
activated() {
this.$refs.pageScroll && this.$refs.pageScroll.scrollTo(0, 0, 0);
this.loadData(this.productId);
... ... @@ -240,20 +245,9 @@ export default {
},
// 加载商品详情数据
loadData(productId = this.productId, loading) {
loading && loading.show();
loadData(productId = this.productId) {
this.fetchBrandTop({productId});
this.fetchFav({productId});
return this.fetchProductInfo({productId}).then(() => {
loading && loading.hide();
setTimeout(() => {
this.refresh();
}, 200);
}).catch(() => {
loading && loading.hide();
});
},
/**
... ...