feat:开发商品详情

merge-requests/8/head
张征 3 years ago
parent be7f50ddcd
commit 3461adb9fa

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

@ -34,3 +34,7 @@ a { text-decoration:none;
color: #333; color: #333;
&:hover { text-decoration:none;} &:hover { text-decoration:none;}
} }
.layout-box {
width: 1200px;
margin: 0 auto;
}

@ -7,8 +7,8 @@
--> -->
<template> <template>
<div class="layout"> <div class="layout">
<Header /> <!-- <Header /> -->
<div class="layout-box"><Nuxt /></div> <Nuxt />
<div class="layout-footer"></div> <div class="layout-footer"></div>
</div> </div>
</template> </template>
@ -21,10 +21,6 @@ export default {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.layout-box {
width: 1200px;
margin: 0 auto;
}
.layout-footer{ .layout-footer{
height: 189px; height: 189px;
background: #ddd; background: #ddd;

@ -1,23 +1,131 @@
<!--
* @Author: ch
* @Date: 2022-05-04 17:29:09
* @LastEditors: ch
* @LastEditTime: 2022-05-04 17:29:24
* @Description: file content
-->
<template> <template>
<div>我是商品详情</div> <div>
<nav class="nav flex flex-middle flex-center">
<p class="nav__crumbs">
全部商品
<i class="el-icon-arrow-right"></i>
开发书籍
<i class="el-icon-arrow-right"></i>
后端书籍
<i class="el-icon-arrow-right"></i>
Java从入门到项目实战
</p>
</nav>
<main class="main flex">
<aside class="main__preview"></aside>
<article class="main__details">
<p class="main__details-title">
<span class="main__details-title--label">新品</span>
Java从入门到项目实战全程视频版
编程入门it计算机书籍算法java编程思想java从入门到精通java核心技术javascript
</p>
<div class="main__details-msg">
<div class="main__details-msg--price flex">
<span class="msg-txt">售价</span>
<UiMoney :money="123"></UiMoney>
</div>
<div class="hr"></div>
<div class="main__details-msg--service flex flex-middle">
<span class="msg-txt">服务</span>
<span class="msg-service"
>假一赔四 · 全国包邮 · 不支持7天无理由退换</span
>
<img
class="msg-icon"
src="~/assets/images/goods/more.png"
alt="服务"
/>
</div>
</div>
</article>
</main>
</div>
</template> </template>
<script> <script>
import UiMoney from "@/components/UiMoney.vue";
export default { export default {
componetns: { UiMoney },
data() { data() {
return { return {};
},
created() {
console.log(this.$route.params.id);
},
};
</script>
<style lang="scss" scoped>
.nav {
width: 100%;
height: 40px;
background: #f2f4f6;
margin-bottom: 14px;
&__crumbs {
width: 1200px;
} }
} }
.main {
width: 1200px;
margin: 0 auto;
&__preview {
width: 456px;
margin-right: 30px;
}
&__details {
width: 714px;
&-title {
font-size: 16px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #333333;
padding-bottom: 20px;
&--label {
display: inline-block;
font-size: 12px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #3083ff;
padding: 4px 8px;
margin-right: 6px;
background: rgba(48, 131, 255, 0.1);
}
}
&-msg {
width: 714px;
height: 127px;
background: #f8f8f8;
padding: 30px 20px 0;
.msg-txt {
font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #9e9e9e;
margin-right: 20px;
} }
</script>
<style lang="scss" scoped>
.msg-service {
font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #666666;
}
.msg-icon {
margin-left: 6px;
width: 12px;
height: 12px;
}
&--price {
padding-bottom: 30px;
}
.hr {
width: 673px;
height: 1px;
background: #dddddd;
}
&--service{
padding-top: 16px;
}
}
}
}
</style> </style>

@ -13,26 +13,117 @@
<p class="main__nav-crumbs"> <p class="main__nav-crumbs">
全部商品<i class="el-icon-arrow-right"></i>开发书籍 全部商品<i class="el-icon-arrow-right"></i>开发书籍
</p> </p>
<div class="main__nav-sort"> <div class="main__nav-sort flex flex-middle">
<span class="main__nav-sort-txt">排序 :</span> <span class="main__nav-sort-txt">排序 :</span>
<span class="main__nav-sort-btn">综合</span> <span
<Sort sortText="价格"></Sort> class="main__nav-sort-btn"
<span class="main__nav-sort-btn">上新</span> :class="navActive == 0 ? 'main__nav-sort-active' : ''"
@click="onNavClick(0)"
>综合</span
>
<Sort
:class="navActive == 1 ? 'main__nav-sort-active' : ''"
sortText="价格"
:sortType="sortType"
@onSort="onSort"
></Sort>
<span
:class="navActive == 3 ? 'main__nav-sort-active' : ''"
class="main__nav-sort-btn"
@click="onNavClick(3)"
>上新</span
>
</div> </div>
</nav> </nav>
<div class="main__content"> <div class="main__content">
<GoodsItem v-for="(item, index) in 11" :key="index"></GoodsItem> <GoodsItem
:item="item"
v-for="item in listData"
:key="item.id"
></GoodsItem>
</div> </div>
<el-pagination
class="main__pagination flex flex-right"
@current-change="handleCurrentChange"
:current-page.sync="params.pageIndex"
:page-size="100"
layout="prev, pager, next, jumper"
:total="total"
>
</el-pagination>
</main> </main>
</div> </div>
</template> </template>
<script> <script>
import { ApiGetGoodsList } from "@/plugins/api/goods";
import Sort from "./module/SortItem.vue"; import Sort from "./module/SortItem.vue";
import GoodsItem from "./module/Item.vue"; import GoodsItem from "./module/Item.vue";
export default { export default {
components: { Sort, GoodsItem }, components: { Sort, GoodsItem },
data() { data() {
return {}; return {
navActive: 0,
listData: [],
total: 0,
// 0:,1:desc,2:asc,3:
sortType: 0,
params: {
length: 20,
pageIndex: 1,
name: "",
categoryId: "",
order: "",
},
};
},
async created() {
this.getGoodsListData();
},
methods: {
onNavClick(i) {
console.log(i);
let vm = this;
vm.sortType = i;
vm.navActive = i;
vm.getGoodsListData();
},
onSort() {
let vm = this;
vm.navActive = 1;
vm.sortType < 2 ? vm.sortType++ : (vm.sortType = 1);
vm.getGoodsListData();
},
//
async getGoodsListData() {
let vm = this;
switch (vm.sortType) {
case 0:
vm.$set(vm.params, "order", "");
break;
case 1:
vm.$set(vm.params, "order", "starting_price:desc");
break;
case 2:
vm.$set(vm.params, "order", "starting_price:asc");
break;
case 3:
vm.$set(vm.params, "order", "create_time");
break;
}
let res = await ApiGetGoodsList(vm.params);
if (res.error) {
vm.$message.error(res.error.message);
return false;
}
vm.total = res.result.data.total;
vm.listData = res.result.data.records;
console.log(`goodListRes`, res.result);
},
handleCurrentChange(val) {
let vm = this;
vm.$set(vm.params, "pageIndex", val);
vm.getGoodsListData();
},
}, },
}; };
</script> </script>
@ -44,10 +135,19 @@ export default {
} }
.main { .main {
width: 75rem; width: 1200px;
margin: 0 auto; margin: 0 auto;
padding-top: 14px;
padding-bottom: 60px;
&__nav { &__nav {
&::after {
display: block;
width: 1200px;
content: "";
height: 1px;
background: #eee;
}
&-crumbs { &-crumbs {
.el-icon-arrow-right { .el-icon-arrow-right {
margin: 0 10px; margin: 0 10px;
@ -55,28 +155,62 @@ export default {
} }
&-sort { &-sort {
width: 100%; width: 100%;
height: 48px; height: 50px;
background: #fff; margin-top: 24px;
margin-top: 0.88rem; padding: 0 30px;
margin-bottom: 1.13rem;
display: flex;
align-items: center;
padding: 0 1.88rem;
&-txt { &-txt {
color: #999999; color: #999999;
margin-right: 1.88rem; margin-right: 30px;
} }
&-btn { &-btn {
margin-right: 3.13rem; margin-right: 50px;
cursor: pointer;
}
&-active {
color: #ff512b;
} }
} }
} }
&__content { &__content {
margin-top: 30px;
display: grid; display: grid;
width: 100%; width: 100%;
grid-template-columns: repeat(auto-fill, 14.5rem); grid-template-columns: repeat(auto-fill, 232px);
justify-content: space-between; justify-content: space-between;
grid-row-gap: 0.63rem; grid-row-gap: 10px;
}
&__pagination {
margin-top: 60px;
/deep/.el-pager {
margin-left: 8px;
}
/deep/button,
/deep/.number,
/deep/.btn-quicknext,
/deep/.btn-quickprev {
width: 32px;
height: 32px;
text-align: center;
line-height: 32px;
margin-left: 8px;
border-radius: 2px 2px 2px 2px;
border: 1px solid rgba(0, 0, 0, 0.15);
font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: rgba(0, 0, 0, 0.65);
} }
/deep/.active {
background: #ff512b;
color: #fff;
}
}
}
</style>
<style>
.tab-category__menu {
display: none;
} }
</style> </style>

@ -1,22 +1,92 @@
<template> <template>
<div class="goods-item"></div> <div class="goods-item" @click="onItem">
<img class="goods-item__img" :src="item.mainPicture" alt="商品图片" />
<div class="goods-item__title">
<span class="goods-item__title-label" v-if="isLabel(item.labelList)">
{{ getLabel(item.labelList) }}
</span>
{{ item.name }}
</div>
<div class="goods-item__price">
<UiMoney :money="item.startingPrice"></UiMoney>
</div>
</div>
</template> </template>
<script> <script>
import UiMoney from "@/components/UiMoney.vue";
export default { export default {
name: "GoodsItem", name: "GoodsItem",
props: {}, componetns: { UiMoney },
props: {
item: {
type: Object,
default: () => {},
},
},
data() { data() {
return {}; return {};
}, },
methods: {}, methods: {
isLabel(arr) {
return arr.some((item) => item.code);
},
getLabel(arr) {
let str = "";
for (let i = 0; i < arr.length; i++) {
if (arr[i].code != "miaosha") {
str = arr[i].text;
break;
}
}
return str;
},
onItem() {
this.$router.push({
path: "/goods/detail/" + this.item.id,
});
},
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.goods-item { .goods-item {
width: 14.5rem; width: 232px;
height: 21.25rem; height: 340px;
// background: #ffffff; cursor: pointer;
background: url(~/assets/images/goods/item.png); background: #ffffff;
background-size: contain;
&__img {
width: 232px;
height: 232px;
}
&__title {
width: 200px;
height: 45px;
margin: 17px auto 10px;
font-size: 14px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
&-label {
display: inline-block;
padding: 4px 8px;
background: rgba(255, 135, 91, 0.1);
font-size: 12px;
font-family: Microsoft YaHei-Regular, Microsoft YaHei;
font-weight: 400;
color: #ff875b;
text-align: center;
margin-right: 8px;
}
}
&__price {
width: 200px;
margin: 0 auto;
}
} }
</style> </style>

@ -3,17 +3,17 @@
<span class="sort-item-txt">{{ sortText }}</span> <span class="sort-item-txt">{{ sortText }}</span>
<div class="sort-img-box"> <div class="sort-img-box">
<img <img
v-if="sortType === 1" v-if="sortType === 0 || sortType === 1"
src="~/assets/images/goods/sort-t1.png" src="~/assets/images/goods/sort-t1.png"
alt="sort" alt="sort"
/> />
<img <img
v-if="sortType === 0" v-if="sortType === 2"
src="~/assets/images/goods/sort-t2.png" src="~/assets/images/goods/sort-t2.png"
alt="sort" alt="sort"
/> />
<img <img
v-if="sortType === 0" v-if="sortType === 0 || sortType === 2"
src="~/assets/images/goods/sort-b1.png" src="~/assets/images/goods/sort-b1.png"
alt="sort" alt="sort"
/> />
@ -26,7 +26,6 @@
</div> </div>
</template> </template>
<script> <script>
import { Debounce } from "~/plugins/utils";
export default { export default {
name: "SortItem", name: "SortItem",
props: { props: {
@ -34,6 +33,11 @@ export default {
type: String, type: String,
default: "", default: "",
}, },
/*
0:未选中
1:desc
2:asc
*/
sortType: { sortType: {
type: Number, type: Number,
default: 0, default: 0,
@ -43,28 +47,23 @@ export default {
return {}; return {};
}, },
methods: { methods: {
// onSort:Debounce((e) => { onSort() {
// console.log(1) this.$emit("onSort");
// }, 1000)
onSort: function () {
console.log(Debounce)
Debounce(()=>{
console.log(1)
}, 1000)();
}, },
}, },
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.sort-item { .sort-item {
margin-right: 3.13rem; margin-right: 50px;
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
.sort-item-txt { .sort-item-txt {
margin-right: 0.38rem; margin-right: 6px;
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 14px;
} }
.sort-img-box { .sort-img-box {
display: flex; display: flex;
@ -73,9 +72,9 @@ export default {
flex-direction: column; flex-direction: column;
} }
img { img {
width: 0.38rem; width: 6px;
height: 0.19rem; height: 3px;
margin: 0.08rem 0; margin: 3px 0;
} }
} }
</style> </style>

@ -16,7 +16,7 @@ const BASE_URL = `${ENV.base_url}/mall/product`;
* @param {*} params * @param {*} params
*/ */
export const ApiGetGoodsList = (params) => export const ApiGetGoodsList = (params) =>
ToAsyncAwait(axios.get(`${BASE_URL}/app/product/page`, params)); ToAsyncAwait(axios.get(`${BASE_URL}/app/product/page`, {params}));
/** /**
* 获取推荐商品 * 获取推荐商品
* @param {*} params * @param {*} params

@ -1,5 +1,5 @@
import Vue from 'vue' import Vue from 'vue'
import Element from 'element-ui' import Element from 'element-ui'
import locale from 'element-ui/lib/locale/lang/en' import locale from 'element-ui/lib/locale/lang/zh-CN'
Vue.use(Element, { locale }) Vue.use(Element, { locale })

Loading…
Cancel
Save