u-button.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "u-button",
  5. mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.button, common_vendor.openType, common_vendor.props$11],
  6. data() {
  7. return {};
  8. },
  9. computed: {
  10. // 生成bem风格的类名
  11. bemClass() {
  12. if (!this.color) {
  13. return this.bem(
  14. "button",
  15. ["type", "shape", "size"],
  16. ["disabled", "plain", "hairline"]
  17. );
  18. } else {
  19. return this.bem(
  20. "button",
  21. ["shape", "size"],
  22. ["disabled", "plain", "hairline"]
  23. );
  24. }
  25. },
  26. loadingColor() {
  27. if (this.plain) {
  28. return this.color ? this.color : common_vendor.index.$u.config.color[`u-${this.type}`];
  29. }
  30. if (this.type === "info") {
  31. return "#c9c9c9";
  32. }
  33. return "rgb(200, 200, 200)";
  34. },
  35. iconColorCom() {
  36. if (this.iconColor)
  37. return this.iconColor;
  38. if (this.plain) {
  39. return this.color ? this.color : this.type;
  40. } else {
  41. return this.type === "info" ? "#000000" : "#ffffff";
  42. }
  43. },
  44. baseColor() {
  45. let style = {};
  46. if (this.color) {
  47. style.color = this.plain ? this.color : "white";
  48. if (!this.plain) {
  49. style["background-color"] = this.color;
  50. }
  51. if (this.color.indexOf("gradient") !== -1) {
  52. style.borderTopWidth = 0;
  53. style.borderRightWidth = 0;
  54. style.borderBottomWidth = 0;
  55. style.borderLeftWidth = 0;
  56. if (!this.plain) {
  57. style.backgroundImage = this.color;
  58. }
  59. } else {
  60. style.borderColor = this.color;
  61. style.borderWidth = "1px";
  62. style.borderStyle = "solid";
  63. }
  64. }
  65. return style;
  66. },
  67. // nvue版本按钮的字体不会继承父组件的颜色,需要对每一个text组件进行单独的设置
  68. nvueTextStyle() {
  69. let style = {};
  70. if (this.type === "info") {
  71. style.color = "#323233";
  72. }
  73. if (this.color) {
  74. style.color = this.plain ? this.color : "white";
  75. }
  76. style.fontSize = this.textSize + "px";
  77. return style;
  78. },
  79. // 字体大小
  80. textSize() {
  81. let fontSize = 14, { size } = this;
  82. if (size === "large")
  83. fontSize = 16;
  84. if (size === "normal")
  85. fontSize = 14;
  86. if (size === "small")
  87. fontSize = 12;
  88. if (size === "mini")
  89. fontSize = 10;
  90. return fontSize;
  91. }
  92. },
  93. emits: [
  94. "click",
  95. "getphonenumber",
  96. "getuserinfo",
  97. "error",
  98. "opensetting",
  99. "launchapp"
  100. ],
  101. methods: {
  102. clickHandler() {
  103. if (!this.disabled && !this.loading) {
  104. common_vendor.index.$u.throttle(() => {
  105. this.$emit("click");
  106. }, this.throttleTime);
  107. }
  108. },
  109. // 下面为对接uniapp官方按钮开放能力事件回调的对接
  110. getphonenumber(res) {
  111. this.$emit("getphonenumber", res);
  112. },
  113. getuserinfo(res) {
  114. this.$emit("getuserinfo", res);
  115. },
  116. error(res) {
  117. this.$emit("error", res);
  118. },
  119. opensetting(res) {
  120. this.$emit("opensetting", res);
  121. },
  122. launchapp(res) {
  123. this.$emit("launchapp", res);
  124. }
  125. }
  126. };
  127. if (!Array) {
  128. const _easycom_u_loading_icon2 = common_vendor.resolveComponent("u-loading-icon");
  129. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  130. (_easycom_u_loading_icon2 + _easycom_u_icon2)();
  131. }
  132. const _easycom_u_loading_icon = () => "../u-loading-icon/u-loading-icon.js";
  133. const _easycom_u_icon = () => "../u-icon/u-icon.js";
  134. if (!Math) {
  135. (_easycom_u_loading_icon + _easycom_u_icon)();
  136. }
  137. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  138. return common_vendor.e({
  139. a: _ctx.loading
  140. }, _ctx.loading ? {
  141. b: common_vendor.p({
  142. mode: _ctx.loadingMode,
  143. size: _ctx.loadingSize * 1.15,
  144. color: $options.loadingColor
  145. }),
  146. c: common_vendor.t(_ctx.loadingText || _ctx.text),
  147. d: common_vendor.s({
  148. fontSize: $options.textSize + "px"
  149. })
  150. } : common_vendor.e({
  151. e: _ctx.icon
  152. }, _ctx.icon ? {
  153. f: common_vendor.p({
  154. name: _ctx.icon,
  155. color: $options.iconColorCom,
  156. size: $options.textSize * 1.35,
  157. customStyle: {
  158. marginRight: "2px"
  159. }
  160. })
  161. } : {}, {
  162. g: common_vendor.t(_ctx.text),
  163. h: common_vendor.s({
  164. fontSize: $options.textSize + "px"
  165. })
  166. }), {
  167. i: Number(_ctx.hoverStartTime),
  168. j: Number(_ctx.hoverStayTime),
  169. k: _ctx.formType,
  170. l: _ctx.openType,
  171. m: _ctx.appParameter,
  172. n: _ctx.hoverStopPropagation,
  173. o: _ctx.sendMessageTitle,
  174. p: _ctx.sendMessagePath,
  175. q: _ctx.lang,
  176. r: _ctx.dataName,
  177. s: _ctx.sessionFrom,
  178. t: _ctx.sendMessageImg,
  179. v: _ctx.showMessageCard,
  180. w: common_vendor.o((...args) => $options.getphonenumber && $options.getphonenumber(...args)),
  181. x: common_vendor.o((...args) => $options.getuserinfo && $options.getuserinfo(...args)),
  182. y: common_vendor.o((...args) => $options.error && $options.error(...args)),
  183. z: common_vendor.o((...args) => $options.opensetting && $options.opensetting(...args)),
  184. A: common_vendor.o((...args) => $options.launchapp && $options.launchapp(...args)),
  185. B: !_ctx.disabled && !_ctx.loading ? "u-button--active" : "",
  186. C: common_vendor.s($options.baseColor),
  187. D: common_vendor.s(_ctx.$u.addStyle(_ctx.customStyle)),
  188. E: common_vendor.o((...args) => $options.clickHandler && $options.clickHandler(...args)),
  189. F: common_vendor.n($options.bemClass)
  190. });
  191. }
  192. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-461e713c"], ["__file", "D:/project/赋强公证/notarization_applet/node_modules/uview-plus/components/u-button/u-button.vue"]]);
  193. wx.createComponent(Component);