You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
4.0 KiB

4 years ago
  1. <template>
  2. <view class="mix-loading center">
  3. <view v-if="!isTimeout" class="center">
  4. <view v-if="mask" class="mask" @click.stop.prevent="stopPrevent" @touchmove.stop.prevent="stopPrevent"></view>
  5. <!-- 黑底菊花 -->
  6. <view v-if="type === 1" class="chry column center">
  7. <view class="icon"></view>
  8. <text class="tit">{{ title }}</text>
  9. </view>
  10. <!-- 仓鼠 -->
  11. <image v-else-if="type === 2" class="hamster" src="/static/loading/hamster.gif"></image>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. /**
  17. * loading
  18. * @prop type 1 黑底菊花 2 小胖仓鼠
  19. * @prop mask 遮罩层
  20. * @prop timeout 超时时间 默认10s
  21. */
  22. export default {
  23. name: 'MixIconLoading',
  24. data(){
  25. return {
  26. isTimeout: false
  27. }
  28. },
  29. props: {
  30. type: {
  31. type: Number,
  32. default: 1
  33. },
  34. mask: {
  35. type: Boolean,
  36. default: false
  37. },
  38. timeout: {
  39. type: Number,
  40. default: 10
  41. },
  42. title: {
  43. type: String,
  44. default: '请稍候'
  45. }
  46. },
  47. created() {
  48. this._timer = setTimeout(()=>{
  49. if(!this.isLoading){
  50. return;
  51. }
  52. this.isTimeout = true;
  53. uni.showToast({
  54. title: '加载超时,请重试',
  55. icon: 'none'
  56. })
  57. }, this.timeout * 1000)
  58. },
  59. destroyed() {
  60. this._timer && clearTimeout(this._timer);
  61. }
  62. }
  63. </script>
  64. <style scoped lang='scss'>
  65. .mix-loading{
  66. position: fixed;
  67. left: 50vw;
  68. top: 46vh;
  69. width: 0;
  70. height: 0;
  71. z-index: 999;
  72. }
  73. .mask{
  74. position: fixed;
  75. left: 0;
  76. top: 0;
  77. right: 0;
  78. bottom: 0;
  79. }
  80. .chry{
  81. min-width: 120rpx;
  82. min-height: 116rpx;
  83. border-radius: 10rpx;
  84. background-color: rgba(17,17,17,.7);
  85. .icon{
  86. width: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gxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=);
  89. background-repeat: no-repeat;
  90. background-size: 100% 100%;
  91. animation: mix-loading 1s steps(12) infinite;
  92. }
  93. .tit{
  94. margin: 10rpx 0 6rpx;
  95. font-size: 20rpx;
  96. color: #e9e9e9;
  97. }
  98. }
  99. @keyframes mix-loading{
  100. from {
  101. transform:rotate(0deg)
  102. }
  103. to {
  104. transform: rotate(1turn)
  105. }
  106. }
  107. .hamster{
  108. width: 106rpx;
  109. height: 120rpx;
  110. }
  111. </style>