|
| 1 | +<template> |
| 2 | +<main class="container"> |
| 3 | + <div class="product"> |
| 4 | + |
| 5 | + <products-header :product-title=selectDetailInfo.productTitle :product-price=selectDetailInfo.productPrice :author-list=selectDetailInfo.authorList :translator-list=selectDetailInfo.translatorList> |
| 6 | + </products-header> |
| 7 | + |
| 8 | + <!-- 暂时先隐藏下载的工具条 --> |
| 9 | + <!-- <products-download-tool> |
| 10 | + </products-download-tool> --> |
| 11 | + |
| 12 | + <products-preview-tool :preview-url=this.resolve(this.$route.path)> |
| 13 | + </products-preview-tool> |
| 14 | + |
| 15 | + <div class="product-description"> |
| 16 | + <products-introduce :product-subtitle=selectDetailInfo.productSubtitle :product-text=selectDetailInfo.productText> |
| 17 | + </products-introduce> |
| 18 | + |
| 19 | + <products-content :content-info=selectDetailInfo.contentInfo> |
| 20 | + </products-content> |
| 21 | + |
| 22 | + <hr> |
| 23 | + |
| 24 | + <products-author :author-list=selectDetailInfo.authorList :translator-list=selectDetailInfo.translatorList> |
| 25 | + </products-author> |
| 26 | + |
| 27 | + <hr> |
| 28 | + |
| 29 | + <products-problem :problem-list=selectDetailInfo.problemList> |
| 30 | + </products-problem> |
| 31 | + |
| 32 | + <hr> |
| 33 | + |
| 34 | + <!-- 暂时先隐藏下载的工具条 --> |
| 35 | + <!-- <products-download-tool> |
| 36 | + </products-download-tool> --> |
| 37 | + |
| 38 | + <products-preview-tool :preview-url=this.resolve(this.$route.path)> |
| 39 | + </products-preview-tool> |
| 40 | + |
| 41 | + </div> |
| 42 | + </div> |
| 43 | + |
| 44 | +</main> |
| 45 | +</template> |
| 46 | + |
| 47 | +<script> |
| 48 | +import ProductsHeader from '@/components/productsDetailInfo/productsHeader' |
| 49 | +import ProductsDownloadTool from '@/components/productsDetailInfo/ProductsDownloadTool' |
| 50 | +import ProductsIntroduce from '@/components/productsDetailInfo/productsIntroduce' |
| 51 | +import ProductsContent from '@/components/productsDetailInfo/productsContent' |
| 52 | +import ProductsAuthor from '@/components/productsDetailInfo/productsAuthor' |
| 53 | +import ProductsProblem from '@/components/productsDetailInfo/productsProblem' |
| 54 | +import ProductsPreviewTool from '@/components/productsDetailInfo/productsPreviewTool' |
| 55 | +import axios from 'axios' |
| 56 | +
|
| 57 | +export default { |
| 58 | + created() { |
| 59 | + axios.post('http://localhost:8080/api/getProductsDetailInfoList') |
| 60 | + .then((response) => { |
| 61 | + this.productsDetailInfoList = response.data |
| 62 | + this.selectDetailInfo = this.productsDetailInfoList[this.resolve(this.$route.path)] |
| 63 | + }) |
| 64 | + .catch((error) => { |
| 65 | + console.log('出错啦~', error) |
| 66 | + }) |
| 67 | + }, |
| 68 | + computed: { |
| 69 | + selectDetailInfo() { |
| 70 | + console.log(this.$route.path) |
| 71 | +
|
| 72 | + let url = this.resolve(this.$route.path) |
| 73 | + if (this.productsDetailInfoList[url] === undefined) { |
| 74 | + return this.defaultDetailInfo |
| 75 | + } else { |
| 76 | + return this.productsDetailInfoList[url] |
| 77 | + } |
| 78 | + } |
| 79 | + }, |
| 80 | + components: { |
| 81 | + ProductsHeader, |
| 82 | + ProductsDownloadTool, |
| 83 | + ProductsPreviewTool, |
| 84 | + ProductsIntroduce, |
| 85 | + ProductsContent, |
| 86 | + ProductsAuthor, |
| 87 | + ProductsProblem |
| 88 | + }, |
| 89 | + methods: { |
| 90 | + resolve(url) { |
| 91 | + if (url.substr(url.length - 1, 1) === '/') { |
| 92 | + return url.substring(0, url.length - 1) |
| 93 | + } else { |
| 94 | + return url |
| 95 | + } |
| 96 | + } |
| 97 | + }, |
| 98 | + data() { |
| 99 | + return { |
| 100 | + productsDetailInfoList: {}, |
| 101 | + defaultDetailInfo: { |
| 102 | + productTitle: '', |
| 103 | + productPrice: '', |
| 104 | + authorList: [], |
| 105 | + translatorList: [], |
| 106 | + productSubtitle: '', |
| 107 | + productText: '', |
| 108 | + contentInfo: [], |
| 109 | + problemList: [] |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | +} |
| 114 | +</script> |
| 115 | + |
| 116 | +<style> |
| 117 | +
|
| 118 | +</style> |
0 commit comments