重新提问,补上product的全部文件
来源:3-3 项目作业
一拍
2020-05-05 22:56:59
1、数据能获取到。轮播图是正常的,从index.vue传给子组件content,content不显示数据
2、看不到loading,不知道有没有加上?
4、主要框架都写好了,就差获取数据了,还有什么问题老师看看
3、后面个人中心页面和购物车视频里说一张图片,没有素材啊?
config.js
export const sliderOptions = { // 轮播图配置 direction: 'horizontal', // horizontal:水平 vertical:垂直 loop: true, // 是否无缝滚动 interval: 0, // 自动播放时间间隔,为0则不自动播放 pagination: true // 是否需要分页器 };
content.vue
<template> <div class="wrap"> <me-loading v-if="!loaded"/> <div class="content" > <div class="price"> <span class="price-num">{{contentData.priceText}}</span> <div class="sell-num">{{contentData.soldCount}}1477件已售</div> </div> <div class="title"> <h1>卡夫斌肝卡夫斌肝卡夫斌肝卡夫斌肝卡夫斌肝</h1> <div class="title-detail"> <span>快递包邮</span> <span>快递包邮</span> <span>快递包邮</span> </div> </div> <div class="evaluate"> <h1 class="evaluate-title">商品评价(3010)</h1> <div class="evaluate-tag"> <span>好吃</span> <span>好吃</span> <span>好吃</span> </div> <div class="custom"> <img src alt /> <span>久久</span> </div> <div class="evaluate-content"> 文字中文字文字文字文字为智能为你我文字文字文字为 文字文字文字为智能为文字文字文字为智能为文字 文字文字为智能为文字文字文字为智能为智能为文字文字文字为智能为 </div> <div class="evaluate-detail">2018-05-06 口味</div> </div> <div class="shop"> <div class="shop-name"> <img src alt /> <h3>零食店</h3> <h3>天猫</h3> </div> <div class="shop-detail"> <span>宝贝描述</span> <span>卖家服务</span> <span>物流服务</span> </div> </div> </div> </div> </template> <script> import MeLoading from 'base/loading'; export default { name: "ProductContent", components: { MeLoading }, props: { contentData: { type: Object, default:{} }, loaded:{ type:Boolean, default:false } }, }; </script> <style lang="scss" scoped> .price { background-color: #ef3563; height: 46px; position: relative; &-num { color: #fff; line-height: 46px; font-size: 18px; padding-left: 5px; } .sell-num { background-color: rgba(204, 46, 62, 0.8); color: #fff; position: absolute; right: 9px; top: 12px; padding: 5px; border-radius: 3px; } } .title { background-color: #fff; margin-bottom: 10px; h1 { line-height: 36px; text-indent: 10px; color: black; } &-detail { display: flex; justify-content: space-between; margin: 0 10px; line-height: 28px; } } .evaluate { padding: 0 10px; background-color: #fff; line-height: 30px; margin-bottom: 10px; &-tag { // line-height: 36px; span { margin: 5px; padding: 5px; border-radius: 3px; background-color: rgba(255, 238, 238, 0.8); } } .custom { text-indent: 16px; } &-content { line-height: 16px; } } .shop{ background-color: #fff; padding-bottom: 100px; &-detail{ display: flex; justify-content: space-around; line-height: 16px; } } </style>
header.vue
<template> <me-navbar class="header"> <i class="iconfont icon-back" slot="left" @click="goBack" ></i> <div slot="center" class="header-title"> 商品详情 </div> <i class="iconfont icon-cart" slot="right"></i> </me-navbar> </template> <script> import MeNavbar from 'base/navbar'; export default { name: 'ProductHeader', components: { MeNavbar, }, methods:{ getQuery(query) { console.log(query); }, goBack() { this.$router.back(); } } }; </script> <style lang="scss" scoped> @import "~assets/scss/mixins"; .header { &.mine-navbar { background-color: $header-bgc-translucent; } .iconfont { color: $icon-color-default; font-size: $icon-font-size; } .header-title{ font-size: 18px; text-align: center; color: #fff; } } </style>
index.vue
<template> <transition name="product" appear> <div class="product"> <header class="g-header-container"> <product-header/> </header> <me-scroll ref="scroll" > <product-slider @load="updateScroll" :picData="items"/> <product-content :contentData="contents" :loaded="loaded"></product-content> </me-scroll> <div class="g-footer-container"> <me-cart></me-cart> </div> </div> </transition> </template> <script> import {getProductDetail} from 'api/product'; import ProductHeader from './header'; import MeScroll from 'base/scroll'; import ProductSlider from './slider'; import ProductContent from './content' import MeCart from 'components/cart' export default { name: 'Product', components: { MeScroll, ProductHeader, ProductSlider, ProductContent, MeCart }, data(){ return{ items:[],//保存幻灯片 contents:{},//保存产品详情 loaded:false } }, methods:{ updateScroll() { this.$refs.scroll && this.$refs.scroll.update(); console.log(1); } }, created() { getProductDetail(this.$route.params.id).then(data =>{ // console.log(data); // this.products=data.data; if(data){ this.items=data.data.item.images; const apiStack=JSON.parse(data.data.apiStack[0].value); this.contents.priceText=apiStack.price.price.priceText; //单价 this.contents.soldCount=apiStack.vertical.jhs.soldCount;//已售件数 console.log(this.contents); this.loaded=true; } }) } }; </script> <style lang="scss" scoped> @import "~assets/scss/mixins"; .product { overflow: hidden; position: absolute; top: 0; left: 0; z-index: $product-z-index; width: 100%; height: 100%; background-color: $bgc-theme; } .product-enter-active, .product-leave-active { transition: all 0.3s; } .product-enter, .product-leave-to { transform: translate(100%, 0); } </style>
slider.vue
<template> <div class="slider-wapper"> <me-loading v-if="loaded"/> <me-slider :direction="direction" :loop="loop" :interval="interval" :pagination="pagination" v-else > <swiper-slide v-for="(item, index) in picData" :key="index" > <a href="#" class="slider-link"> <img @load="updateScroll" :src="item" alt="pic" class="slider-img"> </a> </swiper-slide> </me-slider> </div> </template> <script> import MeSlider from 'base/slider'; import {swiperSlide} from 'vue-awesome-swiper'; import {sliderOptions} from './config'; import MeLoading from 'base/loading'; export default { name: 'ProductSlider', components: { MeSlider, MeLoading, swiperSlide }, data() { return { direction: sliderOptions.direction, loop: sliderOptions.loop, interval: sliderOptions.interval, pagination: sliderOptions.pagination, }; }, props:{ picData:{ type:Array, default(){ return [] } }, loaded:{ type:Boolean, default:false } }, methods:{ updateScroll() { this.$refs.scroll && this.$refs.scroll.update(); } } }; </script> <style lang="scss" scoped> .slider-wapper { // width: 100%; height: 375px; } .slider-link { display: block; } .slider-link, .slider-img { overflow: hidden; width: 100%; height: 100%; } </style>
1回答
好帮手慕慕子
2020-05-06
同学你好,没有product页面请求数据的相关代码,无法进行准确的测试,另,由于涉及到多个文件,情况比较特殊,老师在私信中帮助同学解决,同学可以查看下私信,祝学习愉快~
相似问题