You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

328 lines
7.2 KiB

<template>
<view class="productDetail">
<view class="top-btn">
<view class="" @click="goBack"><img src="/static/product/46646.png" alt="" /></view>
<!-- <view class=""><img src="/static/product/46647.png" alt="" /></view> -->
</view>
<view class="swiper">
<u-swiper :list="product.image" indicator indicatorMode="dot" circular height="65vh"
:indicatorStyle="{bottom : '0px'}" indicatorActiveColor="#E01717"
indicatorInactiveColor="#E2E2E2"></u-swiper>
</view>
<view class="content">
<view class="title">
{{ product.title }}
</view>
<view class="line-price">
<text class="price">{{ product.price }}</text>
<text class="oldPrice" v-if="product.oldPrice">{{ product.oldPrice }}</text>
</view>
<view class="const">
<!-- <text>{{ $t('page.productDetail.Gross-sales') }}{{ product.payNum }}</text>
<text>{{ $t('page.productDetail.inventory') }}{{ product.num }}</text> -->
</view>
<u-parse :content="product.shopDetails"></u-parse>
</view>
<view class="bottom-shop">
<view class="left-shop">
<view class="icon" @click="goHome">
<u-icon name="home" size="25px" color="#E01717"></u-icon>
<view class="">
{{ $t('tabbar.title.1') }}
</view>
</view>
<view class="icon">
<u-icon name="heart" size="25px" v-if="!product.cel" @click="collect"></u-icon>
<u-icon name="heart-fill" size="25px" v-else color="#E01717" @click="collect"></u-icon>
<view class="">
{{ $t('page.productDetail.collect') }}
</view>
</view>
</view>
<view class="right-shop">
<view class="cart" @click="type = false;show = true">
{{ $t('page.productDetail.Add-to-cart') }}
</view>
<view class="Buy" @click="type = true;show = true">
{{ $t('page.productDetail.Buy-now') }}
</view>
</view>
</view>
<!-- 购买 -->
<u-popup :show="show" mode="bottom" @close="close" @open="open">
<view class="shop-box">
<view class="top-info">
<view class="left-img">
<img :src="product.image[0]" width="100%" alt="" />
</view>
<view class="right-text">
<view class="title">
{{ product.title }}
</view>
<view class="price">
{{ product.price }}
</view>
</view>
</view>
<view class="const" style="margin: 0 20px;">
<!-- <text>{{ $t('page.productDetail.Gross-sales') }}:{{ product.payNum }}</text>
<text>{{ $t('page.productDetail.inventory') }}:{{ product.num }}</text> -->
</view>
<view class="number-box">
<view class="">
{{ type ? $t('page.productDetail.buy-quantity') : $t('page.productDetail.Add-cart-quantity' )}}
</view>
<u-number-box v-model="quantity" :min="1" :max="product.num" style="transform: scale(0.8);"
@change="valChange"></u-number-box>
</view>
</view>
<u-button :style="{'background-color': type ? '#EC534E' : '#F8AA48',color: '#fff'}"
:text="type ? $t('page.productDetail.Buy-now') : $t('page.productDetail.Add-to-cart')"
@click="submit"></u-button>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
show: false,
type: false,
quantity: 1,
product: {
image: []
}
}
},
onShow() {
this.getData()
},
methods: {
collect(){
this.request('collectionShop', {}, {
shopId : this.product.id
})
.then(res => {
if(res.code == 200){
this.product.cel = !this.product.cel
uni.$u.toast(this.$t('success-operation'))
}
})
},
getData() {
this.request('getShopOne', {}, {
"id": this.$route.query.id,
token : localStorage.getItem('token')
}).then(res => {
res.result.image = res.result.image.split(',')
this.product = res.result
})
},
goBack() {
uni.navigateBack({
delta: 3
})
},
goHome() {
uni.switchTab({
url: '/pages/home/home'
})
},
close() {
this.show = false
},
open() {},
valChange() {},
submit() {
this.show = false
if (this.type) {
this.request("createOrder", {
shopId: this.$route.query.id,
num: this.quantity,
price: this.product.price,
image : this.product.image[0],
title : this.product.title,
subTitle : this.product.subTitle,
}).then(res => {
if (res.code === 200) {
return uni.navigateTo({
url: '/pages/productDetail/payOrder/payOrder?id='
+ res.result.id +
'&quantity=' + this
.quantity,
})
}
})
} else { //添加购物车
this.request('saveCart', {
shopId: this.$route.query.id,
shopName: this.product.title,
num: this.quantity,
price: this.product.price,
image: this.product.image[0],
}).then(res => {
if (res.code == 200) {
this.$MyToast(this.$t('page.productDetail.Add-cart-success'), {
title: this.$t('myToactTitle')
})
}
})
}
}
}
}
</script>
<style scoped lang="scss">
.productDetail {
width: 100%;
background-color: #fff;
min-height: 100vh;
.top-btn {
position: absolute;
top: 0;
padding: 15px;
display: flex;
justify-content: space-between;
z-index: 99999999;
width: 100%;
box-sizing: border-box;
}
.swiper {
padding: 20px;
}
.content {
padding: 0 20px;
padding-bottom: 50px;
.line-price {
height: 90rpx;
line-height: 90rpx;
border-bottom: 1px solid #B8B8B8;
.price {
font-size: 49rpx;
padding-right: 8px;
color: #E01717;
}
.oldPrice {
font-size: 28rpx;
text-decoration: line-through;
color: #B8B8B8;
}
}
}
.const {
display: flex;
justify-content: space-between;
height: 10px;
// height: 30px;
// background-color: #F3F3F3;
line-height: 30px;
padding: 0 10px;
color: #333333;
// margin: 15px 0;
font-size: 28rpx;
}
.bottom-shop {
position: fixed;
bottom: 0;
left: 0;
height: 50px;
display: flex;
width: 100%;
background-color: #fff;
.left-shop {
flex: 2;
display: flex;
justify-content: space-around;
box-sizing: border-box;
align-items: center;
.icon {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 11px;
}
}
.right-shop {
flex: 3;
display: flex;
color: #fff;
font-size: 26rpx;
.cart {
width: 50%;
height: 100%;
background-color: #F8AA48;
display: flex;
justify-content: center;
align-items: center;
}
.Buy {
width: 50%;
height: 100%;
background-color: #EC534E;
display: flex;
justify-content: center;
align-items: center;
}
}
}
.shop-box {
.top-info {
display: flex;
width: 100%;
box-sizing: border-box;
padding: 20px;
.left-img {
flex: 1;
}
.right-text {
flex: 3;
padding-left: 10px;
.title {
font-size: 28rpx;
margin-bottom: 5px;
}
.price {
font-size: 39rpx;
padding-right: 8px;
color: #E01717;
}
}
}
.number-box {
display: flex;
justify-content: space-between;
height: 30px;
line-height: 30px;
padding: 0 10px;
color: #333333;
margin: 15px 0;
font-size: 28rpx;
}
}
}
</style>