index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view class="content">
  3. <!--搜索栏-->
  4. <view>
  5. <u-search :shape="square" @search="doSearch" :showAction="false" :height="searchHeight" placeholder="日照香炉生紫烟" v-model="keyword"></u-search>
  6. </view>
  7. <!--轮播图-->
  8. <view class="banner">
  9. <swiper :autoplay="true" :circular="true" :interval="3000" class="swiper" :indicator-dots="true">
  10. <swiper-item class="swiperItem" v-for="(item,index) in slideshowLinks" :key="index">
  11. <view class="swiperImgView ">
  12. <image class="swiperImg" :src="item"></image>
  13. </view>
  14. </swiper-item>
  15. </swiper>
  16. </view>
  17. <!-- 标题栏 -->
  18. <u-sticky>
  19. <View>
  20. <u-tabs :list="tabList" :current="tabIndex" @click="clickTab"></u-tabs>
  21. </View>
  22. </u-sticky>
  23. <!-- 商品列表 -->
  24. <view :style="{'height':windowHeight}">
  25. <swiper :style="{'height':windowHeight}" :current="tabIndex" @change="swiperChange">
  26. <swiper-item class="swiperItem" v-for="(item,index) in tabList" :key="index" >
  27. <scroll-view :style="{'height':windowHeight}" :scroll-y="true" @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower">
  28. <uni-grid :column="2" :square="false" :showBorder="false">
  29. <uni-grid-item v-for="i in 10" :key="i">
  30. <view class="goods flex-col" @click="goGoodsDetail">
  31. <view class="goodsImgView">
  32. <image class="goodsImg" src="/static/0e733b67a401b9b5776b5196cd5b38e0.jpg"></image>
  33. </view>
  34. <view class="goodsName">
  35. <text>美女</text>
  36. </view>
  37. <view class="goodsImgTitle">
  38. <text>商品说明</text>
  39. </view>
  40. <view class="goodsPrice">
  41. <text>¥700</text>
  42. </view>
  43. </view>
  44. </uni-grid-item>
  45. </uni-grid>
  46. </scroll-view>
  47. </swiper-item>
  48. </swiper>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. swiperList: ['integral', 'kefu-ermai', 'coupon', 'gift', 'scan', 'pause-circle', 'wifi', 'email', 'list'],
  57. slideshowLinks: [
  58. 'http://rredu.obs.cn-southwest-2.myhuaweicloud.com/upload/20230709/b1a1d6fcfb8b30f13b20607739e1b344.png',
  59. 'http://rredu.obs.cn-southwest-2.myhuaweicloud.com/upload/20230709/c3d1ebde245651d602211ba7af4d1a92.png',
  60. 'http://rredu.obs.cn-southwest-2.myhuaweicloud.com/upload/20230709/ee83d2c5934cea4d66a43a3a34d2cf86.png'
  61. ],
  62. tabList: [{
  63. name: '关注',
  64. }, {
  65. name: '推荐',
  66. }, {
  67. name: '电影'
  68. }, {
  69. name: '科技'
  70. }, {
  71. name: '音乐'
  72. }, {
  73. name: '美食'
  74. }, {
  75. name: '文化'
  76. }, {
  77. name: '财经'
  78. }, {
  79. name: '手工'
  80. }],
  81. menuButtonTop:'',//胶囊按钮距离屏幕上边的距离
  82. menuButtonLeft:'',//胶囊按钮距离屏幕左边的距离
  83. searchHeight:'',//搜索框的高度
  84. windowHeight:'',//屏幕的可用高度
  85. tabIndex:0,
  86. keyword:'',
  87. }
  88. },
  89. onLoad() {
  90. this.getmessage()
  91. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  92. console.log('+++++menuButtonInfo+++++++',menuButtonInfo)
  93. this.menuButtonTop =menuButtonInfo.top+'px'; //胶囊按钮距离屏幕上边的距离
  94. this.menuButtonLeft =menuButtonInfo.left +'px'; //胶囊按钮距离屏幕左边的距离
  95. this.searchHeight=menuButtonInfo.bottom-menuButtonInfo.top +'px' //搜索框的高度
  96. let sysInfo = uni.getSystemInfoSync()
  97. this.windowHeight =sysInfo.windowHeight-44+'px'//除标题栏栏外的屏幕可用高度
  98. },
  99. methods: {
  100. /*下拉刷新的回调 */
  101. downCallback() {
  102. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  103. // loadSwiper();
  104. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  105. this.mescroll.resetUpScroll()
  106. },
  107. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  108. upCallback(page) {
  109. //联网加载数据
  110. // getSchoolPage(page.num, 10).then(res => {
  111. // console.log(res)
  112. // this.mescroll.endSuccess(res.data.data.records.length,res.data.data.records.length === 10);
  113. // if (page.num === 1) this.schoolMsgs = []; //如果是第一页需手动制空列表
  114. // if (res.data.data.records.length > 0){
  115. // this.schoolMsgs = this.schoolMsgs.concat(res.data.data.records); //追加新数据
  116. // }
  117. // }).catch((err) => {
  118. // //联网失败, 结束加载
  119. // this.mescroll.endErr();
  120. // })
  121. },
  122. //点击空布局按钮的回调
  123. emptyClick() {
  124. uni.showToast({
  125. title: '点击了按钮,具体逻辑自行实现'
  126. })
  127. },
  128. // 搜索
  129. doSearch() {
  130. console.log('sousuo')
  131. this.list = []; // 先清空列表,显示加载进度
  132. this.mescroll.resetUpScroll();
  133. },
  134. goGoodsDetail() {
  135. uni.navigateTo({
  136. url: '/orderPages/goodsDetail/index'
  137. })
  138. },
  139. getmessage() {
  140. this.$api.payTheBill({}).then(res => {
  141. console.log(res)
  142. })
  143. },
  144. clickTab(e){
  145. this.tabIndex = e.index
  146. },
  147. swiperChange(e){
  148. this.tabIndex = e.detail.current
  149. },
  150. scrolltoupper(){
  151. },
  152. scrolltolower(){
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. @import '/common/css/common.css';
  159. @import './index.rpx.css';
  160. </style>