u-loading-icon.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "u-loading-icon",
  5. mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$4],
  6. data() {
  7. return {
  8. // Array.form可以通过一个伪数组对象创建指定长度的数组
  9. // https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/from
  10. array12: Array.from({
  11. length: 12
  12. }),
  13. // 这里需要设置默认值为360,否则在安卓nvue上,会延迟一个duration周期后才执行
  14. // 在iOS nvue上,则会一开始默认执行两个周期的动画
  15. aniAngel: 360,
  16. // 动画旋转角度
  17. webviewHide: false,
  18. // 监听webview的状态,如果隐藏了页面,则停止动画,以免性能消耗
  19. loading: false
  20. // 是否运行中,针对nvue使用
  21. };
  22. },
  23. computed: {
  24. // 当为circle类型时,给其另外三边设置一个更轻一些的颜色
  25. // 之所以需要这么做的原因是,比如父组件传了color为红色,那么需要另外的三个边为浅红色
  26. // 而不能是固定的某一个其他颜色(因为这个固定的颜色可能浅蓝,导致效果没有那么细腻良好)
  27. otherBorderColor() {
  28. const lightColor = common_vendor.index.$u.colorGradient(this.color, "#ffffff", 100)[80];
  29. if (this.mode === "circle") {
  30. return this.inactiveColor ? this.inactiveColor : lightColor;
  31. } else {
  32. return "transparent";
  33. }
  34. }
  35. },
  36. watch: {
  37. show(n) {
  38. }
  39. },
  40. mounted() {
  41. this.init();
  42. },
  43. methods: {
  44. init() {
  45. setTimeout(() => {
  46. }, 20);
  47. },
  48. // 监听webview的显示与隐藏
  49. addEventListenerToWebview() {
  50. const pages = getCurrentPages();
  51. const page = pages[pages.length - 1];
  52. const currentWebview = page.$getAppWebview();
  53. currentWebview.addEventListener("hide", () => {
  54. this.webviewHide = true;
  55. });
  56. currentWebview.addEventListener("show", () => {
  57. this.webviewHide = false;
  58. });
  59. }
  60. }
  61. };
  62. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  63. return common_vendor.e({
  64. a: _ctx.show
  65. }, _ctx.show ? common_vendor.e({
  66. b: !$data.webviewHide
  67. }, !$data.webviewHide ? common_vendor.e({
  68. c: _ctx.mode === "spinner"
  69. }, _ctx.mode === "spinner" ? {
  70. d: common_vendor.f($data.array12, (item, index, i0) => {
  71. return {
  72. a: index
  73. };
  74. })
  75. } : {}, {
  76. e: common_vendor.n(`u-loading-icon__spinner--${_ctx.mode}`),
  77. f: _ctx.color,
  78. g: _ctx.$u.addUnit(_ctx.size),
  79. h: _ctx.$u.addUnit(_ctx.size),
  80. i: _ctx.color,
  81. j: $options.otherBorderColor,
  82. k: $options.otherBorderColor,
  83. l: $options.otherBorderColor,
  84. m: `${_ctx.duration}ms`,
  85. n: _ctx.mode === "semicircle" || _ctx.mode === "circle" ? _ctx.timingFunction : ""
  86. }) : {}, {
  87. o: _ctx.text
  88. }, _ctx.text ? {
  89. p: common_vendor.t(_ctx.text),
  90. q: _ctx.$u.addUnit(_ctx.textSize),
  91. r: _ctx.textColor
  92. } : {}, {
  93. s: common_vendor.s(_ctx.$u.addStyle(_ctx.customStyle)),
  94. t: common_vendor.n(_ctx.vertical && "u-loading-icon--vertical")
  95. }) : {});
  96. }
  97. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-00752c6d"], ["__file", "D:/project/赋强公证/notarization_applet/node_modules/uview-plus/components/u-loading-icon/u-loading-icon.vue"]]);
  98. wx.createComponent(Component);