Files
cmgd-mini-app/pages/config/goodsDetail.vue
2026-01-05 12:47:14 +08:00

341 lines
6.6 KiB
Vue

<template>
<view class="content">
<nut-watermark v-if="detail.status?.value === 10" class="mark1" :z-index="1" content="此商品已下架"></nut-watermark>
<nut-watermark v-if="detail.status?.value === 30" class="mark1" :z-index="1" content="此商品已锁定"></nut-watermark>
<nut-watermark v-if="detail.status?.value === 40" class="mark1" :z-index="1" content="此商品已售出"></nut-watermark>
<swiper class="swiper" circular indicator-dots autoplay>
<swiper-item @click="showGoodsImages(idx)" v-for="(item,idx) in detail.image" :key="idx">
<image :src="item.file_path" mode="aspectFill"></image>
</swiper-item>
</swiper>
<view class='goods_info'>
<nut-cell-group>
<view class="price">
<text class="unit"></text>
<text class="value">{{detail.goods_price}}</text>
</view>
</nut-cell-group>
<nut-cell-group>
<view class="name">
<view class="top">
<view class="tag">
<text>{{detail.degree?.degree_name}}</text>
</view>
<text class="title">{{detail.goods_name}}</text>
</view>
<view>
<text class="info">{{detail.content}}</text>
</view>
</view>
</nut-cell-group>
<view class="service">
<view class="info">
<text class="title">服务</text>
<text class="value">{{serviceTxt}}</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import {
reactive,
ref
} from 'vue';
import {
navigateTo,
switchTab,
goToLoginPage
} from '@/utils/helper';
import {
onShareAppMessage,
onShareTimeline,
onLoad
} from '@dcloudio/uni-app'
import {
fetchGoodsDetail,
} from '@/api/goods';
import {
fetchGetConfig,
} from '@/api/config';
// 审核模式 默认开启 true
// const audit = ref(true);
const serviceTxt = ref('')
const id = ref(0)
const detail = reactive({})
onLoad(options => {
console.log('init');
// 获取配置
getConfig()
// 获取商品详情
id.value = options.id
fetchGoodsDetail(id.value).then(res => {
Object.assign(detail, res)
})
})
// 获取配置
const getConfig = () => {
fetchGetConfig().then(res => {
console.log('getConfig=====>', res)
// audit.value = res.appConfig.is_audit == 1
serviceTxt.value = res.appConfig.service_txt
})
}
// 分享给朋友圈
onShareTimeline((res) => {
return {
title: detail.goods_name,
path: '/pages/mall/detail?id=' + detail.goods_id,
imageUrl: detail.image[0].file_path
};
})
// 分享
onShareAppMessage((res) => {
return {
title: detail.goods_name,
path: '/pages/mall/detail?id=' + detail.goods_id,
imageUrl: detail.image[0].file_path
}
})
// 显示图片
const showGoodsImages = (index) => {
uni.previewImage({
current: index, // 指定当前显示的图片索引
urls: detail.image.map(e => {
return e.file_path
}),
});
}
</script>
<style scoped lang="scss">
.bottom-action {
position: fixed;
bottom: 0;
left: 0;
height: 50px;
background: #fff;
width: calc(100% - 20px);
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 auto;
padding: 5px 10px;
.bottom-action-icon {
align-items: center;
display: flex;
justify-content: center;
.bottom-action-icon-item {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
text {
color: rgba(0, 0, 0, .5);
font-size: 11px;
}
}
}
.bottom-action-btn {
-ms-flex-align: center;
-ms-flex-pack: end;
-webkit-align-items: center;
align-items: center;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
gap: 5px;
-webkit-justify-content: flex-end;
justify-content: flex-end;
}
}
.content {
display: flex;
flex-direction: column;
min-height: calc(100vh - 50px); //100vh;
/* align-items: center; */
// justify-content: center;
background-color: #f2f3f5;
// height: calc(100% - 50px);
--nut-cell-group-title-color: #000;
--nut-collapse-item-padding: 10px 10px 10px 10px;
--nut-collapse-wrapper-content-padding: 10px 10px 10px 10px;
--nut-collapse-item-color: #000;
padding-bottom: 50px;
}
.report-inner {
display: flex;
flex-direction: column;
gap: 5px;
.report-item {
.report-item-name {
color: rgba(0, 0, 0, .9);
font-weight: 700;
}
.report-item-content {
display: flex;
flex-wrap: wrap;
.report-item-content-item {
padding-top: 2px;
padding-bottom: 2px;
width: 50%;
display: flex;
align-items: center;
}
}
}
}
.count-item {
display: flex;
justify-content: center;
align-items: center;
gap: 2px;
}
.swiper {
width: 100%;
height: 414px;
image {
width: 100%;
height: 100%;
}
}
.goods_info {
padding: 5px;
color: #000;
.price {
border-radius: 5px;
padding: 10px;
background: #fff;
.unit {
font-size: 12px;
}
.value {
font-size: 24px;
}
}
.name {
border-radius: 5px;
padding: 10px;
background: #fff;
display: flex;
gap: 5px;
flex-direction: column;
.top {
display: flex;
gap: 5px;
.tag {
background: #000;
padding: 1px 2px;
justify-content: center;
align-items: center;
display: flex;
border-radius: 2px;
text {
font-size: 10px;
color: #fff;
}
}
.title {
font-size: 16px;
}
}
.info {
color: rgba(0, 0, 0, .7);
font-size: 13px;
}
}
.service {
border-radius: 5px;
padding: 10px;
background: #fff;
display: flex;
align-items: center;
justify-content: space-between;
.info {
display: flex;
flex-direction: column;
justify-content: center;
gap: 5px;
.title {
font-size: 16px;
}
.value {
color: rgba(0, 0, 0, .7);
font-size: 13px;
}
}
.right_icon {
background-color: currentColor;
mask: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiMxQTFBMUEiIGQ9Ik0zNTMuODMgMTU4LjE3YTQyLjY3IDQyLjY3IDAgMSAxIDYwLjM0LTYwLjM0bDM4NCAzODRhNDIuNjcgNDIuNjcgMCAwIDEgMCA2MC4zNmwtMzg0IDM4NGE0Mi42NyA0Mi42NyAwIDEgMS02MC4zNC02MC4zNkw3MDcuNjcgNTEyeiIvPjwvc3ZnPg==') 0 0/100% 100% no-repeat;
width: 12px;
height: 12px;
}
}
.report {
border-radius: 5px;
padding: 1px;
background: #fff;
}
}
</style>