detail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div>
  3. <a-page-header :ghost="false" :backIcon="false" class="newProductDetail-back">
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="newProductDetail-back-btn" href="javascript:;" @click="goBack">
  7. <a-icon type="left" />
  8. 返回
  9. </a>
  10. </template>
  11. </a-page-header>
  12. <div class="newProductDetail-modal">
  13. <!-- 产品详情 -->
  14. <h4>{{ (detailsData && detailsData.name) || '--' }}</h4>
  15. <div class="productHead">
  16. <div class="productInfo">
  17. <a-descriptions bordered :column="2" size="small">
  18. <a-descriptions-item label="产品品牌:">{{ (detailsData && detailsData.productBrandName) || '--' }}</a-descriptions-item>
  19. <a-descriptions-item label="产品编码:">{{ (detailsData && detailsData.code) || '--' }}</a-descriptions-item>
  20. <a-descriptions-item label="原厂编码:">{{ (detailsData && detailsData.origCode) || '--' }}</a-descriptions-item>
  21. <a-descriptions-item label="商品尺寸:">{{ (detailsData && detailsData.size) || '--' }}</a-descriptions-item>
  22. <a-descriptions-item label="重量:">{{ (detailsData && detailsData.weight) || '--' }}</a-descriptions-item>
  23. <a-descriptions-item label="计量单位:">{{ (detailsData && detailsData.unit) || '--' }}</a-descriptions-item>
  24. </a-descriptions>
  25. <div class="productDetail">
  26. <h4>产品介绍</h4>
  27. <div class="productDesc">
  28. <div v-if="detailsData && detailsData.description" v-html="detailsData.description"></div>
  29. <span v-else>暂无产品介绍</span>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="productImg" v-if="detailsData && detailsData.productPicList && detailsData.productPicList.length>0">
  34. <a-carousel arrows dots-class="slick-dots slick-thumb">
  35. <a slot="customPaging" slot-scope="props">
  36. <img :src="detailsData.productPicList[props.i].imageUrl" />
  37. </a>
  38. <div slot="prevArrow" slot-scope="props" class="custom-slick-arrow" style="left: 10px;zIndex: 1"><a-icon type="left-circle" style="color: #314659;" /></div>
  39. <div slot="nextArrow" slot-scope="props" class="custom-slick-arrow" style="right: 10px"><a-icon type="right-circle" style="color: #314659;" /></div>
  40. <div v-for="(item, index) in detailsData.productPicList" :key="index">
  41. <img-zoom :src="item.imageUrl" width="100%" height="100%" :bigsrc="item.imageUrl" :configs="configs"></img-zoom>
  42. </div>
  43. </a-carousel>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import imgZoom from 'vue2.0-zoom'
  51. import { productDetail } from '@/api/product.js'
  52. export default {
  53. name: 'ProductInfoDetail',
  54. components: { imgZoom },
  55. computed: {
  56. productTypeName () {
  57. const productTypeName1 = this.detailsData && this.detailsData.productTypeName1 ? this.detailsData.productTypeName1 : ''
  58. const productTypeName2 = this.detailsData && this.detailsData.productTypeName2 ? ' > ' + this.detailsData.productTypeName2 : ''
  59. const productTypeName3 = this.detailsData && this.detailsData.productTypeName3 ? ' > ' + this.detailsData.productTypeName3 : ''
  60. return productTypeName1 + productTypeName2 + productTypeName3
  61. }
  62. },
  63. data () {
  64. return {
  65. itemId: null,
  66. detailsData: null, // 详情数据
  67. prevPageInfo: null,
  68. configs: {
  69. width: 600,
  70. height: 350,
  71. maskWidth: 80,
  72. maskHeight: 80,
  73. maskColor: 'red',
  74. maskOpacity: 0.2
  75. }
  76. }
  77. },
  78. methods: {
  79. // 获取详情
  80. getDetail () {
  81. this.detailsData = null
  82. productDetail({ sn: this.itemId }).then(res => {
  83. if (res.status == 200) {
  84. this.detailsData = res.data
  85. } else {
  86. this.detailsData = null
  87. }
  88. })
  89. },
  90. // 返回
  91. goBack () {
  92. this.$router.push({ path: this.prevPageInfo && this.prevPageInfo.path })
  93. }
  94. },
  95. mounted () {
  96. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  97. this.itemId = this.$route.params.sn
  98. this.getDetail()
  99. }
  100. },
  101. activated () {
  102. this.itemId = this.$route.params.sn
  103. this.getDetail()
  104. },
  105. beforeRouteEnter (to, from, next) {
  106. next(vm => {
  107. vm.prevPageInfo = from
  108. })
  109. }
  110. }
  111. </script>
  112. <style lang="less">
  113. #_magnifier_layer{
  114. left: 500px!important;
  115. }
  116. /* For demo */
  117. .ant-carousel .slick-slide {
  118. text-align: center;
  119. overflow: hidden;
  120. display: flex;
  121. justify-content: center;
  122. align-items: center;
  123. }
  124. .ant-carousel .custom-slick-arrow {
  125. width: 25px;
  126. height: 25px;
  127. font-size: 25px;
  128. color: #fff;
  129. opacity: 0.3;
  130. }
  131. .ant-carousel .custom-slick-arrow:before {
  132. display: none;
  133. }
  134. .ant-carousel .custom-slick-arrow:hover {
  135. opacity: 0.5;
  136. }
  137. .ant-carousel .slick-slide img {
  138. width: 100%;
  139. max-height: 100%;
  140. }
  141. .ant-carousel{
  142. border: 1px solid #e8e8e8;
  143. }
  144. .ant-carousel .slick-dots {
  145. height: auto;
  146. }
  147. .ant-carousel .slick-slide img {
  148. border: 5px solid #fff;
  149. display: block;
  150. margin: auto;
  151. max-width: 90%;
  152. }
  153. .ant-carousel .slick-thumb {
  154. bottom: -40px;
  155. }
  156. .ant-carousel .slick-thumb li {
  157. width: 40px;
  158. height: 35px;
  159. }
  160. .ant-carousel .slick-thumb li img {
  161. width: 100%;
  162. height: 100%;
  163. filter: grayscale(100%);
  164. }
  165. .ant-carousel .slick-thumb li.slick-active img {
  166. filter: grayscale(0%);
  167. }
  168. .newProductDetail-back {
  169. margin-bottom: 10px;
  170. }
  171. .newProductDetail-modal {
  172. background-color: #fff;
  173. padding: 15px 15px 55px;
  174. h4 {
  175. font-size: 18px;
  176. }
  177. .productHead {
  178. display: flex;
  179. .productImg {
  180. width: 240px;
  181. }
  182. .productInfo {
  183. flex-grow: 1;
  184. margin-right: 10px;
  185. }
  186. .sycxImg {
  187. margin-top: 10px;
  188. p {
  189. font-size: 14px;
  190. padding: 5px 10px;
  191. background-color: #dcf1ff;
  192. }
  193. img {
  194. width: 100px;
  195. }
  196. }
  197. }
  198. .productDetail {
  199. border: 1px solid #eee;
  200. margin-top: 10px;
  201. h4 {
  202. font-size: 14px;
  203. padding: 5px 10px;
  204. background-color: #dcf1ff;
  205. }
  206. .productDesc {
  207. padding: 15px;
  208. }
  209. }
  210. .ant-descriptions-item-label.ant-descriptions-item-colon {
  211. width: 120px;
  212. }
  213. .btn-cont {
  214. text-align: center;
  215. margin: 35px 0 10px;
  216. }
  217. }
  218. </style>