u-popup.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "u-popup",
  5. mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$9],
  6. data() {
  7. return {
  8. overlayDuration: this.duration + 50
  9. };
  10. },
  11. watch: {
  12. show(newValue, oldValue) {
  13. if (newValue === true) {
  14. const children = this.$children;
  15. this.retryComputedComponentRect(children);
  16. }
  17. }
  18. },
  19. computed: {
  20. transitionStyle() {
  21. const style = {
  22. zIndex: this.zIndex,
  23. position: "fixed",
  24. display: "flex"
  25. };
  26. style[this.mode] = 0;
  27. if (this.mode === "left") {
  28. return common_vendor.index.$u.deepMerge(style, {
  29. bottom: 0,
  30. top: 0
  31. });
  32. } else if (this.mode === "right") {
  33. return common_vendor.index.$u.deepMerge(style, {
  34. bottom: 0,
  35. top: 0
  36. });
  37. } else if (this.mode === "top") {
  38. return common_vendor.index.$u.deepMerge(style, {
  39. left: 0,
  40. right: 0
  41. });
  42. } else if (this.mode === "bottom") {
  43. return common_vendor.index.$u.deepMerge(style, {
  44. left: 0,
  45. right: 0
  46. });
  47. } else if (this.mode === "center") {
  48. return common_vendor.index.$u.deepMerge(style, {
  49. alignItems: "center",
  50. "justify-content": "center",
  51. top: 0,
  52. left: 0,
  53. right: 0,
  54. bottom: 0
  55. });
  56. }
  57. },
  58. contentStyle() {
  59. const style = {};
  60. common_vendor.index.$u.sys();
  61. if (this.mode !== "center") {
  62. style.flex = 1;
  63. }
  64. if (this.bgColor) {
  65. style.backgroundColor = this.bgColor;
  66. }
  67. if (this.round) {
  68. const value = common_vendor.index.$u.addUnit(this.round);
  69. if (this.mode === "top") {
  70. style.borderBottomLeftRadius = value;
  71. style.borderBottomRightRadius = value;
  72. } else if (this.mode === "bottom") {
  73. style.borderTopLeftRadius = value;
  74. style.borderTopRightRadius = value;
  75. } else if (this.mode === "center") {
  76. style.borderRadius = value;
  77. }
  78. }
  79. return common_vendor.index.$u.deepMerge(style, common_vendor.index.$u.addStyle(this.customStyle));
  80. },
  81. position() {
  82. if (this.mode === "center") {
  83. return this.zoom ? "fade-zoom" : "fade";
  84. }
  85. if (this.mode === "left") {
  86. return "slide-left";
  87. }
  88. if (this.mode === "right") {
  89. return "slide-right";
  90. }
  91. if (this.mode === "bottom") {
  92. return "slide-up";
  93. }
  94. if (this.mode === "top") {
  95. return "slide-down";
  96. }
  97. }
  98. },
  99. methods: {
  100. // 点击遮罩
  101. overlayClick() {
  102. if (this.closeOnClickOverlay) {
  103. this.$emit("close");
  104. }
  105. },
  106. close(e) {
  107. this.$emit("close");
  108. },
  109. afterEnter() {
  110. this.$emit("open");
  111. },
  112. clickHandler() {
  113. if (this.mode === "center") {
  114. this.overlayClick();
  115. }
  116. this.$emit("click");
  117. },
  118. retryComputedComponentRect(children) {
  119. const names = [
  120. "u-calendar-month",
  121. "u-album",
  122. "u-collapse-item",
  123. "u-dropdown",
  124. "u-index-item",
  125. "u-index-list",
  126. "u-line-progress",
  127. "u-list-item",
  128. "u-rate",
  129. "u-read-more",
  130. "u-row",
  131. "u-row-notice",
  132. "u-scroll-list",
  133. "u-skeleton",
  134. "u-slider",
  135. "u-steps-item",
  136. "u-sticky",
  137. "u-subsection",
  138. "u-swipe-action-item",
  139. "u-tabbar",
  140. "u-tabs",
  141. "u-tooltip"
  142. ];
  143. for (let i = 0; i < children.length; i++) {
  144. const child = children[i];
  145. const grandChild = child.$children;
  146. if (names.includes(child.$options.name) && typeof (child == null ? void 0 : child.init) === "function") {
  147. common_vendor.index.$u.sleep(50).then(() => {
  148. child.init();
  149. });
  150. }
  151. if (grandChild.length) {
  152. this.retryComputedComponentRect(grandChild);
  153. }
  154. }
  155. }
  156. }
  157. };
  158. if (!Array) {
  159. const _easycom_u_overlay2 = common_vendor.resolveComponent("u-overlay");
  160. const _easycom_u_status_bar2 = common_vendor.resolveComponent("u-status-bar");
  161. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  162. const _easycom_u_safe_bottom2 = common_vendor.resolveComponent("u-safe-bottom");
  163. const _easycom_u_transition2 = common_vendor.resolveComponent("u-transition");
  164. (_easycom_u_overlay2 + _easycom_u_status_bar2 + _easycom_u_icon2 + _easycom_u_safe_bottom2 + _easycom_u_transition2)();
  165. }
  166. const _easycom_u_overlay = () => "../u-overlay/u-overlay.js";
  167. const _easycom_u_status_bar = () => "../u-status-bar/u-status-bar.js";
  168. const _easycom_u_icon = () => "../u-icon/u-icon.js";
  169. const _easycom_u_safe_bottom = () => "../u-safe-bottom/u-safe-bottom.js";
  170. const _easycom_u_transition = () => "../u-transition/u-transition.js";
  171. if (!Math) {
  172. (_easycom_u_overlay + _easycom_u_status_bar + _easycom_u_icon + _easycom_u_safe_bottom + _easycom_u_transition)();
  173. }
  174. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  175. return common_vendor.e({
  176. a: _ctx.overlay
  177. }, _ctx.overlay ? {
  178. b: common_vendor.o($options.overlayClick),
  179. c: common_vendor.p({
  180. show: _ctx.show,
  181. duration: $data.overlayDuration,
  182. customStyle: _ctx.overlayStyle,
  183. opacity: _ctx.overlayOpacity
  184. })
  185. } : {}, {
  186. d: _ctx.safeAreaInsetTop
  187. }, _ctx.safeAreaInsetTop ? {} : {}, {
  188. e: _ctx.closeable
  189. }, _ctx.closeable ? {
  190. f: common_vendor.p({
  191. name: "close",
  192. color: "#909399",
  193. size: "18",
  194. bold: true
  195. }),
  196. g: common_vendor.o((...args) => $options.close && $options.close(...args)),
  197. h: common_vendor.n("u-popup__content__close--" + _ctx.closeIconPos)
  198. } : {}, {
  199. i: _ctx.safeAreaInsetBottom
  200. }, _ctx.safeAreaInsetBottom ? {} : {}, {
  201. j: common_vendor.s($options.contentStyle),
  202. k: common_vendor.o((...args) => _ctx.noop && _ctx.noop(...args)),
  203. l: common_vendor.o($options.afterEnter),
  204. m: common_vendor.o($options.clickHandler),
  205. n: common_vendor.p({
  206. show: _ctx.show,
  207. customStyle: $options.transitionStyle,
  208. mode: $options.position,
  209. duration: _ctx.duration
  210. })
  211. });
  212. }
  213. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-74921bef"], ["__file", "F:/兴元/开门柜项目/平台端管理系统小程序/node_modules/uview-plus/components/u-popup/u-popup.vue"]]);
  214. wx.createComponent(Component);