index.vue 5.7 KB

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