Files
dtx_store/pages/store/shop/shopDetail.vue
2022-08-11 17:22:58 +08:00

433 lines
15 KiB
Vue

<template>
<view class="shopDetail">
<view class="top">
<view class="search" @click="search">
<uni-icons type="left" class="back" size="30" @click="$Router.back();" />
<view class="input">
<uni-icons type="search" class="search-icon" color="grey" size="20" /> 请输入要搜索商品的关键词
</view>
</view>
<view class="shopInfo">
<view class="shopInfo-title-left">
<image class="shop-logo" :src="logo" mode="aspectFill" />
<view class="shop-title">
<view class="shop-titl">{{name}}</view>
<view>店铺评分:<span class='no'>5.0</span> 服务态度 :<span class='no'>5.0</span></view>
</view>
</view>
<view class="shopInfo-title-right" v-if="shopType === 2" @click="goVip"> {{!vip.status?'开通会员':vip.name}}
</view>
</view>
</view>
<view class="content">
<view class="left">
<scroll-view scroll-y="true" class="scroll-view-left">
<view :class="['classify-item', item.category_id === category_id?'active_classify_item':'']"
v-for="(item,index) in classify" :key="index" @click="selectClassify(item.category_id)">
{{item.name}}
</view>
</scroll-view>
</view>
<view class="right">
<scroll-view scroll-y="true" class="scroll-view-right" @scrolltolower='lower'>
<block v-if="goods.length > 0">
<view class="goods-item" v-for="(item,index) in goods" :key="index"
@click="onGoods(item.goods_id)">
<image :src="item.cover" mode="aspectFill" class="good-img" />
<view class="item--content">
<view class="title">{{item.name}}</view>
<view class="sub_title">{{item.shop.name}}</view>
<view class="price">{{item.price.price_min || '0'}}
<view class="price-type">
<text> DT积分</text>
<text class="kucun"> 库存量:{{item.stock}}</text>
</view>
</view>
</view>
</view>
</block>
<block v-else>
<view class="vertical pages-empty">
<u-empty icon="http://cdn.uviewui.com/uview/empty/list.png" textColor="#999" text="暂无相关商品">
</u-empty>
</view>
</block>
</scroll-view>
</view>
</view>
</view>
</template>
<script>
import {
shopsDetail,
shopsGoods
} from "@/apis/interfaces/store"
export default {
data() {
return {
name: '',
logo: '',
category_id: '',
classify: [],
goods: [],
has_more: true,
page: 1,
ShopId: '',
shopType: '', // 1。普通商品 2.会员制商品
vip: {},
}
},
onLoad(e) {
this.ShopId = this.$Route.query.ShopId
shopsDetail(this.ShopId).then(res => {
// vip 制 商品
if (res.type.code == 2) {
this.classify = [{
category_id: '',
name: '全部活动',
}, ...res.identities]
} else {
// 普通商品
this.classify = [{
category_id: '',
name: '全部商品',
}, ...res.categories]
}
this.name = res.name
this.logo = res.cover
this.vip = res.vip
this.shopType = res.type.code
this.getGoods()
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
onPullDownRefresh() {
this.has_more = true;
this.page = 1;
this.goods = [];
this.getGoods()
},
methods: {
getGoods() {
uni.showLoading({
title: '请求中~',
mask: true,
})
let data = {
shop_id: this.ShopId,
page: this.page,
}
if (this.shopType == 2) {
data.identity_id = this.category_id
data.is_user = 1
} else {
data.category_id = this.category_id
}
shopsGoods(data).then(res => {
this.goods = this.goods.concat(res.data);
this.has_more = res.page.has_more;
uni.hideLoading();
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
lower() {
if (this.has_more) {
this.page = this.page + 1
this.getGoods();
} else {
uni.showToast({
title: '没有更多~',
icon: "none",
mask: true,
})
}
},
selectClassify(id) {
if (id === this.category_id) return;
this.category_id = id;
this.page = 1;
this.goods = [];
this.has_more = true;
this.getGoods()
},
search() {
this.$Router.push({
name: 'StoreSearch'
});
},
goVip() {
uni.navigateTo({
url: '/pages/store/vip/index/index?id=' + this.ShopId
})
},
onGoods(id) {
this.$Router.push({
name: 'StoreGoods',
params: {
id: id
}
})
}
}
}
</script>
<style lang="scss">
.pages-empty {
height: 70vh;
}
.shopDetail {
width: 100%;
height: 100vh;
.top {
height: 320rpx;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-end;
box-sizing: border-box;
padding-top: 44px;
width: 100%;
.search {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
width: 100%;
padding-right: $padding;
.back {
padding: 0 $padding;
}
.input {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
background-color: #f9f9f9;
color: gray;
font-size: 26rpx;
border-radius: 30rpx;
padding: 10rpx $padding;
.search-icon {
margin-right: $margin;
}
}
}
.shopInfo {
border-top: solid 1 #f9f9f9;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
width: 100%;
padding: $padding - 10;
background-color: #fff;
.shopInfo-title-left {
width: 500rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
.shop-logo {
width: 100rpx;
height: 100rpx;
border-radius: 10rpx;
border: solid 1rpx #f9f9f9;
}
.shop-title {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
box-sizing: border-box;
font-size: 26rpx;
margin-left: $margin;
color: #999;
width: 370rpx;
.no {
color: $text-price;
padding-left: 4rpx;
padding-right: 10rpx;
}
.shop-titl {
font-size: 34rpx;
color: #333;
font-weight: bold;
margin-bottom: 6rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 100%;
}
}
}
.shopInfo-title-right {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
box-sizing: border-box;
font-size: 28rpx;
color: #222;
background-color: $main-color;
padding: 6rpx $padding;
color: #FFF;
}
}
}
.content {
height: calc(100vh - 320rpx);
background-color: #eee;
display: flex;
flex-direction: row;
align-items: center;
padding-top: 20rpx;
box-sizing: border-box;
.left {
width: 180rpx;
height: 100%;
.scroll-view-left {
height: 100%;
width: 100%;
}
.classify-item {
width: 100%;
padding: $padding 0;
font-size: 26rpx;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #222;
display: inline-block;
}
.active_classify_item {
background-color: #FFFFFF;
}
}
.right {
width: calc(100% - 180rpx);
height: 100%;
background-color: #fff;
.scroll-view-right {
width: 100%;
height: 100%;
.goods-item {
width: 100%;
display: inline-block;
border-bottom: solid 1rpx #eee;
// padding: $padding;
padding-left: $padding;
padding-top: $padding;
padding-bottom: $padding;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
box-sizing: border-box;
.good-img {
width: 160rpx;
height: 160rpx;
border-radius: 10rpx;
}
.item--content {
flex: 1;
padding: $padding - 10;
&>.title {
font-size: 28rpx;
color: #333;
// @extend .ellipsis-1;
}
&>.sub_title {
color: #a05f0c;
font-size: 24rpx;
padding-top: 4rpx;
// @extend .ellipsis-1;
}
&>.price {
padding-top: $padding/2;
display: flex;
flex-direction: row;
align-items: flex-end;
justify-content: flex-start;
box-sizing: border-box;
line-height: 40rpx;
font-weight: bold;
font-size: 32rpx;
color: $text-price;
// @extend .ellipsis-1;
.price-type {
display: flex;
flex-direction: row;
align-items: flex-end;
justify-content: space-between;
box-sizing: border-box;
flex: 1;
position: relative;
top: 5rpx;
text {
margin-right: $margin/2;
padding-left: 6rpx;
font-size: 70%;
}
.kucun {
color: $text-gray;
font-weight: normal;
}
}
}
}
}
}
}
}
}
</style>