index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="content">
  3. <!--搜索栏-->
  4. <view class="search" :style="{'margin-top':menuButtonTop,'width':menuButtonLeft}">
  5. <u-search @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. <mescroll-uni :ref="mescrollRef" @init="mescrollInit" :height="windowHeight" :down="downOption"
  28. :up="upOption" @down="downCallback" @up="upCallback" @emptyclick="emptyClick">
  29. <uni-grid :column="2" :square="false" :showBorder="false">
  30. <uni-grid-item>
  31. <view class="goods flex-col">
  32. <view class="goodsImgView">
  33. <image class="goodsImg" src="/static/0e733b67a401b9b5776b5196cd5b38e0.jpg"></image>
  34. </view>
  35. <view class="goodsName">
  36. <text>美女</text>
  37. </view>
  38. <view class="goodsImgTitle">
  39. <text>商品说明</text>
  40. </view>
  41. <view class="goodsPrice">
  42. <text>¥700</text>
  43. </view>
  44. </view>
  45. </uni-grid-item>
  46. <uni-grid-item>
  47. <view class="goods flex-col">
  48. <view class="goodsImgView">
  49. <image class="goodsImg" src="/static/0e733b67a401b9b5776b5196cd5b38e0.jpg"></image>
  50. </view>
  51. <view class="goodsName">
  52. <text>商品名字商品名字商商品名字商品名字商品名字</text>
  53. </view>
  54. <view class="goodsImgTitle">
  55. <text>商品说明</text>
  56. </view>
  57. <view class="goodsPrice">
  58. <text>¥700</text>
  59. </view>
  60. </view>
  61. </uni-grid-item>
  62. <uni-grid-item>
  63. <view class="goods flex-col">
  64. <view class="goodsImgView">
  65. <image class="goodsImg" src="/static/0e733b67a401b9b5776b5196cd5b38e0.jpg"></image>
  66. </view>
  67. <view class="goodsName">
  68. <text>商品名字商品品名字</text>
  69. </view>
  70. <view class="goodsImgTitle">
  71. <text>商品说明</text>
  72. </view>
  73. <view class="goodsPrice">
  74. <text>¥700</text>
  75. </view>
  76. </view>
  77. </uni-grid-item>
  78. <uni-grid-item>
  79. <view class="goods flex-col">
  80. <view class="goodsImgView">
  81. <image class="goodsImg" src="/static/0e733b67a401b9b5776b5196cd5b38e0.jpg"></image>
  82. </view>
  83. <view class="goodsName">
  84. <text>商品名字商品名字商品名字商品名字商品名字商品品名字商品名字商品名字商品名字商品名字</text>
  85. </view>
  86. <view class="goodsImgTitle">
  87. <text>商品说明</text>
  88. </view>
  89. <view class="goodsPrice">
  90. <text>¥700</text>
  91. </view>
  92. </view>
  93. </uni-grid-item>
  94. <uni-grid-item>
  95. <view class="goods flex-col">
  96. <view class="goodsImgView">
  97. <image class="goodsImg" src="/static/0e733b67a401b9b5776b5196cd5b38e0.jpg"></image>
  98. </view>
  99. <view class="goodsName">
  100. <text>商品名字商品名字商品名字商品名字商品名字商品名字商品名字商品名名字商品名字</text>
  101. </view>
  102. <view class="goodsImgTitle">
  103. <text>商品说明</text>
  104. </view>
  105. <view class="goodsPrice">
  106. <text>¥700</text>
  107. </view>
  108. </view>
  109. </uni-grid-item>
  110. <uni-grid-item>
  111. <view class="goods flex-col">
  112. <view class="goodsImgView">
  113. <image class="goodsImg" src="/static/0e733b67a401b9b5776b5196cd5b38e0.jpg"></image>
  114. </view>
  115. <view class="goodsName">
  116. <text>商品名字商品名字商品名字商</text>
  117. </view>
  118. <view class="goodsImgTitle">
  119. <text>商品说明</text>
  120. </view>
  121. <view class="goodsPrice">
  122. <text>¥700</text>
  123. </view>
  124. </view>
  125. </uni-grid-item>
  126. </uni-grid>
  127. </mescroll-uni>
  128. </swiper-item>
  129. </swiper>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  135. import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";
  136. export default {
  137. mixins: [MescrollMixin, MescrollMoreItemMixin], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
  138. data() {
  139. return {
  140. downOption: {
  141. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  142. },
  143. upOption: {
  144. auto: false, // 不自动加载
  145. // page: {
  146. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  147. // size: 10 // 每页数据的数量
  148. // },
  149. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  150. empty: {
  151. icon: '/static/imageIcon/empty.png',
  152. tip: '暂无内容', // 提示
  153. // btnText: '去看看'
  154. },
  155. textNoMore: '没有更多了'
  156. },
  157. swiperList: ['integral', 'kefu-ermai', 'coupon', 'gift', 'scan', 'pause-circle', 'wifi', 'email', 'list'],
  158. slideshowLinks: [
  159. 'http://rredu.obs.cn-southwest-2.myhuaweicloud.com/upload/20230709/b1a1d6fcfb8b30f13b20607739e1b344.png',
  160. 'http://rredu.obs.cn-southwest-2.myhuaweicloud.com/upload/20230709/c3d1ebde245651d602211ba7af4d1a92.png',
  161. 'http://rredu.obs.cn-southwest-2.myhuaweicloud.com/upload/20230709/ee83d2c5934cea4d66a43a3a34d2cf86.png'
  162. ],
  163. tabList: [{
  164. name: '关注',
  165. }, {
  166. name: '推荐',
  167. }, {
  168. name: '电影'
  169. }, {
  170. name: '科技'
  171. }, {
  172. name: '音乐'
  173. }, {
  174. name: '美食'
  175. }, {
  176. name: '文化'
  177. }, {
  178. name: '财经'
  179. }, {
  180. name: '手工'
  181. }],
  182. menuButtonTop:'',//胶囊按钮距离屏幕上边的距离
  183. menuButtonLeft:'',//胶囊按钮距离屏幕左边的距离
  184. searchHeight:'',//搜索框的高度
  185. windowHeight:'',//屏幕的可用高度
  186. tabIndex:0,
  187. keyword:'',
  188. }
  189. },
  190. onLoad() {
  191. this.getmessage()
  192. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  193. this.menuButtonTop =menuButtonInfo.top+'px'; //胶囊按钮距离屏幕上边的距离
  194. this.menuButtonLeft =menuButtonInfo.left+'px'; //胶囊按钮距离屏幕左边的距离
  195. this.searchHeight=menuButtonInfo.bottom-menuButtonInfo.top +'px' //搜索框的高度
  196. let sysInfo = uni.getSystemInfoSync()
  197. this.windowHeight =sysInfo.windowHeight-44+'px'//除标题栏栏外的屏幕可用高度
  198. },
  199. methods: {
  200. /*下拉刷新的回调 */
  201. downCallback() {
  202. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  203. // loadSwiper();
  204. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  205. this.mescroll.resetUpScroll()
  206. },
  207. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  208. upCallback(page) {
  209. //联网加载数据
  210. // getSchoolPage(page.num, 10).then(res => {
  211. // console.log(res)
  212. // this.mescroll.endSuccess(res.data.data.records.length,res.data.data.records.length === 10);
  213. // if (page.num === 1) this.schoolMsgs = []; //如果是第一页需手动制空列表
  214. // if (res.data.data.records.length > 0){
  215. // this.schoolMsgs = this.schoolMsgs.concat(res.data.data.records); //追加新数据
  216. // }
  217. // }).catch((err) => {
  218. // //联网失败, 结束加载
  219. // this.mescroll.endErr();
  220. // })
  221. },
  222. //点击空布局按钮的回调
  223. emptyClick() {
  224. uni.showToast({
  225. title: '点击了按钮,具体逻辑自行实现'
  226. })
  227. },
  228. // 搜索
  229. doSearch() {
  230. console.log('sousuo')
  231. this.list = []; // 先清空列表,显示加载进度
  232. this.mescroll.resetUpScroll();
  233. },
  234. goOrderDetail() {
  235. uni.navigateTo({
  236. url: '/orderPages/orderDetail/index'
  237. })
  238. },
  239. getmessage() {
  240. this.$api.payTheBill({}).then(res => {
  241. console.log(res)
  242. })
  243. },
  244. clickTab(e){
  245. this.tabIndex = e.index
  246. },
  247. swiperChange(e){
  248. this.tabIndex = e.detail.current
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss">
  254. @import '/common/css/common.css';
  255. @import './index.rpx.css';
  256. </style>