前端问题处理

This commit is contained in:
17600048398
2023-03-09 18:16:10 +08:00
parent 7d0b3c6908
commit f4ddeaa5c5
7 changed files with 90 additions and 22 deletions

View File

@@ -59,7 +59,7 @@ export function withdrawalApply (params) {
});
}
// 收藏商品、店铺
// 收藏商品
export function collectGoods (type, id) {
return request({
url: `/buyer/member/collection/add/${type}/${id}`,
@@ -68,7 +68,16 @@ export function collectGoods (type, id) {
});
}
// 取消 收藏商品、店铺
// 收藏店铺
export function collectStore (type, id) {
return request({
url: `/buyer/member/storeCollection/add/${type}/${id}`,
method: Method.POST,
needToken: true
});
}
// 取消 收藏商品
export function cancelCollect (type, id) {
return request({
url: `/buyer/member/collection/delete/${type}/${id}`,
@@ -77,7 +86,16 @@ export function cancelCollect (type, id) {
});
}
// 查看是否收藏
// 取消 收藏店铺
export function cancelStoreCollect (type, id) {
return request({
url: `/buyer/member/storeCollection/delete/${type}/${id}`,
method: Method.DELETE,
needToken: true
});
}
// 查看是否收藏商品
export function isCollection (type, goodsId) {
return request({
url: `/buyer/member/collection/isCollection/${type}/${goodsId}`,
@@ -86,7 +104,16 @@ export function isCollection (type, goodsId) {
});
}
// 会员收藏列表
// 查看是否收藏店铺
export function isStoreCollection (type, goodsId) {
return request({
url: `/buyer/member/storeCollection/isCollection/${type}/${goodsId}`,
method: Method.GET,
needToken: true
});
}
// 会员收藏商品列表
export function collectList (params) {
return request({
url: `/buyer/member/collection/${params.type}`,
@@ -96,6 +123,16 @@ export function collectList (params) {
});
}
// 会员收藏店铺列表
export function storeCollectList (params) {
return request({
url: `/buyer/member/storeCollection/${params.type}`,
method: Method.GET,
needToken: true,
params
});
}
// 单个商品评价
export function goodsComment (params) {
return request({

View File

@@ -44,9 +44,9 @@ import ShowGoods from "@/components/goodsDetail/ShowGoods";
import ShowGoodsDetail from "@/components/goodsDetail/ShowGoodsDetail";
import { goodsSkuDetail } from "@/api/goods";
import {
cancelCollect,
collectGoods,
isCollection,
cancelStoreCollect,
collectStore,
isStoreCollection,
getGoodsDistribution,
} from "@/api/member";
import { getDetailById } from "@/api/shopentry";
@@ -121,7 +121,7 @@ export default {
this.$set(this, "goodsMsg", res.result);
// 判断是否收藏
if (this.Cookies.getItem("userInfo")) {
isCollection("STORE", this.goodsMsg.data.storeId).then((res) => {
isStoreCollection("STORE", this.goodsMsg.data.storeId).then((res) => {
if (res.success && res.result) {
this.storeCollected = true;
}
@@ -159,13 +159,13 @@ export default {
async collect () {
// 收藏店铺
if (this.storeCollected) {
let cancel = await cancelCollect("STORE", this.goodsMsg.data.storeId);
let cancel = await cancelStoreCollect("STORE", this.goodsMsg.data.storeId);
if (cancel.success) {
this.$Message.success("已取消收藏");
this.storeCollected = false;
}
} else {
let collect = await collectGoods("STORE", this.goodsMsg.data.storeId);
let collect = await collectStore("STORE", this.goodsMsg.data.storeId);
if (collect.code === 200) {
this.storeCollected = true;
this.$Message.success("收藏店铺成功,可以前往个人中心我的收藏查看");

View File

@@ -108,7 +108,7 @@
<script>
import {getDetailById, getCateById} from "@/api/shopentry";
import {cancelCollect, collectGoods, isCollection} from "@/api/member";
import {cancelStoreCollect, collectStore, isStoreCollection} from "@/api/member";
import {goodsList} from "@/api/goods";
import Search from "@/components/Search";
import ModelForm from "@/components/indexDecorate/ModelForm";
@@ -296,13 +296,13 @@ export default {
async collect() {
// 收藏店铺
if (this.storeCollected) {
let cancel = await cancelCollect("STORE", this.storeMsg.storeId);
let cancel = await cancelStoreCollect("STORE", this.storeMsg.storeId);
if (cancel.success) {
this.$Message.success("已取消收藏");
this.storeCollected = false;
}
} else {
let collect = await collectGoods("STORE", this.storeMsg.storeId);
let collect = await collectStore("STORE", this.storeMsg.storeId);
if (collect.code === 200) {
this.storeCollected = true;
this.$Message.success("收藏店铺成功,可以前往个人中心我的收藏查看");

View File

@@ -25,7 +25,7 @@
<Button size="small" type="primary" @click="buynow(item.skuId, item.goodsId)" v-if="params.type === 'GOODS'">立即购买</Button>
<Button size="small" type="primary" @click="goShop(item.id)" v-else>店铺购买</Button>
<Button size="small" v-if="params.type === 'GOODS'" @click="cancel(item.skuId)">取消收藏</Button>
<Button size="small" v-if="params.type === 'SHOP'" @click="cancel(item.id)">取消收藏</Button>
<Button size="small" v-if="params.type === 'STORE'" @click="cancelStore(item.id)">取消收藏</Button>
</div>
</div>
</template>
@@ -36,7 +36,7 @@
</template>
<script>
import { collectList, cancelCollect } from '@/api/member.js'
import { collectList, cancelCollect,storeCollectList,cancelStoreCollect} from '@/api/member.js'
export default {
name: 'Favorites',
props: {
@@ -66,10 +66,16 @@ export default {
if (res.success) this.list = res.result.records;
})
},
getStoreList () { // 获取收藏列表
this.spinShow = true
storeCollectList(this.params).then(res => {
this.spinShow = false
if (res.success) this.list = res.result.records;
})
},
change (index) { // tab栏切换
if (index === 0) { this.params.type = 'GOODS' }
if (index === 1) { this.params.type = 'SHOP' }
this.getList()
if (index === 0) { this.params.type = 'GOODS',this.getList()}
if (index === 1) { this.params.type = 'STORE',this.getStoreList()}
},
cancel (id) { // 取消收藏
let typeName = this.params.type === 'GOODS' ? '商品' : '店铺'
@@ -85,6 +91,20 @@ export default {
}
});
},
cancelStore (id) { // 取消收藏
let typeName = this.params.type === 'GOODS' ? '商品' : '店铺'
this.$Modal.confirm({
title: 'Title',
content: `<p>确定取消收藏该${typeName}吗?</p>`,
onOk: () => {
cancelStoreCollect(this.params.type, id).then(res => {
if (res.success) {
this.getStoreList();
}
})
}
});
},
buynow (skuId, goodsId) { // 跳转详情
let url = this.$router.resolve({
path: '/goodsDetail',