actions.js
718 Bytes
export default {
async postProductFav(actions, {productId, productSkn, favorite, productType}) {
let postUrl, params;
if (productType === 1) {
postUrl = favorite ? '/api/favorite/add' : '/api/favorite/cancel';
if (favorite) {
params = {
type: 'product',
id: productId
};
} else {
params = {
type: 'product',
fav_id: productId
};
}
} else if (productType === 2) { // ufo
postUrl = favorite ? '/api/ufo/user/favoriteAdd' : '/api/ufo/user/favoriteCancel';
params = {
productId: productSkn
};
}
const result = await this.$api.post(postUrl, params);
return result;
}
};