BrandGoodsList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="shop-car-container">
  3. <scroll-view
  4. refresher-enabled refresher-background="#3f3d3d" scroll-y style="height: 100%;"
  5. scroll-with-animation
  6. >
  7. <!-- <view class="shop-list">
  8. <view class="shop-car-list">
  9. <view class="shop-goods-list">
  10. <view v-if="brandDetail.goodsVoList && brandDetail.goodsVoList.length">
  11. <view v-for="(item, index) in brandDetail.goodsVoList" :key="item.id" class="goods-item">
  12. <JAvatar radius="10" :size="120" :src="common.seamingImgUrl(item.picUrl)"></JAvatar>
  13. <view class="goods-pane-right">
  14. <view class="goods-pane-name">{{ item.name.trim() }} </view>
  15. <view class="goods-pane-desc-content">
  16. <text class="goods-pane-desc">
  17. 商品编号:{{ item.goodsSn }}
  18. </text>
  19. </view>
  20. <view class="goods-pane-footer">
  21. <text class="goods-pane-price">¥{{ item.retailPrice }}</text>
  22. <view class="ops">
  23. <tui-button type="warning" width="120rpx" height="50rpx" shape="circle" @click="handleChooseGoods(item)">选择</tui-button>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view v-else>
  30. <tui-no-data>暂无数据</tui-no-data>
  31. </view>
  32. </view>
  33. </view>
  34. </view> -->
  35. <view class="store-goods-list-container">
  36. <view
  37. v-if="brandDetail.categoryList && brandDetail.categoryList.length"
  38. style="display: flex;box-sizing: border-box;"
  39. >
  40. <view style="background-color: #f3f3f3;">
  41. <view
  42. v-for="item in brandDetail.categoryList" :key="item.serverNameOne"
  43. style="max-width: 144upx;padding: 20upx 28upx;word-break: break-all;box-sizing: border-box;"
  44. :style="{ backgroundColor: item.id === currentTab ? '#ffffff' : 'transparent' }"
  45. @click="(currentTab = item.id) && (currentGoods = brandDetail.categoryList.find(part => part.id === item.id).goodsList || [])"
  46. >
  47. {{ item.name }}
  48. </view>
  49. </view>
  50. <view style="flex: 1;padding: 20upx;">
  51. <view v-if="currentGoods && currentGoods.length">
  52. <view v-for="item in currentGoods" :key="item.id">
  53. <StoreGoods :goods-data="item" :show-icon="false" :show-tag="false" :show-msg="false" show-sn>
  54. <template #button>
  55. <tui-button
  56. v-if="showSelectBtn" type="warning" width="120rpx" height="50rpx"
  57. shape="circle"
  58. @click="handleChooseGoods(item)"
  59. >
  60. 选择
  61. </tui-button>
  62. <slot name="button" :data="item"></slot>
  63. </template>
  64. </StoreGoods>
  65. </view>
  66. </view>
  67. <view v-else style="margin: 40upx 0;text-align: center;">
  68. 暂无商品~
  69. </view>
  70. </view>
  71. </view>
  72. <view v-else class="no-data">
  73. 暂无数据
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </template>
  79. <script>
  80. // import {
  81. // getBrandDetailApi
  82. // } from '../../api/brand'
  83. export default {
  84. name: 'BrandGoodsList',
  85. components: {},
  86. props: {
  87. showSelectBtn: {
  88. type: Boolean,
  89. default: true
  90. },
  91. brandId: {
  92. type: [String, Number],
  93. required: true
  94. }
  95. },
  96. data() {
  97. return {
  98. currentTab: '',
  99. currentGoods: [],
  100. brandDetail: {}
  101. }
  102. },
  103. computed: {},
  104. watch: {
  105. brandDetail: {
  106. handler(newVal) {
  107. if (newVal) {
  108. if (this.brandDetail.categoryList && this.brandDetail.categoryList.length) {
  109. (this.currentTab = this.brandDetail.categoryList[0].id) && (this.currentGoods = this.brandDetail.categoryList[0].goodsList || [])
  110. }
  111. }
  112. },
  113. immediate: true,
  114. deep: true
  115. }
  116. },
  117. created() {
  118. this.getGoodsList()
  119. },
  120. methods: {
  121. // 获取商品列表
  122. async getGoodsList() {
  123. if (!this.brandId) return
  124. uni.showLoading({
  125. title: '加载中'
  126. })
  127. const { data } = await getBrandDetailApi({
  128. id: this.brandId,
  129. longitude: this.$store.state.location.locationInfo.streetNumber.location.split(',')[0],
  130. latitude: this.$store.state.location.locationInfo.streetNumber.location.split(',')[1]
  131. })
  132. this.brandDetail = data || {}
  133. uni.hideLoading()
  134. },
  135. // 选择
  136. handleChooseGoods(goods) {
  137. // this.$emit('send', { goodsId: goods.id, goodsName: goods.name || '' })
  138. this.$emit('send', goods)
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="less" scoped>
  144. .shop-car-container {
  145. height: 100%;
  146. padding: 32upx 10upx;
  147. box-sizing: border-box;
  148. // .shop-list {
  149. // // height: 100%;
  150. // // overflow-y: auto;
  151. // .shop-car-list {
  152. // margin-bottom: 20px;
  153. // }
  154. // .goods-item {
  155. // .flex();
  156. // box-sizing: border-box;
  157. // margin-top: 30upx;
  158. // .goods-pane-right {
  159. // width: 100%;
  160. // margin-left: 30upx;
  161. // font-size: @f12;
  162. // color: @c0;
  163. // .goods-pane-name {
  164. // width: 404upx;
  165. // white-space: nowrap;
  166. // text-overflow: ellipsis;
  167. // overflow: hidden;
  168. // }
  169. // .goods-pane-desc-content {
  170. // margin: 14upx 0 10upx 0;
  171. // }
  172. // .goods-pane-desc {
  173. // font-size: 20upx;
  174. // margin-right: 10upx;
  175. // }
  176. // .goods-pane-footer {
  177. // .flex();
  178. // .goods-pane-price {
  179. // color: #fa5151;
  180. // font-size: 28upx;
  181. // }
  182. // .ops {
  183. // margin-right: 40rpx;
  184. // background-color: #f5f5f5;
  185. // }
  186. // }
  187. // }
  188. // }
  189. // .no-data {
  190. // .flex(center, center);
  191. // min-height: 180upx;
  192. // color: #999999;
  193. // font-size: 36upx;
  194. // letter-spacing: 2px;
  195. // }
  196. // }
  197. .store-goods-list-container {
  198. width: 100%;
  199. font-size: 32upx;
  200. .no-data {
  201. display: flex;
  202. align-items: center;
  203. justify-content: center;
  204. min-height: 200upx;
  205. color: #ccc;
  206. padding: 20upx 0;
  207. flex-direction: column;
  208. }
  209. }
  210. }
  211. </style>