graceNvueFullLoading.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="grace-full-loading" v-if="graceFullLoading" @tap.stop="" @touchmove.stop.prevent=""
  3. :style="{
  4. backgroundColor:background, left:graceFullLoading?'0px':'-1000px',
  5. opacity:graceFullLoading?1:0}">
  6. <image class="grace-full-loading-image" ref="loadingLogos" :src="logoUrl" mode="widthFix" :style="{width:size, height:size}"></image>
  7. <text class="grace-full-loading-text" :style="{color:textColor, fontSize:fontSize}">{{text}}</text>
  8. </view>
  9. </template>
  10. <script>
  11. var animation = weex.requireModule('animation');
  12. export default {
  13. name: "graceFullLoading",
  14. props: {
  15. graceFullLoading: {
  16. type : Boolean,
  17. default : false
  18. },
  19. logoUrl : {
  20. type : String,
  21. default : ""
  22. },
  23. text : {
  24. type : String,
  25. default : "Loading ..."
  26. },
  27. fontSize : {
  28. type : String,
  29. default : "22rpx"
  30. },
  31. textColor : {
  32. type : String,
  33. default : "#999999"
  34. },
  35. size : {
  36. type : String,
  37. default : "138rpx"
  38. },
  39. background : {
  40. type : String,
  41. default : 'rgba(255,255,255,1)'
  42. }
  43. },
  44. updated : function(){
  45. setTimeout(()=>{
  46. var loadingLogos = this.$refs.loadingLogos;
  47. this.animation1(loadingLogos);
  48. }, 200);
  49. },
  50. methods: {
  51. animation1 : function(loadingLogos){
  52. if(!this.graceFullLoading){return ;}
  53. var _self = this;
  54. animation.transition(loadingLogos, {
  55. styles: { opacity:0.3},
  56. duration: 1000,
  57. timingFunction: 'linear',
  58. needLayout:false,
  59. delay: 0
  60. }, function (){
  61. _self.animation2(loadingLogos);
  62. });
  63. },
  64. animation2 : function(loadingLogos){
  65. if(!this.graceFullLoading){return ;}
  66. var _self = this;
  67. animation.transition(loadingLogos, {
  68. styles: { opacity: 1},
  69. duration: 1000,
  70. timingFunction: 'linear',
  71. needLayout:false,
  72. delay: 0
  73. }, function (){_self.animation1(loadingLogos);}
  74. );
  75. }
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. .grace-full-loading{width:750rpx; justify-content:center; align-items:center; background-color:rgba(255,255,255,0.9); position:fixed; top:0; bottom:0;}
  81. .grace-full-loading-image{width:150rpx; height:150rpx; border-radius:150rpx;}
  82. .grace-full-loading-text{line-height:50rpx; font-size:22rpx; margin-top:10rpx; text-align:center;}
  83. </style>