goods-shop.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="goods-shop">
  3. <view class="title flex">
  4. <u-image width="100rpx" height="100rpx" border-radius="50%" :src="shop.logo"></u-image>
  5. <view class="flex-1 shop-name m-l-20 m-r-20">
  6. <view class="bold lg line-1">{{shop.name}}</view>
  7. <view class="xs m-t-10">在售商品 {{shop.goods_on_sale}}件</view>
  8. </view>
  9. <router-link class="flex-none" :to="{path: '/pages/store_index/store_index', query: {id: shop.id}}">
  10. <view class="primary btn br60 sm">进入店铺</view>
  11. </router-link>
  12. </view>
  13. <view v-if="list.length">
  14. <scroll-view style="white-space: nowrap;" scroll-x="true" scroll-with-animation="true"
  15. @scroll="scrollBarChange">
  16. <view class="goods">
  17. <goods-list type="row" :list="list"></goods-list>
  18. </view>
  19. </scroll-view>
  20. <view class="flex row-center progress" v-if="list.length > 3">
  21. <cu-progress :progress-bar-color="colorConfig.primary" :left="progressPer"></cu-progress>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { mapGetters } from 'vuex';
  28. import {
  29. getRect
  30. } from '@/utils/tools';
  31. export default {
  32. data() {
  33. return {
  34. progressPer: 0,
  35. list: []
  36. };
  37. },
  38. props: {
  39. shop: {
  40. type: Object,
  41. default: () => ({})
  42. }
  43. },
  44. computed: {
  45. ...mapGetters([
  46. 'appConfig',
  47. ])
  48. },
  49. watch: {
  50. shop: {
  51. handler: function(val) {
  52. this.list = val.goods_list || []
  53. this.$nextTick(() => {
  54. getRect(".goods-shop", false, this).then(res => {
  55. this.rectWidth = res.width;
  56. });
  57. })
  58. },
  59. immediate: true,
  60. deep: true
  61. }
  62. },
  63. methods: {
  64. scrollBarChange(e) {
  65. let {
  66. progressPer
  67. } = this;
  68. let {
  69. scrollLeft,
  70. scrollWidth
  71. } = e.detail;
  72. progressPer = scrollLeft / (scrollWidth - this.rectWidth) * 100;
  73. progressPer = Number(progressPer.toFixed(0))
  74. this.progressPer = progressPer
  75. }
  76. }
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .goods-shop {
  81. .title {
  82. padding: 20rpx;
  83. border-bottom: $-solid-border;
  84. .shop-name {
  85. width: 300rpx;
  86. }
  87. .btn {
  88. border: 1px solid $-color-primary;
  89. padding: 6rpx 28rpx;
  90. }
  91. }
  92. .progress {
  93. padding-bottom: 20rpx;
  94. }
  95. .goods {
  96. display: inline-block;
  97. padding: 20rpx;
  98. }
  99. }
  100. </style>