productBottom.vue 3.4 KB

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