index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="width-100 height-100 view-page">
  3. <u-tabs ref="tabs" :list="tabList" :scrollable="false" :current="currentTab" @change="tabChange" lineColor="#65371b"
  4. :activeStyle="{color:'#65371b'}" inactiveStyle="{color:'#65371b'}"></u-tabs>
  5. <view class="info-list">
  6. <view class="info-item" v-for="(item, index) in 10" :key="index">
  7. <view class="info-pic"></view>
  8. <view class="info-title">
  9. 标题标题标题标
  10. </view>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import themeMixins from '@/pages/yuecai/mixins/themeMixins.js';
  17. export default {
  18. mixins: [themeMixins],
  19. data() {
  20. return {
  21. page: {
  22. loading: false,
  23. current: 1,
  24. size: 10,
  25. total: 0,
  26. // loadmore loading nomore
  27. status: 'loadmore',
  28. loadingText: '正在加载中',
  29. loadmoreText: '上拉加载更多',
  30. nomoreText: '没有更多了'
  31. },
  32. keyword: '',
  33. list: [],
  34. tabList: [{
  35. name: '名菜'
  36. }, {
  37. name: '名店',
  38. }, {
  39. name: '名点',
  40. }],
  41. currentTab: 0
  42. }
  43. },
  44. onLoad(options) {
  45. this.collectionType = options.type || '';
  46. },
  47. onShow() {
  48. this.keyword = '';
  49. this.doRefresh();
  50. },
  51. methods: {
  52. scrolltolower() {
  53. this.loadmore()
  54. },
  55. loadmore() {
  56. this.page.current++;
  57. this.getCollectionList();
  58. },
  59. doRefresh() {
  60. this.page.current = 1;
  61. this.page.status = 'loadmore'
  62. this.list = [];
  63. this.getCollectionList();
  64. },
  65. getCollectionList() {
  66. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  67. // 防止重复下拉
  68. return;
  69. }
  70. this.page.status = 'loading';
  71. //
  72. this.$u.api.getCollectionList(this.page.current, this.page.size, {
  73. collectType: this.collectionType || ''
  74. }).then(res => {
  75. if (res.data.records && res.data.records.length > 0) {
  76. this.list.push(...res.data.records)
  77. }
  78. this.page.total = res.data.total || 0;
  79. if (this.page.size * this.page.current >= res.data.total) {
  80. this.page.status = 'nomore'
  81. } else {
  82. this.page.status = 'loadmore'
  83. }
  84. }).catch(e => {
  85. this.page.status = 'loadmore'
  86. })
  87. },
  88. toDetail(id) {
  89. if (this.collectionType == 'dish') {
  90. uni.navigateTo({
  91. url: "/pages/yuecai/dish/detail/index?id=" + id,
  92. })
  93. } else if (this.collectionType == 'snacks') {
  94. uni.navigateTo({
  95. url: "/pages/yuecai/snacks/detail/index?id=" + id,
  96. })
  97. } else if (this.collectionType == 'restaurant') {
  98. uni.navigateTo({
  99. url: "/pages/yuecai/restaurant/detail/index?id=" + id,
  100. })
  101. }
  102. },
  103. deleteCollection(id, index) {
  104. if (this.loading) {
  105. return;
  106. }
  107. this.loading = true;
  108. this.$u.api.deleteCollection(id).then(res => {
  109. this.list.splice(index, 1);
  110. this.loading = false;
  111. }).catch(e => {
  112. this.loading = false;
  113. })
  114. }
  115. },
  116. }
  117. </script>
  118. <style scoped lang="scss">
  119. .view-page {
  120. overflow: hidden;
  121. }
  122. .info-list {
  123. display: flex;
  124. flex-wrap: wrap;
  125. .info-item {
  126. padding: 20rpx;
  127. width: 33%;
  128. box-sizing: border-box;
  129. .info-pic {
  130. margin: auto;
  131. width: 175rpx;
  132. height: 175rpx;
  133. background: bisque;
  134. }
  135. .info-title {
  136. color: #65371b;
  137. font-size: 24rpx;
  138. font-weight: 300;
  139. line-height: 47rpx;
  140. word-spacing: 2rpx;
  141. overflow: hidden;
  142. text-overflow: -o-ellipsis-lastline;
  143. overflow: hidden;
  144. text-overflow: ellipsis;
  145. display: -webkit-box;
  146. -webkit-line-clamp: 1;
  147. line-clamp: 3;
  148. -webkit-box-orient: vertical;
  149. }
  150. }
  151. }
  152. .info-list {
  153. display: flex;
  154. flex-wrap: wrap;
  155. .info-item {
  156. padding: 20rpx;
  157. width: 33%;
  158. box-sizing: border-box;
  159. .info-pic {
  160. margin: auto;
  161. width: 175rpx;
  162. height: 175rpx;
  163. background: bisque;
  164. }
  165. .info-title {
  166. text-align: center;
  167. color: #65371b;
  168. font-size: 24rpx;
  169. font-weight: 300;
  170. line-height: 47rpx;
  171. word-spacing: 2rpx;
  172. overflow: hidden;
  173. text-overflow: -o-ellipsis-lastline;
  174. overflow: hidden;
  175. text-overflow: ellipsis;
  176. display: -webkit-box;
  177. -webkit-line-clamp: 1;
  178. line-clamp: 3;
  179. -webkit-box-orient: vertical;
  180. }
  181. }
  182. }
  183. </style>