productBottom.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 class="btm-btn">
  16. <view class="add-btn" @click="buy(2)" v-if="showAdd">加入购物车</view>
  17. <view class="buy-btn" @click="buy(1)" :class="{'quck':!showAdd }">立即购买</view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { collectAdd, collectDel } from '@/api/product.js';
  23. export default {
  24. props: {
  25. many: {
  26. default: 9
  27. },
  28. goodsObjact: {
  29. default: function() {
  30. return {};
  31. }
  32. },
  33. goodsid: {
  34. default: ''
  35. },
  36. showAdd: {
  37. default: true
  38. }
  39. },
  40. data() {
  41. return {};
  42. },
  43. methods: {
  44. buy(type) {
  45. this.$emit('specOPne', type);
  46. },
  47. //收藏
  48. toFavorite(item) {
  49. let obj = this;
  50. item.userCollect = !item.userCollect;
  51. if (!item.userCollect) {
  52. collectDel({ id: obj.goodsid, category: 'product' }).then(function(e) {
  53. uni.showToast({
  54. title: '成功取消收藏',
  55. type: 'top',
  56. duration: 1500
  57. });
  58. });
  59. } else {
  60. collectAdd({ id: obj.goodsid, category: 'product' }).then(function(e) {
  61. uni.showToast({
  62. title: '成功加入收藏',
  63. type: 'top',
  64. duration: 1500
  65. });
  66. });
  67. }
  68. }
  69. }
  70. };
  71. </script>
  72. <style lang="scss">
  73. /* 底部操作菜单 */
  74. .page-bottom {
  75. position: fixed;
  76. bottom: 0rpx;
  77. z-index: 95;
  78. display: flex;
  79. justify-content: center;
  80. align-items: center;
  81. width: 750rpx;
  82. height: 120rpx;
  83. background-color: #ffffff;
  84. /* box-shadow: 0 0 20rpx 0 rgba(0, 0, 0, 0.5);
  85. border-radius: 16rpx; */
  86. .p-b-btn {
  87. display: flex;
  88. flex-direction: column;
  89. align-items: center;
  90. justify-content: center;
  91. font-size: $font-sm;
  92. color: $font-color-base;
  93. width: 96rpx;
  94. height: 80rpx;
  95. .iconfont {
  96. font-size: 40rpx;
  97. line-height: 48rpx;
  98. color: $font-color-light;
  99. }
  100. &.active,
  101. &.active .iconfont {
  102. color: $uni-color-primary;
  103. }
  104. .iconlikefill {
  105. font-size: 46rpx;
  106. }
  107. image {
  108. width: 56rpx;
  109. height: 58rpx;
  110. }
  111. }
  112. .action-btn-group {
  113. display: flex;
  114. height: 76rpx;
  115. border-radius: 100px;
  116. overflow: hidden;
  117. margin-left: 20rpx;
  118. position: relative;
  119. &:after {
  120. content: '';
  121. position: absolute;
  122. top: 50%;
  123. right: 50%;
  124. transform: translateY(-50%);
  125. height: 28rpx;
  126. width: 0;
  127. border-right: 1px solid rgba(255, 255, 255, 0.5);
  128. }
  129. .action-btn {
  130. display: flex;
  131. align-items: center;
  132. justify-content: center;
  133. // width: 270rpx;
  134. // height: 100%;
  135. font-size: $font-base;
  136. padding: 0;
  137. border-radius: 0;
  138. background: transparent;
  139. width: 339rpx;
  140. height: 90rpx;
  141. &.buy-now-btn {
  142. background-color: #303e49;
  143. }
  144. &.add-cart-btn {
  145. background-color: #fff;
  146. color: #ff4c4c;
  147. border: #ff4c4c 1px solid;
  148. }
  149. }
  150. }
  151. }
  152. .p-b-btn {
  153. display: flex;
  154. flex-direction: column;
  155. align-items: center;
  156. justify-content: center;
  157. font-size: $font-sm;
  158. color: $font-color-base;
  159. width: 96rpx;
  160. height: 80rpx;
  161. .iconfont {
  162. font-size: 40rpx;
  163. line-height: 48rpx;
  164. color: $font-color-light;
  165. }
  166. &.active,
  167. &.active .iconfont {
  168. color: $uni-color-primary;
  169. }
  170. .icon-fenxiang2 {
  171. font-size: 42rpx;
  172. transform: translateY(-2rpx);
  173. }
  174. .iconlikefill {
  175. font-size: 46rpx;
  176. }
  177. }
  178. .btm-btn {
  179. z-index: 2;
  180. width: 750rpx;
  181. height: 97rpx;
  182. display: flex;
  183. // justify-content: space-between;
  184. position: fixed;
  185. bottom: 0;
  186. background-color: #fff;
  187. text-align: center;
  188. .add-btn {
  189. text-align: center;
  190. width: 375rpx;
  191. height: 97rpx;
  192. background: #FFB238;
  193. font-size: 36rpx;
  194. font-weight: 500;
  195. color: #fff;
  196. line-height: 97rpx;
  197. }
  198. .buy-btn {
  199. text-align: center;
  200. border: none;
  201. width: 375rpx;
  202. height: 97rpx;
  203. background: #6EAB4E;
  204. font-size: 36rpx;
  205. font-weight: 500;
  206. color: #fff;
  207. line-height: 97rpx;
  208. color: #fff;
  209. }
  210. .quck {
  211. width: 691px;
  212. }
  213. }
  214. </style>