graceLoading.nvue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <view class="grace-loading grace-ellipsis" v-if="loadingType < 4">
  3. <text class="grace-loading-icon grace-icons" ref="loadingIcon" v-if="loadingType === 1" :style="{color:iconColor}">&#xe9db;</text>
  4. <text class="grace-loading-text" :style="{color:textColor}">{{loadingText[loadingType]}}</text>
  5. </view>
  6. </template>
  7. <script>
  8. const animation = weex.requireModule('animation');
  9. export default {
  10. props: {
  11. loadingType: {
  12. type : Number,
  13. default: 0
  14. },
  15. loadingText : {
  16. type : Array,
  17. default : function () {
  18. return ["上拉加载更多", "正在努力加载", "已经加载全部数据",'',''];
  19. }
  20. },
  21. iconColor : {
  22. type : String,
  23. default : "#888888"
  24. },
  25. textColor : {
  26. type : String,
  27. default : "#888888"
  28. }
  29. },
  30. watch:{
  31. loadingType : function (nval, oval) {
  32. if(nval == 1){
  33. setTimeout(()=>{this.rotate360();}, 300);
  34. }
  35. }
  36. },
  37. methods: {
  38. rotate360 : function(){
  39. var el = this.$refs.loadingIcon;
  40. animation.transition(el, {
  41. styles: {transform: 'rotate(7200deg)'},
  42. duration: 20000,
  43. timingFunction: 'linear',
  44. needLayout:false,
  45. delay: 0
  46. });
  47. }
  48. }
  49. }
  50. </script>
  51. <style scoped>
  52. .grace-loading{flex-direction:row; flex-wrap:nowrap; justify-content:center; padding:16rpx 0; padding-bottom:36rpx; align-items:center;}
  53. .grace-loading-text{margin-left:12rpx; font-size:26rpx;}
  54. .grace-loading-icon{width:40rpx; height:40rpx; justify-content:center; line-height:40rpx; font-size:30rpx; text-align:center;}
  55. </style>