Yer 2023-05-16 18:04:23 +08:00
commit d5ea5a4fa9
3 changed files with 39 additions and 10 deletions

View File

@ -202,6 +202,22 @@ export function getGoodsCollection(params, type) {
}); });
} }
/**
* 获取商品收藏
* @param params
* @returns {AxiosPromise}
*/
export function getStoreCollection(params, type) {
return http.request({
url: `/member/storeCollection/${type}`,
method: Method.GET,
needToken: true,
loading: false,
message: false,
params,
});
}
/** /**
* 收藏商品 * 收藏商品
* @returns {AxiosPromise} * @returns {AxiosPromise}
@ -236,7 +252,7 @@ export function deleteGoodsCollection(ids) {
*/ */
export function deleteStoreCollection(store_id) { export function deleteStoreCollection(store_id) {
return http.request({ return http.request({
url: `/member/collection/delete/STORE/${store_id}`, url: `/member/storeCollection/delete/STORE/${store_id}`,
method: Method.DELETE, method: Method.DELETE,
needToken: true, needToken: true,
}); });
@ -255,6 +271,19 @@ export function getGoodsIsCollect(type, good_id) {
}); });
} }
/**
* 获取商品是否被收藏
* @param good_id
*/
export function getStoreIsCollect(type, store_id) {
return http.request({
url: `/member/storeCollection/isCollection/${type}/${store_id}`,
method: Method.GET,
needToken: true,
loading: false,
});
}
/** /**
* 收藏店铺 * 收藏店铺
* @param store_id 店铺ID * @param store_id 店铺ID
@ -262,10 +291,9 @@ export function getGoodsIsCollect(type, good_id) {
*/ */
export function collectionStore(store_id) { export function collectionStore(store_id) {
return http.request({ return http.request({
url: "members/collection/store", url: `/member/storeCollection/add/STORE/${store_id}`,
header: { "content-type": "application/x-www-form-urlencoded" },
method: Method.POST, method: Method.POST,
data: { store_id }, needToken: true,
}); });
} }

View File

@ -64,6 +64,7 @@
<script> <script>
import { import {
getGoodsCollection, getGoodsCollection,
getStoreCollection,
deleteGoodsCollection, deleteGoodsCollection,
deleteStoreCollection, deleteStoreCollection,
} from "@/api/members.js"; } from "@/api/members.js";
@ -154,7 +155,7 @@
* 点击店铺左侧取消收藏 * 点击店铺左侧取消收藏
*/ */
clickStoreSwiperAction(val) { clickStoreSwiperAction(val) {
deleteStoreCollection(val.storeId).then((res) => { deleteStoreCollection(val.id).then((res) => {
if (res.statusCode == 200) { if (res.statusCode == 200) {
this.storeList = []; this.storeList = [];
this.getStoreList(); this.getStoreList();
@ -224,7 +225,7 @@
uni.showLoading({ uni.showLoading({
title: "加载中", title: "加载中",
}); });
getGoodsCollection(this.navList[1].params, "store").then((res) => { getStoreCollection(this.navList[1].params, "STORE").then((res) => {
if (this.$store.state.isShowToast){ uni.hideLoading() }; if (this.$store.state.isShowToast){ uni.hideLoading() };
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
if (res.data.success) { if (res.data.success) {

View File

@ -181,8 +181,8 @@ import { getStoreBaseInfo, getStoreCategory } from "@/api/store.js";
import { import {
receiveCoupons, receiveCoupons,
deleteStoreCollection, deleteStoreCollection,
collectionGoods, collectionStore,
getGoodsIsCollect, getStoreIsCollect,
} from "@/api/members.js"; } from "@/api/members.js";
import config from "@/config/config"; import config from "@/config/config";
@ -374,7 +374,7 @@ export default {
}, },
/**是否收藏店铺 */ /**是否收藏店铺 */
async enableGoodsIsCollect() { async enableGoodsIsCollect() {
let res = await getGoodsIsCollect("STORE", this.storeId); let res = await getStoreIsCollect("STORE", this.storeId);
if (res.data.success) { if (res.data.success) {
this.isCollection = res.data.result; this.isCollection = res.data.result;
} }
@ -465,7 +465,7 @@ export default {
} }
}); });
} else { } else {
collectionGoods("STORE", this.storeId).then((res) => { collectionStore(this.storeId).then((res) => {
if (res.data.success) { if (res.data.success) {
this.isCollection = true; this.isCollection = true;
uni.showToast({ uni.showToast({