productBottomVip.vue 3.2 KB

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