index.vue 1.5 KB

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