From 53cc6f817625897935fb10c3845ad7be400f3036 Mon Sep 17 00:00:00 2001 From: Sanakey <714737083@qq.com> Date: 星期日, 31 一月 2021 20:04:55 +0800 Subject: [PATCH] 团购相关功能 --- src/vant-weapp/index-bar/index.js | 29 ++++++++++++----------------- 1 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/vant-weapp/index-bar/index.js b/src/vant-weapp/index-bar/index.js index 914041a..c092f12 100644 --- a/src/vant-weapp/index-bar/index.js +++ b/src/vant-weapp/index-bar/index.js @@ -1,5 +1,7 @@ -import { VantComponent } from '../common/component'; import { GREEN } from '../common/color'; +import { VantComponent } from '../common/component'; +import { useChildren } from '../common/relation'; +import { getRect } from '../common/utils'; import { pageScrollMixin } from '../mixins/page-scroll'; const indexList = () => { const indexList = []; @@ -10,17 +12,9 @@ return indexList; }; VantComponent({ - relation: { - name: 'index-anchor', - type: 'descendant', - current: 'index-bar', - linked() { - this.updateData(); - }, - unlinked() { - this.updateData(); - }, - }, + relation: useChildren('index-anchor', function () { + this.updateData(); + }), props: { sticky: { type: Boolean, @@ -45,7 +39,8 @@ }, mixins: [ pageScrollMixin(function (event) { - this.scrollTop = event.scrollTop || 0; + this.scrollTop = + (event === null || event === void 0 ? void 0 : event.scrollTop) || 0; this.onScroll(); }), ], @@ -82,7 +77,7 @@ setAnchorsRect() { return Promise.all( this.children.map((anchor) => - anchor.getRect('.van-index-anchor-wrapper').then((rect) => { + getRect(anchor, '.van-index-anchor-wrapper').then((rect) => { Object.assign(anchor, { height: rect.height, top: rect.top + this.scrollTop, @@ -92,7 +87,7 @@ ); }, setListRect() { - return this.getRect('.van-index-bar').then((rect) => { + return getRect(this, '.van-index-bar').then((rect) => { Object.assign(this, { height: rect.height, top: rect.top + this.scrollTop, @@ -100,7 +95,7 @@ }); }, setSiderbarRect() { - return this.getRect('.van-index-bar__sidebar').then((res) => { + return getRect(this, '.van-index-bar__sidebar').then((res) => { this.sidebar = { height: res.height, top: res.top, @@ -119,7 +114,7 @@ } }, getAnchorRect(anchor) { - return anchor.getRect('.van-index-anchor-wrapper').then((rect) => ({ + return getRect(anchor, '.van-index-anchor-wrapper').then((rect) => ({ height: rect.height, top: rect.top, })); -- Gitblit v1.8.0