|
@@ -1,120 +1,112 @@
|
|
import { prefixPagePath } from "../../../../core/utils";
|
|
import { prefixPagePath } from "../../../../core/utils";
|
|
-import { createSubscribe } from 'applet-page-component';
|
|
|
|
-import { reportCmPV_YL } from '../../utils/cloudMonitorHelper';
|
|
|
|
|
|
+import { createSubscribe } from "applet-page-component";
|
|
|
|
+import { reportCmPV_YL } from "../../utils/cloudMonitorHelper";
|
|
const app = getApp();
|
|
const app = getApp();
|
|
|
|
|
|
-const getRect = id => new Promise(resolve => {
|
|
|
|
- my.createSelectorQuery().select(`#${id}`).boundingClientRect().exec(resolve);
|
|
|
|
-});
|
|
|
|
|
|
+const getRect = (id) =>
|
|
|
|
+ new Promise((resolve) => {
|
|
|
|
+ my.createSelectorQuery()
|
|
|
|
+ .select(`#${id}`)
|
|
|
|
+ .boundingClientRect()
|
|
|
|
+ .exec(resolve);
|
|
|
|
+ });
|
|
|
|
|
|
-const getExtInfo = item => {
|
|
|
|
- const {
|
|
|
|
- componentExtInfo
|
|
|
|
- } = item;
|
|
|
|
- return componentExtInfo;
|
|
|
|
|
|
+const getExtInfo = (item) => {
|
|
|
|
+ const { componentExtInfo } = item;
|
|
|
|
+ return componentExtInfo;
|
|
};
|
|
};
|
|
|
|
|
|
-Component(createSubscribe({
|
|
|
|
- // eslint-disable-next-line no-unused-vars
|
|
|
|
- async onPageScroll(_, {
|
|
|
|
- scrollTop
|
|
|
|
- }) {
|
|
|
|
- const {
|
|
|
|
- id,
|
|
|
|
- isScrollOver
|
|
|
|
- } = this.data;
|
|
|
|
- let contentHeight = 0;
|
|
|
|
|
|
+Component(
|
|
|
|
+ createSubscribe({
|
|
|
|
+ // eslint-disable-next-line no-unused-vars
|
|
|
|
+ async onPageScroll(_, { scrollTop }) {
|
|
|
|
+ const { id, isScrollOver } = this.data;
|
|
|
|
+ let contentHeight = 0;
|
|
|
|
|
|
- if (this.contentHeight) {
|
|
|
|
- // eslint-disable-next-line prefer-destructuring
|
|
|
|
- contentHeight = this.contentHeight;
|
|
|
|
- } else {
|
|
|
|
- const res = await getRect(id);
|
|
|
|
- const [rect] = res;
|
|
|
|
- const {
|
|
|
|
- height = 0
|
|
|
|
- } = rect || {};
|
|
|
|
- contentHeight = height;
|
|
|
|
- }
|
|
|
|
- /* 这里动态设置标题栏 */
|
|
|
|
|
|
+ if (this.contentHeight) {
|
|
|
|
+ // eslint-disable-next-line prefer-destructuring
|
|
|
|
+ contentHeight = this.contentHeight;
|
|
|
|
+ } else {
|
|
|
|
+ const res = await getRect(id);
|
|
|
|
+ const [rect] = res;
|
|
|
|
+ const { height = 0 } = rect || {};
|
|
|
|
+ contentHeight = height;
|
|
|
|
+ }
|
|
|
|
+ /* 这里动态设置标题栏 */
|
|
|
|
|
|
|
|
+ if (scrollTop > contentHeight) {
|
|
|
|
+ if (!isScrollOver) {
|
|
|
|
+ const { componentData } = this.props;
|
|
|
|
+ const { title } = getExtInfo(componentData);
|
|
|
|
+ my.setNavigationBar({
|
|
|
|
+ title,
|
|
|
|
+ });
|
|
|
|
+ this.setData({
|
|
|
|
+ isScrollOver: true,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else if (isScrollOver) {
|
|
|
|
+ my.setNavigationBar({
|
|
|
|
+ title: " ",
|
|
|
|
+ });
|
|
|
|
+ this.setData({
|
|
|
|
+ isScrollOver: false,
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ my.setNavigationBar({
|
|
|
|
+ title: " ",
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ })({
|
|
|
|
+ props: {
|
|
|
|
+ componentData: {},
|
|
|
|
+ },
|
|
|
|
+ data: {
|
|
|
|
+ navHeight: 72,
|
|
|
|
|
|
- if (scrollTop > contentHeight) {
|
|
|
|
- if (!isScrollOver) {
|
|
|
|
- const {
|
|
|
|
- componentData
|
|
|
|
- } = this.props;
|
|
|
|
- const {
|
|
|
|
- title
|
|
|
|
- } = getExtInfo(componentData);
|
|
|
|
- my.setNavigationBar({
|
|
|
|
- title
|
|
|
|
- });
|
|
|
|
- this.setData({
|
|
|
|
- isScrollOver: true
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- } else if (isScrollOver) {
|
|
|
|
- my.setNavigationBar({
|
|
|
|
- title: ' '
|
|
|
|
- });
|
|
|
|
- this.setData({
|
|
|
|
- isScrollOver: false
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ /* 消息通知是否显示 */
|
|
|
|
+ showMsg: true,
|
|
|
|
+ isScrollOver: false,
|
|
|
|
+ id: `index_heart_${Date.now()}`,
|
|
|
|
+ imgSrcPrefix: app.globalData.imgSrcPrefix,
|
|
|
|
+ },
|
|
|
|
|
|
-})({
|
|
|
|
- props: {
|
|
|
|
- componentData: {}
|
|
|
|
- },
|
|
|
|
- data: {
|
|
|
|
- navHeight: 72,
|
|
|
|
|
|
+ didMount() {},
|
|
|
|
|
|
- /* 消息通知是否显示 */
|
|
|
|
- showMsg: true,
|
|
|
|
- isScrollOver: false,
|
|
|
|
- id: `index_heart_${Date.now()}`,
|
|
|
|
- imgSrcPrefix: app.globalData.imgSrcPrefix
|
|
|
|
- },
|
|
|
|
|
|
+ methods: {
|
|
|
|
+ /**
|
|
|
|
+ * 关闭消息通知
|
|
|
|
+ */
|
|
|
|
+ closeMsgBtn() {
|
|
|
|
+ this.setData({
|
|
|
|
+ showMsg: false,
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
|
|
- didMount() {},
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 跳转到医院特色
|
|
|
|
+ */
|
|
|
|
+ goToDetail() {
|
|
|
|
+ const pageCode = "hospital-characteristics";
|
|
|
|
+ my.navigateTo({
|
|
|
|
+ url: `${prefixPagePath}/one/index?pageCode=${pageCode}`,
|
|
|
|
+ });
|
|
|
|
+ /* 服务预警,医院介绍 */
|
|
|
|
|
|
- methods: {
|
|
|
|
- /**
|
|
|
|
- * 关闭消息通知
|
|
|
|
- */
|
|
|
|
- closeMsgBtn() {
|
|
|
|
- this.setData({
|
|
|
|
- showMsg: false
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
|
|
+ reportCmPV_YL({
|
|
|
|
+ title: "医院介绍",
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
|
|
- /**
|
|
|
|
- * 跳转到医院特色
|
|
|
|
- */
|
|
|
|
- goToDetail() {
|
|
|
|
- const pageCode = 'hospital-characteristics';
|
|
|
|
- my.navigateTo({
|
|
|
|
- url: `${prefixPagePath}/one/index?pageCode=${pageCode}`
|
|
|
|
- });
|
|
|
|
- /* 服务预警,医院介绍 */
|
|
|
|
-
|
|
|
|
- reportCmPV_YL({
|
|
|
|
- title: '医院介绍'
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取头部初始头部初始padding-top
|
|
|
|
- */
|
|
|
|
- onCallback({
|
|
|
|
- height
|
|
|
|
- }) {
|
|
|
|
- this.setData({
|
|
|
|
- navHeight: height
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-}));
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取头部初始头部初始padding-top
|
|
|
|
+ */
|
|
|
|
+ onCallback({ height }) {
|
|
|
|
+ this.setData({
|
|
|
|
+ navHeight: height,
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+);
|