index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view>
  3. <sell-container ref="sellContainer"></sell-container>
  4. <ActivityHost ref="activityHost" :enable-upsell="false"></ActivityHost>
  5. <policy-consent-host />
  6. </view>
  7. </template>
  8. <script>
  9. import ActivityHost from "@/components/activity-host.vue";
  10. import PolicyConsentHost from "@/components/policy-consent-host.vue";
  11. export default {
  12. components: {
  13. ActivityHost,
  14. PolicyConsentHost,
  15. },
  16. data() {
  17. return {
  18. pendingActivityOptions: {}
  19. }
  20. },
  21. onLoad(options) {
  22. this.pendingActivityOptions = options || {};
  23. },
  24. onReady() {
  25. this.$nextTick(() => {
  26. if (this.hasActivityEntryOptions(this.pendingActivityOptions)) {
  27. this.$refs.activityHost?.handlePageOptions(this.pendingActivityOptions);
  28. }
  29. this.pendingActivityOptions = {};
  30. });
  31. },
  32. onShow() {
  33. this.$updateCartBadge();
  34. },
  35. onShareAppMessage(res) {
  36. return this.$refs.activityHost?.getShareAppMessage(res) || {
  37. title: "书嗨",
  38. path: "/pages/sell/index",
  39. };
  40. },
  41. onShareTimeline(res) {
  42. return this.$refs.activityHost?.getShareTimeline(res) || {
  43. title: "书嗨",
  44. path: "/pages/sell/index",
  45. };
  46. },
  47. onPullDownRefresh() {
  48. if (this.$refs.sellContainer) {
  49. this.$refs.sellContainer.hasShareList();
  50. this.$refs.sellContainer.getIndexCateInfo();
  51. }
  52. setTimeout(() => {
  53. uni.stopPullDownRefresh();
  54. }, 1000);
  55. },
  56. onPageScroll(e) {
  57. const comp = this.$refs.sellContainer;
  58. if (!comp) return;
  59. comp.scrollTop = e.scrollTop;
  60. },
  61. methods: {
  62. hasActivityEntryOptions(options = {}) {
  63. return !!(options.scene || options.reduceCode || options.upsellCode);
  64. }
  65. }
  66. }
  67. </script>
  68. <style>
  69. /* Empty style as content is in the component */
  70. </style>