You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
3.4 KiB

3 years ago
  1. <template>
  2. <view class="mix-botoom-operation row">
  3. <view class="nav-group row">
  4. <view class="nav column center" @click="switchTab('/pages/tabbar/home')">
  5. <text class="mix-icon icon-home"></text>
  6. <text class="tit">首页</text>
  7. </view>
  8. <view class="nav column center" @click="switchTab('/pages/tabbar/cart')">
  9. <text class="mix-icon icon-gouwuche"></text>
  10. <text class="tit">购物车</text>
  11. <view v-if="cartCount > 0" class="number center">
  12. <text>{{ cartCount }}</text>
  13. </view>
  14. </view>
  15. <view class="nav column center" :class="{active: is_fav === 1}" @click="changeFav">
  16. <text class="mix-icon" :class="is_fav === 1 ? 'icon-shoucang' : 'icon-shoucang-1'"></text>
  17. <text class="tit">收藏</text>
  18. </view>
  19. </view>
  20. <view class="btn-group row">
  21. <view class="btn center" @click="onOprationClick('cart')">
  22. <text>加入购物车</text>
  23. </view>
  24. <view class="btn center" @click="onOprationClick('buy')">
  25. <text>立即购买</text>
  26. </view>
  27. </view>
  28. <mix-loading v-if="isLoading" :mask="true"></mix-loading>
  29. </view>
  30. </template>
  31. <script>
  32. /**
  33. * 商品详情页 底部操作菜单
  34. */
  35. export default {
  36. name: 'BotoomOperation',
  37. data() {
  38. return {
  39. is_fav: 0
  40. };
  41. },
  42. computed: {
  43. cartCount(){
  44. return this.$store.state.cartCount;
  45. }
  46. },
  47. props: {
  48. infoData: {
  49. type: Object,
  50. default(){
  51. return {}
  52. }
  53. }
  54. },
  55. watch: {
  56. infoData(data){
  57. this.is_fav = data.fav;
  58. }
  59. },
  60. methods: {
  61. //收藏
  62. async changeFav(){
  63. if(!this.$util.isLogin()){
  64. return;
  65. }
  66. const operation = this.is_fav === 1 ? 'remove': 'add';
  67. const response = await this.$request('favorite', operation, {
  68. product_id: this.infoData._id
  69. }, {showLoading: true})
  70. if(response.status === 1){
  71. this.is_fav = this.is_fav === 1 ? 0: 1;
  72. }else{
  73. this.$util.msg(this.is_fav === 1 ? '取消收藏失败' : '收藏失败');
  74. }
  75. },
  76. onOprationClick(type){
  77. this.$emit('onOprationClick', type)
  78. },
  79. switchTab(url){
  80. uni.switchTab({
  81. url
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style scoped lang="scss">
  88. .mix-botoom-operation{
  89. position: fixed;
  90. left: 0;
  91. bottom: 0;
  92. z-index: 90;
  93. width: 100%;
  94. height: 100rpx;
  95. background-color: #fff;
  96. box-shadow: 0 -2rpx 10rpx 0 rgba(0,0,0,.1);
  97. box-sizing: content-box;
  98. padding-bottom: constant(safe-area-inset-bottom);
  99. padding-bottom: env(safe-area-inset-bottom);
  100. }
  101. .nav-group{
  102. padding-left: 6rpx;
  103. .nav{
  104. width: 90rpx;
  105. height: 80rpx;
  106. color: #333;
  107. position: relative;
  108. &.active{
  109. color: $base-color;
  110. }
  111. }
  112. .tit{
  113. font-size: 20rpx;
  114. }
  115. .mix-icon{
  116. height: 48rpx;
  117. line-height: 48rpx;
  118. font-size: 38rpx;
  119. margin-bottom: 6rpx;
  120. }
  121. .number{
  122. position: absolute;
  123. right: 16rpx;
  124. top: 2rpx;
  125. min-width: 24rpx;
  126. height: 24rpx;
  127. padding: 0 8rpx;
  128. font-size: 16rpx;
  129. color: #fff;
  130. background-color: $base-color;
  131. border-radius: 100rpx;
  132. }
  133. }
  134. .btn-group{
  135. flex: 1;
  136. margin: 0 16rpx 0 14rpx;
  137. overflow: hidden;
  138. .btn{
  139. flex: 1;
  140. height: 76rpx;
  141. font-size: 30rpx;
  142. color: #fff;
  143. background-color: orange;
  144. border-radius: 100rpx 0 0 100rpx;
  145. &:last-child{
  146. background-color: $base-color;
  147. border-radius: 0 100rpx 100rpx 0;
  148. }
  149. }
  150. }
  151. </style>