index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="list">
  3. <view class="msearch">
  4. <u-search v-model="param.name" :animation="true" action-text="取消" placeholder="输入搜索内容" shape="round" @search="search" @clear="clear"></u-search>
  5. </view>
  6. <view class="r_item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  7. <image :src="ip + item.showPictures[0]" mode="aspectFill" class="pic"></image>
  8. <view class="con">
  9. <view class="title omit">{{ item.name }}</view>
  10. <view class="ms omit">
  11. <text class="icon">&#xe64a;</text>
  12. <text class="tti">{{ item.addres }}</text>
  13. </view>
  14. <view class="ms">
  15. <u-rate :count="5" v-model="value" active-color="#FF9800" :disabled="true"></u-rate>
  16. <text>5.0</text>
  17. </view>
  18. </view>
  19. <view class="clear"></view>
  20. </view>
  21. <view class="loading"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. ip: this.$http.urls.ip,
  29. value: 5,
  30. list: [],
  31. param: { pageNum: 1, pageSize: 10, name: '' },
  32. loadMore: true
  33. };
  34. },
  35. onLoad() {
  36. this.getData();
  37. },
  38. methods: {
  39. //获取数据
  40. getData() {
  41. this.$http.request({
  42. url: this.$http.urls.hotelList,
  43. data: this.param,
  44. loading: 'false',
  45. success: res => {
  46. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  47. res.data.rows.forEach(item => {
  48. item.showPictures = item.showPictures.split(',');
  49. this.list.push(item);
  50. });
  51. }
  52. });
  53. },
  54. //详情
  55. detail(item) {
  56. uni.navigateTo({ url: '/pages/shop/detail?shopId=' + item.shopId });
  57. },
  58. //点击键盘搜索按钮触发
  59. search() {
  60. this.refresh();
  61. },
  62. //清空搜索内容
  63. clear() {
  64. this.refresh();
  65. },
  66. //刷新数据
  67. refresh() {
  68. this.loadMore = true;
  69. this.param.pageNum = 1;
  70. this.list = [];
  71. this.getData();
  72. }
  73. },
  74. //下拉刷新
  75. onPullDownRefresh() {
  76. setTimeout(() => {
  77. uni.stopPullDownRefresh();
  78. this.refresh();
  79. }, 1000);
  80. },
  81. //上拉加载
  82. onReachBottom() {
  83. if (this.loadMore) {
  84. this.param.pageNum++;
  85. this.getData();
  86. }
  87. }
  88. };
  89. </script>
  90. <style lang="scss">
  91. .list {
  92. padding: 10px 17px 70px 17px;
  93. }
  94. </style>