gui-loadmore.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="gui-load-more gui-flex gui-rows gui-align-items-center gui-justify-content-center"
  3. v-if="!hidden" @tap.stop.prevent="tapme">
  4. <view class="gui-load-more-icon" ref="loadingiconforloadmore"
  5. v-if="loadMoreStatus == 1">
  6. <text class="gui-icons gui-rotate360 gui-block-text"
  7. :style="{
  8. fontSize:loadMoreFontSize,
  9. color:loadMoreColor[loadMoreStatus]}">&#xe9db;</text>
  10. </view>
  11. <text class="gui-block-text"
  12. :style="{
  13. fontSize:loadMoreFontSize,
  14. color:loadMoreColor[loadMoreStatus]
  15. }">{{loadMoreText[loadMoreStatus]}}</text>
  16. </view>
  17. </template>
  18. <script>
  19. // #ifdef APP-NVUE
  20. var animation = weex.requireModule('animation');
  21. // #endif
  22. export default{
  23. name : "gui-loadmore",
  24. props : {
  25. loadMoreText : {type:Array, default:function () {
  26. return ['','更多数据加载中', '已加载全部数据', '暂无数据'];
  27. }},
  28. loadMoreColor : {type:Array, default:function () {
  29. return ['rgba(69, 90, 100, 0.6)', 'rgba(69, 90, 100, 0.6)', 'rgba(69, 90, 100, 0.8)', 'rgba(69, 90, 100, 0.6)'];
  30. }},
  31. loadMoreFontSize : {type:String, default:'26rpx'},
  32. status : {type:Number, default:0},
  33. },
  34. data() {
  35. return {
  36. loadMoreStatus : 0,
  37. hidden : false
  38. }
  39. },
  40. created:function(){
  41. this.loadMoreStatus = this.status;
  42. },
  43. methods:{
  44. loading : function(){
  45. this.loadMoreStatus = 1;
  46. // #ifdef APP-NVUE
  47. setTimeout(()=>{
  48. this.rotate360();
  49. }, 200);
  50. // #endif
  51. },
  52. stoploadmore : function(){
  53. this.loadMoreStatus = 0;
  54. },
  55. nomore : function(){
  56. this.loadMoreStatus = 2;
  57. },
  58. empty : function(){
  59. this.loadMoreStatus = 3;
  60. },
  61. hide : function(){
  62. this.hidden = true;
  63. },
  64. rotate360 : function(){
  65. var el = this.$refs.loadingiconforloadmore;
  66. animation.transition(el, {
  67. styles : {transform: 'rotate(7200deg)'},
  68. duration : 20000,
  69. timingFunction: 'linear',
  70. needLayout :false,
  71. delay: 0
  72. });
  73. },
  74. tapme : function(){
  75. if(this.loadMoreStatus == 0){
  76. this.$emit('tapme');
  77. }
  78. }
  79. }
  80. }
  81. </script>
  82. <style>
  83. .gui-load-more{overflow:hidden; padding:25rpx;}
  84. .gui-load-more-text{line-height:35rpx;}
  85. .gui-load-more-icon{padding:0 12rpx; line-height:35rpx;}
  86. </style>