detail-tabbar.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!-- 商品详情的底部导航 -->
  2. <template>
  3. <su-fixed bottom placeholder bg="bg-white">
  4. <view class="ui-tabbar-box">
  5. <view class="ui-tabbar ss-flex ss-col-center ss-row-between">
  6. <view v-if="serviceIcon" class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
  7. @tap="onIndex">
  8. <image class="item-icon" src="@/static/icon/index.png"
  9. mode="aspectFit" />
  10. <view class="item-title">{{$t('common.home')}}</view>
  11. </view>
  12. <view v-if="serviceIcon" class="detail-tabbar-item ss-flex ss-flex-col ss-row-center ss-col-center"
  13. @tap="onShopIndex">
  14. <image class="item-icon" src="@/static/icon/shop.png"
  15. mode="aspectFit" />
  16. <view class="item-title">{{$t('title.shop_home')}}</view>
  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="@/static/icon/service.png"
  21. mode="aspectFit" />
  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="sheep.$router.go('/pages/index/cart');">
  26. <image class="item-icon" src="@/static/icon/cart.png"
  27. mode="aspectFit" />
  28. <view class="item-title">{{$t('common.cart')}}</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. import {
  46. reactive
  47. } from 'vue';
  48. import sheep from '@/sheep';
  49. import {
  50. showShareModal
  51. } from '@/sheep/hooks/useModal';
  52. import FavoriteApi from '@/sheep/api/product/favorite';
  53. // 数据
  54. const state = reactive({});
  55. // 接收参数
  56. const props = defineProps({
  57. modelValue: {
  58. type: Object,
  59. default () {},
  60. },
  61. bg: {
  62. type: String,
  63. default: 'bg-white',
  64. },
  65. bgStyles: {
  66. type: Object,
  67. default () {},
  68. },
  69. ui: {
  70. type: String,
  71. default: '',
  72. },
  73. noFixed: {
  74. type: Boolean,
  75. default: false,
  76. },
  77. topRadius: {
  78. type: Number,
  79. default: 0,
  80. },
  81. collectIcon: {
  82. type: Boolean,
  83. default: true,
  84. },
  85. serviceIcon: {
  86. type: Boolean,
  87. default: true,
  88. },
  89. shareIcon: {
  90. type: Boolean,
  91. default: true,
  92. }
  93. });
  94. // async function onFavorite() {
  95. // // 情况一:取消收藏
  96. // if (props.modelValue.favorite) {
  97. // const {
  98. // code
  99. // } = await FavoriteApi.deleteFavorite(props.modelValue.id);
  100. // if (code !== 0) {
  101. // return
  102. // }
  103. // sheep.$helper.toast('取消收藏');
  104. // props.modelValue.favorite = false;
  105. // // 情况二:添加收藏
  106. // } else {
  107. // const {
  108. // code
  109. // } = await FavoriteApi.createFavorite(props.modelValue.id);
  110. // if (code !== 0) {
  111. // return
  112. // }
  113. // sheep.$helper.toast('收藏成功');
  114. // props.modelValue.favorite = true;
  115. // }
  116. // }
  117. const onShopIndex = () => {
  118. sheep.$router.go('/pages/shop/index', {
  119. shopId: props.modelValue.shopId,
  120. shopName: props.modelValue.shopName,
  121. merchantId: props.modelValue.merchantId,
  122. });
  123. };
  124. const onChat = () => {
  125. sheep.$router.go('/pages/chat/index', {
  126. id: props.modelValue.id,
  127. });
  128. };
  129. const onIndex = () => {
  130. sheep.$router.go('/pages/index/index');
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .ui-tabbar-box {
  135. box-shadow: 0px -6px 10px 0px rgba(51, 51, 51, 0.2);
  136. }
  137. .ui-tabbar {
  138. display: flex;
  139. height: 50px;
  140. background: #fff;
  141. .detail-tabbar-item {
  142. width: 100rpx;
  143. .item-icon {
  144. width: 40rpx;
  145. height: 40rpx;
  146. }
  147. .item-title {
  148. font-size: 20rpx;
  149. font-weight: 500;
  150. line-height: 20rpx;
  151. margin-top: 12rpx;
  152. }
  153. }
  154. }
  155. </style>