detail-tabbar.vue 3.7 KB

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