su-fixed.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../index.js");
  4. require("../../api/index.js");
  5. require("../../api/distri/score.js");
  6. require("../../request/index.js");
  7. require("../../config/index.js");
  8. require("../../store/index.js");
  9. require("../../store/app.js");
  10. require("../../api/promotion/diy.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("../../hooks/useModal.js");
  21. require("../../helper/index.js");
  22. require("../../helper/test.js");
  23. require("../../helper/digit.js");
  24. require("../../api/member/signin.js");
  25. require("../../helper/throttle.js");
  26. require("../../url/index.js");
  27. require("../../platform/pay.js");
  28. require("../../api/pay/order.js");
  29. require("../../store/user.js");
  30. require("../../store/cart.js");
  31. require("../../api/trade/cart.js");
  32. require("../../api/pay/wallet.js");
  33. require("../../api/trade/order.js");
  34. require("../../api/promotion/coupon.js");
  35. require("../../store/sys.js");
  36. require("../../store/modal.js");
  37. require("../../api/distri/share.js");
  38. require("../../api/distri/team.js");
  39. require("../../api/infra/file.js");
  40. require("../../api/member/address.js");
  41. require("../../api/member/point.js");
  42. require("../../api/migration/app.js");
  43. require("../../api/migration/chat.js");
  44. require("../../api/migration/index.js");
  45. require("../../api/migration/third.js");
  46. require("../../api/pay/channel.js");
  47. require("../../api/product/category.js");
  48. require("../../api/product/comment.js");
  49. require("../../api/product/favorite.js");
  50. require("../../api/product/history.js");
  51. require("../../api/product/spu.js");
  52. require("../../api/promotion/activity.js");
  53. require("../../api/promotion/article.js");
  54. require("../../api/promotion/bargain.js");
  55. require("../../api/promotion/combination.js");
  56. require("../../api/promotion/rewardActivity.js");
  57. require("../../api/promotion/seckill.js");
  58. require("../../api/system/area.js");
  59. require("../../api/system/voice.js");
  60. require("../../api/trade/afterSale.js");
  61. require("../../api/trade/brokerage.js");
  62. require("../../api/trade/config.js");
  63. require("../../api/trade/delivery.js");
  64. require("../../config/zIndex.js");
  65. const _sfc_main = {
  66. __name: "su-fixed",
  67. props: {
  68. noNav: {
  69. type: Boolean,
  70. default: false
  71. },
  72. bottom: {
  73. type: Boolean,
  74. default: false
  75. },
  76. bg: {
  77. type: String,
  78. default: ""
  79. },
  80. bgStyles: {
  81. type: Object,
  82. default() {
  83. }
  84. },
  85. val: {
  86. type: Number,
  87. default: 0
  88. },
  89. width: {
  90. type: [String, Number],
  91. default: 0
  92. },
  93. alway: {
  94. type: Boolean,
  95. default: true
  96. },
  97. opacity: {
  98. type: Boolean,
  99. default: false
  100. },
  101. index: {
  102. type: [Number, String],
  103. default: 0
  104. },
  105. placeholder: {
  106. type: [Boolean],
  107. default: false
  108. },
  109. sticky: {
  110. type: [Boolean],
  111. default: false
  112. },
  113. noFixed: {
  114. type: Boolean,
  115. default: false
  116. },
  117. ui: {
  118. type: String,
  119. default: ""
  120. },
  121. clickTo: {
  122. type: Boolean,
  123. default: false
  124. },
  125. //是否需要安全区
  126. isInset: {
  127. type: Boolean,
  128. default: true
  129. }
  130. },
  131. setup(__props) {
  132. const { safeAreaInsets } = sheep_index.sheep.$platform.device;
  133. const vm = common_vendor.getCurrentInstance();
  134. const uuid = sheep_index.sheep.$helper.guid();
  135. const sys_navBar = sheep_index.sheep.$platform.navbar;
  136. const state = common_vendor.reactive({
  137. content: {},
  138. fixed: true,
  139. scrollTop: 0,
  140. opacityVal: 0
  141. });
  142. const insetHeight = common_vendor.computed(() => {
  143. if (state.fixed && props.bottom) {
  144. if (props.isInset) {
  145. return props.val + "px";
  146. } else {
  147. return props.val + safeAreaInsets.bottom + "px";
  148. }
  149. } else {
  150. return "auto";
  151. }
  152. });
  153. const props = __props;
  154. state.fixed = !common_vendor.unref(props.sticky);
  155. common_vendor.onPageScroll((e) => {
  156. let top = e.scrollTop;
  157. state.scrollTop = top;
  158. state.opacityVal = top > sheep_index.sheep.$platform.navbar ? 1 : top * 0.01;
  159. });
  160. common_vendor.onMounted(() => {
  161. common_vendor.nextTick$1(() => {
  162. computedQuery();
  163. });
  164. });
  165. const computedQuery = () => {
  166. common_vendor.index.createSelectorQuery().in(vm).select(`#fixed-${uuid}`).boundingClientRect((data) => {
  167. if (data != null) {
  168. state.content = data;
  169. if (common_vendor.unref(props.sticky)) {
  170. setFixed(state.scrollTop);
  171. }
  172. }
  173. }).exec();
  174. };
  175. const setFixed = (value) => {
  176. if (common_vendor.unref(props.bottom)) {
  177. state.fixed = value >= state.content.bottom - sheep_index.sheep.$platform.device.windowHeight + state.content.height + common_vendor.unref(props.val);
  178. } else {
  179. state.fixed = value >= state.content.top - (common_vendor.unref(props.noNav) ? common_vendor.unref(props.val) : common_vendor.unref(props.val) + sheep_index.sheep.$platform.navbar);
  180. }
  181. };
  182. const toTop = () => {
  183. if (props.hasToTop) {
  184. common_vendor.index.pageScrollTo({
  185. scrollTop: state.content.top,
  186. duration: 100
  187. });
  188. }
  189. };
  190. return (_ctx, _cache) => {
  191. return common_vendor.e({
  192. a: common_vendor.unref(safeAreaInsets).bottom && __props.bottom && __props.isInset
  193. }, common_vendor.unref(safeAreaInsets).bottom && __props.bottom && __props.isInset ? {
  194. b: common_vendor.s({
  195. height: common_vendor.unref(safeAreaInsets).bottom + "px"
  196. })
  197. } : {}, {
  198. c: common_vendor.o(toTop),
  199. d: common_vendor.s({
  200. zIndex: __props.index + common_vendor.unref(sheep_index.sheep).$zIndex.navbar
  201. }),
  202. e: __props.bottom
  203. }, __props.bottom ? {
  204. f: common_vendor.n(__props.bg)
  205. } : {}, {
  206. g: common_vendor.n(__props.ui),
  207. h: common_vendor.n(__props.bg),
  208. i: common_vendor.s({
  209. zIndex: __props.index + common_vendor.unref(sheep_index.sheep).$zIndex.navbar - 1
  210. }),
  211. j: common_vendor.s(__props.bgStyles),
  212. k: common_vendor.s(__props.opacity ? {
  213. opacity: state.opacityVal
  214. } : ""),
  215. l: `fixed-${common_vendor.unref(uuid)}`,
  216. m: common_vendor.n({
  217. fixed: state.fixed
  218. }),
  219. n: common_vendor.s({
  220. left: __props.sticky ? "auto" : "0px",
  221. top: state.fixed && !__props.bottom ? (__props.noNav ? __props.val : __props.val + common_vendor.unref(sys_navBar)) + "px" : "auto",
  222. bottom: insetHeight.value,
  223. zIndex: __props.index + common_vendor.unref(sheep_index.sheep).$zIndex.navbar
  224. }),
  225. o: common_vendor.s(!__props.alway ? {
  226. opacity: state.opacityVal
  227. } : ""),
  228. p: __props.sticky ? state.fixed : __props.placeholder && state.fixed
  229. }, (__props.sticky ? state.fixed : __props.placeholder && state.fixed) ? {
  230. q: common_vendor.s({
  231. height: state.content.height + "px",
  232. width: __props.width + "px"
  233. })
  234. } : {});
  235. };
  236. }
  237. };
  238. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/zx/mall-front-app/sheep/ui/su-fixed/su-fixed.vue"]]);
  239. wx.createComponent(Component);