u-popup.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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$6],
  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.deepMerge(style, {
  29. bottom: 0,
  30. top: 0
  31. });
  32. } else if (this.mode === "right") {
  33. return common_vendor.deepMerge(style, {
  34. bottom: 0,
  35. top: 0
  36. });
  37. } else if (this.mode === "top") {
  38. return common_vendor.deepMerge(style, {
  39. left: 0,
  40. right: 0
  41. });
  42. } else if (this.mode === "bottom") {
  43. return common_vendor.deepMerge(style, {
  44. left: 0,
  45. right: 0
  46. });
  47. } else if (this.mode === "center") {
  48. return common_vendor.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.getWindowInfo();
  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.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.deepMerge(style, common_vendor.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. emits: ["open", "close", "click", "update:show"],
  100. methods: {
  101. // 点击遮罩
  102. overlayClick() {
  103. if (this.closeOnClickOverlay) {
  104. this.$emit("update:show", false);
  105. this.$emit("close");
  106. }
  107. },
  108. open(e) {
  109. this.$emit("update:show", true);
  110. },
  111. close(e) {
  112. this.$emit("update:show", false);
  113. this.$emit("close");
  114. },
  115. afterEnter() {
  116. this.$emit("open");
  117. },
  118. clickHandler() {
  119. if (this.mode === "center") {
  120. this.overlayClick();
  121. }
  122. this.$emit("click");
  123. },
  124. retryComputedComponentRect(children) {
  125. const names = [
  126. "u-calendar-month",
  127. "u-album",
  128. "u-collapse-item",
  129. "u-dropdown",
  130. "u-index-item",
  131. "u-index-list",
  132. "u-line-progress",
  133. "u-list-item",
  134. "u-rate",
  135. "u-read-more",
  136. "u-row",
  137. "u-row-notice",
  138. "u-scroll-list",
  139. "u-skeleton",
  140. "u-slider",
  141. "u-steps-item",
  142. "u-sticky",
  143. "u-subsection",
  144. "u-swipe-action-item",
  145. "u-tabbar",
  146. "u-tabs",
  147. "u-tooltip"
  148. ];
  149. for (let i = 0; i < children.length; i++) {
  150. const child = children[i];
  151. const grandChild = child.$children;
  152. if (names.includes(child.$options.name) && typeof (child == null ? void 0 : child.init) === "function") {
  153. common_vendor.sleep(50).then(() => {
  154. child.init();
  155. });
  156. }
  157. if (grandChild.length) {
  158. this.retryComputedComponentRect(grandChild);
  159. }
  160. }
  161. }
  162. }
  163. };
  164. if (!Array) {
  165. const _easycom_u_overlay2 = common_vendor.resolveComponent("u-overlay");
  166. const _easycom_u_status_bar2 = common_vendor.resolveComponent("u-status-bar");
  167. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  168. const _easycom_u_safe_bottom2 = common_vendor.resolveComponent("u-safe-bottom");
  169. const _easycom_u_transition2 = common_vendor.resolveComponent("u-transition");
  170. (_easycom_u_overlay2 + _easycom_u_status_bar2 + _easycom_u_icon2 + _easycom_u_safe_bottom2 + _easycom_u_transition2)();
  171. }
  172. const _easycom_u_overlay = () => "../u-overlay/u-overlay.js";
  173. const _easycom_u_status_bar = () => "../u-status-bar/u-status-bar.js";
  174. const _easycom_u_icon = () => "../u-icon/u-icon.js";
  175. const _easycom_u_safe_bottom = () => "../u-safe-bottom/u-safe-bottom.js";
  176. const _easycom_u_transition = () => "../u-transition/u-transition.js";
  177. if (!Math) {
  178. (_easycom_u_overlay + _easycom_u_status_bar + _easycom_u_icon + _easycom_u_safe_bottom + _easycom_u_transition)();
  179. }
  180. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  181. return common_vendor.e({
  182. a: common_vendor.o((...args) => $options.open && $options.open(...args)),
  183. b: _ctx.overlay
  184. }, _ctx.overlay ? {
  185. c: common_vendor.o($options.overlayClick),
  186. d: common_vendor.p({
  187. show: _ctx.show,
  188. zIndex: _ctx.zIndex,
  189. duration: $data.overlayDuration,
  190. customStyle: _ctx.overlayStyle,
  191. opacity: _ctx.overlayOpacity
  192. })
  193. } : {}, {
  194. e: _ctx.safeAreaInsetTop
  195. }, _ctx.safeAreaInsetTop ? {} : {}, {
  196. f: _ctx.closeable
  197. }, _ctx.closeable ? {
  198. g: common_vendor.p({
  199. name: "close",
  200. color: "#909399",
  201. size: "18",
  202. bold: true
  203. }),
  204. h: common_vendor.o((...args) => $options.close && $options.close(...args)),
  205. i: common_vendor.n("u-popup__content__close--" + _ctx.closeIconPos)
  206. } : {}, {
  207. j: _ctx.safeAreaInsetBottom
  208. }, _ctx.safeAreaInsetBottom ? {} : {}, {
  209. k: common_vendor.s($options.contentStyle),
  210. l: common_vendor.o((...args) => _ctx.noop && _ctx.noop(...args)),
  211. m: common_vendor.o((...args) => _ctx.noop && _ctx.noop(...args)),
  212. n: common_vendor.o($options.afterEnter),
  213. o: common_vendor.o($options.clickHandler),
  214. p: common_vendor.p({
  215. show: _ctx.show,
  216. customStyle: $options.transitionStyle,
  217. mode: $options.position,
  218. duration: _ctx.duration
  219. }),
  220. q: common_vendor.n(_ctx.customClass)
  221. });
  222. }
  223. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-74921bef"], ["__file", "C:/Users/Administrator/Desktop/srcaaa/node_modules/uview-plus/components/u-popup/u-popup.vue"]]);
  224. wx.createComponent(Component);