s-custom-navbar.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../index.js");
  4. const sheep_hooks_useModal = require("../../hooks/useModal.js");
  5. require("../../url/index.js");
  6. require("../../store/index.js");
  7. require("../../store/app.js");
  8. require("../../api/promotion/diy.js");
  9. require("../../request/index.js");
  10. require("../../config/index.js");
  11. require("../../platform/index.js");
  12. require("../../platform/provider/wechat/index.js");
  13. require("../../platform/provider/wechat/miniProgram.js");
  14. require("../../api/member/auth.js");
  15. require("../../api/member/social.js");
  16. require("../../api/member/user.js");
  17. require("../../platform/provider/apple/index.js");
  18. require("../../platform/share.js");
  19. require("../../router/index.js");
  20. require("../../helper/throttle.js");
  21. require("../../platform/pay.js");
  22. require("../../helper/index.js");
  23. require("../../helper/test.js");
  24. require("../../helper/digit.js");
  25. require("../../api/pay/order.js");
  26. require("../../store/user.js");
  27. require("../../store/cart.js");
  28. require("../../api/trade/cart.js");
  29. require("../../api/pay/wallet.js");
  30. require("../../api/trade/order.js");
  31. require("../../api/promotion/coupon.js");
  32. require("../../store/sys.js");
  33. require("../../store/modal.js");
  34. require("../../config/zIndex.js");
  35. if (!Math) {
  36. (NavbarItem + Navbar)();
  37. }
  38. const Navbar = () => "./components/navbar.js";
  39. const NavbarItem = () => "./components/navbar-item.js";
  40. const _sfc_main = {
  41. __name: "s-custom-navbar",
  42. props: {
  43. data: {
  44. type: Object,
  45. default: () => ({})
  46. },
  47. showLeftButton: {
  48. type: Boolean,
  49. default: false
  50. }
  51. },
  52. setup(__props) {
  53. const props = __props;
  54. const hasHistory = sheep_index.sheep.$router.hasHistory();
  55. const sticky = common_vendor.computed(() => {
  56. if (props.data.mode == "inner") {
  57. if (props.data.alway) {
  58. return false;
  59. }
  60. }
  61. if (props.data.mode == "normal") {
  62. return false;
  63. }
  64. });
  65. const navList = common_vendor.computed(() => {
  66. if (!props.data.list)
  67. return [];
  68. return props.data.list.mp;
  69. });
  70. const windowWidth = sheep_index.sheep.$platform.device.windowWidth;
  71. const cell = common_vendor.computed(() => {
  72. if (common_vendor.unref(navList).length) {
  73. let cell2 = (windowWidth - 90) / 8;
  74. cell2 = (windowWidth - 80 - common_vendor.unref(sheep_index.sheep.$platform.capsule).width) / 6;
  75. return cell2;
  76. }
  77. });
  78. const parseImgStyle = (item) => {
  79. let obj = {
  80. width: item.width * cell.value + (item.width - 1) * 10 + "px",
  81. left: item.left * cell.value + (item.left + 1) * 10 + "px",
  82. "border-radius": item.borderRadius + "px"
  83. };
  84. return obj;
  85. };
  86. const isAlway = common_vendor.computed(
  87. () => props.data.mode === "inner" ? Boolean(props.data.alwaysShow) : true
  88. );
  89. const isOpacity = common_vendor.computed(
  90. () => props.data.mode === "normal" ? false : props.showLeftButton ? false : props.data.mode === "inner"
  91. );
  92. const isPlaceholder = common_vendor.computed(() => props.data.mode === "normal");
  93. const bgStyles = common_vendor.computed(() => {
  94. if (props.data.type) {
  95. return {
  96. background: props.data.type == "color" ? props.data.color : `url(${sheep_index.sheep.$url.cdn(props.data.src)}) no-repeat top center / 100% 100%`
  97. };
  98. }
  99. });
  100. function onClickLeft() {
  101. if (hasHistory) {
  102. sheep_index.sheep.$router.back();
  103. } else {
  104. sheep_index.sheep.$router.go("/pages/index/index");
  105. }
  106. }
  107. function onClickRight() {
  108. sheep_hooks_useModal.showMenuTools();
  109. }
  110. return (_ctx, _cache) => {
  111. return common_vendor.e({
  112. a: __props.showLeftButton
  113. }, __props.showLeftButton ? common_vendor.e({
  114. b: common_vendor.unref(hasHistory)
  115. }, common_vendor.unref(hasHistory) ? {} : {}, {
  116. c: common_vendor.o(onClickLeft),
  117. d: common_vendor.o(onClickRight),
  118. e: __props.data.mode == "inner" ? 1 : ""
  119. }) : {}, {
  120. f: common_vendor.f(common_vendor.unref(navList), (item, index, i0) => {
  121. return {
  122. a: "6417c6b5-1-" + i0 + ",6417c6b5-0",
  123. b: common_vendor.p({
  124. data: item,
  125. width: parseImgStyle(item).width
  126. }),
  127. c: index,
  128. d: common_vendor.s(parseImgStyle(item)),
  129. e: common_vendor.n({
  130. "ss-flex ss-col-center ss-row-center": item.type !== "search"
  131. })
  132. };
  133. }),
  134. g: common_vendor.p({
  135. alway: common_vendor.unref(isAlway),
  136. back: false,
  137. bg: "",
  138. placeholder: common_vendor.unref(isPlaceholder),
  139. bgStyles: common_vendor.unref(bgStyles),
  140. opacity: common_vendor.unref(isOpacity),
  141. sticky: common_vendor.unref(sticky)
  142. })
  143. });
  144. };
  145. }
  146. };
  147. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6417c6b5"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/components/s-custom-navbar/s-custom-navbar.vue"]]);
  148. wx.createComponent(Component);