cgc非遗
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.

790 lines
17 KiB

5 months ago
<template>
<view class="bg" id="bg" v-if="info">
<view class="swipe-box">
<swiper class="swiper" :indicator-dots="false" :autoplay="false" :interval="3000" :duration="1000" circular>
<swiper-item v-if="info && info.videourl">
<video
:src="showImg(info.videourl)"
id="detailVideo"
:poster="showImg(info.image)"
@play="play"
@error="videoErrorCallback"
controls
style="width: 100%;height: 100%;"
object-fit="cover"
></video>
</swiper-item>
<swiper-item v-for="(item, index) in info.list_images.split(',')" :key="item.id">
<view class="swiper-item">
<image class="item-img" :src="showImg(item)" mode="aspectFill"></image>
</view>
</swiper-item>
</swiper>
5 months ago
<view class="swiper-item-num">{{ info.list_images.split(',').length }}</view>
5 months ago
</view>
5 months ago
<view class="w-full relative" style="padding: 26rpx 0;top: -52rpx;">
5 months ago
<view class="price-box ">
<view class="price-zan">
<view class="price">
<view class="present-price">{{ info.money / 100 }}</view>
</view>
</view>
<view class="tag no-scrollbar" v-if="info.goods_new_tag">
<view class="tag-item" v-for="(item, index) in info.goods_new_tag.split(',')" :key="index">
{{ item }}
</view>
</view>
5 months ago
<view class="title">{{ info.title }}</view>
5 months ago
</view>
5 months ago
<view class="sku-box" v-if="sku.length>0">
<view class="sku-item" v-for="(item,i) in sku" :key="i">
<image :src="showImg(item.image)"></image>
<view class="sku-content">
<view class="flex-1">{{item.title}}</view>
<view class="present-price">{{item.money/100}}</view>
5 months ago
</view>
</view>
</view>
5 months ago
5 months ago
<view class="notice" v-if="info.reserve_content">
5 months ago
<view class="title">购买须知</view>
5 months ago
<view class="rich-text" v-html="formateRichText(info.reserve_content)"></view>
5 months ago
</view>
<view class="notice" >
<view class="title">商品须知</view>
5 months ago
<view class="rich-text" v-html="formateRichText(info.special_content)"></view>
</view>
</view>
5 months ago
<template v-if="!popShow">
5 months ago
<view class="btn-list" v-if="!paramData.showCart">
<view class="left-box">
5 months ago
<view class="img-box" slot="content">
5 months ago
<uni-badge class="uni-badge-left-margin" :text="paramData.num" absolute="rightTop" :offset="[5, 5]" size="small"
5 months ago
:custom-style="{background:'#D90F01',color:'#ffffff',border:'1px solid #ffffff'}">
5 months ago
<image @click.stop="showCartClick" :src="showImg('/uploads/20250513/29fd015f8c779f08e53d1016d3643c58.png')" mode="aspectFill"
5 months ago
style="width: 60rpx;height: 50rpx;"></image>
5 months ago
</uni-badge>
5 months ago
<text class="text">购物车</text>
5 months ago
</view>
</view>
5 months ago
<view class="btn-post">
5 months ago
<view class="left-btn-buy" @click="openPop(true)">加入购物车</view>
<view class="right-btn-buy" @click="openPop(false)">立即购买</view>
</view>
</view>
<view class="btn-list" v-else>
<view class="left-box">
<view class="img-box" slot="content">
<uni-badge class="uni-badge-left-margin" :text="paramData.num" absolute="rightTop" :offset="[5, 5]" size="small"
5 months ago
:custom-style="{background:'#D90F01',color:'#ffffff',border:'1px solid #ffffff'}">
<image @click.stop="showCartClick" :src="showImg('/uploads/20250513/29fd015f8c779f08e53d1016d3643c58.png')" mode="aspectFill"
style="width: 60rpx;height: 50rpx;"></image>
5 months ago
</uni-badge>
5 months ago
<text class="text">购物车</text>
5 months ago
</view>
<view class="bottom-price">
5 months ago
<text style="color: #000000;">总计</text>
5 months ago
<view class="bottom-price-yuan">{{paramData.iNum}}</view>
<view>.{{paramData.fNum}}</view>
</view>
</view>
<view class="btn-buy" @click="goCartOrder">
5 months ago
去结算
5 months ago
</view>
</view>
5 months ago
</template>
5 months ago
<cartDataVue ref="cartDataVueRef" :paramData="paramData" @changeParamData="changeParamData" :key="new Date().getTime()"></cartDataVue>
5 months ago
<uni-popup ref="popup" type="bottom" @change="changPopShow"
:safe-area="false" style="position: relative;z-index: 50;">
5 months ago
<view class="popup-content" v-if="sku.length>0">
<view @click="closePopup" style="padding: 31rpx 0 0 639rpx;width: 50rpx;height: 80rpx;">
<uni-icons type="closeempty" size="24"></uni-icons>
</view>
<view class="bottom-productImg">
<img :src="showImg(sku[productIndex].image)" alt="">
<view class="right-content">
<view class="bottom-productPrice com-price">{{(sku[productIndex].money||0)/100}}</view>
<view class="bottom-content text-overflow">已选择{{sku[productIndex].title}}</view>
</view>
</view>
<view>
<view class="sp">
规格
</view>
<view style="display: flex;align-items: center;justify-content: space-between;flex-wrap: wrap;">
<view style="position:relative;" v-for="(botItem,botIndex) in sku" :key="botIndex">
<view :class="['botProduct','text-overflow',{'noStore':botItem.store==0},{'botProducts':productIndex==botIndex}]"
@click="changeProduct(botItem,botIndex)">
{{botItem.title}}
</view>
<view class="noStore-text" v-if="botItem.store==0">
不可购买
</view>
5 months ago
<!-- <view class="noStore-text" v-else-if="is_post==1&&botItem.is_post!=1">不可加购</view> -->
5 months ago
</view>
</view>
</view>
<view class="buy-num com-flex-tao">
数量
<view class="number-btn">
<view>
<text @click="delNumber">-</text>
</view>
<view style="width: 96rpx;height: 69rpx;margin: 0 14rpx;">{{ buyNum }}</view>
<view>
<text @click="addNumber">+</text>
</view>
</view>
</view>
</view>
5 months ago
<!-- <view style="height: 100rpx;"></view> -->
<view class="btn-box">
<view class="buy-btn" @click="openPop(addCartOrOrder)">
{{addCartOrOrder?'加入购物车':'立即购买'}}
5 months ago
</view>
5 months ago
</view>
5 months ago
</uni-popup>
</view>
</template>
<script>
5 months ago
import cartDataVue from '../../components/cartData.vue'
5 months ago
export default {
5 months ago
components: {cartDataVue},
5 months ago
data() {
return {
id: null,
info: null,
sku: [],
productIndex: 0,
5 months ago
is_post: "1",
5 months ago
isCollect: false,
showLength: 0,
buyNum: 1,
popShow: false,
paramData: {allPrice: 0,iNum:0, fNum:'00', showCart: false, num: 0},
5 months ago
addCartOrOrder: null, //true 加入购物车 false 购买
5 months ago
};
},
onLoad(option) {
this.id = option.id;
this.getInfo();
this.getSpecificationsByGoodsId();
},
methods: {
changPopShow (e) {
this.popShow = e.show
},
getInfo() {
this.Post({
goods_id: this.id
},
'/api/goods/getGoodDetail'
).then(res => {
if (res.data.flag == 0) {
setTimeout(() => {
uni.showToast({
title: '商品不存在或已下架',
icon: 'none'
})
}, 0)
setTimeout(() => {
this.goBack()
}, 2000)
}
this.info = res.data;
5 months ago
// this.isCollect = this.info.is_collect;
if (this.info.title) {
uni.setNavigationBarTitle({
title: this.info.title
})
5 months ago
}
});
},
getSpecificationsByGoodsId() {
this.Post({
goods_id: this.id
},
'/api/goods/getSpecificationsByGoodsId'
).then(res => {
if (res) {
this.sku = res.data || [];
// todo
5 months ago
// this.is_post = "2"
// if (this.sku.length>0 && this.sku.some(v=>v.is_post == 1)) {
// this.is_post = "1"
5 months ago
5 months ago
// }
5 months ago
}
});
},
// 收藏
collect() {
this.Post({
type: 5,
id: this.id
},
'/api/scenic/collect'
).then(res => {
if (res) {
uni.showToast({
title: res.msg,
icon: 'none'
});
this.isCollect = !this.isCollect
}
});
},
//数量加减
addNumber() {
this.buyNum += 1;
},
delNumber() {
if (this.buyNum <= 1) {
return;
}
this.buyNum -= 1;
},
closePopup() {
this.$refs.popup.close()
},
// false 下单 true 加入购物车
openPop(flag) {
if (!this.sku||this.sku.length<=0) {
uni.showToast({
title:'暂无可选规格',
icon:'none'
})
return
}
if (!this.popShow) {
this.$refs.popup.open()
5 months ago
this.addCartOrOrder = flag
5 months ago
} else {
if (flag) {
this.addToCart()
} else {
this.order()
}
}
},
order(item) {
let goods = this.sku[this.productIndex]
goods.buyNum = this.buyNum
let orderInfo = {
5 months ago
// is_post: goods.is_post || "2",
is_post: 1,
5 months ago
goods: [{goodsInfo: this.info, skuInfo: goods }],
post: 0,
}
uni.setStorageSync('teChanOrder', JSON.stringify(orderInfo)); //规格
// uni.setStorageSync('teChanInfo', JSON.stringify(this.info)); //商品
uni.navigateTo({
url: '/subPackages/techan/order'
});
},
addToCart () {
let goods = this.sku[this.productIndex]
goods.buyNum = this.buyNum
let goodsInfo = {goodsInfo:this.info, skuInfo: goods, isSelected: true}
this.Post({good_id: this.info.id, specifications_id: goods.id,num: this.buyNum },
'/api/shopping/addShopping').then(res => {
if (res) {
let selectedData = []
try {
selectedData = JSON.parse(uni.getStorageSync('cartDataInfo'));
} catch(e) {
selectedData = []
}
let currentGoods = selectedData.find(v =>v==goods.id)
if (!currentGoods) {
selectedData.push(goods.id)
}
uni.setStorageSync('cartDataInfo', JSON.stringify(selectedData));
uni.$emit("updateDataByConnect", {msgType:'updateCartDataInfo',data:null})
this.closePopup()
// this.$refs.cartDataVueRef.openPop()
}
});
},
goUser() {
uni.switchTab({
url: '/pages/index/user'
})
},
changeProduct(item,index) {
if (item.store==0) {
uni.showToast({
title:"库存不足!",
icon:'none'
})
return
}
this.productIndex = index
},
// 购物车
changeParamData (data) {
for(let key in this.paramData) {
this.paramData[key] = data[key]
}
},
showCartClick () {
if (this.paramData.showCart) {
this.$refs.cartDataVueRef.closePopup()
} else {
this.$refs.cartDataVueRef.openPop()
}
},
goCartOrder () {
this.$refs.cartDataVueRef.goCartOrder()
},
},
onReachBottom() {
}
};
</script>
<style lang="scss" scoped>
.bg {
min-height: 100vh;
overflow-x: hidden;
background: #f2f4f7;
padding-bottom: 210rpx;
}
view {
box-sizing: border-box;
}
.swipe-box {
5 months ago
height: 750rpx;
5 months ago
position: relative;
.swiper-item-num {
width: 90rpx;
height: 40rpx;
background: rgba(0, 0, 0, 0.5);
border-radius: 20rpx;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #ffffff;
text-align: center;
line-height: 40rpx;
position: absolute;
right: 30rpx;
bottom: 50rpx;
}
}
.swiper {
5 months ago
height: 750rpx;
5 months ago
position: relative;
.swiper-item {
width: 100%;
5 months ago
height: 750rpx;
5 months ago
.item-img {
width: 750rpx;
5 months ago
height: 750rpx;
5 months ago
}
}
}
.price-box {
width: 100%;
background: #ffffff;
border-radius: 20rpx 20rpx 0 0;
padding: 24rpx 30rpx;
.price-zan {
display: flex;
align-items: center;
justify-content: space-between;
.price {
display: flex;
}
}
.tag {
margin:24rpx 0 15rpx 0;
display: flex;
align-items: center;
flex-wrap: nowrap;
overflow-x: auto;
.tag-item {
5 months ago
margin-right: 10rpx;
padding: 0rpx 15rpx;
5 months ago
flex-shrink: 0;
font-weight: 500;
5 months ago
font-size: 23rpx;
color: #60989E;
height: 37rpx;
line-height: 37rpx;
background: rgba(96, 152, 158, 0.2);
border-radius: 4rpx;
5 months ago
}
}
.title {
5 months ago
margin-top: 22rpx;
5 months ago
font-family: PingFang;
font-weight: bold;
font-size: 31rpx;
color: #000000;
}
}
5 months ago
.present-price {
font-size: 42rpx;
font-family: PingFang SC;
font-weight: 500;
color: #FC5109;
&:before {
content: '¥';
display: inline-block;
font-size: 26rpx;
5 months ago
}
5 months ago
&:after {
content: '起';
display: inline-block;
font-size: 24rpx;
font-family: PingFangSC;
color: #B5BCC9;
5 months ago
}
}
5 months ago
.notice {
width: 700rpx;
margin: 25rpx auto 0;
background: #ffffff;
border-radius: 20rpx;
padding: 40rpx 25rpx;
.title{
5 months ago
font-weight: bold;
5 months ago
font-size: 36rpx;
5 months ago
color: #000000;
5 months ago
margin-bottom: 30rpx;
5 months ago
}
}
.btn-list {
position: fixed;
z-index: 9999;
bottom: 0;
width: 750rpx;
height: 180rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(6, 0, 1, 0.1);
display: flex;
justify-content: space-between;
5 months ago
padding: 30rpx 25rpx 0 50rpx;
5 months ago
.left-box {
display: flex;
align-items: flex-start;
.bottom-price{
display: flex;
align-items: baseline;
font-family: PingFang SC;
font-weight: bold;
font-size: 27rpx;
5 months ago
color: #D70000;
5 months ago
padding-top: 20rpx;
.bottom-price-yuan{
font-size: 40rpx;
}
}
.bottom-detail-icon{
font-size: 24rpx;
display: flex;
align-items: center;
}
.img-box {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
5 months ago
margin-right: 50rpx;
5 months ago
image {
width: 48rpx;
height: 48rpx;
}
.text {
5 months ago
font-weight: 500;
font-size: 22rpx;
color: #4D526C;
5 months ago
}
}
}
.btn-buy {
5 months ago
width: 240rpx;
5 months ago
height: 78rpx;
5 months ago
background: #74A5AA;
5 months ago
border-radius: 40rpx;
text-align: center;
line-height: 78rpx;
font-size: 32rpx;
font-family: PingFangSC;
font-weight: 500;
color: #FFFFFF;
}
}
.popup-content {
background-color: white;
padding: 0rpx 39rpx 51rpx 39rpx;
height: auto;
border-radius: 20rpx 20rpx 0 0;
5 months ago
.bottom-productImg {
display: flex;
margin-bottom: 23rpx;
img {
width: 218rpx;
height: 179rpx;
background: #666666;
border-radius: 13rpx;
}
}
.right-content {
margin: 10rpx 0 0 41rpx;
}
.bottom-productPrice {
font-size: 40rpx;
color: #FC524B;
&:before {
content: "¥";
font-size: 26rpx;
}
}
.bottom-content {
width: 331rpx;
font-size: 27rpx;
font-family: PingFang SC;
font-weight: 400;
color: #666666;
5 months ago
}
}
.botProduct {
width: 320rpx;
// height: 78rpx;
border-radius: 13rpx;
5 months ago
background-color: #EFEFEF;
5 months ago
font-size: 29rpx;
font-family: PingFang SC;
font-weight: 400;
color: #333333;
line-height: 78rpx;
text-align: center;
margin-bottom: 25rpx;
display: inline-block;
position: relative;
padding: 0 40rpx;
}
.noStore{
background-color: rgba(239, 239, 239, 1);
color: rgba(153, 153, 153, 1);
}
.noStore-text{
width: 113rpx;
height: 43rpx;
background: #C0C0C0;
border-radius: 7rpx 0rpx 7rpx 0rpx;
text-align: center;
line-height: 43rpx;
position: absolute;
right: -14rpx;
top: -20rpx;
font-size: 23rpx;
font-family: PingFangSC;
font-weight: 400;
color: #FFFFFF;
}
.botProducts {
// border: 1rpx solid #00AAFF;
// background-color: rgba(254, 180, 25, 1);
5 months ago
background: #74A5AA;
5 months ago
color: #FFFFFF;
}
.buy-num {
font-size: 29rpx;
font-family: PingFang SC;
font-weight: 400;
color: #333333;
// border-top: 1rpx solid #CCCCCC;
padding: 39rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
5 months ago
.number-btn {
display: flex;
}
5 months ago
}
.buy-num .number-btn view {
display: flex;
justify-content: center;
align-items: center;
width: 69rpx;
height: 69rpx;
border: 1rpx solid #CCCCCC;
border-radius: 7rpx;
}
.buy-num .number-btn>view text {
font-size: 46rpx;
}
.buy-btn {
width: 670rpx;
height: 78rpx;
text-align: center;
line-height: 78rpx;
5 months ago
background: #74A5AA;
5 months ago
border-radius: 40rpx;
font-size: 34rpx;
font-family: PingFangSC;
font-weight: 500;
color: #FFFFFF;
}
.btn-box {
width: 750rpx;
height: 151rpx;
background: #FFFFFF;
box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(6, 0, 1, 0.1);
display: flex;
align-items: center;
justify-content: center;
}
.sp {
width: 100%;
height: 30rpx;
font-size: 32rpx;
font-family: PingFangSC;
font-weight: 400;
color: #060001;
line-height: 30rpx;
border-top: solid 2rpx #ccc;
margin: 60rpx 0;
padding-top: 30rpx;
}
.btn-post{
font-weight: 500;
5 months ago
font-size: 32rpx;
color: #60989E;
5 months ago
line-height: 77rpx;
text-align: center;
display: flex;
.left-btn-buy{
5 months ago
width: 186rpx;
5 months ago
height: 77rpx;
5 months ago
color: #60989E;
5 months ago
border-radius: 39rpx 0rpx 0rpx 39rpx;
5 months ago
background: rgba(116, 165, 170, 0.3);
5 months ago
}
.right-btn-buy{
5 months ago
width: 187rpx;
5 months ago
height: 77rpx;
5 months ago
background: #74A5AA;
5 months ago
border-radius: 0rpx 39rpx 39rpx 0rpx;
5 months ago
color: white;
}
}
.sku-box{
width: 700rpx;
margin: 25rpx auto 0;
background: #FFFFFF;
border-radius: 20rpx;
.sku-item{
5 months ago
// border-radius: 20rpx;
5 months ago
width: 100%;
padding: 14rpx;
display: flex;
border-bottom: 1px solid #D8D8D8;
.sku-content{
display: flex;
padding-left: 16rpx;
flex: 1;
width: 1rpx;
}
image{
width: 160rpx;
height: 160rpx;
border-radius: 13rpx;
flex-shrink: 0;
}
.flex-1{
font-weight: 500;
font-size: 29rpx;
color: #000000;
height: 160rpx;
padding-right: 75rpx;
overflow: hidden;
}
.present-price{
display: flex;
align-items: center;
}
.present-price::after{
content: '';
}
}
.sku-item:last-of-type{
border: none;
5 months ago
}
}
</style>