com-goods-detail.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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 in detail.img">
  46. <el-image style="height: 300px; width: 560px" :src="item.image_url" 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.goods.goods_name }}</span>
  55. <span class="goods-staus">
  56. <span v-if="detail.goods.if_sale == 1">上架</span>
  57. <span v-else>下架</span>
  58. </span>
  59. </div>
  60. </el-card>
  61. <!-- 规格 -->
  62. <el-card class="goods-sku-body">
  63. <div v-for="sku in detail.goods.spec">
  64. <!-- 规格 -->
  65. <div class="goods-spec">
  66. <span class="goods-spec-name">规格</span>
  67. <span class="goods-spec-value">{{ sku.spec_1 }}</span>
  68. </div>
  69. <!-- 价格 -->
  70. <div class="goods-price">
  71. <li v-for="item in prices">
  72. <span class="price-name">{{ item.name }}</span>
  73. <span class="price">{{ sku[item.index]|addZero(detail.rate) }}</span>
  74. </li>
  75. </div>
  76. </div>
  77. </el-card>
  78. <!-- 详情 -->
  79. <el-card class="goods-desc-body">
  80. <div v-html="detail.goods.description"></div>
  81. </el-card>
  82. </div>
  83. </template>
  84. <!-- 页脚 -->
  85. <span slot="footer" class="dialog-footer">
  86. <el-button type="primary" @click="closeDetail">确 定</el-button>
  87. </span>
  88. </el-dialog>
  89. </template>
  90. <script>
  91. Vue.component('com-goods-detail', {
  92. template: '#com-goods-detail',
  93. filters: {
  94. addZero: function(data, rate) {
  95. return data == undefined
  96. ? '未定义'
  97. : (Math.floor(data * rate * 100) * 0.01).toFixed(2) + '元';
  98. },
  99. },
  100. props: {
  101. goodsId: {
  102. type: Number,
  103. default: 0,
  104. },
  105. },
  106. watch: {
  107. goodsId: {
  108. handler(val) {
  109. this.getDetail(val)
  110. }
  111. }
  112. },
  113. data() {
  114. return {
  115. id: 0,
  116. appendToBody: true,
  117. detail: {
  118. goods: {},
  119. images: [],
  120. specs: [],
  121. specs_list: {},
  122. specs_list_v1: {},
  123. specs_name: {},
  124. specs_name_v1: {},
  125. rate: 1,
  126. },
  127. show: false,
  128. load: true,
  129. prices: [
  130. {
  131. 'name': '供货价',
  132. 'index': 'gonghuojia',
  133. },
  134. {
  135. 'name': '建议零售价',
  136. 'index': 'retail_price',
  137. },
  138. {
  139. 'name': '商品价格',
  140. 'index': 'price',
  141. },
  142. ],
  143. };
  144. },
  145. methods: {
  146. getDetail(id) {
  147. let self = this;
  148. self.show = true
  149. request({
  150. method: 'get',
  151. params: {
  152. r: 'qi-shang-tong/goods/detail',
  153. id: id,
  154. },
  155. }).then(e => {
  156. if (e.data.code === 0) {
  157. self.load = false
  158. self.detail = e.data.data
  159. } else {
  160. this.$message.error(e.data.msg);
  161. }
  162. }).catch(e => {
  163. this.$message.error(e.data.msg);
  164. });
  165. },
  166. // 关闭弹窗
  167. closeDetail() {
  168. this.show = false
  169. this.load = true
  170. },
  171. },
  172. });
  173. </script>
  174. <style>
  175. .goods-name {
  176. font-size: 18px;
  177. font-weight: 900;
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. }
  182. .goods-desc-body,
  183. .goods-sku-body,
  184. .goods-name-body {
  185. margin: 10px;
  186. /* background: #fff; */
  187. /* border-radius: 5px; */
  188. /* padding: 10px; */
  189. }
  190. .shadow-border {
  191. box-shadow: 0px -5px 10px 0px #f0f0f0,
  192. -6px 0px 6px 0px #f0f0f0,
  193. 6px 0px 6px 0px #f0f0f0,
  194. 0px 5px 19px 0px #f0f0f0;
  195. }
  196. .goods-price li {
  197. list-style: none;
  198. margin-left: 15px;
  199. }
  200. .price-name::after,
  201. .goods-spec-name::after {
  202. content: ":";
  203. }
  204. .goods-price {
  205. text-align: left;
  206. padding: 10px 10px 0 10px;
  207. font-weight: 100;
  208. display: flex;
  209. }
  210. .goods-spec li {
  211. list-style: none;
  212. }
  213. .goods-desc-body img {
  214. /*max-width: 540px;*/
  215. width: 100%;
  216. }
  217. .goods-body {
  218. height: 600px;
  219. overflow-y: scroll;
  220. scroll-behavior: auto;
  221. }
  222. /* .goods-body::-webkit-scrollbar {
  223. width:10px;
  224. height:10px;
  225. }
  226. .goods-body::-webkit-scrollbar-thumb {
  227. border-radius:10px;
  228. -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
  229. background:#535353;
  230. }
  231. .goods-body::-webkit-scrollbar-track {
  232. -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
  233. border-radius:10px;
  234. background:#EDEDED;
  235. } */
  236. .goods-img-images {
  237. width: 540px;
  238. }
  239. </style>