mixins.js
809 Bytes
import {createNamespacedHelpers} from 'vuex';
const { mapState, mapActions } = createNamespacedHelpers('product');
export default {
computed: {
...mapState(['products', 'fav', 'topLists']),
productDetail() {
this.ensureProduct({ productId: this.productId });
return this.products[this.productId];
},
imageList() {
return this.productDetail.goods_list[0].image_list;
},
resource() {
return this.productDetail.resource || {};
},
activity() {
return this.productDetail.activity;
},
isFav() {
return this.fav[this.productId];
},
topList() {
return this.topLists[this.productId];
},
recommend() {
return this.productDetail.recommend;
},
},
methods: {
...mapActions(['ensureProduct']),
},
};