index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="zs-banner">
  3. <!-- <view class="position-box" :style="{height:navBareight +'px',top:statusBarHeight+'px'}" v-if="position"> -->
  4. <view class="position-box" :style="{height:navBareight +'px',background:background?'#fff':''}" v-if="position">
  5. <view class="position">
  6. <image class="position-icon" src="../../static/black-position.png" mode=""></image>
  7. <text class="city">{{city}}</text>
  8. </view>
  9. <view class="search-box" @click="handleSearch">
  10. <input class="search" :style="{height:height+'px'}" type="text" placeholder="搜索" v-model="search" />
  11. <image class="icon" src="../../static/search.png" mode=""></image>
  12. </view>
  13. </view>
  14. <view class="top-box" :style="{'--bg':theme}">
  15. <swiper class="swiper" @change="swiperChange" :indicator-dots="true" circular :autoplay="true"
  16. :interval="3000" :duration="1000">
  17. <swiper-item v-for="(item,index) in bannerList" :key="index">
  18. <image class="swiper-item" mode="" :src="item.bannerImg">
  19. </image>
  20. </swiper-item>
  21. </swiper>
  22. </view>
  23. <u-notice-bar bgColor="none" icon="volume-fill" color="#6F4F23" direction="column" :fontSize='26' :text="textList"></u-notice-bar>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. getNotification,
  29. getBanner
  30. } from '@/api/common.js'
  31. export default {
  32. options:{
  33. styleIsolation:'shared'
  34. },
  35. props: {
  36. position: {
  37. type: Boolean,
  38. default: false
  39. },
  40. city:{
  41. type: String,
  42. default: '定位中'
  43. },
  44. background: {
  45. type: Boolean,
  46. default: false
  47. }
  48. },
  49. data() {
  50. return {
  51. navBareight:0,
  52. height:0,
  53. search:'',
  54. theme: '#FD9E59', //顶部颜色
  55. textList: [], //通知列表
  56. bannerList: [
  57. // {
  58. // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/LasLcHe8z6F9c7c569e98cf778f866ac466404589d03.png/1.png',
  59. // theme: '#FD9E59'
  60. // },
  61. // {
  62. // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/QdulVZUZ9HYH190ae2e9392281ee1b845573e68ece1e.png/1.png',
  63. // theme: '#FDD34C'
  64. // },
  65. // {
  66. // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/N7kknVWzDPKLbb7e15025599a818bbf11e3b030b6765.png/1.png',
  67. // theme: '#B0ACF9'
  68. // },
  69. // {
  70. // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/rJ1Crwfuf0if0e3285089cb737285b7583c890a905db.png/1.png',
  71. // theme: '#85DCF4'
  72. // },
  73. // {
  74. // src:'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/WBcUUqzpi50Dd1012af5dd52b6e28758a49e79e3fd07.png/1.png',
  75. // theme: '#FE6646'
  76. // }
  77. ],
  78. };
  79. },
  80. methods: {
  81. // swiper变动
  82. swiperChange(val) {
  83. this.theme = this.bannerList[val.detail.current].colour
  84. },
  85. // 获取通知列表
  86. getNotification() {
  87. // this.loading = true
  88. getNotification({
  89. page: 1,
  90. pageSize: 10
  91. }).then(res => {
  92. if(res.state == 'Success'){
  93. this.textList = []
  94. res.content.records.map(item => {
  95. this.textList.push(`用户${item.phoneNum}注册成功,本月累计节省${item.economizeTheMoney||0}元`)
  96. })
  97. }
  98. }).catch(e=>{
  99. console.log(3,e);
  100. })
  101. },
  102. getBanner(){
  103. getBanner({currentPage:1,pageSize:10}).then(res=>{
  104. if(res.state == 'Success'){
  105. this.bannerList = res.content.records
  106. this.theme = this.bannerList[0].colour
  107. }
  108. })
  109. },
  110. jump(){
  111. uni.navigateTo({
  112. url:'../../pages/index/position'
  113. })
  114. },
  115. handleSearch(){
  116. this.$emit('search',this.search)
  117. },
  118. getNavHeight(){
  119. //去除
  120. //#ifndef H5 || MP-ALIPAY ||APP-PLUS
  121. //获取小程序胶囊的高度
  122. let {
  123. bottom,
  124. height
  125. } = uni.getMenuButtonBoundingClientRect()
  126. this.height = height
  127. this.navBareight = bottom
  128. //#endif
  129. }
  130. },
  131. created() {
  132. this.getNotification()
  133. this.getBanner()
  134. this.getNavHeight()
  135. }
  136. }
  137. </script>
  138. <style lang="scss" >
  139. // 通知喇叭样式
  140. .zs-banner ::v-deep .u-notice .u-icon__icon{
  141. font-size: 32rpx!important;
  142. }
  143. .zs-banner{
  144. position: relative;
  145. height: 584rpx;
  146. .position-box{
  147. position: fixed;
  148. width: 100%;
  149. top: 0;
  150. left: 0;
  151. z-index: 2;
  152. display: flex;
  153. align-items: flex-end;
  154. justify-content: center;
  155. box-sizing: border-box;
  156. // padding-bottom: 6rpx;
  157. .position{
  158. position: absolute;
  159. // top: 50%;
  160. left: 30rpx;
  161. // transform: translateY(-50%);
  162. color: #222;
  163. display: flex;
  164. align-items: center;
  165. font-size: 24rpx;
  166. .position-icon{
  167. width: 40rpx;
  168. height: 40rpx;
  169. }
  170. .city{
  171. margin-left: 6rpx;
  172. line-height: 60rpx;
  173. }
  174. }
  175. .search-box {
  176. width: 380rpx;
  177. // height: 60rpx;
  178. background: #FFFFFF;
  179. border-radius: 30rpx;
  180. position: absolute;
  181. left: 160rpx;
  182. box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(0,0,0,0.1);
  183. .icon {
  184. width: 34rpx;
  185. height: 34rpx;
  186. position: absolute;
  187. top: 50%;
  188. left: 22rpx;
  189. transform: translateY(-50%);
  190. }
  191. .search {
  192. // line-height: 60rpx;
  193. // height: 60rpx;
  194. padding-left: 80rpx;
  195. }
  196. }
  197. }
  198. .top-box {
  199. background: linear-gradient(180deg, var(--bg) 0%, #FFF 100%);
  200. // padding: 100rpx 32rpx 0;
  201. height: 536rpx;
  202. box-sizing: border-box;
  203. display: flex;
  204. flex-direction: column;
  205. justify-content: flex-end;
  206. .swiper {
  207. height: 584rpx;
  208. border-radius: 16rpx;
  209. .swiper-item {
  210. width: 100%;
  211. height: 100%;
  212. // border-radius: 16rpx;
  213. object-fit: cover;
  214. }
  215. }
  216. }
  217. }
  218. </style>