|
|
@@ -0,0 +1,213 @@
|
|
|
+<template>
|
|
|
+ <ion-page class="product">
|
|
|
+ <ion-content>
|
|
|
+ <swiper class="bannerSwiper">
|
|
|
+ <swiper-slide v-for="(item, index) in info.pic" :key="index">
|
|
|
+ <van-image :src="item" fit="cover" height="100vw" width="100vw" />
|
|
|
+ </swiper-slide>
|
|
|
+ </swiper>
|
|
|
+ <div class="info">
|
|
|
+ <div class="card">
|
|
|
+ <div class="title">
|
|
|
+ {{ info.name }}
|
|
|
+ </div>
|
|
|
+ <div class="badges">
|
|
|
+ <div class="badge">{{ category.name }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="datas">
|
|
|
+ <div class="data">
|
|
|
+ <div class="val">{{ info.currentPrice }}</div>
|
|
|
+ <div class="name">当前价(元)</div>
|
|
|
+ </div>
|
|
|
+ <div class="data">
|
|
|
+ <div class="val">3%</div>
|
|
|
+ <div class="name">日化收益</div>
|
|
|
+ </div>
|
|
|
+ <div class="data">
|
|
|
+ <div class="val">{{ info.premium || 0 }}</div>
|
|
|
+ <div class="name">明日可得(元)</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="creator" v-if="user.id">
|
|
|
+ <div class="text1">产品持有人:</div>
|
|
|
+ <van-image width="20" height="20" radius="4" :src="user.avatar"></van-image>
|
|
|
+ <div class="text2">{{ user.nickname }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="detail">
|
|
|
+ <div class="card">
|
|
|
+ <div class="detail-title">商品详情</div>
|
|
|
+ <div class="detail-content">
|
|
|
+ <van-image
|
|
|
+ v-for="(item, index) in info.pic"
|
|
|
+ :key="index"
|
|
|
+ :src="item"
|
|
|
+ radius="4"
|
|
|
+ fit="scale-down"
|
|
|
+ width="100%"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </ion-content>
|
|
|
+ <ion-footer v-if="info.status === 'IN_STOCK'">
|
|
|
+ <ion-toolbar>
|
|
|
+ <div class="footer">
|
|
|
+ <van-button type="primary" block>立即购买</van-button>
|
|
|
+ </div>
|
|
|
+ </ion-toolbar>
|
|
|
+ </ion-footer>
|
|
|
+ </ion-page>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { Swiper, SwiperSlide } from 'swiper/vue'
|
|
|
+import 'swiper/swiper.min.css'
|
|
|
+import { ref, getCurrentInstance, onMounted, computed } from 'vue'
|
|
|
+import { useRoute } from 'vue-router'
|
|
|
+
|
|
|
+const {
|
|
|
+ appContext: {
|
|
|
+ config: { globalProperties: global }
|
|
|
+ }
|
|
|
+} = getCurrentInstance()
|
|
|
+const route = useRoute()
|
|
|
+
|
|
|
+const info = ref({
|
|
|
+ pic: []
|
|
|
+})
|
|
|
+
|
|
|
+const category = computed(() => {
|
|
|
+ return info.value.category || {}
|
|
|
+})
|
|
|
+const user = computed(() => {
|
|
|
+ return info.value.user || {}
|
|
|
+})
|
|
|
+
|
|
|
+function getDetail() {
|
|
|
+ global.$http.get('/product/get/' + route.query.id).then(res => {
|
|
|
+ info.value = res
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getDetail()
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.info {
|
|
|
+ transform: translateY(-20px);
|
|
|
+ position: relative;
|
|
|
+ z-index: 2;
|
|
|
+
|
|
|
+ .title {
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 28px;
|
|
|
+ margin-bottom: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .badges {
|
|
|
+ .f();
|
|
|
+ .badge {
|
|
|
+ font-size: 10px;
|
|
|
+ background: #e9effb;
|
|
|
+ color: #4078de;
|
|
|
+ line-height: 16px;
|
|
|
+ padding: 0 2px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .datas {
|
|
|
+ .f();
|
|
|
+ .data {
|
|
|
+ width: 33%;
|
|
|
+ .f-col();
|
|
|
+ align-items: center;
|
|
|
+ margin-top: 16px;
|
|
|
+ .val {
|
|
|
+ font-size: 20px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ .name {
|
|
|
+ font-size: 12px;
|
|
|
+ color: rgba(0, 0, 0, 0.6);
|
|
|
+ line-height: 17px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:nth-child(1) {
|
|
|
+ align-items: flex-start;
|
|
|
+ .val {
|
|
|
+ color: var(--red);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &:nth-child(2) {
|
|
|
+ .val {
|
|
|
+ color: var(--green);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .creator {
|
|
|
+ .f();
|
|
|
+ background: #f5f7fa;
|
|
|
+ border-radius: 4px;
|
|
|
+ padding: 7px 12px;
|
|
|
+ margin-top: 16px;
|
|
|
+
|
|
|
+ .text1 {
|
|
|
+ font-size: 12px;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 17px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .text2 {
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 17px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .van-image {
|
|
|
+ margin: 0 6px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.detail {
|
|
|
+ transform: translateY(-10px);
|
|
|
+}
|
|
|
+.bannerSwiper {
|
|
|
+ position: relative;
|
|
|
+ z-index: 1;
|
|
|
+}
|
|
|
+.card {
|
|
|
+ background: #ffffff;
|
|
|
+ border-radius: 16px;
|
|
|
+ padding: 16px 16px 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.detail {
|
|
|
+ .detail-title {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 24px;
|
|
|
+ padding-bottom: 16px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.footer {
|
|
|
+ padding: 6px 24px;
|
|
|
+ --van-button-border-width: 0;
|
|
|
+ --van-button-primary-background: linear-gradient(135deg, #d700ff 0%, #3e22ff 100%);
|
|
|
+}
|
|
|
+</style>
|