goodsDetail.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="">
  3. <view class="goods-scroll"><u-swiper :list="list" :height="340" indicator-pos="bottomRight" mode="number"></u-swiper></view>
  4. <view class="goods-info info-view">
  5. <view class="goods-name">{{ goods_detail.title||'' }}</view>
  6. <view class="goods-desc">{{ goods_detail.describe||'' }}</view>
  7. <view class="goods-code clearfix">
  8. <view class="float_left">
  9. <text class="info-label">商品编码</text>
  10. {{ goods_detail.code||'' }}
  11. </view>
  12. <view class="float_right" v-if="goods_detail.storage">
  13. <text class="info-label">货架编码</text>
  14. {{ goods_detail.storage || '未设置' }}
  15. </view>
  16. </view>
  17. </view>
  18. <view class="goods-info-other info-view">
  19. <view class="info-li">
  20. <view class="info-label">商品分类</view>
  21. <view class="info-val">{{ goods_detail.categoryTitle||'' }}</view>
  22. </view>
  23. <view class="info-li">
  24. <view class="info-label">商品品牌</view>
  25. <view class="info-val">{{ goods_detail.brandTitle || '未设置'}}</view>
  26. </view>
  27. <view class="info-li">
  28. <view class="info-label">保质期/天</view>
  29. <view class="info-val">{{ goods_detail.expireTime || '未设置' }}</view>
  30. </view>
  31. <view class="info-li">
  32. <view class="info-label">商品状态</view>
  33. <view class="info-val">{{ goods_detail.enableStatus === 5 ? '启用' : '禁用' }}</view>
  34. </view>
  35. </view>
  36. <view class="info-view tag-view" >
  37. <text class="info-label">关键词</text>
  38. <u-tag v-for="(item,index) in tag_list" :key="index" class="tag-li" mode="plain" :text="item" />
  39. <text v-if="!tag_list.length" class="input-pl">未设置</text>
  40. </view>
  41. <view class="info-view tag-view">
  42. <view class="unit-master">
  43. <text class="info-label">基本单位</text>
  44. <text>{{ master_unit.unitName||'' }}</text>
  45. </view>
  46. <view>
  47. <text class="info-label">辅助单位</text>
  48. <block v-for="(item, index) in other_unit_data" :key="index">
  49. <u-tag v-if="item.isMaster !== 5" class="tag-li" mode="plain" :text="'1' + item.unitName + '='+ Number(item.conversion) + master_unit.unitName" />
  50. </block>
  51. <text v-if="!other_unit_data.length" class="input-pl">未设置</text>
  52. </view>
  53. </view>
  54. <view class="sku-detail" v-if="goods_detail.specType === 1">
  55. <view class="info-title">规格明细</view>
  56. <view class="info-view uni-sku-view" v-for="(item, index) in goods_detail.unitData" :key="index">
  57. <view class="sku-label">{{ item.unitName }}</view>
  58. <view class="sku-info-ul">
  59. <view class="sku-info-li">
  60. <view class="sku-info-name">商品条码</view>
  61. <view class="sku-info-val">{{ item.barCode|| '未设置' }}</view>
  62. </view>
  63. <view class="sku-info-li">
  64. <view class="sku-info-name">商品重量</view>
  65. <view class="sku-info-val">{{ (item.weight||0) / 1000 }}kg</view>
  66. </view>
  67. <view class="sku-info-li">
  68. <view class="sku-info-name">默认属性</view>
  69. <view class="sku-info-val">{{ item.isDefault === 5 ? '是' : '否' }}</view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="sku-detail" v-if="goods_detail.specType === 2">
  75. <view class="info-title">规格明细</view>
  76. <view class="info-view" v-for="(item, index) in goods_detail.specMultiple">
  77. <view class="sku-label">
  78. <image :src="item.specImage || list[0].image" mode="aspectFill"></image>
  79. <text class="sku-name">
  80. <block v-for="(its, ins) in item.specGroup" :key="ins">{{ its.specValueName }};</block>
  81. </text>
  82. </view>
  83. <view class="clearfix sku-info-ul">
  84. <text class="info-label">商品条码</text>
  85. <view class="info-val">
  86. <view class="val-li" v-for="(itu, inu) in goods_detail.unitData" :key="inu">{{ itu.unitName }}:{{ item.barCode[itu.unitId] || '未设置' }}</view>
  87. </view>
  88. </view>
  89. <view class="clearfix sku-info-ul">
  90. <text class="info-label">商品重量</text>
  91. <view class="info-val">
  92. <view class="val-li" v-for="(itu, inu) in goods_detail.unitData" :key="inu">{{ itu.unitName }}:{{ item.weight[itu.unitId] || '未设置' }}</view>
  93. </view>
  94. </view>
  95. <view class="clearfix sku-info-ul">
  96. <text class="info-label">默认属性</text>
  97. <view class="info-val">
  98. <view class="val-li" v-for="(itu, inu) in goods_detail.unitData" :key="inu">{{ itu.unitName }}:{{ item.isDefault[itu.unitId] === 5 ? '是' : '否' }}</view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="sku-detail">
  104. <view class="info-title">商品详情</view>
  105. <view class="detail-view"><rich-text :nodes="goods_detail.description"></rich-text></view>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. export default {
  111. data() {
  112. return {
  113. list: [],
  114. goods_id: '',
  115. goods_detail: {},
  116. master_unit: {},
  117. other_unit_data: [],
  118. tag_list:[]
  119. };
  120. },
  121. onLoad(options) {
  122. if(options.id){
  123. this.goods_id = options.id;
  124. this.getGoodsBasicInfoById();
  125. }
  126. },
  127. methods: {
  128. getGoodsBasicInfoById() {
  129. this.$u.api.getGoodsBasicInfoById(this.goods_id).then(res => {
  130. this.goods_detail = res.data;
  131. this.list = res.data.images.map(item => {
  132. return {
  133. image: item
  134. };
  135. });
  136. this.tag_list=res.data.tag?res.data.tag.split(','):[]
  137. this.master_unit = res.data.unitData.find(item => item.isMaster === 5);
  138. this.other_unit_data = res.data.unitData.filter(item => item.isMaster === 4);
  139. });
  140. }
  141. }
  142. };
  143. </script>
  144. <style scoped lang="scss">
  145. .goods-scroll {
  146. width: 702rpx;
  147. margin: 0 auto 20rpx;
  148. }
  149. .info-view {
  150. background-color: #ffffff;
  151. width: 702rpx;
  152. margin: 0 auto;
  153. border-radius: 10rpx;
  154. margin-bottom: 20rpx;
  155. padding: 20rpx;
  156. .info-label {
  157. font-size: 24rpx;
  158. color: #999999;
  159. }
  160. }
  161. .goods-info {
  162. font-size: 24rpx;
  163. .goods-name {
  164. font-size: 28rpx;
  165. font-weight: 700;
  166. }
  167. .goods-desc {
  168. padding: 10rpx 0;
  169. color: #999999;
  170. }
  171. .goods-code {
  172. .info-label {
  173. margin-right: 10rpx;
  174. }
  175. }
  176. }
  177. .goods-info-other {
  178. display: flex;
  179. .info-li {
  180. flex: 4;
  181. font-size: 26rpx;
  182. text-align: center;
  183. border-right: 1px solid #f5f5f5;
  184. .info-label {
  185. padding-bottom: 20rpx;
  186. }
  187. &:last-child {
  188. border-right: 0 none;
  189. }
  190. }
  191. }
  192. .tag-view {
  193. .info-label {
  194. margin-right: 20rpx;
  195. }
  196. .tag-li {
  197. margin-right: 10rpx;
  198. }
  199. }
  200. .unit-master {
  201. padding-bottom: 20rpx;
  202. }
  203. .sku-detail {
  204. .info-title {
  205. text-align: center;
  206. line-height: 90rpx;
  207. font-size: 24rpx;
  208. color: #666666;
  209. }
  210. .sku-label {
  211. image {
  212. width: 120rpx;
  213. height: 120rpx;
  214. border-radius: 8rpx;
  215. vertical-align: middle;
  216. margin-right: 30rpx;
  217. }
  218. }
  219. .sku-info-ul {
  220. position: relative;
  221. padding: 20rpx 0;
  222. padding-left: 120rpx;
  223. border-bottom: 1px solid #f5f5f5;
  224. line-height: 40rpx;
  225. &:last-child {
  226. border-bottom: 0;
  227. }
  228. .info-label {
  229. position: absolute;
  230. left: 0;
  231. top: 50%;
  232. font-size: 24rpx;
  233. transform: translateY(-50%);
  234. }
  235. .info-val {
  236. border-left: 1px solid #f5f5f5;
  237. padding-left: 30rpx;
  238. font-size: 28rpx;
  239. }
  240. }
  241. .uni-sku-view {
  242. .sku-label {
  243. padding-bottom: 20rpx;
  244. position: relative;
  245. text-align: center;
  246. &::before {
  247. display: block;
  248. content: '';
  249. width: 50rpx;
  250. height: 6rpx;
  251. background-color: $uni-color-primary;
  252. bottom: 10rpx;
  253. position: absolute;
  254. left: 50%;
  255. transform: translateX(-50%);
  256. }
  257. }
  258. .sku-info-ul {
  259. display: flex;
  260. padding-left: 0;
  261. .sku-info-li {
  262. flex: 3;
  263. text-align: center;
  264. border-right: 1px solid #f5f5f5;
  265. .sku-info-name {
  266. color: #999999;
  267. padding-bottom: 10rpx;
  268. font-size: 24rpx;
  269. }
  270. &:last-child {
  271. border-right: 0;
  272. }
  273. }
  274. }
  275. }
  276. }
  277. .detail-view {
  278. background-color: #ffffff;
  279. padding: 20rpx;
  280. img{
  281. width: 100%;
  282. }
  283. }
  284. </style>