goods-action-icon.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="goods-action-icon" :class="'goods-action-icon-'+icon" @click="btn">
  3. <view class="goods-action-btn">
  4. <view v-if="icon == 'home'" class="icon iconfont" style="font-size: 18px">&#xe657;</view>
  5. <view v-if="icon == 'online'" class="icon iconfont" style="font-size: 18px">&#xe605;</view>
  6. <view v-if="icon == 'cart'" class="icon iconfont" style="font-size: 18px;">&#xe60f;</view>
  7. <view v-if="icon == 'collect'" class="icon iconfont" :class="{active:active}" style="font-size: 18px">&#xe635;</view>
  8. <text v-if="count > 0">{{count}}</text>
  9. </view>
  10. <view><text :class="{active:active}">{{text}}</text></view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. icon: {
  17. type: String,
  18. default: ""
  19. },
  20. text: {
  21. type: String,
  22. default: ""
  23. },
  24. count: {
  25. type: [String,Number],
  26. default: "0"
  27. },
  28. active: {
  29. type: Boolean,
  30. default: false
  31. }
  32. },
  33. methods:{
  34. btn(){
  35. this.$emit("click");
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. .goods-action-icon{
  42. display: flex;
  43. flex-direction: column;
  44. justify-content: center;
  45. min-width: 108rpx;
  46. height: 99rpx;
  47. color: #646566;
  48. font-size: 24rpx;
  49. text-align: center;
  50. background-color: #fff;
  51. cursor: pointer;
  52. .goods-action-btn {
  53. display: block; text-align: center;
  54. font-size: 26rpx; color: #666;
  55. position: relative;
  56. &:first-child {
  57. position: relative;
  58. view {
  59. display: inline-block;
  60. width: 36rpx; height: 36rpx;
  61. padding: 6rpx 0;
  62. }
  63. .active {
  64. color: #ff5000;
  65. }
  66. text {
  67. position: absolute;
  68. top: 10rpx;
  69. right: 24rpx;
  70. box-sizing: border-box;
  71. min-width: 36rpx;
  72. padding: 0 6rpx;
  73. color: #fff;
  74. font-weight: 500;
  75. font-size: 24rpx;
  76. line-height: 28rpx;
  77. text-align: center;
  78. background-color: #ee0a24;
  79. border: 2rpx solid #fff;
  80. border-radius: 64rpx;
  81. transform: translate(50%,-50%);
  82. transform-origin: 100%;
  83. }
  84. }
  85. &:last-child{
  86. font-size: 48rpx;
  87. -webkit-transform:scale(0.90);
  88. .active {
  89. color: #ff5000;
  90. }
  91. }
  92. }
  93. }
  94. </style>