<template>
|
<view class="details" v-if="info">
|
<u-swiper :list="info.banner" height="375" @click="preview"></u-swiper>
|
<view class="info">
|
<view class="info-title">
|
{{info.name}}
|
</view>
|
<view class="commodity-item-box-price">
|
<view class="commodity-item-box-price-a">
|
<text>{{info.minPrice[0]}}</text>
|
<text>.{{info.minPrice[1]}}</text>
|
</view>
|
<view class="commodity-item-box-price-b">
|
原价¥{{info.price}}
|
</view>
|
</view>
|
<view class="info-num">
|
<text>已售 {{info.saleNum + info.realSaleNum}}+</text>
|
<text>库存 {{info.stock}}</text>
|
</view>
|
</view>
|
<view class="content">
|
<view class="content-label">商品详情</view>
|
<view class="content-val" v-html="info.content"></view>
|
</view>
|
<view style="width: 100%; height: calc(env(safe-area-inset-bottom) + 108rpx);"></view>
|
<view class="footer">
|
<view class="edit">
|
<view class="edit-left">
|
<view class="edit-left-row" @click="toIndex">
|
<image src="/static/icon/detail_ic_home@2x.png" mode="widthFix"></image>
|
<text>首页</text>
|
</view>
|
<view class="edit-left-row">
|
<button open-type="contact">客服</button>
|
<image src="/static/icon/detail_ic_kefu@2x.png" mode="widthFix"></image>
|
<text>客服</text>
|
</view>
|
<view class="edit-left-row" @click="toCard">
|
<image src="/static/icon/detail_ic_cart@2x.png" mode="widthFix"></image>
|
<text>购物车</text>
|
<view class="edit-left-row-num" v-if="cardObj && cardObj.cartTypeNum > 0">{{cardObj.cartTypeNum}}</view>
|
</view>
|
</view>
|
<view class="edit-btn">
|
<view class="edit-btn-a" @click="addCard(info)">加入购物车</view>
|
<view class="edit-btn-b">立即购买</view>
|
</view>
|
</view>
|
<view style="width: 100%; height: env(safe-area-inset-bottom);"></view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import { mapState } from 'vuex'
|
export default {
|
computed: {
|
...mapState(['userInfo'])
|
},
|
data() {
|
return {
|
id: null,
|
info: null,
|
cardObj: null
|
};
|
},
|
onLoad(option) {
|
this.id = option.id
|
this.getDetails()
|
this.cardNum()
|
},
|
methods: {
|
addCard(e) {
|
this.$u.api.addCart({
|
goodsId: e.id,
|
goodsSkuId: e.skuResponsesList[0].id,
|
num: 1
|
}).then(res => {
|
if (res.code === 200) {
|
this.cardNum()
|
uni.showToast({ title: '添加成功', icon: 'none' })
|
}
|
})
|
},
|
toCard() {
|
uni.navigateTo({
|
url: '/pages/shopping-cart/shopping-cart'
|
})
|
},
|
toIndex() {
|
uni.switchTab({
|
url: '/pages/index/index'
|
})
|
},
|
cardNum() {
|
this.$u.api.myInfo({})
|
.then(res => {
|
if (res.code === 200) {
|
this.cardObj = res.data
|
}
|
})
|
},
|
// 轮播图预览
|
preview(index) {
|
uni.previewImage({
|
urls: this.info.banner,
|
current: this.info.banner[index]
|
})
|
},
|
getDetails() {
|
this.$u.api.goodsInfo({
|
goodsId: this.id,
|
memberId: this.userInfo ? this.userInfo.id : null,
|
}).then(res => {
|
if (res.code === 200) {
|
res.data.minPrice = res.data.minPrice.toFixed(2).split('.')
|
if (res.data.goodBannerMultiFiles && res.data.goodBannerMultiFiles.length > 0) {
|
res.data.banner = res.data.goodBannerMultiFiles.map(item => item.fileurlfull)
|
}
|
this.info = res.data
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style>
|
page {
|
background-color: #F9F9FB;
|
}
|
</style>
|
<style lang="scss" scoped>
|
.details {
|
width: 100%;
|
.footer {
|
width: 100%;
|
position: fixed;
|
bottom: 0;
|
left: 0;
|
padding: 0 30rpx;
|
box-sizing: border-box;
|
background-color: #ffffff;
|
height: calc(env(safe-area-inset-bottom) + 108rpx);
|
.edit {
|
width: 100%;
|
height: 108rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
.edit-left {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
.edit-left-row {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
position: relative;
|
button {
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
opacity: 0;
|
}
|
.edit-left-row-num {
|
position: absolute;
|
top: -10rpx;
|
right: -10rpx;
|
width: 30rpx;
|
height: 22rpx;
|
line-height: 22rpx;
|
text-align: center;
|
background: #E4001D;
|
border-radius: 12rpx;
|
border: 1rpx solid #FFFFFF;
|
font-weight: 400;
|
font-size: 20rpx;
|
color: #FFFFFF;
|
}
|
image {
|
width: 44rpx;
|
height: 44rpx;
|
}
|
text {
|
font-weight: 400;
|
font-size: 22rpx;
|
color: #666666;
|
margin-top: 4rpx;
|
}
|
}
|
}
|
.edit-btn {
|
flex-shrink: 0;
|
display: flex;
|
align-items: center;
|
margin-left: 24rpx;
|
display: flex;
|
align-items: center;
|
.edit-btn-a {
|
width: 200rpx;
|
height: 88rpx;
|
line-height: 88rpx;
|
text-align: center;
|
border-radius: 44rpx;
|
border: 1rpx solid #004096;
|
font-weight: 500;
|
font-size: 30rpx;
|
color: #004096;
|
margin-right: 20rpx;
|
}
|
.edit-btn-b {
|
width: 200rpx;
|
height: 88rpx;
|
line-height: 88rpx;
|
text-align: center;
|
background: #004096;
|
border-radius: 44rpx;
|
font-weight: 500;
|
font-size: 30rpx;
|
color: #FFFFFF;
|
}
|
}
|
}
|
}
|
.content {
|
width: 100%;
|
padding: 30rpx;
|
box-sizing: border-box;
|
background-color: #ffffff;
|
margin-top: 20rpx;
|
.content-label {
|
font-weight: 500;
|
font-size: 32rpx;
|
color: #111111;
|
}
|
.content-val {
|
width: 100%;
|
margin-top: 30rpx;
|
}
|
}
|
.info {
|
width: 100%;
|
padding: 30rpx;
|
box-sizing: border-box;
|
background-color: #ffffff;
|
.info-title {
|
width: 100%;
|
font-weight: 600;
|
font-size: 36rpx;
|
color: #222222;
|
}
|
.commodity-item-box-price {
|
width: 100%;
|
display: flex;
|
align-items: baseline;
|
margin-top: 8rpx;
|
.commodity-item-box-price-a {
|
display: flex;
|
align-items: baseline;
|
margin-right: 8rpx;
|
text {
|
&:nth-child(1) {
|
font-weight: bold;
|
font-size: 48rpx;
|
color: #E4001D;
|
&::before {
|
content: '¥';
|
font-weight: 400;
|
font-size: 26rpx;
|
color: #E4001D;
|
}
|
}
|
&:nth-child(2) {
|
font-weight: 400;
|
font-size: 26rpx;
|
color: #E4001D;
|
}
|
}
|
}
|
.commodity-item-box-price-b {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #999999;
|
text-decoration: line-through;
|
}
|
}
|
.info-num {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-top: 20rpx;
|
text {
|
font-weight: 400;
|
font-size: 24rpx;
|
color: #999999;
|
}
|
}
|
}
|
}
|
</style>
|