gui-order.vue 2.6 KB

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