123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <template>
- <view class="zs-banner">
- <!-- <view class="position-box" :style="{height:navBareight +'px',top:statusBarHeight+'px'}" v-if="position"> -->
- <view class="position-box" :style="{height:navBareight +'px',background:background?'#fff':''}" v-if="position">
- <view class="position" @click="handlePosition">
- <image class="position-icon" src="../../static/black-position.png" mode=""></image>
- <text class="city">{{city}}</text>
- </view>
- <view class="search-box" @click="handleSearch">
- <input class="search" :style="{height:height+'px'}" type="text" placeholder="搜索" v-model="search" />
- <image class="icon" src="../../static/search.png" mode=""></image>
- </view>
- </view>
- <view class="top-box" :style="{'--bg':theme}">
-
- <swiper class="swiper" @change="swiperChange" skip-hidden-item-layout :indicator-dots="true" circular :autoplay="true" :interval="3000" :duration="1000">
- <swiper-item v-for="(item,index) in bannerList" :key="index" @click="goDetail(item.jumpUrl)">
- <image class="swiper-item" mode="" :src="item.bannerImg">
- </image>
- </swiper-item>
-
- </swiper>
- </view>
- <!-- <u-notice-bar bgColor="none" icon="volume-fill" color="#6F4F23" direction="column" :fontSize='26' :text="textList"></u-notice-bar> -->
- </view>
- </template>
- <script>
-
- import {
- getNotification,
- getBanner
- } from '@/api/common.js'
- export default {
- options:{
- styleIsolation:'shared'
- },
- props: {
- position: {
- type: Boolean,
- default: false
- },
- city:{
- type: String,
- default: '定位中'
- },
- background: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
- navBareight:0,
- height:0,
- search:'',
- theme: '#FD9E59', //顶部颜色
- textList: [], //通知列表
- bannerList: [
- // {
- // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/LasLcHe8z6F9c7c569e98cf778f866ac466404589d03.png/1.png',
- // theme: '#FD9E59'
- // },
- // {
- // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/QdulVZUZ9HYH190ae2e9392281ee1b845573e68ece1e.png/1.png',
- // theme: '#FDD34C'
- // },
- // {
- // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/N7kknVWzDPKLbb7e15025599a818bbf11e3b030b6765.png/1.png',
- // theme: '#B0ACF9'
- // },
- // {
- // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/rJ1Crwfuf0if0e3285089cb737285b7583c890a905db.png/1.png',
- // theme: '#85DCF4'
- // },
- // {
- // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/WBcUUqzpi50Dd1012af5dd52b6e28758a49e79e3fd07.png/1.png',
- // theme: '#FE6646'
- // }
- ],
- };
- },
- methods: {
- // 跳转优惠详情
- goDetail(url) {
- uni.navigateTo({
- url,
- })
- },
- // swiper变动
- swiperChange(val) {
- this.theme = this.bannerList[val.detail.current].colour
- },
- // 获取通知列表
- getNotification() {
- // this.loading = true
- getNotification({
- page: 1,
- pageSize: 10
- }).then(res => {
- if(res.state == 'Success'){
- this.textList = []
- res.content.records.map(item => {
- this.textList.push(`用户${item.phoneNum}注册成功,本月累计节省${item.economizeTheMoney||0}元`)
- })
- }
- }).catch(e=>{
- console.log(3,e);
- })
- },
- getBanner(){
- getBanner({currentPage:1,pageSize:10,belongType:2}).then(res=>{
- if(res.state == 'Success'){
- this.bannerList = res.content.records
- this.theme = this.bannerList[0].colour
- }
- })
- },
- jump(){
- uni.navigateTo({
- url:'../../pages/index/position'
- })
- },
- handleSearch(){
- this.$emit('search',this.search)
- },
- handlePosition(){
- this.$emit('handlePosition','')
- },
- getNavHeight(){
-
- //去除
- //#ifndef H5 || MP-ALIPAY ||APP-PLUS
- //获取小程序胶囊的高度
- let {
- bottom,
- height
- } = uni.getMenuButtonBoundingClientRect()
- this.height = height
- this.navBareight = bottom
- //#endif
- }
- },
- created() {
- // this.getNotification()
- this.getBanner()
- this.getNavHeight()
- }
- }
- </script>
- <style lang="scss" >
- // 通知喇叭样式
- .zs-banner ::v-deep .u-notice .u-icon__icon{
- font-size: 32rpx!important;
- }
-
- .zs-banner{
- position: relative;
- // height: 584rpx;
- .position-box{
- position: fixed;
- width: 100%;
- top: 0;
- left: 0;
- z-index: 2;
- display: flex;
- align-items: flex-end;
- justify-content: center;
- box-sizing: border-box;
- // padding-bottom: 6rpx;
- .position{
- position: absolute;
- // top: 50%;
- left: 30rpx;
- // transform: translateY(-50%);
- color: #222;
- display: flex;
- align-items: center;
- font-size: 24rpx;
- .position-icon{
- width: 40rpx;
- height: 40rpx;
- }
- .city{
- margin-left: 6rpx;
- line-height: 60rpx;
- }
- }
- .search-box {
- width: 380rpx;
- // height: 60rpx;
- background: #FFFFFF;
- border-radius: 30rpx;
- position: absolute;
- left: 160rpx;
- box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(0,0,0,0.1);
- .icon {
- width: 34rpx;
- height: 34rpx;
- position: absolute;
- top: 50%;
- left: 22rpx;
- transform: translateY(-50%);
- }
-
- .search {
- // line-height: 60rpx;
- // height: 60rpx;
- padding-left: 80rpx;
- }
- }
- }
- .top-box {
- background: linear-gradient(180deg, var(--bg) 0%, #FFF 100%);
- // padding: 100rpx 32rpx 0;
- height: 536rpx;
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- justify-content: flex-end;
-
-
-
- .swiper {
- height: 584rpx;
- border-radius: 16rpx;
- .swiper-item {
- width: 100%;
- height: 100%;
- // border-radius: 16rpx;
- object-fit: cover;
- }
- }
- }
- }
- </style>
|