productBottom.vue 3.5 KB

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