vr-shopxo-uniapp/components/diy/header.vue

172 lines
8.3 KiB
Vue
Raw Normal View History

<template>
2024-09-25 06:00:46 +00:00
<view v-if="(value || null) !== null" class="header-container" :style="roll_style + position">
2024-09-25 07:30:44 +00:00
<view class="bg-white" :style="top_content_style">
2024-09-25 03:56:33 +00:00
<view class="header-content flex-row align-c padding-vertical-xs" style="height: 34px">
2024-09-25 01:56:47 +00:00
<view class="model-top flex-1">
<view class="roll pr z-i">
<view class="model-head tc pr padding-horizontal-sm flex-row align-c" :style="header_style">
<view class="flex-row align-c jc-sb gap-16 wh-auto padding-horizontal-main pr">
<view v-if="['1', '2', '3'].includes(form.content.theme)" class="flex-1 flex-row align-c jc-c ht-auto gap-16" :style="text_style + 'justify-content:' + form.content.indicator_location || 'center'">
<template v-if="['2', '3'].includes(form.content.theme)">
<view class="logo-outer-style">
2024-09-26 02:06:20 +00:00
<image-empty :imageSrc="form.content.logo[0].url" class="logo-style" errorStyle="width:40rpx;height:40rpx;"></image-empty>
2024-09-25 01:56:47 +00:00
</view>
</template>
<view v-if="['1', '2'].includes(form.content.theme)">{{ form.content.title }}</view>
<template v-if="['3', '5'].includes(form.content.theme)">
<view class="flex-1">
<componentDiySearch :value="form" :is-page-settings="true"></componentDiySearch>
</view>
</template>
</view>
<view v-else-if="['4', '5'].includes(form.content.theme)" class="flex-1 flex-row align-c h gap-10">
2024-09-25 08:39:28 +00:00
<view class="flex-row align-c gap-2" @tap="go_map_event">
2024-09-25 01:56:47 +00:00
<iconfont name="icon-location" size="12" color="0"></iconfont>
2024-09-25 05:35:34 +00:00
<text class="size-14 cr-3 text-line-1">{{ form.content.positioning_name }}</text>
2024-09-25 01:56:47 +00:00
<iconfont v-if="form.content.is_arrows_show == '1'" name="icon-arrow-right" size="24rpx" color="#000"></iconfont>
2024-09-24 06:17:18 +00:00
</view>
2024-09-25 01:56:47 +00:00
<template v-if="['5'].includes(form.content.theme)">
<view class="flex-1">
<componentDiySearch :value="form" :is-page-settings="true"></componentDiySearch>
</view>
</template>
2024-09-24 06:17:18 +00:00
</view>
2024-09-25 01:56:47 +00:00
<view v-if="!isEmpty(form.content.icon_setting)" class="flex-row align-c" :class="['1'].includes(form.content.theme) ? 'pa right-0 padding-right-main' : ''" :style="{ gap: form.style.img_space * 2 + 'rpx' }">
2024-09-25 08:39:28 +00:00
<view v-for="(item, index) in form.content.icon_setting" :key="index" :style="{ width: form.style.img_size * 2 + 'rpx', height: form.style.img_size * 2 + 'rpx' }" :data-value="item.link.page" @tap="url_event">
2024-09-26 02:06:20 +00:00
<image-empty v-if="item.img.length > 0" :imageSrc="item.img[0].url" :errorStyle="'width: ' + Number(form.style.img_size) * 2 + 'rpx;height:' + Number(form.style.img_size) * 2 + 'rpx;'"></image-empty>
2024-09-25 01:56:47 +00:00
<iconfont v-else :name="'icon-' + item.icon" :size="form.style.img_size * 2 + 'rpx'" color="#666"></iconfont>
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-19 10:09:42 +00:00
</view>
</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-24 06:17:18 +00:00
import { isEmpty, background_computer, gradient_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
export default {
2024-09-24 06:17:18 +00:00
props: {
2024-09-26 01:59:23 +00:00
propValue: {
2024-09-24 06:17:18 +00:00
type: Object,
default: () => ({}),
},
},
components: {
componentDiySearch,
2024-09-24 07:10:26 +00:00
imageEmpty,
2024-09-24 06:17:18 +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,
// #ifdef MP
2024-09-25 03:40:12 +00:00
top_content_style: 'padding-top:' + (bar_height + 5) + 'px;padding-bottom:12px;',
2024-09-25 01:56:47 +00:00
// #endif
// #ifdef H5 || MP-TOUTIAO
2024-09-25 03:40:12 +00:00
top_content_style: 'padding-top:' + (bar_height + 7) + 'px;padding-bottom:12px;',
2024-09-25 01:56:47 +00:00
// #endif
// #ifdef APP
2024-09-25 03:40:12 +00:00
top_content_style: 'padding-top:' + bar_height + 'px;padding-bottom:12px;',
2024-09-25 01:56:47 +00:00
// #endif
2024-09-19 10:09:42 +00:00
};
},
2024-09-24 07:10:26 +00:00
created() {
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: {
isEmpty,
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 = '';
const { header_background_img, header_background_img_style, header_background_color_list, header_background_direction, header_background_type } = new_style;
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 };
new_roll_style += gradient_computer(gradient) + background_computer(back);
} else {
new_roll_style += `background: transparent;`;
}
2024-09-24 08:24:16 +00:00
// 小程序下,获取小程序胶囊的宽度
2024-09-24 10:01:05 +00:00
let menuButtonInfo = 'max-width:100%';
2024-09-24 08:24:16 +00:00
// #ifdef MP-WEIXIN || MP-BAIDU || MP-QQ || MP-KUAISHOU
2024-09-24 10:01:05 +00:00
const custom = uni.getMenuButtonBoundingClientRect();
2024-09-25 03:01:54 +00:00
menuButtonInfo = `max-width:calc(100% - ${custom.width + 30}px);`;
2024-09-24 08:24:16 +00:00
// #endif
2024-09-24 06:17:18 +00:00
this.setData({
2024-09-26 01:59:23 +00:00
form: this.propValue,
2024-09-25 07:30:44 +00:00
position: new_style.up_slide_display == '1' ? 'position:fixed;' : 'position:relative;',
2024-09-24 06:17:18 +00:00
roll_style: new_roll_style,
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-09-25 01:56:47 +00:00
header_style: menuButtonInfo,
2024-09-24 06:17:18 +00:00
});
},
2024-09-25 08:39:28 +00:00
go_map_event() {
console.log('地图方法');
},
url_event(e) {
app.globalData.url_event(e);
},
2024-09-24 06:17:18 +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-24 06:17:18 +00:00
z-index: 2;
2024-09-25 07:30:44 +00:00
width: 100%;
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;
cursor: pointer;
}
.img {
width: 680rpx;
}
2024-09-24 06:17:18 +00:00
}
2024-09-25 01:56:47 +00:00
.model-head {
overflow: hidden;
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-09-24 06:17:18 +00:00
height: 64rpx;
2024-09-25 01:56:47 +00:00
.function-icon {
height: 64rpx;
}
2024-09-24 06:17:18 +00:00
}
2024-09-25 01:56:47 +00:00
.logo-outer-style {
2024-09-24 07:10:26 +00:00
height: 64rpx;
2024-09-25 01:56:47 +00:00
.logo-style {
height: 64rpx;
width: 64rpx;
}
2024-09-24 06:17:18 +00:00
}
2024-09-19 10:09:42 +00:00
}
</style>