detail-navbar.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const sheep_index = require("../../../../sheep/index.js");
  4. const sheep_helper_throttle = require("../../../../sheep/helper/throttle.js");
  5. const sheep_hooks_useModal = require("../../../../sheep/hooks/useModal.js");
  6. require("../../../../sheep/url/index.js");
  7. require("../../../../sheep/store/index.js");
  8. require("../../../../sheep/store/app.js");
  9. require("../../../../sheep/api/promotion/diy.js");
  10. require("../../../../sheep/request/index.js");
  11. require("../../../../sheep/config/index.js");
  12. require("../../../../sheep/platform/index.js");
  13. require("../../../../sheep/platform/provider/wechat/index.js");
  14. require("../../../../sheep/platform/provider/wechat/miniProgram.js");
  15. require("../../../../sheep/api/member/auth.js");
  16. require("../../../../sheep/api/member/social.js");
  17. require("../../../../sheep/api/member/user.js");
  18. require("../../../../sheep/platform/provider/apple/index.js");
  19. require("../../../../sheep/platform/share.js");
  20. require("../../../../sheep/router/index.js");
  21. require("../../../../sheep/platform/pay.js");
  22. require("../../../../sheep/helper/index.js");
  23. require("../../../../sheep/helper/test.js");
  24. require("../../../../sheep/helper/digit.js");
  25. require("../../../../sheep/api/pay/order.js");
  26. require("../../../../sheep/store/user.js");
  27. require("../../../../sheep/store/cart.js");
  28. require("../../../../sheep/api/trade/cart.js");
  29. require("../../../../sheep/api/pay/wallet.js");
  30. require("../../../../sheep/api/trade/order.js");
  31. require("../../../../sheep/api/promotion/coupon.js");
  32. require("../../../../sheep/store/sys.js");
  33. require("../../../../sheep/store/modal.js");
  34. require("../../../../sheep/config/zIndex.js");
  35. if (!Array) {
  36. const _easycom_su_status_bar2 = common_vendor.resolveComponent("su-status-bar");
  37. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  38. (_easycom_su_status_bar2 + _easycom_su_fixed2)();
  39. }
  40. const _easycom_su_status_bar = () => "../../../../sheep/ui/su-status-bar/su-status-bar.js";
  41. const _easycom_su_fixed = () => "../../../../sheep/ui/su-fixed/su-fixed.js";
  42. if (!Math) {
  43. (_easycom_su_status_bar + _easycom_su_fixed)();
  44. }
  45. const _sfc_main = {
  46. __name: "detail-navbar",
  47. emits: ["clickLeft"],
  48. setup(__props, { emit: emits }) {
  49. const sys_statusBar = sheep_index.sheep.$platform.device.statusBarHeight;
  50. const sys_navBar = sheep_index.sheep.$platform.navbar;
  51. const capsuleStyle = {
  52. width: sheep_index.sheep.$platform.capsule.width + "px",
  53. height: sheep_index.sheep.$platform.capsule.height + "px"
  54. };
  55. const state = common_vendor.reactive({
  56. tabOpacityVal: 0,
  57. curTab: "goods",
  58. tabList: [
  59. {
  60. label: "商品",
  61. value: "goods",
  62. to: "detail-swiper-selector"
  63. },
  64. {
  65. label: "评价",
  66. value: "comment",
  67. to: "detail-comment-selector"
  68. },
  69. {
  70. label: "详情",
  71. value: "detail",
  72. to: "detail-content-selector"
  73. }
  74. ]
  75. });
  76. const hasHistory = sheep_index.sheep.$router.hasHistory();
  77. function onClickLeft() {
  78. if (hasHistory) {
  79. sheep_index.sheep.$router.back();
  80. } else {
  81. sheep_index.sheep.$router.go("/pages/index/index");
  82. }
  83. emits("clickLeft");
  84. }
  85. function onClickRight() {
  86. sheep_hooks_useModal.showMenuTools();
  87. }
  88. let commentCard = {
  89. top: 0,
  90. bottom: 0
  91. };
  92. function getCommentCardNode() {
  93. return new Promise((res, rej) => {
  94. common_vendor.index.createSelectorQuery().select(".detail-comment-selector").boundingClientRect((data) => {
  95. if (data) {
  96. commentCard.top = data.top;
  97. commentCard.bottom = data.top + data.height;
  98. res(data);
  99. } else {
  100. res(null);
  101. }
  102. }).exec();
  103. });
  104. }
  105. function onTab(tab) {
  106. let scrollTop = 0;
  107. if (tab.value === "comment") {
  108. scrollTop = commentCard.top - sys_navBar + 1;
  109. } else if (tab.value === "detail") {
  110. scrollTop = commentCard.bottom - sys_navBar + 1;
  111. }
  112. common_vendor.index.pageScrollTo({
  113. scrollTop,
  114. duration: 200
  115. });
  116. }
  117. common_vendor.onPageScroll((e) => {
  118. state.tabOpacityVal = e.scrollTop > sheep_index.sheep.$platform.navbar ? 1 : e.scrollTop * 0.01;
  119. if (commentCard.top === 0) {
  120. sheep_helper_throttle.throttle(() => {
  121. getCommentCardNode();
  122. }, 50);
  123. }
  124. if (e.scrollTop < commentCard.top - sys_navBar) {
  125. state.curTab = "goods";
  126. } else if (e.scrollTop >= commentCard.top - sys_navBar && e.scrollTop <= commentCard.bottom - sys_navBar) {
  127. state.curTab = "comment";
  128. } else {
  129. state.curTab = "detail";
  130. }
  131. });
  132. return (_ctx, _cache) => {
  133. return common_vendor.e({
  134. a: common_vendor.unref(hasHistory)
  135. }, common_vendor.unref(hasHistory) ? {} : {}, {
  136. b: common_vendor.o(onClickLeft),
  137. c: common_vendor.o(onClickRight),
  138. d: common_vendor.f(state.tabList, (item, k0, i0) => {
  139. return {
  140. a: common_vendor.t(item.label),
  141. b: common_vendor.n(state.curTab === item.value ? "cur-tab-title" : ""),
  142. c: state.curTab === item.value,
  143. d: item.value,
  144. e: common_vendor.o(($event) => onTab(item), item.value)
  145. };
  146. }),
  147. e: common_vendor.s({
  148. opacity: state.tabOpacityVal
  149. }),
  150. f: common_vendor.s(capsuleStyle),
  151. g: common_vendor.s({
  152. height: common_vendor.unref(sys_navBar) - common_vendor.unref(sys_statusBar) + "px"
  153. }),
  154. h: common_vendor.p({
  155. alway: true,
  156. bgStyles: {
  157. background: "#fff"
  158. },
  159. val: 0,
  160. noNav: true,
  161. opacity: true,
  162. placeholder: false
  163. })
  164. });
  165. };
  166. }
  167. };
  168. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3e9ea950"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/goods/components/detail/detail-navbar.vue"]]);
  169. wx.createComponent(Component);