productBottom.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="page-bottom" v-if="is_gold == 0 && is_integral == 0">
  3. <view class="p-b-btn" :class="{ active: goodsObjact.userCollect }" @click="toFavorite(goodsObjact)">
  4. <text class="iconfont " :class="{ iconlike: !goodsObjact.userCollect, iconlikefill: goodsObjact.userCollect }"></text>
  5. <text>收藏</text>
  6. </view>
  7. <view class="action-btn-group">
  8. <button type="primary" class=" action-btn no-border add-cart-btn" @click="buy(2)">加入购物车</button>
  9. <button type="primary" class=" action-btn no-border buy-now-btn" @click="buy(1)">立即购买</button>
  10. </view>
  11. </view>
  12. <view class="page-bottom" v-else>
  13. <view class="action-btn-group">
  14. <button type="primary" style="width: 750rpx;" class=" action-btn no-border buy-now-btn" @click="buy(1)">立即购买</button>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { collectAdd, collectDel } from '@/api/product.js';
  20. export default {
  21. props: {
  22. many: {
  23. default: 9
  24. },
  25. goodsObjact: {
  26. default: function() {
  27. return {};
  28. }
  29. },
  30. goodsid:{
  31. default: ''
  32. },
  33. is_gold: {
  34. default: 0
  35. },
  36. is_integral: {
  37. default: 0
  38. }
  39. },
  40. data() {
  41. return {};
  42. },
  43. mounted() {
  44. console.log(this.is_gold)
  45. },
  46. methods: {
  47. buy(type) {
  48. this.$emit('specOPne',type);
  49. },
  50. //收藏
  51. toFavorite(item) {
  52. let obj = this;
  53. item.userCollect = !item.userCollect;
  54. if (!item.userCollect) {
  55. collectDel({ id: obj.goodsid, category: 'product' }).then(function(e) {
  56. uni.showToast({
  57. title: '成功取消收藏',
  58. type: 'top',
  59. duration: 1500
  60. });
  61. });
  62. } else {
  63. collectAdd({ id: obj.goodsid, category: 'product' }).then(function(e) {
  64. uni.showToast({
  65. title: '成功加入收藏',
  66. type: 'top',
  67. duration: 1500
  68. });
  69. });
  70. }
  71. }
  72. }
  73. };
  74. </script>
  75. <style lang="scss">
  76. /* 底部操作菜单 */
  77. .page-bottom {
  78. position: fixed;
  79. left: 0rpx;
  80. bottom: 0rpx;
  81. z-index: 95;
  82. display: flex;
  83. justify-content: center;
  84. align-items: center;
  85. width: 750rpx;
  86. height: 98rpx;
  87. background: rgba(255, 255, 255, 0.9);
  88. box-shadow: 0 0 20rpx 0 rgba(0, 0, 0, 0.5);
  89. // border-radius: 16rpx;
  90. .p-b-btn {
  91. display: flex;
  92. flex-direction: column;
  93. align-items: center;
  94. justify-content: center;
  95. font-size: $font-sm;
  96. color: $font-color-base;
  97. width: 100rpx;
  98. height: 98rpx;
  99. .iconfont {
  100. font-size: 40rpx;
  101. line-height: 48rpx;
  102. color: $font-color-light;
  103. }
  104. &.active,
  105. &.active .iconfont {
  106. color: $uni-color-primary;
  107. }
  108. .icon-fenxiang2 {
  109. font-size: 42rpx;
  110. transform: translateY(-2rpx);
  111. }
  112. .iconlikefill {
  113. font-size: 46rpx;
  114. }
  115. }
  116. .action-btn-group {
  117. display: flex;
  118. height: 98rpx;
  119. overflow: hidden;
  120. position: relative;
  121. .action-btn {
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. width: 375rpx;
  126. height: 100%;
  127. font-size: $font-base;
  128. padding: 0;
  129. border-radius: 0;
  130. // background: transparent;
  131. background: #ffb238;
  132. &.buy-now-btn {
  133. background-color: #FF4C4C;
  134. }
  135. &.add-cart-btn {
  136. background: #ffb238;
  137. }
  138. }
  139. }
  140. }
  141. </style>