123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- <template>
- <!-- 搜索框 -->
- <!-- #ifdef H5 -->
- <view class="header" :style="[headerStyle]">
- <view class="serch-wrapper acea-row row-middle" :style="[serchWrapperStyle,txtPosition]">
- <view class="logo skeleton-rect" v-if="styleConfig == 0 && styleTypeConfig == 2 && logoConfig">
- <image :src="logoConfig" mode="heightFix"></image>
- </view>
- <view class="title" :style="[txtStyle]" v-if="titleConfig && (styleConfig==1 || (styleConfig==0 && styleTypeConfig == 0))" @click="goLink">{{ titleConfig }}</view>
- <view class="map" :style="[txtStyle]" v-if="styleConfig==2 || (styleConfig==0 && styleTypeConfig == 1)">
- <text class="iconfont icon-ic_location51" v-if="fixConfig !=0"></text>
- <text v-if="styleConfig===2 && fixConfig == 1">{{addressInfos}}</text>
- <text v-if="styleConfig===2 && fixConfig == 0">{{storeName.slice(0,7) || '选择门店'}}</text>
- <text v-if="styleConfig===0 && fixConfig == 1">{{addressInfo}}</text>
- <text v-if="styleConfig===0 && fixConfig == 0">{{storeName.slice(0,4) || '选择门店'}}</text>
- <text class="iconfont icon-ic_rightarrow"></text>
- </view>
- <navigator v-if="styleConfig===0" url="/pages/goods/goods_search/index" class="input acea-row row-middle skeleton-rect" hover-class="none">
- <view class="search acea-row row-middle" :style="[searchStyle]">
- <text class="iconfont icon-ic_search"></text>
- <swiper v-if="hotWords.length" :autoplay="true" :interval="3000" :duration="1000" :vertical="true" :circular="true" class="swiper"
- :style="{ color: dataConfig.hotWordsColor.color[0].item }">
- <swiper-item v-for="(item, index) in hotWords" :key="index">
- {{ item.val }}
- </swiper-item>
- </swiper>
- <text v-else>{{ dataConfig.tipConfig.value }}</text>
- </view>
- </navigator>
- </view>
- </view>
- <!-- #endif -->
- <!-- #ifdef MP || APP-PLUS -->
- <view>
- <view class="mp-header" :style="[headerStyle, { paddingRight: serchRight + 'px' }]">
- <view class="sys-head" :style="{ height: statusBarHeight + 'px'}"></view>
- <view class="serch-box" :style="[serchWrapperStyle, { height: serchHeight + 'px' }]">
- <view class="serch-wrapper acea-row row-middle" :style="[txtPosition]">
- <view class="logo skeleton-rect" v-if="styleConfig == 0 && styleTypeConfig == 2 && logoConfig">
- <image :src="logoConfig" mode="heightFix"></image>
- </view>
- <view class="title" :style="[txtStyle]" v-if="titleConfig && (styleConfig==1 || (styleConfig==0 && styleTypeConfig == 0))" @click="goLink">{{ titleConfig }}</view>
- <view class="map" :style="[txtStyle]" v-if="styleConfig==2 || (styleConfig==0 && styleTypeConfig == 1)" @click="chooseLocation">
- <text class="iconfont icon-ic_location51" v-if="fixConfig !=0"></text>
- <text v-if="styleConfig===2 && fixConfig == 1">{{addressInfos}}</text>
- <text v-if="styleConfig===2 && fixConfig == 0">{{storeName.slice(0,7) || '选择门店'}}</text>
- <text v-if="styleConfig===0 && fixConfig == 1">{{addressInfo}}</text>
- <text v-if="styleConfig===0 && fixConfig == 0">{{storeName.slice(0,4) || '选择门店'}}</text>
- <text class="iconfont icon-ic_rightarrow"></text>
- </view>
- <navigator v-if="styleConfig===0" url="/pages/goods/goods_search/index" class="input acea-row row-middle skeleton-rect" hover-class="none">
- <view class="search acea-row row-middle" :style="[searchStyle]">
- <text class="iconfont icon-ic_search"></text>
- <swiper v-if="hotWords.length" :autoplay="true" :interval="3000" :duration="1000" :vertical="true" :circular="true" class="swiper"
- :style="{ color: dataConfig.hotWordsColor.color[0].item }">
- <swiper-item v-for="(item, index) in hotWords" :key="index">
- {{ item.val }}
- </swiper-item>
- </swiper>
- <text v-else>{{ dataConfig.tipConfig.value }}</text>
- </view>
- </navigator>
- </view>
- </view>
- </view>
- <view :style="'height:'+(statusBarHeight+serchHeight)+'px;'"></view>
- </view>
- <!-- #endif -->
- </template>
- <script>
- let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
- import location from "@/mixins/location";
- export default {
- name: 'headerSerch',
- props: {
- dataConfig: {
- type: Object,
- default: () => {}
- }
- },
- data() {
- return {
- statusBarHeight: statusBarHeight,
- marTop: 63,
- styleConfig: this.dataConfig.styleConfig.tabVal,
- styleTypeConfig:this.dataConfig.styleTypeConfig.tabVal,
- bgColor: this.dataConfig.moduleColor.color,
- titleConfig: this.dataConfig.titleConfig.value,
- txtColor: this.dataConfig.txtColor.color[0].item,
- txtStyleConfig: this.dataConfig.txtStyleConfig.tabList[this.dataConfig.txtStyleConfig.tabVal].style,
- txtSize: this.dataConfig.txtSize.val,
- fixConfig: this.dataConfig.fixConfig.tabVal,
- logoConfig: this.dataConfig.logoConfig.url,
- txtFixConfig: this.dataConfig.txtFixConfig.tabVal,
- boxStyle: '',
- mbConfig: '',
- hotWords: [],
- prConfig: '',
- tabVal: '',
- radioVal: '',
- textColor: '',
- textStyle: '',
- serchHeight: '',
- serchRight: ''
- };
- },
- computed: {
- txtStyle() {
- let num = 0
- if(this.styleConfig==0 && this.styleTypeConfig != 2){
- num = 30
- }
- return {
- color:`${this.txtColor}`,
- fontStyle:`${this.txtStyleConfig!='bold'?this.txtStyleConfig:''}`,
- fontWeight:`${this.txtStyleConfig=='bold'?this.txtStyleConfig:''}`,
- fontSize:`${this.txtSize*2}rpx`,
- marginRight:`${num}rpx`
- };
- },
- headerStyle() {
- return {
- padding: `${this.dataConfig.topConfig.val*2}rpx ${this.dataConfig.prConfig.val*2}rpx ${this.dataConfig.bottomConfig.val*2}rpx`,
- background: this.dataConfig.bottomBgColor.color[0].item,
- };
- },
- serchWrapperStyle() {
- let borderRadius = [];
- if (this.dataConfig.fillet.type) {
- for (let i = 0; i < this.dataConfig.fillet.valList.length; i++) {
- borderRadius.push(`${this.dataConfig.fillet.valList[i].val*2}rpx`);
- }
- } else {
- for (let i = 0; i < 4; i++) {
- borderRadius.push(`${this.dataConfig.fillet.val*2}rpx`);
- }
- }
- return {
- borderRadius: borderRadius.join(' '),
- background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
- };
- },
- txtPosition(){
- return {
- justifyContent:this.styleConfig !=0 && this.txtFixConfig===1?'center':this.styleConfig !=0 && this.txtFixConfig===2?'flex-end':'flex-start',
- paddingLeft:this.styleConfig !=0 && this.txtFixConfig===1?this.serchRight+'px !important':0
- }
- },
- searchStyle() {
- return {
- background: this.dataConfig.searchBoxColor.color[0].item,
- color: this.dataConfig.tipColor.color[0].item,
- justifyContent:this.txtFixConfig==0?'flex-start':this.txtFixConfig==2?'flex-end':'center'
- };
- },
- },
- mixins: [location],
- mounted() {
- let that = this;
- that.hotWords = that.dataConfig.hotWords.list.filter(item => {
- if (item.val) {
- return item;
- }
- });
- uni.setStorageSync('hotList', that.hotWords);
- that.$store.commit('hotWords/setHotWord', that.hotWords);
- // #ifdef MP || APP-PLUS
- setTimeout(() => {
- // 获取小程序头部高度
- let info = uni.createSelectorQuery().in(this).select(".mp-header");
- info.boundingClientRect(function(data) {
- that.marTop = data.height
- }).exec()
- }, 100)
- // #endif
- // #ifdef MP
- const {
- windowWidth,
- statusBarHeight,
- } = uni.getSystemInfoSync();
- const {
- top,
- left,
- width,
- height,
- } = uni.getMenuButtonBoundingClientRect();
- that.serchHeight = (top - statusBarHeight) * 2 + height;
- that.serchRight = windowWidth - left;
- // #endif
- if(this.styleConfig===2 || (this.styleConfig===0 && this.styleTypeConfig === 1)){
- this.selfLocation();
- }
- },
- methods: {
- goLink() {
- let url = this.dataConfig.linkConfig.value;
- this.$util.JumpPath(url);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .serch-wrapper {
- &.center {
- justify-content: center;
- }
- &.right {
- justify-content: flex-end;
- /* #ifdef MP */
- padding-right: 185rpx !important;
- /* #endif */
- }
- }
- .title {
- margin-right: 30rpx;
- font-weight: 400;
- font-size: 30rpx;
- color: #333333;
- }
- .map {
- color: #fff;
- font-size: 28rpx;
- margin-right: 20rpx;
- .info {
- &.on {
- max-width: 260rpx;
- }
- &.on1 {
- max-width: 156rpx;
- }
- }
- .iconfont {
- font-size: 28rpx;
- }
- .icon-ic_rightarrow {
- opacity: 0.8;
- }
- .icon-ic_location51{
- margin-right: 6rpx;
- }
- }
- .header {
- width: 100%;
- // height: 100rpx;
- // background: linear-gradient(90deg, $bg-star 50%, $bg-end 100%);
- .serch-wrapper {
- height: 96rpx;
- padding: 18rpx 30rpx !important;
- .logo {
- height: 60rpx;
- margin-right: 20rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .input {
- position: relative;
- flex: 1;
- .search {
- flex: 1;
- height: 60rpx;
- padding: 0 32rpx;
- border-radius: 30rpx;
- background: #F5F5F5;
- font-size: 28rpx;
- line-height: 32rpx;
- }
- .iconfont {
- margin-right: 16rpx;
- font-size: 32rpx;
- }
- .swiper {
- flex: 1;
- height: 32rpx;
- }
- }
- }
- }
- /* #ifdef MP || APP-PLUS */
- .mp-header {
- z-index: 30;
- position: fixed;
- left: 0;
- top: 0;
- width: 100%;
- background: linear-gradient(90deg, $bg-star 50%, $bg-end 100%);
- .serch-wrapper {
- height: 100%;
- /* #ifdef MP */
- padding: 0 30rpx !important;
- /* #endif */
- /* #ifdef APP-PLUS */
- padding: 0 50rpx 0 40rpx;
- /* #endif */
- .logo {
- height: 60rpx;
- margin-right: 20rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .input {
- position: relative;
- flex: 1;
- .search {
- flex: 1;
- height: 60rpx;
- padding: 0 32rpx;
- border-radius: 30rpx;
- background: #F5F5F5;
- font-size: 28rpx;
- line-height: 32rpx;
- }
- .iconfont {
- font-size: 32rpx;
- margin-right: 18rpx;
- }
- .swiper {
- flex: 1;
- height: 32rpx;
- }
- .button {
- position: absolute;
- top: 4rpx;
- right: 4rpx;
- height: 52rpx;
- padding: 0 24rpx;
- border-radius: 26rpx;
- background: var(--view-theme);
- font-weight: 500;
- line-height: 52rpx;
- font-size: 22rpx;
- color: #FFFFFF;
- }
- .button2 {
- margin-left: 20rpx;
- font-size: 30rpx;
- color: var(--view-theme);
- }
- // 没有logo,直接搜索框
- &.on {
- /* #ifdef MP */
- width: 70%;
- /* #endif */
- /* #ifdef APP-PLUS */
- width: 100%;
- /* #endif */
- }
- // 设置圆角
- &.fillet {
- border-radius: 29rpx;
- }
- // 文本框文字居中
- &.row-center {
- padding: 0;
- }
- }
- }
- }
- /* #endif */
- .row-center uni-swiper-item, .row-center swiper-item{
- text-align: center;
- }
- </style>
|