2024-09-06 07:28:48 +00:00
|
|
|
|
<template>
|
2024-09-28 09:47:13 +00:00
|
|
|
|
<view v-if="(propValue || null) !== null" class="header-container">
|
2024-10-10 10:29:45 +00:00
|
|
|
|
<view class="header-around wh-auto" :style="roll_style + position">
|
2024-10-10 10:18:13 +00:00
|
|
|
|
<view class="wh-auto" :style="roll_img_style">
|
2024-10-11 06:37:56 +00:00
|
|
|
|
<view class="wh-auto ht-auto pa up_slide_bg" :style="up_slide_style">
|
|
|
|
|
|
<view class="wh-auto ht-auto" :style="up_slide_img_style"></view>
|
|
|
|
|
|
</view>
|
2024-10-10 10:18:13 +00:00
|
|
|
|
<view :style="top_content_style">
|
|
|
|
|
|
<view class="header-content flex-row align-s">
|
|
|
|
|
|
<view class="model-top flex-1 mt-1">
|
|
|
|
|
|
<view class="roll pr z-i">
|
2024-10-17 09:29:50 +00:00
|
|
|
|
<view class="model-head pr padding-left-main padding-right-main" style="box-sizing: border-box">
|
2024-10-19 08:01:55 +00:00
|
|
|
|
<view class="flex-col" :style="'gap:' + data_alone_row_space">
|
2024-10-17 09:27:27 +00:00
|
|
|
|
<view class="model-head-content flex-row align-c jc-sb gap-16 wh-auto pr" :style="header_style">
|
2024-10-22 06:02:55 +00:00
|
|
|
|
<!-- 支付宝小程序自带返回按钮,这里就不给返回按钮了,这里给留出一点空间就行 -->
|
|
|
|
|
|
<!-- #ifndef MP-ALIPAY -->
|
2024-10-17 07:09:31 +00:00
|
|
|
|
<view v-if="!is_tabbar_pages" class="z-i dis-inline-block margin-top-xs" @tap="top_nav_left_back_event">
|
|
|
|
|
|
<iconfont name="icon-arrow-left" size="40rpx" propContainerDisplay="flex" :color="form.style.left_back_btn_color || '#333'"></iconfont>
|
|
|
|
|
|
</view>
|
2024-10-22 06:02:55 +00:00
|
|
|
|
<!-- #endif -->
|
|
|
|
|
|
<!-- #ifdef MP-ALIPAY -->
|
|
|
|
|
|
<view class="dis-inline-block padding-left-sm"></view>
|
|
|
|
|
|
<!-- #endif -->
|
2024-10-17 07:09:31 +00:00
|
|
|
|
<view v-if="['1', '2', '3'].includes(form.content.theme)" class="flex-1">
|
|
|
|
|
|
<view class="flex-row align-c jc-c ht-auto gap-16" :class="position_class" :style="text_style + 'justify-content:' + form.content.indicator_location || 'center'">
|
|
|
|
|
|
<template v-if="['2', '3'].includes(form.content.theme)">
|
2024-11-03 03:32:03 +00:00
|
|
|
|
<view v-if="form.content.logo.length > 0" class="logo-outer-style re flex-row align-c">
|
2024-10-31 07:15:25 +00:00
|
|
|
|
<template v-if="form.style.up_slide_logo && form.style.up_slide_logo.length > 0">
|
|
|
|
|
|
<!-- 有上滑logo的处理逻辑 -->
|
2024-11-03 03:32:03 +00:00
|
|
|
|
<view v-if="(propScrollTop - 5) / (header_top + 33) < 1" class="logo-style" :style="up_slide_old_logo_style">
|
|
|
|
|
|
<image class="logo-style" :src="form.content.logo[0].url" mode="heightFix" />
|
|
|
|
|
|
</view>
|
2024-12-26 08:00:14 +00:00
|
|
|
|
<view :class="['logo-style left-0', { pa: (propScrollTop - 5) / (header_top + 33) < 1 }]" :style="'opacity:0;' + up_slide_opacity">
|
2024-11-03 03:32:03 +00:00
|
|
|
|
<image class="logo-style" :src="form.style.up_slide_logo[0].url" mode="heightFix" />
|
|
|
|
|
|
</view>
|
2024-10-31 07:15:25 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<!-- 没有上滑logo的处理逻辑 -->
|
|
|
|
|
|
<image class="logo-style" :src="form.content.logo[0].url" mode="heightFix" />
|
|
|
|
|
|
</template>
|
2024-10-17 07:09:31 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
2024-11-08 03:47:13 +00:00
|
|
|
|
<view v-if="['1', '2', '3'].includes(form.content.theme) && !isEmpty(form.content.title)">{{ form.content.title }}</view>
|
2024-10-22 06:07:24 +00:00
|
|
|
|
<template v-if="['3'].includes(form.content.theme) && !is_search_alone_row">
|
2024-11-12 03:46:08 +00:00
|
|
|
|
<view class="flex-1 fw-n">
|
2024-10-17 07:09:31 +00:00
|
|
|
|
<componentDiySearch :propValue="form" :propIsPageSettings="true"></componentDiySearch>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2024-12-06 02:45:31 +00:00
|
|
|
|
<view v-else-if="['4', '5'].includes(form.content.theme)" class="flex-1 flex-row align-c">
|
|
|
|
|
|
<view v-if="form.content.positioning_name_float !== '1'" class="flex-row align-c gap-2">
|
2024-12-02 02:37:55 +00:00
|
|
|
|
<view :style="location_margin">
|
2024-12-24 10:58:22 +00:00
|
|
|
|
<component-choice-location :propLocationContainerStyle="style_location_container" :propLocationImgContainerStyle="style_location_img_container" :propBaseColor="location_color" :propTextDefaultName="form.content.positioning_name" :propIsLeftIconArrow="form.content.is_location_left_icon_show == '1'" :propLeftImgValue="form.content.location_left_img" :propLeftIconValue="'icon-' + form.content.location_left_icon" :propIconLocationSize="location_left_size" :propIconArrowSize="location_right_size" :propIsRightIconArrow="form.content.is_location_right_icon_show == '1'" :propRightImgValue="form.content.location_right_img" :propRightIconValue="'icon-' + form.content.location_right_icon" :propTextMaxWidth="location_name_style" propContainerDisplay="flex" @onBack="choice_location_back"></component-choice-location>
|
2024-10-10 10:18:13 +00:00
|
|
|
|
</view>
|
2024-10-17 07:09:31 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
<template v-if="['5'].includes(form.content.theme) && !is_search_alone_row">
|
2024-10-10 10:18:13 +00:00
|
|
|
|
<view class="flex-1">
|
2024-12-06 06:17:18 +00:00
|
|
|
|
<componentDiySearch :propValue="form" :propIsPageSettings="true" :propLocationMargin="location_margin" propSearchType="header" :propLocationContainerStyle="style_location_container" :propLocationImgContainerStyle="style_location_img_container" :propBaseColor="location_color" :propIconLocationSize="location_left_size" :propIconArrowSize="location_right_size" @onBack="choice_location_back"></componentDiySearch>
|
2024-10-10 10:18:13 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</view>
|
2024-10-17 07:09:31 +00:00
|
|
|
|
<view v-if="!isEmpty(form.content.icon_setting) && !is_icon_alone_row" class="flex-row align-c z-i" :class="['1'].includes(form.content.theme) ? 'right-0' : ''" :style="{ gap: form.style.img_space * 2 + 'rpx' }">
|
2024-10-31 07:15:25 +00:00
|
|
|
|
<view v-for="(item, index) in form.content.icon_setting" :key="index" class="pr" :style="{ width: form.style.img_size * 2 + 'rpx', height: form.style.img_size * 2 + 'rpx' }" :data-value="item.link.page" @tap="url_event">
|
2024-10-17 07:09:31 +00:00
|
|
|
|
<imageEmpty v-if="item.img.length > 0" :propImageSrc="item.img[0].url" :propErrorStyle="'width: ' + Number(form.style.img_size) * 2 + 'rpx;height:' + Number(form.style.img_size) * 2 + 'rpx;'"></imageEmpty>
|
|
|
|
|
|
<iconfont v-else :name="'icon-' + item.icon" :size="form.style.img_size * 2 + 'rpx'" :color="form.style.img_color" propContainerDisplay="flex"></iconfont>
|
2024-10-31 07:15:25 +00:00
|
|
|
|
<view v-if="!isEmpty(item.badge) && item.badge !== 0" class="pa badge-style">
|
|
|
|
|
|
<component-badge :propNumber="item.badge || 0"></component-badge>
|
|
|
|
|
|
</view>
|
2024-10-17 07:09:31 +00:00
|
|
|
|
</view>
|
2024-10-10 10:18:13 +00:00
|
|
|
|
</view>
|
2024-10-17 07:09:31 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
<view v-if="is_search_alone_row || is_icon_alone_row" class="model-head-content flex-row align-c gap-16">
|
|
|
|
|
|
<template v-if="['3', '5'].includes(form.content.theme) && is_search_alone_row">
|
2024-10-08 06:47:39 +00:00
|
|
|
|
<view class="flex-1">
|
2024-12-23 09:33:26 +00:00
|
|
|
|
<componentDiySearch :propValue="form" :propIsPageSettings="true" :propLocationMargin="location_margin" propSearchType="header" :propLocationContainerStyle="style_location_container" :propLocationImgContainerStyle="style_location_img_container" :propBaseColor="location_color" :propIconLocationSize="location_left_size" :propIconArrowSize="location_right_size" @onBack="choice_location_back"></componentDiySearch>
|
2024-10-08 06:47:39 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
2024-10-17 07:09:31 +00:00
|
|
|
|
<view v-if="!isEmpty(form.content.icon_setting) && is_icon_alone_row" class="flex-row align-c z-i" :class="['1'].includes(form.content.theme) ? 'right-0' : ''" :style="{ gap: form.style.img_space * 2 + 'rpx' }">
|
2024-10-31 07:15:25 +00:00
|
|
|
|
<view v-for="(item, index) in form.content.icon_setting" :key="index" class="pr" :style="{ width: form.style.img_size * 2 + 'rpx', height: form.style.img_size * 2 + 'rpx' }" :data-value="item.link.page" @tap="url_event">
|
2024-10-17 07:09:31 +00:00
|
|
|
|
<imageEmpty v-if="item.img.length > 0" :propImageSrc="item.img[0].url" :propErrorStyle="'width: ' + Number(form.style.img_size) * 2 + 'rpx;height:' + Number(form.style.img_size) * 2 + 'rpx;'"></imageEmpty>
|
|
|
|
|
|
<iconfont v-else :name="'icon-' + item.icon" :size="form.style.img_size * 2 + 'rpx'" :color="form.style.img_color" propContainerDisplay="flex"></iconfont>
|
2024-10-31 07:15:25 +00:00
|
|
|
|
<view v-if="!isEmpty(item.badge) && item.badge !== 0" class="pa badge-style">
|
|
|
|
|
|
<component-badge :propNumber="item.badge || 0"></component-badge>
|
|
|
|
|
|
</view>
|
2024-10-17 07:09:31 +00:00
|
|
|
|
</view>
|
2024-09-28 09:47:13 +00:00
|
|
|
|
</view>
|
2024-09-25 01:56:47 +00:00
|
|
|
|
</view>
|
2024-09-24 06:17:18 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2024-09-20 04:00:57 +00:00
|
|
|
|
</view>
|
2024-09-29 03:40:18 +00:00
|
|
|
|
<block v-if="!is_immersion_model">
|
|
|
|
|
|
<view v-if="!is_positon_realative" class="nav-seat" :style="top_content_style">
|
2024-10-19 08:01:55 +00:00
|
|
|
|
<view :style="'height:' + (is_search_alone_row || is_icon_alone_row ? 'calc(132rpx + ' + data_alone_row_space + ');' : '66rpx;')"></view>
|
2024-09-29 03:40:18 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
</block>
|
2024-09-28 09:47:13 +00:00
|
|
|
|
<!-- #ifndef H5 || MP-TOUTIAO -->
|
|
|
|
|
|
<view v-if="is_positon_realative" class="wh-auto pf top-0 left-0 right-0" :style="roll_style">
|
2024-09-29 03:40:18 +00:00
|
|
|
|
<view :style="top_content_style">
|
2024-10-19 08:01:55 +00:00
|
|
|
|
<view :style="'height:' + (is_search_alone_row || is_icon_alone_row ? 'calc(132rpx + ' + data_alone_row_space + ');' : '66rpx;')"></view>
|
2024-09-28 09:47:13 +00:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<!-- #endif -->
|
2024-09-19 10:09:42 +00:00
|
|
|
|
</view>
|
2024-09-06 07:28:48 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-09-19 10:09:42 +00:00
|
|
|
|
const app = getApp();
|
2024-09-24 06:17:18 +00:00
|
|
|
|
import componentDiySearch from '@/components/diy/search';
|
2024-09-24 07:10:26 +00:00
|
|
|
|
import imageEmpty from '@/components/diy/modules/image-empty';
|
2024-09-29 07:41:57 +00:00
|
|
|
|
import componentChoiceLocation from '@/components/choice-location/choice-location';
|
2024-10-31 07:15:25 +00:00
|
|
|
|
import componentBadge from '@/components/badge/badge';
|
2024-11-29 09:38:57 +00:00
|
|
|
|
import { isEmpty, background_computer, gradient_computer, margin_computer, padding_computer, radius_computer } from '@/common/js/common/common.js';
|
2024-09-19 10:09:42 +00:00
|
|
|
|
// 状态栏高度
|
|
|
|
|
|
var bar_height = parseInt(app.globalData.get_system_info('statusBarHeight', 0));
|
|
|
|
|
|
// #ifdef MP-TOUTIAO
|
|
|
|
|
|
bar_height = 0;
|
|
|
|
|
|
// #endif
|
2024-09-06 07:28:48 +00:00
|
|
|
|
export default {
|
2024-09-24 06:17:18 +00:00
|
|
|
|
props: {
|
2024-09-26 01:59:23 +00:00
|
|
|
|
propValue: {
|
2024-10-22 11:16:02 +00:00
|
|
|
|
type: [String, Number, Object],
|
2024-10-21 13:29:38 +00:00
|
|
|
|
default: '',
|
2024-09-24 06:17:18 +00:00
|
|
|
|
},
|
2024-10-18 10:15:44 +00:00
|
|
|
|
// 滚动距离
|
2024-09-29 03:40:18 +00:00
|
|
|
|
propScrollTop: {
|
|
|
|
|
|
type: Number,
|
|
|
|
|
|
default: 0,
|
|
|
|
|
|
},
|
2024-10-18 02:26:37 +00:00
|
|
|
|
propKey: {
|
2024-10-22 11:16:02 +00:00
|
|
|
|
type: [String, Number],
|
2024-10-08 06:48:12 +00:00
|
|
|
|
default: '',
|
2024-10-08 08:19:14 +00:00
|
|
|
|
},
|
2024-09-24 06:17:18 +00:00
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
componentDiySearch,
|
2024-09-24 07:10:26 +00:00
|
|
|
|
imageEmpty,
|
2024-09-29 07:41:57 +00:00
|
|
|
|
componentChoiceLocation,
|
2024-12-26 08:00:14 +00:00
|
|
|
|
componentBadge,
|
2024-09-24 06:17:18 +00:00
|
|
|
|
},
|
2024-09-06 07:28:48 +00:00
|
|
|
|
data() {
|
2024-09-19 10:09:42 +00:00
|
|
|
|
return {
|
2024-09-24 06:17:18 +00:00
|
|
|
|
form: {},
|
|
|
|
|
|
new_style: {},
|
|
|
|
|
|
position: '',
|
|
|
|
|
|
roll_style: '',
|
|
|
|
|
|
text_style: '',
|
2024-09-24 10:01:05 +00:00
|
|
|
|
header_style: 'max-width:100%',
|
2024-09-25 01:56:47 +00:00
|
|
|
|
common_app_is_header_nav_fixed: 0,
|
2024-11-08 09:53:29 +00:00
|
|
|
|
// 5,7,0 是误差,, 10 是下边距,66是高度,bar_height是不同小程序下的导航栏距离顶部的高度
|
2024-09-25 01:56:47 +00:00
|
|
|
|
// #ifdef MP
|
2024-11-08 09:53:29 +00:00
|
|
|
|
top_content_style: 'padding-top:' + (bar_height + 5) + 'px;padding-bottom:10px;',
|
2024-09-25 01:56:47 +00:00
|
|
|
|
// #endif
|
|
|
|
|
|
// #ifdef H5 || MP-TOUTIAO
|
2024-11-08 09:53:29 +00:00
|
|
|
|
top_content_style: 'padding-top:' + (bar_height + 7) + 'px;padding-bottom:10px;',
|
2024-09-25 01:56:47 +00:00
|
|
|
|
// #endif
|
|
|
|
|
|
// #ifdef APP
|
2024-11-08 09:53:29 +00:00
|
|
|
|
top_content_style: 'padding-top:' + bar_height + 'px;padding-bottom:10px;',
|
2024-09-25 01:56:47 +00:00
|
|
|
|
// #endif
|
2024-09-28 09:47:13 +00:00
|
|
|
|
is_positon_realative: false,
|
2024-09-29 03:40:18 +00:00
|
|
|
|
// 顶部背景样式类别
|
|
|
|
|
|
header_background_type: 'color_image',
|
|
|
|
|
|
// #ifdef MP
|
2024-11-08 10:04:23 +00:00
|
|
|
|
header_top: bar_height + 5 + 10 + 33,
|
2024-09-29 03:40:18 +00:00
|
|
|
|
// #endif
|
|
|
|
|
|
// #ifdef H5 || MP-TOUTIAO
|
2024-11-08 10:04:23 +00:00
|
|
|
|
header_top: bar_height + 7 + 10 + 33,
|
2024-09-29 03:40:18 +00:00
|
|
|
|
// #endif
|
|
|
|
|
|
// #ifdef APP
|
2024-11-08 10:04:23 +00:00
|
|
|
|
header_top: bar_height + 0 + 10 + 33,
|
2024-09-29 03:40:18 +00:00
|
|
|
|
// #endif
|
|
|
|
|
|
// 判断是否是沉浸模式
|
|
|
|
|
|
is_immersion_model: false,
|
2024-10-31 07:15:25 +00:00
|
|
|
|
up_slide_opacity: '',
|
|
|
|
|
|
up_slide_old_logo_style: '',
|
2024-10-11 06:37:56 +00:00
|
|
|
|
up_slide_style: '',
|
|
|
|
|
|
up_slide_img_style: '',
|
2024-10-13 09:45:16 +00:00
|
|
|
|
// 当前页面是否在底部菜单中
|
|
|
|
|
|
is_tabbar_pages: app.globalData.is_tabbar_pages(),
|
2024-10-17 02:50:29 +00:00
|
|
|
|
// 判断header的查询是否独行
|
|
|
|
|
|
is_search_alone_row: false,
|
2024-10-17 07:09:31 +00:00
|
|
|
|
is_icon_alone_row: false,
|
2024-10-19 08:01:55 +00:00
|
|
|
|
data_alone_row_space: '0rpx',
|
2024-11-29 09:38:57 +00:00
|
|
|
|
// 定位设置
|
|
|
|
|
|
style_location_container: '',
|
|
|
|
|
|
style_location_img_container: '',
|
2024-12-06 02:45:31 +00:00
|
|
|
|
location_left_size: '24rpx',
|
|
|
|
|
|
location_right_size: '24rpx',
|
2024-12-02 02:37:55 +00:00
|
|
|
|
location_margin: '', // 悬浮之后有间距,所以要将margin设置成外padding
|
2024-12-06 02:45:31 +00:00
|
|
|
|
location_color: '', // 定位颜色
|
2024-12-23 09:33:26 +00:00
|
|
|
|
location_name_style: '', // 定位样式
|
2024-12-02 02:37:55 +00:00
|
|
|
|
// 默认数据
|
|
|
|
|
|
old_radius: { radius: 0, radius_top_left: 0, radius_top_right: 0, radius_bottom_left: 0, radius_bottom_right: 0 },
|
|
|
|
|
|
old_padding: { padding: 0, padding_top: 0, padding_bottom: 0, padding_left: 0, padding_right: 0 },
|
|
|
|
|
|
old_margin: { margin: 0, margin_top: 0, margin_bottom: 0, margin_left: 0, margin_right: 0 },
|
2024-09-19 10:09:42 +00:00
|
|
|
|
};
|
2024-09-06 07:28:48 +00:00
|
|
|
|
},
|
2024-09-29 03:40:18 +00:00
|
|
|
|
watch: {
|
2024-10-18 10:15:44 +00:00
|
|
|
|
// 监听滚动距离
|
2024-09-29 03:40:18 +00:00
|
|
|
|
propScrollTop(newVal) {
|
2024-10-31 07:15:25 +00:00
|
|
|
|
const { up_slide_background_color_list, up_slide_background_direction, up_slide_background_img, up_slide_background_img_style, up_slide_display } = this.propValue.style || {};
|
|
|
|
|
|
if (up_slide_display == '1') {
|
|
|
|
|
|
// 渐变
|
|
|
|
|
|
const gradient = { color_list: up_slide_background_color_list, direction: up_slide_background_direction };
|
|
|
|
|
|
// 背景图
|
|
|
|
|
|
const back = { background_img: up_slide_background_img, background_img_style: up_slide_background_img_style };
|
|
|
|
|
|
const up_slide_opacity = 'opacity:' + ((newVal - 20) / (this.header_top + 33) > 1 ? 1 : ((newVal - 20) / (this.header_top + 33)).toFixed(2)) + ';';
|
2024-12-26 08:00:14 +00:00
|
|
|
|
this.up_slide_opacity = up_slide_opacity;
|
|
|
|
|
|
// 来的logo要比新的隐藏的快,所以要比原来的logo快一点
|
|
|
|
|
|
this.up_slide_old_logo_style = 'opacity:' + ((newVal - 5) / (this.header_top + 33) > 1 ? 0 : (1 - (newVal - 5) / (this.header_top + 33)).toFixed(2)) + ';';
|
|
|
|
|
|
// =0是大小误差
|
|
|
|
|
|
this.up_slide_style = gradient_computer(gradient) + up_slide_opacity;
|
|
|
|
|
|
this.up_slide_img_style = background_computer(back);
|
2024-10-31 07:15:25 +00:00
|
|
|
|
}
|
2024-09-29 03:40:18 +00:00
|
|
|
|
},
|
2024-10-18 02:26:37 +00:00
|
|
|
|
propKey(val) {
|
2024-10-08 06:48:12 +00:00
|
|
|
|
if ((this.propValue || null) !== null) {
|
|
|
|
|
|
this.init();
|
|
|
|
|
|
}
|
2024-10-08 08:19:14 +00:00
|
|
|
|
},
|
2024-09-29 03:40:18 +00:00
|
|
|
|
},
|
2024-09-24 07:10:26 +00:00
|
|
|
|
created() {
|
2024-10-18 10:15:44 +00:00
|
|
|
|
// 判断是否有值初始化
|
2024-09-26 01:59:23 +00:00
|
|
|
|
if ((this.propValue || null) !== null) {
|
2024-09-25 06:00:46 +00:00
|
|
|
|
this.init();
|
|
|
|
|
|
}
|
2024-09-24 06:17:18 +00:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-10-18 10:15:44 +00:00
|
|
|
|
// 判断是否为空
|
2024-09-24 06:17:18 +00:00
|
|
|
|
isEmpty,
|
2024-10-18 10:15:44 +00:00
|
|
|
|
// 初始化
|
2024-09-24 06:17:18 +00:00
|
|
|
|
init() {
|
2024-09-26 01:59:23 +00:00
|
|
|
|
const new_content = this.propValue.content || {};
|
|
|
|
|
|
const new_style = this.propValue.style || {};
|
2024-09-24 06:17:18 +00:00
|
|
|
|
let new_roll_style = '';
|
2024-10-10 10:18:13 +00:00
|
|
|
|
let new_roll_img_style = '';
|
2024-09-29 03:40:18 +00:00
|
|
|
|
const { header_background_img, header_background_img_style, header_background_color_list, header_background_direction, header_background_type, immersive_style } = new_style;
|
2024-09-24 06:17:18 +00:00
|
|
|
|
if (header_background_type === 'color_image') {
|
|
|
|
|
|
// 渐变
|
|
|
|
|
|
const gradient = { color_list: header_background_color_list, direction: header_background_direction };
|
|
|
|
|
|
// 背景图
|
|
|
|
|
|
const back = { background_img: header_background_img, background_img_style: header_background_img_style };
|
2024-10-10 10:18:13 +00:00
|
|
|
|
new_roll_style += gradient_computer(gradient);
|
|
|
|
|
|
new_roll_img_style += background_computer(back);
|
2024-09-24 06:17:18 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
new_roll_style += `background: transparent;`;
|
|
|
|
|
|
}
|
2024-09-24 08:24:16 +00:00
|
|
|
|
// 小程序下,获取小程序胶囊的宽度
|
2024-10-13 09:45:16 +00:00
|
|
|
|
let menu_button_info = 'max-width:100%';
|
2024-10-08 10:18:45 +00:00
|
|
|
|
let new_text_style = `font-weight:${new_style.header_background_title_typeface}; font-size: ${new_style.header_background_title_size * 2}rpx; color: ${new_style.header_background_title_color};`;
|
2024-10-22 11:16:02 +00:00
|
|
|
|
// #ifndef MP-TOUTIAO
|
2024-10-22 06:02:55 +00:00
|
|
|
|
// #ifdef MP
|
2024-09-24 10:01:05 +00:00
|
|
|
|
const custom = uni.getMenuButtonBoundingClientRect();
|
2024-10-13 09:45:16 +00:00
|
|
|
|
menu_button_info = `max-width:calc(100% - ${custom.width + 10}px);`;
|
2024-10-08 10:18:45 +00:00
|
|
|
|
new_text_style += `right:-${custom.width + 10}px;`;
|
2024-09-24 08:24:16 +00:00
|
|
|
|
// #endif
|
2024-10-22 11:16:02 +00:00
|
|
|
|
// #endif
|
2024-12-26 08:00:14 +00:00
|
|
|
|
const { location_margin = this.old_margin } = new_style;
|
2024-09-24 06:17:18 +00:00
|
|
|
|
this.setData({
|
2024-09-26 01:59:23 +00:00
|
|
|
|
form: this.propValue,
|
2024-11-12 08:23:37 +00:00
|
|
|
|
position: new_style.up_slide_display == '1' ? 'position:fixed;' : new_style.immersive_style === '1' ? 'position:absolute;' : 'position:reactive;',
|
2024-09-28 09:47:13 +00:00
|
|
|
|
is_positon_realative: new_style.up_slide_display == '1' ? false : true,
|
2024-09-24 06:17:18 +00:00
|
|
|
|
roll_style: new_roll_style,
|
2024-10-10 10:18:13 +00:00
|
|
|
|
roll_img_style: new_roll_img_style,
|
2024-10-08 10:18:45 +00:00
|
|
|
|
text_style: new_text_style,
|
2024-10-08 06:47:39 +00:00
|
|
|
|
position_class: new_content.indicator_location == 'center' ? `indicator-center` : '',
|
2024-10-13 09:45:16 +00:00
|
|
|
|
header_style: menu_button_info,
|
2024-09-29 03:40:18 +00:00
|
|
|
|
header_background_type: header_background_type,
|
|
|
|
|
|
is_immersion_model: header_background_type !== 'color_image' && immersive_style == '1',
|
2024-10-19 08:01:55 +00:00
|
|
|
|
data_alone_row_space: new_style.data_alone_row_space * 2 + 'rpx',
|
2024-10-17 09:27:27 +00:00
|
|
|
|
is_search_alone_row: new_content.data_alone_row_value && new_content.data_alone_row_value.includes('search'),
|
2024-10-17 09:29:50 +00:00
|
|
|
|
is_icon_alone_row: new_content.data_alone_row_value && new_content.data_alone_row_value.includes('icon'),
|
2024-11-29 09:38:57 +00:00
|
|
|
|
style_location_container: this.get_style_location_container(new_style),
|
|
|
|
|
|
style_location_img_container: this.get_style_location_img_container(new_style),
|
2024-12-06 02:45:31 +00:00
|
|
|
|
location_left_size: !isEmpty(new_style.location_left_icon_size) ? new_style.location_left_icon_size * 2 + 'rpx' : '24rpx',
|
|
|
|
|
|
location_right_size: !isEmpty(new_style.location_right_icon_size) ? new_style.location_right_icon_size * 2 + 'rpx' : '24rpx',
|
|
|
|
|
|
location_color: !isEmpty(new_style.location_color) ? new_style.location_color : new_style?.position_color || '',
|
2024-12-23 09:33:26 +00:00
|
|
|
|
location_name_style: this.get_location_name_style(new_content),
|
2024-12-02 02:37:55 +00:00
|
|
|
|
location_margin: `padding: ${location_margin.margin_top * 2}rpx ${location_margin.margin_right * 2}rpx ${location_margin.margin_bottom * 2}rpx ${location_margin.margin_left * 2}rpx;`, // 悬浮之后有间距,所以要将margin设置成外padding
|
2024-09-24 06:17:18 +00:00
|
|
|
|
});
|
2024-10-18 02:26:37 +00:00
|
|
|
|
this.$emit('onImmersionModelCallBack', this.is_immersion_model);
|
2024-09-29 03:40:18 +00:00
|
|
|
|
},
|
2024-12-26 08:00:14 +00:00
|
|
|
|
get_location_name_style(new_content) {
|
2024-12-23 09:33:26 +00:00
|
|
|
|
const is_search_alone_row = new_content.data_alone_row_value && new_content.data_alone_row_value.includes('search');
|
|
|
|
|
|
const is_icon_alone_row = new_content.data_alone_row_value && new_content.data_alone_row_value.includes('icon');
|
|
|
|
|
|
let width = 0;
|
|
|
|
|
|
if (is_search_alone_row && is_icon_alone_row) {
|
|
|
|
|
|
width = 200;
|
|
|
|
|
|
} else if (is_search_alone_row || is_icon_alone_row) {
|
|
|
|
|
|
width = 100;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (new_content.theme == '4') {
|
2024-12-26 08:00:14 +00:00
|
|
|
|
return `${(150 + width) * 2}rpx;`;
|
2024-12-23 09:33:26 +00:00
|
|
|
|
} else {
|
2024-12-26 08:00:14 +00:00
|
|
|
|
return `${(100 + width) * 2}rpx;`;
|
2024-12-23 09:33:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-11-29 09:38:57 +00:00
|
|
|
|
// 定位设置
|
|
|
|
|
|
get_style_location_container(new_style) {
|
2024-12-26 08:00:14 +00:00
|
|
|
|
const { location_margin = this.old_margin, location_radius = this.old_radius } = new_style;
|
2024-11-29 09:38:57 +00:00
|
|
|
|
const style = {
|
2024-12-02 02:37:55 +00:00
|
|
|
|
color_list: new_style?.location_color_list || [],
|
|
|
|
|
|
direction: new_style?.location_direction || '',
|
2024-12-26 08:00:14 +00:00
|
|
|
|
};
|
2024-12-02 02:37:55 +00:00
|
|
|
|
const height = 32 - location_margin.margin_top - location_margin.margin_bottom;
|
2024-12-26 08:00:14 +00:00
|
|
|
|
return gradient_computer(style) + radius_computer(location_radius) + `height: ${height * 2}rpx;line-height: ${height * 2}rpx;`;
|
2024-11-29 09:38:57 +00:00
|
|
|
|
},
|
|
|
|
|
|
// 背景图片
|
2024-12-26 08:00:14 +00:00
|
|
|
|
get_style_location_img_container(new_style) {
|
2024-12-24 01:50:23 +00:00
|
|
|
|
const { location_background_img = [], location_background_img_style = '2', location_border_show = '0', location_padding = this.old_padding, location_margin = this.old_margin, location_border_size = this.old_padding, location_border_color = '', location_border_style = 'solid' } = new_style;
|
2024-11-29 09:38:57 +00:00
|
|
|
|
const style = {
|
|
|
|
|
|
background_img: location_background_img,
|
|
|
|
|
|
background_img_style: location_background_img_style,
|
2024-12-26 08:00:14 +00:00
|
|
|
|
};
|
2024-11-29 09:38:57 +00:00
|
|
|
|
let border = ``;
|
2024-12-02 02:37:55 +00:00
|
|
|
|
if (location_border_show == '1') {
|
2024-12-26 08:00:14 +00:00
|
|
|
|
border += `border-width: ${location_border_size.padding_top}px ${location_border_size.padding_right}px ${location_border_size.padding_bottom}px ${location_border_size.padding_left}px;border-style: ${location_border_style};border-color: ${location_border_color};`;
|
2024-11-29 09:38:57 +00:00
|
|
|
|
}
|
2024-12-02 02:37:55 +00:00
|
|
|
|
const height = 32 - (location_margin.margin_top || 0) - (location_margin.margin_bottom || 0);
|
2024-12-26 08:00:14 +00:00
|
|
|
|
return background_computer(style) + padding_computer(location_padding) + border + `height: ${height * 2}rpx;line-height: ${height * 2}rpx;box-sizing: border-box;`;
|
2024-11-29 09:38:57 +00:00
|
|
|
|
},
|
2024-09-29 03:40:18 +00:00
|
|
|
|
// 获取顶部导航高度
|
|
|
|
|
|
get_nav_height() {
|
|
|
|
|
|
const query = uni.createSelectorQuery().in(this);
|
|
|
|
|
|
query
|
|
|
|
|
|
.select('.article-tabs')
|
|
|
|
|
|
.boundingClientRect((res) => {
|
|
|
|
|
|
if ((res || null) != null) {
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
tabs_top: res.top,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.exec();
|
2024-09-24 06:17:18 +00:00
|
|
|
|
},
|
2024-10-13 09:45:16 +00:00
|
|
|
|
// 位置回调
|
2024-10-18 02:26:37 +00:00
|
|
|
|
choice_location_back(e) {
|
|
|
|
|
|
this.$emit('onLocationBack', e);
|
2024-09-29 07:43:24 +00:00
|
|
|
|
},
|
2024-10-13 09:45:16 +00:00
|
|
|
|
// 打开地址
|
2024-09-25 08:39:28 +00:00
|
|
|
|
url_event(e) {
|
|
|
|
|
|
app.globalData.url_event(e);
|
|
|
|
|
|
},
|
2024-10-13 09:45:16 +00:00
|
|
|
|
// 返回事件
|
|
|
|
|
|
top_nav_left_back_event() {
|
|
|
|
|
|
app.globalData.page_back_prev_event();
|
|
|
|
|
|
},
|
2024-09-24 06:17:18 +00:00
|
|
|
|
},
|
2024-09-06 07:28:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2024-09-19 10:09:42 +00:00
|
|
|
|
<style lang="scss" scoped>
|
2024-09-25 01:56:47 +00:00
|
|
|
|
.header-container {
|
2024-09-25 07:30:44 +00:00
|
|
|
|
width: 100%;
|
2024-10-10 10:29:45 +00:00
|
|
|
|
.header-around {
|
2024-10-15 06:40:17 +00:00
|
|
|
|
z-index: 4;
|
2024-09-28 09:47:13 +00:00
|
|
|
|
}
|
2024-09-25 01:56:47 +00:00
|
|
|
|
.model-top {
|
|
|
|
|
|
.roll {
|
2024-09-25 04:01:20 +00:00
|
|
|
|
width: 100%;
|
2024-09-25 01:56:47 +00:00
|
|
|
|
height: 100%;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
.img {
|
|
|
|
|
|
width: 680rpx;
|
|
|
|
|
|
}
|
2024-09-24 06:17:18 +00:00
|
|
|
|
}
|
2024-09-25 01:56:47 +00:00
|
|
|
|
.model-head {
|
2024-10-08 06:47:39 +00:00
|
|
|
|
.model-head-content {
|
|
|
|
|
|
height: 66rpx;
|
2024-10-31 07:15:25 +00:00
|
|
|
|
// overflow: hidden;
|
2024-10-08 09:59:08 +00:00
|
|
|
|
top: -1rpx;
|
2024-10-22 11:16:02 +00:00
|
|
|
|
/* #ifdef H5 || MP-TOUTIAO */
|
2024-10-21 14:42:25 +00:00
|
|
|
|
top: 4rpx;
|
|
|
|
|
|
/* #endif */
|
2024-10-08 06:47:39 +00:00
|
|
|
|
}
|
2024-09-24 06:17:18 +00:00
|
|
|
|
}
|
2024-09-25 01:56:47 +00:00
|
|
|
|
.model-head-icon {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
2024-10-08 06:47:39 +00:00
|
|
|
|
height: 66rpx;
|
2024-09-25 01:56:47 +00:00
|
|
|
|
.function-icon {
|
2024-10-08 06:47:39 +00:00
|
|
|
|
height: 66rpx;
|
2024-09-25 01:56:47 +00:00
|
|
|
|
}
|
2024-09-24 06:17:18 +00:00
|
|
|
|
}
|
2024-09-25 01:56:47 +00:00
|
|
|
|
.logo-outer-style {
|
2024-10-10 09:49:07 +00:00
|
|
|
|
height: 56rpx;
|
2024-09-25 01:56:47 +00:00
|
|
|
|
.logo-style {
|
2024-10-10 09:49:07 +00:00
|
|
|
|
height: 56rpx;
|
2024-10-10 06:03:17 +00:00
|
|
|
|
width: 100%;
|
2024-09-25 01:56:47 +00:00
|
|
|
|
}
|
2024-09-24 06:17:18 +00:00
|
|
|
|
}
|
2024-09-19 10:09:42 +00:00
|
|
|
|
}
|
2024-10-08 06:47:39 +00:00
|
|
|
|
.indicator-center {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
padding-left: 0;
|
|
|
|
|
|
}
|
2024-10-11 06:37:56 +00:00
|
|
|
|
.up_slide_bg {
|
|
|
|
|
|
z-index: -1;
|
|
|
|
|
|
}
|
2024-10-31 07:15:25 +00:00
|
|
|
|
.badge-style {
|
|
|
|
|
|
top: -20rpx;
|
|
|
|
|
|
right: 5rpx;
|
|
|
|
|
|
}
|
2024-09-19 10:09:42 +00:00
|
|
|
|
</style>
|