custom-navbar.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const customStatusBar = () => "./custom-statusbar.js";
  4. const getVal = (val) => typeof val === "number" ? val + "px" : val;
  5. const _sfc_main = {
  6. name: "CustomNavBar",
  7. components: {
  8. customStatusBar
  9. },
  10. emits: ["clickLeft", "clickRight", "clickTitle"],
  11. props: {
  12. dark: {
  13. type: Boolean,
  14. default: false
  15. },
  16. title: {
  17. type: String,
  18. default: ""
  19. },
  20. leftText: {
  21. type: String,
  22. default: ""
  23. },
  24. rightText: {
  25. type: String,
  26. default: ""
  27. },
  28. leftIcon: {
  29. type: String,
  30. default: ""
  31. },
  32. rightIcon: {
  33. type: String,
  34. default: ""
  35. },
  36. fixed: {
  37. type: [Boolean, String],
  38. default: false
  39. },
  40. color: {
  41. type: String,
  42. default: ""
  43. },
  44. backgroundColor: {
  45. type: String,
  46. default: ""
  47. },
  48. statusBar: {
  49. type: [Boolean, String],
  50. default: false
  51. },
  52. shadow: {
  53. type: [Boolean, String],
  54. default: false
  55. },
  56. border: {
  57. type: [Boolean, String],
  58. default: true
  59. },
  60. height: {
  61. type: [Number, String],
  62. default: 44
  63. },
  64. leftWidth: {
  65. type: [Number, String],
  66. default: 60
  67. },
  68. rightWidth: {
  69. type: [Number, String],
  70. default: 60
  71. },
  72. titleFontSize: {
  73. type: [Number, String],
  74. default: 17
  75. },
  76. leftTitleFontSize: {
  77. type: [Number, String],
  78. default: 12
  79. },
  80. customClickLeft: {
  81. type: [Boolean, String],
  82. default: false
  83. }
  84. },
  85. computed: {
  86. themeBgColor() {
  87. if (this.dark) {
  88. if (this.backgroundColor) {
  89. return this.backgroundColor;
  90. } else {
  91. return this.dark ? "#333" : "#FFF";
  92. }
  93. }
  94. return this.backgroundColor || "#FFF";
  95. },
  96. themeColor() {
  97. if (this.dark) {
  98. if (this.color) {
  99. return this.color;
  100. } else {
  101. return this.dark ? "#fff" : "#333";
  102. }
  103. }
  104. return this.color || "#333";
  105. },
  106. navbarHeight() {
  107. return getVal(this.height);
  108. },
  109. leftIconWidth() {
  110. return getVal(this.leftWidth);
  111. },
  112. rightIconWidth() {
  113. return getVal(this.rightWidth);
  114. },
  115. isCustomClickLeft() {
  116. return getVal(this.customClickLeft);
  117. }
  118. },
  119. mounted() {
  120. if (common_vendor.index.report && this.title !== "") {
  121. common_vendor.index.report("title", this.title);
  122. }
  123. },
  124. methods: {
  125. onClickLeft() {
  126. if (this.isCustomClickLeft == false) {
  127. common_vendor.index.navigateBack();
  128. }
  129. this.$emit("clickLeft");
  130. },
  131. onClickRight() {
  132. this.$emit("clickRight");
  133. },
  134. onClickTitle() {
  135. this.$emit("clickTitle");
  136. }
  137. }
  138. };
  139. if (!Array) {
  140. const _component_customStatusBar = common_vendor.resolveComponent("customStatusBar");
  141. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  142. (_component_customStatusBar + _easycom_uni_icons2)();
  143. }
  144. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  145. if (!Math) {
  146. _easycom_uni_icons();
  147. }
  148. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  149. return common_vendor.e({
  150. a: $props.statusBar
  151. }, $props.statusBar ? {} : {}, {
  152. b: $props.leftIcon.length > 0
  153. }, $props.leftIcon.length > 0 ? {
  154. c: common_vendor.p({
  155. color: $options.themeColor,
  156. type: $props.leftIcon,
  157. size: "20"
  158. })
  159. } : {}, {
  160. d: $props.leftText.length
  161. }, $props.leftText.length ? {
  162. e: common_vendor.t($props.leftText),
  163. f: $options.themeColor,
  164. g: $props.leftTitleFontSize + "px",
  165. h: !$props.leftIcon.length > 0 ? 1 : ""
  166. } : {}, {
  167. i: common_vendor.o((...args) => $options.onClickLeft && $options.onClickLeft(...args)),
  168. j: $options.leftIconWidth,
  169. k: $props.title.length > 0
  170. }, $props.title.length > 0 ? {
  171. l: common_vendor.t($props.title),
  172. m: $options.themeColor,
  173. n: $props.titleFontSize + "px"
  174. } : {}, {
  175. o: common_vendor.o((...args) => $options.onClickTitle && $options.onClickTitle(...args)),
  176. p: $props.rightIcon.length
  177. }, $props.rightIcon.length ? {
  178. q: common_vendor.p({
  179. color: $options.themeColor,
  180. type: $props.rightIcon,
  181. size: "22"
  182. })
  183. } : {}, {
  184. r: $props.rightText.length && !$props.rightIcon.length
  185. }, $props.rightText.length && !$props.rightIcon.length ? {
  186. s: common_vendor.t($props.rightText),
  187. t: $options.themeColor
  188. } : {}, {
  189. v: common_vendor.o((...args) => $options.onClickRight && $options.onClickRight(...args)),
  190. w: $options.rightIconWidth,
  191. x: $options.themeColor,
  192. y: $options.themeBgColor,
  193. z: $options.navbarHeight,
  194. A: $props.fixed ? 1 : "",
  195. B: $props.shadow ? 1 : "",
  196. C: $props.border ? 1 : "",
  197. D: $options.themeBgColor,
  198. E: $props.fixed
  199. }, $props.fixed ? common_vendor.e({
  200. F: $props.statusBar
  201. }, $props.statusBar ? {} : {}, {
  202. G: $options.navbarHeight
  203. }) : {}, {
  204. H: $props.dark ? 1 : ""
  205. });
  206. }
  207. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-94e9cc56"], ["__file", "/Users/xy/Desktop/uni_app_project/xs/xs-app/components/custom-navbar/custom-navbar.vue"]]);
  208. tt.createComponent(Component);