Files
barter-app/pages/goods/details.vue

439 lines
12 KiB
Vue

<template>
<view class="content" v-if="!loding">
<!-- 轮播主图 -->
<view class="goods-covers">
<swiper class="swiper" indicator-dots indicator-active-color="#c82626">
<block v-if="goodsObj.pictures.length > 0">
<swiper-item v-for="(item, index) in goodsObj.pictures" :key="index">
<image class="swiper-item" :src="item" mode="aspectFill"/>
</swiper-item>
</block>
</swiper>
</view>
<!-- 产品详情 -->
<view class="goods-content">
<view class="header">
<view class="flex-box">
<view class="price"><text></text>{{goodsObj.price.show}}</view>
<view class="sales">累计易货{{goodsObj.sales}}</view>
</view>
<view class="coupon">
<view class="coupon-list" v-for="(item, index) in couponSee" :key="index">
<view class="coupon-label">
{{item.title}}
</view>
</view>
<view class="coupon-btn">领券<image class="coupon-btn-img" src="../../static/icons/goods_row.png" mode="aspectFill"></image></view>
</view>
<view class="title"><view class="title-hot">热卖</view>{{goodsObj.name}}</view>
<!-- <view class="sub-title">{{goodsObj.description}}</view> -->
</view>
<!-- 商家信息 -->
<view class="store">
<image class="logo" :src="goodsObj.shop.cover" mode="aspectFill"></image>
<view class="store-cont">
<view class="title">{{goodsObj.shop.name}}</view>
<view class="rate">
<uni-rate
:readonly="true"
color="#ddd"
active-color="#c82626"
:value="2.5"
:size="14"
/>
</view>
<view class="openbtn" @click="onOpenWechat">进店</view>
</view>
<view class="tooSee">
<view class="tooSee-label">
区块链证书
</view>
<view class="tooSee-label">
商品认证
</view>
<view class="tooSee-label">
商品溯源
</view>
</view>
</view>
<!-- 产品规格 -->
<view class="size">
<view class="size-item nowrap">
<label class="title">产品规格</label>
{{goodsObj.skus[0].goods_name}}
</view>
<view class="size-item nowrap">
<label class="title">限制</label>
特价商品不可与优惠券叠加使用
</view>
<view class="size-item nowrap">
<label class="title">服务</label>
易货严选自营30天无忧退换不可用券国内部分地区不可配送
</view>
</view>
<!-- 产品详情 -->
<view class="product">
<block v-for="(item, index) in goodsObj.content" :key="index">
<image :src="item" mode="widthFix"></image>
</block>
</view>
</view>
<!-- footer -->
<view class="footer">
<button class="btn" size="default" @click="buyGoods">立即购买</button>
</view>
</view>
</template>
<script>
import { goods } from '@/apis/interfaces/goods'
import userAuth from '@/public/userAuth'
export default {
data() {
return {
loding : true,
goodsObj : {},
identity : '',
company : {},
coupons : {},
couponSee : ""
};
},
created() {
goods(this.$Route.query.id || 16).then(res=>{
console.log(res.coupons)
this.loding = false
this.goodsObj = res
this.identity = res.identity.id || ''
this.company = res.company
this.couponSee= res.coupons.slice(0, 3)
this.coupons = res.coupons
})
},
methods:{
// 提交购买单
buyGoods(){
let token = this.$store.getters.getToken
if(token == ''){
let userLogin = new userAuth()
userLogin.Login()
return
}
this.$Router.push({
name: 'Buy',
params: {
skuId: this.goodsObj.skus[0].sku_id,
qty : this.goodsObj.skus[0].number
}
})
},
// 打开微信小程序
onOpenWechat(){
plus.share.getServices(res => {
let sweixin = null;
for(let val of res){
if(val.id === 'weixin'){
sweixin = val
}
}
/** 以此为例子 显示跳转引导页
* 'index_4'
* index 跳小程序企业首页
* 4 企业id
**/
if(sweixin != null){
sweixin.launchMiniProgram({
id : this.company.original_id,
path: 'pages/login/guide?scene=index_' + this.company.company_id
})
}else{
uni.showToast({
title: '当前环境不支持打开微信小程序',
icon : 'none'
})
}
})
}
}
}
</script>
<style lang="scss" scoped>
.content{
position: relative;
padding-top: 100%;
}
// 轮播图
.goods-covers{
position: fixed;
top: 0;
left: 0;
z-index: 1;
width: 100%;
padding-top: 100%;
.swiper{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
.swiper-item{
width: 100%;
height: 100%;
}
}
}
// 商品详情
.goods-content{
position: relative;
z-index: 2;
background-color: white;
border-radius: $radius $radius 0 0;
padding-bottom: calc((#{$padding} * 2) + (env(safe-area-inset-bottom) / 2) + 90rpx);
padding-bottom: calc((#{$padding} * 2) + (constant(safe-area-inset-bottom) / 2) + 90rpx);
// 详情
.header{
padding: 0 $padding $padding;
.title{
font-size: $title-size;
font-weight: bold;
line-height: 50rpx;
display: flex;
.title-hot {
background-color: #fee195;
font-size: 24rpx;
border-radius: 50rpx;
padding: 0 10rpx;
height: 38rpx;
line-height: 38rpx;
margin: 6rpx 10rpx 0 0;
}
}
.sub-title{
line-height: 40rpx;
font-size: $title-size-sm;
color: $text-gray;
padding-bottom: $padding/3;
}
.flex-box{
display: flex;
justify-content: space-between;
line-height: 90rpx;
.price{
font-weight: bold;
color: $text-price;
font-size: $title-size + 14;
text{
font-size: 70%;
}
width: calc(60% - #{$padding});
}
.sales{
font-size: $title-size-sm;
color: $text-gray;
width: 40%;
text-align: right;
}
}
// 新增优惠券
.coupon {
background-color: #fef2f2;
color: #e1293f;
border-radius: 8rpx;
border: 2rpx solid #e7e2df;
padding: $padding - 10;
box-sizing: border-box;
display: flex;
position: relative;
margin-bottom: $margin - 10;
.coupon-list {
font-size: 24rpx;
.coupon-label {
display: inline-block;
border: 2rpx solid #e1293f;
border-radius: 50rpx;
padding: 4rpx 15rpx;
margin-right: $margin - 10;
}
}
.coupon-btn {
position: absolute;
right: $padding - 10;
top: $padding - 10;
font-size: 28rpx;
display: flex;
font-weight: 700;
.coupon-btn-img {
width: 30rpx;
height: 30rpx;
margin-top: 6rpx;
}
}
}
}
// 店铺
.store{
position: relative;
margin: 0 $margin;
// background: #F8F8F8;
background: #999;
border-radius: $radius/2;
padding: $padding;
min-height: 160rpx;
.logo{
position: absolute;
left: $margin;
top: $margin;
width: 98rpx;
height: 98rpx;
border-radius: $radius/2;
}
.store-cont {
position: absolute;
width: 100%;
left: 0;
top: 0;
padding-left: 150rpx;
padding-top: 20rpx;
box-sizing: border-box;
height: 140rpx;
}
.tooSee {
position: absolute;
top: 150rpx;
left: 0;
font-size: 24rpx;
padding-left: $padding;
box-sizing: border-box;
.tooSee-label {
background-color: #fd683e;
border-radius: 8rpx 4rpx 4rpx 6rpx;
color: #FFFFFF;
height: 52rpx;
line-height: 52rpx;
padding: 0 $padding - 15;
box-sizing: border-box;
display: inline-block;
margin-right: $margin * 2;
position: relative;
&::after, &::before{
content: '';
position: absolute;
}
&::after {
right: -40rpx;
top: 0;
background-color: #f64c37;
width: 40rpx;
height: 100%;
border-radius: 4rpx 8rpx 8rpx 4rpx;
}
&::before {
right: -1rpx;
top: 5%;
border: 1rpx dashed #fb745a;
height: 90%;
z-index: 2;
box-sizing: border-box;
}
&:last-child {
margin: 0;
}
&:first-child {
background-color: #f2d7aa;
color: #362507;
}
&:first-child::after {
background-color: #f1d599;
}
&:first-child::before {
border-color: #fae2b9;
}
}
}
.title{
font-size: $title-size-lg;
font-weight: bold;
line-height: 60rpx;
color: $text-color;
}
// rate
.openbtn{
position: absolute;
right: $margin;
top: $margin * 3;
color: #848484;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: $title-size-m;
margin-top: -30rpx;
}
}
// 产品规格
.size{
margin-top: $margin;
border-top: solid 20rpx #F8F8F8;
border-bottom: solid 20rpx #F8F8F8;
.size-item{
position: relative;
padding: 0 $padding 0 ($padding + 150);
line-height: 90rpx;
font-size: $title-size-m;
&::after{
position: absolute;
left: $margin;
right: 0;
bottom: 0;
content: " ";
height: 1rpx;
background-color: $border-color;
}
&:last-child::after{
display: none;
}
.title{
position: absolute;
left: $margin;
top: 0;
font-weight: bold;
}
}
}
// 产品详情
.product{
image{
vertical-align: top;
width: 100%;
}
}
}
// 立即购买
.footer{
padding: $padding;
background: white;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
z-index: 99;
box-sizing: border-box;
.btn[size='default']{
width: 100%;
height: 90rpx;
line-height: 90rpx;
padding: 0;
border-radius: 0;
box-sizing: border-box;
background: $text-price;
color: white;
font-weight: bold;
font-size: $title-size;
margin-bottom: calc(env(safe-area-inset-bottom) / 2);
margin-bottom: calc(constant(safe-area-inset-bottom) / 2);
}
}
</style>