自主产品,供应链食堂系统。将两个端拆开了。
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.

186 lines
2.6 KiB

  1. <template>
  2. <image
  3. :class="{'loading': loading}"
  4. :data-loading-text="loadingText"
  5. :src="img_src"
  6. :mode="mode"
  7. :lazy-load="true"
  8. @click="click"
  9. @load="load"
  10. @error="error">
  11. </image>
  12. </template>
  13. <script>
  14. export default {
  15. props: {
  16. src: {
  17. type: String,
  18. default: ''
  19. },
  20. mode: {
  21. type: String,
  22. default: 'scaleToFill'
  23. },
  24. errSrc: {
  25. type: String,
  26. default: '../../static/images/empty.png'
  27. },
  28. loadingText: {
  29. type: String,
  30. default: '正在加载中'
  31. }
  32. },
  33. data(){
  34. return {
  35. img_src: this.src,
  36. loading: true
  37. }
  38. },
  39. methods: {
  40. load(event){
  41. this.loading = false;
  42. },
  43. error(event){
  44. this.loading = false;
  45. this.img_src = this.$props.errSrc;
  46. },
  47. click(event){
  48. this.$emit('click', event);
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped="scoped">
  54. .loading{
  55. position: relative;
  56. // background-color: #e5e5e5;
  57. background: linear-gradient(-45deg, #e5e5e5, #d9d9d9, #f1f3f5, #f0f0f0);
  58. animation: gradientBG 15s ease infinite;
  59. background-size: 400% 400%;
  60. transition: all 1s;
  61. &::after{
  62. content: attr(data-loading-text);
  63. position: absolute;
  64. top: 0;
  65. right: 0;
  66. bottom: 0;
  67. left: 0;
  68. color: #969696;
  69. font-size: 20rpx;
  70. display: flex;
  71. justify-content: center;
  72. align-items: center;
  73. flex-wrap: wrap;
  74. animation: flicker-in-1 2s linear both infinite;
  75. transition: all 2s;
  76. }
  77. }
  78. @keyframes gradientBG {
  79. 0% {
  80. background-position: 0% 50%;
  81. }
  82. 50% {
  83. background-position: 100% 50%;
  84. }
  85. 100% {
  86. background-position: 0% 50%;
  87. }
  88. }
  89. @keyframes flicker-in-1 {
  90. 0% {
  91. opacity: 0.5;
  92. }
  93. 10% {
  94. opacity: 0.5;
  95. }
  96. 10.1% {
  97. opacity: 1;
  98. }
  99. 10.2% {
  100. opacity: 0.5;
  101. }
  102. 20% {
  103. opacity: 0.5;
  104. }
  105. 20.1% {
  106. opacity: 1;
  107. }
  108. 20.6% {
  109. opacity: 0.5;
  110. }
  111. 30% {
  112. opacity: 0.5;
  113. }
  114. 30.1% {
  115. opacity: 1;
  116. }
  117. 30.5% {
  118. opacity: 1;
  119. }
  120. 30.6% {
  121. opacity: 0.5;
  122. }
  123. 45% {
  124. opacity: 0.5;
  125. }
  126. 45.1% {
  127. opacity: 1;
  128. }
  129. 50% {
  130. opacity: 1;
  131. }
  132. 55% {
  133. opacity: 1;
  134. }
  135. 55.1% {
  136. opacity: 0.5;
  137. }
  138. 57% {
  139. opacity: 0.5;
  140. }
  141. 57.1% {
  142. opacity: 1;
  143. }
  144. 60% {
  145. opacity: 1;
  146. }
  147. 60.1% {
  148. opacity: 0.5;
  149. }
  150. 65% {
  151. opacity: 0.5;
  152. }
  153. 65.1% {
  154. opacity: 1;
  155. }
  156. 75% {
  157. opacity: 1;
  158. }
  159. 75.1% {
  160. opacity: 0.5;
  161. }
  162. 77% {
  163. opacity: 0.5;
  164. }
  165. 77.1% {
  166. opacity: 1;
  167. }
  168. 85% {
  169. opacity: 1;
  170. }
  171. 85.1% {
  172. opacity: 0.5;
  173. }
  174. 86% {
  175. opacity: 0.5;
  176. }
  177. 86.1% {
  178. opacity: 1;
  179. }
  180. 100% {
  181. opacity: 1;
  182. }
  183. }
  184. </style>