com-goods-detail.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.images">
  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.on_off_status == 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.specs">
  64. <!-- 规格 -->
  65. <div class="goods-spec">
  66. <span class="goods-spec-name">规格</span>
  67. <span class="goods-spec-value">{{ sku.spec_name }}</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. // console.log(`addZero ${data} -- ${rate}`, parseFloat((data * rate) * 0.01).toFixed(2) + '元')
  96. return data == undefined
  97. ? '未定义'
  98. : (Math.floor(data * rate) * 0.01).toFixed(2) + '元';
  99. },
  100. },
  101. props: {
  102. goodsId: {
  103. type: Number,
  104. default: 0,
  105. },
  106. },
  107. watch: {
  108. goodsId: {
  109. handler(val) {
  110. this.getDetail(val)
  111. }
  112. }
  113. },
  114. data() {
  115. return {
  116. id: 0,
  117. appendToBody: true,
  118. detail: {
  119. goods: {},
  120. images: [],
  121. specs: [],
  122. specs_list: {},
  123. specs_list_v1: {},
  124. specs_name: {},
  125. specs_name_v1: {},
  126. rate: 1
  127. },
  128. show: false,
  129. load: true,
  130. prices: [
  131. {
  132. 'name': '供货价',
  133. 'index': 'price',
  134. },
  135. {
  136. 'name': '建议零售价',
  137. 'index': 'retail_price',
  138. },
  139. {
  140. 'name': '最低售价',
  141. 'index': 'lowest_price',
  142. },
  143. ],
  144. };
  145. },
  146. methods: {
  147. getDetail(id) {
  148. let self = this;
  149. self.show = true
  150. request({
  151. method: 'get',
  152. params: {
  153. r: 'qi-ding-dong/goods/detail',
  154. id: id,
  155. },
  156. }).then(e => {
  157. if (e.data.code === 0) {
  158. self.load = false
  159. self.detail = e.data.data
  160. } else {
  161. this.$message.error(e.data.msg);
  162. }
  163. }).catch(e => {
  164. this.$message.error(e.data.msg);
  165. });
  166. },
  167. // 关闭弹窗
  168. closeDetail() {
  169. this.show = false
  170. this.load = true
  171. },
  172. },
  173. });
  174. </script>
  175. <style>
  176. .goods-name {
  177. font-size: 18px;
  178. font-weight: 900;
  179. display: flex;
  180. align-items: center;
  181. justify-content: space-between;
  182. }
  183. .goods-desc-body,
  184. .goods-sku-body,
  185. .goods-name-body {
  186. margin: 10px;
  187. /* background: #fff; */
  188. /* border-radius: 5px; */
  189. /* padding: 10px; */
  190. }
  191. .shadow-border {
  192. box-shadow: 0px -5px 10px 0px #f0f0f0,
  193. -6px 0px 6px 0px #f0f0f0,
  194. 6px 0px 6px 0px #f0f0f0,
  195. 0px 5px 19px 0px #f0f0f0;
  196. }
  197. .goods-price li {
  198. list-style: none;
  199. margin-left: 15px;
  200. }
  201. .price-name::after,
  202. .goods-spec-name::after {
  203. content: ":";
  204. }
  205. .goods-price {
  206. text-align: left;
  207. padding: 10px 10px 0 10px;
  208. font-weight: 100;
  209. display: flex;
  210. }
  211. .goods-spec li {
  212. list-style: none;
  213. }
  214. .goods-desc-body img {
  215. /*max-width: 540px;*/
  216. width: 100%;
  217. }
  218. .goods-body {
  219. height: 600px;
  220. overflow-y: scroll;
  221. scroll-behavior: auto;
  222. }
  223. /* .goods-body::-webkit-scrollbar {
  224. width:10px;
  225. height:10px;
  226. }
  227. .goods-body::-webkit-scrollbar-thumb {
  228. border-radius:10px;
  229. -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
  230. background:#535353;
  231. }
  232. .goods-body::-webkit-scrollbar-track {
  233. -webkit-box-shadow:inset 0 0 5px rgba(0,0,0,0.2);
  234. border-radius:10px;
  235. background:#EDEDED;
  236. } */
  237. .goods-img-images {
  238. width: 540px;
  239. }
  240. </style>