gui-order.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view
  3. @tap="changeOrderBy"
  4. class="gui-flex gui-row gui-nowrap gui-align-items-center gui-justify-content-center">
  5. <view>
  6. <slot></slot>
  7. </view>
  8. <view
  9. v-if="orderByIn == 0"
  10. class="gui-order gui-flex gui-column">
  11. <text
  12. class="gui-block gui-icons gui-order-icon"
  13. :style="{width:(size+10)+'rpx', height:(size)+'rpx',
  14. lineHeight:(size)+'rpx', fontSize:fontSize+'rpx', color:color}">&#xe647;</text>
  15. <text
  16. class="gui-block gui-icons gui-order-icon"
  17. :style="{width:(size+10)+'rpx', height:(size)+'rpx',
  18. lineHeight:(size)+'rpx', fontSize:fontSize+'rpx', color:color}">&#xe661;</text>
  19. </view>
  20. <view
  21. v-if="orderByIn == 1"
  22. class="gui-order gui-flex gui-columns">
  23. <text
  24. class="gui-block gui-icons gui-order-icon"
  25. :style="{width:(size+10)+'rpx', height:(size)+'rpx',
  26. lineHeight:(size)+'rpx', fontSize:fontSize+'rpx', color:activeColor}">&#xe647;</text>
  27. <text class="gui-block gui-icons gui-order-icon"
  28. :style="{width:(size+10)+'rpx', height:(size)+'rpx',
  29. lineHeight:(size)+'rpx', fontSize:fontSize+'rpx', color:color}">&#xe661;</text>
  30. </view>
  31. <view
  32. v-if="orderByIn == 2"
  33. class="gui-order gui-flex gui-columns">
  34. <text
  35. class="gui-block gui-icons gui-order-icon"
  36. :style="{width:(size+10)+'rpx', height:(size)+'rpx',
  37. lineHeight:(size)+'rpx', fontSize:fontSize+'rpx', color:color}">&#xe647;</text>
  38. <text class="gui-block gui-icons gui-order-icon"
  39. :style="{width:(size+10)+'rpx', height:(size)+'rpx',
  40. lineHeight:(size)+'rpx', fontSize:fontSize+'rpx', color:activeColor}">&#xe661;</text>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default{
  46. name : "gui-order",
  47. props : {
  48. size : {type:Number, default:18},
  49. fontSize : {type:Number, default:36},
  50. color : {type:String, default:'rgba(0, 0, 0, 0.5)'},
  51. activeColor : {type:String, default:'#FF0036'},
  52. orderBy : {type:Number, default:0},
  53. limit : {type:Array, default:function(){return [0,2];}}
  54. },
  55. data() {
  56. return {
  57. orderByIn : 0
  58. }
  59. },
  60. created:function(){
  61. this.orderByIn = this.orderBy;
  62. this.init();
  63. },
  64. watch:{
  65. orderBy : function(v){
  66. this.orderByIn = v;
  67. this.init();
  68. }
  69. },
  70. methods:{
  71. changeOrderBy:function(){
  72. this.orderByIn++;
  73. if(this.orderByIn > this.limit[1]){this.orderByIn = this.limit[0];}
  74. this.$emit('change', this.orderByIn);
  75. },
  76. init:function(){
  77. if(this.orderByIn < 0){this.orderByIn = 0;}
  78. else if(this.orderByIn > 2){this.orderByIn = 2;}
  79. }
  80. },
  81. emits : ['change']
  82. }
  83. </script>
  84. <style scoped>
  85. .gui-order{padding:0 12rpx;}
  86. .gui-order-icon{text-align:center; overflow:hidden;}
  87. </style>