com-goods-detail.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template id="com-goods-detail">
  2. <!-- 商品详情 -->
  3. <el-dialog title="供应链商品详情" :visible.sync="show" width="600px" lock-scrol="false" :append-to-body="appendToBody" :before-close="closeDetail">
  4. <!-- 内容 -->
  5. <template>
  6. <!-- 骨架 -->
  7. <el-skeleton :loading="load" animated>
  8. <template slot="template">
  9. <div class="goods-img-body">
  10. <el-carousel indicator-position="outside">
  11. <el-carousel-item>
  12. <el-skeleton-item variant="image" style="height: 300px; width: 560px" />
  13. </el-carousel-item>
  14. </el-carousel>
  15. </div>
  16. <el-card class="goods-name-body">
  17. <!-- 名称 -->
  18. <el-skeleton-item variant="h1" style="width: 20%;" />
  19. <div class="goods-price">
  20. <li v-for="item in prices">
  21. <el-skeleton-item variant="text" style="width: 80%;" />
  22. </li>
  23. </div>
  24. </el-card>
  25. <!-- 规格 -->
  26. <el-card class="goods-sku-body">
  27. <el-skeleton-item variant="h3" style="width: 20%;" />
  28. <div class="goods-price">
  29. <li v-for="item in prices">
  30. <el-skeleton-item variant="text" style="width: 80%;" />
  31. </li>
  32. </div>
  33. </el-card>
  34. <!-- 详情 -->
  35. <el-card class="goods-desc-body">
  36. <el-skeleton-item />
  37. </el-card>
  38. </template>
  39. </el-skeleton>
  40. <!-- 真实内容 -->
  41. <div class="goods-body" v-show="!load">
  42. <!-- 图 -->
  43. <div class="goods-img-body">
  44. <el-carousel indicator-position="outside">
  45. <el-carousel-item v-for="(item, index) in detail.gallery" :key="index">
  46. <el-image style="height: 300px; width: 560px" :src="item.src" fit="contain"></el-image>
  47. </el-carousel-item>
  48. </el-carousel>
  49. </div>
  50. <!-- 名称 -->
  51. <el-card class="goods-name-body">
  52. <!-- 名称 -->
  53. <div class="goods-name">
  54. <span>{{ detail.title }}</span>
  55. <span class="goods-staus">
  56. <span v-if="detail.is_display">上架</span>
  57. <span v-if="!detail.is_display">下架</span>
  58. </span>
  59. </div>
  60. <!-- 价格 -->
  61. <div class="goods-price">
  62. <li v-for="item in prices">
  63. <span class="price-name">{{ item.name }}</span>
  64. <span class="price">{{ detail[item.index]|addZero }}</span>
  65. </li>
  66. </div>
  67. </el-card>
  68. <!-- 规格 -->
  69. <el-card class="goods-sku-body">
  70. <div v-for="sku in detail.skus">
  71. <!-- 规格 -->
  72. <div class="goods-spec">
  73. <li v-for="spec in sku.options">
  74. <span class="goods-spec-name">{{ spec.spec_name }}</span>
  75. <span class="goods-spec-value">{{ spec.spec_item_name }}</span>
  76. </li>
  77. </div>
  78. <!-- 价格 -->
  79. <div class="goods-price">
  80. <li v-for="item in prices">
  81. <span class="price-name">{{ item.name }}</span>
  82. <span class="price">{{ sku[item.index]|addZero }}</span>
  83. </li>
  84. </div>
  85. </div>
  86. </el-card>
  87. <!-- 详情 -->
  88. <el-card class="goods-desc-body" v-if="detail.detail_images">
  89. <div v-html="detail.detail_images"></div>
  90. </el-card>
  91. </div>
  92. </template>
  93. <!-- 页脚 -->
  94. <span slot="footer" class="dialog-footer">
  95. <el-button type="primary" @click="closeDetail">确 定</el-button>
  96. </span>
  97. </el-dialog>
  98. </template>
  99. <script>
  100. Vue.component('com-goods-detail', {
  101. template: '#com-goods-detail',
  102. filters: {
  103. addZero: function(data) {
  104. return data == undefined
  105. ? '未定义'
  106. : Math.round((data / 100) * 100) / 100 + '元';
  107. },
  108. },
  109. props: {
  110. goodsId: {
  111. type: Number,
  112. default: 0,
  113. },
  114. },
  115. watch: {
  116. goodsId: {
  117. handler(val) {
  118. val && this.getDetail(val)
  119. }
  120. }
  121. },
  122. data() {
  123. return {
  124. id: 0,
  125. appendToBody: true,
  126. detail: {},
  127. show: false,
  128. load: true,
  129. prices: [
  130. {
  131. 'name': '指导价',
  132. 'index': 'guide_price',
  133. },
  134. {
  135. 'name': '协议价',
  136. 'index': 'agreement_price',
  137. },
  138. {
  139. 'name': '营销价',
  140. 'index': 'activity_price',
  141. },
  142. {
  143. 'name': '成本价',
  144. 'index': 'cost_price',
  145. },
  146. ],
  147. };
  148. },
  149. methods: {
  150. getDetail(id) {
  151. let self = this;
  152. request({
  153. method: 'post',
  154. data: {
  155. id: id,
  156. },
  157. params: {
  158. r: 'qi-juhe/storage/goods-detail',
  159. },
  160. }).then(e => {
  161. if (e.data.code === 0) {
  162. self.show = true
  163. self.load = false
  164. self.detail = e.data.data
  165. } else {
  166. this.$message.error(e.data.msg);
  167. }
  168. }).catch(e => {
  169. this.$message.error(e.data.msg);
  170. });
  171. },
  172. // 关闭弹窗
  173. closeDetail() {
  174. this.show = false
  175. this.load = true
  176. },
  177. },
  178. });
  179. </script>
  180. <style>
  181. .goods-name {
  182. font-size: 18px;
  183. font-weight: 900;
  184. display: flex;
  185. align-items: center;
  186. justify-content: space-between;
  187. }
  188. .goods-desc-body,
  189. .goods-sku-body,
  190. .goods-name-body {
  191. margin: 10px;
  192. /* background: #fff; */
  193. /* border-radius: 5px; */
  194. /* padding: 10px; */
  195. }
  196. .shadow-border {
  197. box-shadow: 0px -5px 10px 0px #f0f0f0,
  198. -6px 0px 6px 0px #f0f0f0,
  199. 6px 0px 6px 0px #f0f0f0,
  200. 0px 5px 19px 0px #f0f0f0;
  201. }
  202. .goods-price li {
  203. list-style: none;
  204. margin-left: 15px;
  205. }
  206. .price-name::after,
  207. .goods-spec-name::after {
  208. content: ":";
  209. }
  210. .goods-price {
  211. text-align: left;
  212. padding: 10px 10px 0 10px;
  213. font-weight: 100;
  214. display: flex;
  215. }
  216. .goods-spec li {
  217. list-style: none;
  218. }
  219. .goods-desc-body img {
  220. max-width: 540px;
  221. }
  222. .goods-body {
  223. height: 600px;
  224. overflow-y: scroll;
  225. scroll-behavior: auto;
  226. }
  227. /* .goods-body::-webkit-scrollbar {
  228. width:10px;
  229. height:10px;
  230. }
  231. .goods-body::-webkit-scrollbar-thumb {
  232. border-radius:10px;
  233. -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
  234. background:#535353;
  235. }
  236. .goods-body::-webkit-scrollbar-track {
  237. -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
  238. border-radius:10px;
  239. background:#EDEDED;
  240. } */
  241. .goods-img-images {
  242. width: 540px;
  243. }
  244. </style>