detail-tabbar.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <su-fixed bottom placeholder bg="bg-white">
  3. <view class="ui-tabbar-box">
  4. <view class="ui-tabbar ss-flex ss-col-center ss-row-between">
  5. <view
  6. v-if="collectIcon"
  7. class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
  8. @tap="onFavorite"
  9. >
  10. <block v-if="modelValue.favorite">
  11. <image
  12. class="item-icon"
  13. :src="sheep.$url.static('/static/img/shop/goods/collect_1.gif')"
  14. mode="aspectFit"
  15. ></image>
  16. <view class="item-title">已收藏</view>
  17. </block>
  18. <block v-else>
  19. <image
  20. class="item-icon"
  21. :src="sheep.$url.static('/static/img/shop/goods/collect_0.png')"
  22. mode="aspectFit"
  23. ></image>
  24. <view class="item-title">收藏</view>
  25. </block>
  26. </view>
  27. <view
  28. v-if="serviceIcon"
  29. class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
  30. @tap="onChat"
  31. >
  32. <image
  33. class="item-icon"
  34. :src="sheep.$url.static('/static/img/shop/goods/message.png')"
  35. mode="aspectFit"
  36. ></image>
  37. <view class="item-title">客服</view>
  38. </view>
  39. <view
  40. v-if="shareIcon"
  41. class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
  42. @tap="showShareModal"
  43. >
  44. <image
  45. class="item-icon"
  46. :src="sheep.$url.static('/static/img/shop/goods/share.png')"
  47. mode="aspectFit"
  48. ></image>
  49. <view class="item-title">分享</view>
  50. </view>
  51. <slot></slot>
  52. </view>
  53. </view>
  54. </su-fixed>
  55. </template>
  56. <script setup>
  57. /**
  58. *
  59. * 底部导航
  60. *
  61. * @property {String} bg - 背景颜色Class
  62. * @property {String} ui - 自定义样式Class
  63. * @property {Boolean} noFixed - 是否定位
  64. * @property {Boolean} topRadius - 上圆角
  65. *
  66. *
  67. */
  68. import { computed, reactive } from 'vue';
  69. import sheep from '@/sheep';
  70. import { showShareModal } from '@/sheep/hooks/useModal';
  71. // 数据
  72. const state = reactive({});
  73. // 接收参数
  74. const props = defineProps({
  75. modelValue: {
  76. type: Object,
  77. default() {},
  78. },
  79. bg: {
  80. type: String,
  81. default: 'bg-white',
  82. },
  83. bgStyles: {
  84. type: Object,
  85. default() {},
  86. },
  87. ui: {
  88. type: String,
  89. default: '',
  90. },
  91. noFixed: {
  92. type: Boolean,
  93. default: false,
  94. },
  95. topRadius: {
  96. type: Number,
  97. default: 0,
  98. },
  99. collectIcon: {
  100. type: Boolean,
  101. default: true,
  102. },
  103. serviceIcon: {
  104. type: Boolean,
  105. default: true,
  106. },
  107. shareIcon: {
  108. type: Boolean,
  109. default: true,
  110. },
  111. });
  112. const elStyles = computed(() => {
  113. return {
  114. 'border-top-left-radius': props.topRadius + 'rpx',
  115. 'border-top-right-radius': props.topRadius + 'rpx',
  116. overflow: 'hidden',
  117. };
  118. });
  119. const tabbarheight = (e) => {
  120. uni.setStorageSync('tabbar', e);
  121. };
  122. async function onFavorite() {
  123. const { error } = await sheep.$api.user.favorite.do(props.modelValue.id);
  124. if (error === 0) {
  125. if (props.modelValue.favorite) {
  126. props.modelValue.favorite = 0;
  127. } else {
  128. props.modelValue.favorite = 1;
  129. }
  130. }
  131. }
  132. const onChat = () => {
  133. sheep.$router.go('/pages/chat/index', {
  134. id: props.modelValue.id,
  135. });
  136. };
  137. </script>
  138. <style lang="scss" scoped>
  139. .ui-tabbar-box {
  140. box-shadow: 0px -6px 10px 0px rgba(51, 51, 51, 0.2);
  141. }
  142. .ui-tabbar {
  143. display: flex;
  144. height: 50px;
  145. background: #fff;
  146. .detail-tabbar-item {
  147. width: 100rpx;
  148. .item-icon {
  149. width: 40rpx;
  150. height: 40rpx;
  151. }
  152. .item-title {
  153. font-size: 20rpx;
  154. font-weight: 500;
  155. line-height: 20rpx;
  156. margin-top: 12rpx;
  157. }
  158. }
  159. }
  160. </style>