index2.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="width-100 height-100 view-page">
  3. <view class="p-10 dis-flex flex-y-center flex-x-between">
  4. <view class="width-100">
  5. <u-search :clearabled="true" height="35px" placeholder="请输入搜索关键字" v-model="keyword" shape="round"
  6. search="doSearch" @custom="doSearch" bg-color="#e9f0f8" placeholder-color="#65371b"></u-search>
  7. </view>
  8. </view>
  9. <view>
  10. </view>
  11. <u-tabs ref="tabs" :list="tabList" :scrollable="false" :current="currentTab" @change="tabChange" lineColor="#65371b"
  12. :activeStyle="{color:'#65371b'}" inactiveStyle="{color:'#65371b'}"></u-tabs>
  13. <u-list @scrolltolower="scrolltolower" height="calc(100% - 91px)" lowerThreshold="10">
  14. <view class="info-list">
  15. <view class="dis-flex flex-x-between info-item" v-for="(item, index) in list" :key="index"
  16. @click="toDetail(item.id)">
  17. <view class="info-pic">
  18. <u-image width="175rpx" height="175rpx" mode="aspectFill" :src="item.cover"></u-image>
  19. </view>
  20. <view class="info-view">
  21. <view class="info-title">
  22. {{item.subTitle}}
  23. </view>
  24. <view class="dis-flex info-bottom">
  25. <view style="margin-right: 20rpx;">{{item.createTime?item.createTime.substring(0,10):''}}</view>
  26. <u-icon name="thumb-up" color="#7f7f7f" size="18"></u-icon>
  27. <view style="margin-right: 20rpx;">{{item.likeNum || 0}}点赞</view>
  28. <u-icon name="eye" color="#7f7f7f" size="18"></u-icon>
  29. <view>{{item.views || 0}}阅读量</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <u-loadmore :status="page.status" :loading-text="page.loadingText" :loadmore-text="page.loadmoreText"
  35. :nomore-text="page.nomoreText" />
  36. </u-list>
  37. </view>
  38. </template>
  39. <script>
  40. import themeMixins from '@/pages/yuecai/mixins/themeMixins.js';
  41. export default {
  42. mixins: [themeMixins],
  43. data() {
  44. return {
  45. tabList: [{
  46. name: '专业风采'
  47. }, {
  48. name: '名店',
  49. }, {
  50. name: '名菜'
  51. }, {
  52. name: '名点',
  53. }],
  54. currentTab: 0,
  55. //
  56. page: {
  57. current: 1,
  58. size: 10,
  59. total: 0,
  60. // loadmore loading nomore
  61. status: 'loadmore',
  62. loadingText: '正在加载中',
  63. loadmoreText: '上拉加载更多',
  64. nomoreText: '没有更多了'
  65. },
  66. keyword: '',
  67. list: []
  68. }
  69. },
  70. onLoad(options) {
  71. this.keyword = options.keyword;
  72. },
  73. onShow() {
  74. this.doRefresh();
  75. },
  76. methods: {
  77. tabChange(e) {
  78. this.currentTab = e.index;
  79. this.doRefresh();
  80. },
  81. scrolltolower() {
  82. this.loadmore()
  83. },
  84. loadmore() {
  85. this.page.current++;
  86. this.getList();
  87. },
  88. doSearch() {
  89. this.doRefresh();
  90. },
  91. doRefresh() {
  92. this.page.current = 1;
  93. this.page.status = 'loadmore'
  94. this.list = [];
  95. this.getList();
  96. },
  97. getList() {
  98. if (this.page.status == 'loading' || this.page.status == 'nomore') {
  99. // 防止重复下拉
  100. return;
  101. }
  102. this.page.status = 'loading';
  103. //
  104. let listFunc, params = {};
  105. switch (this.currentTab) {
  106. case 0:
  107. listFunc = this.$u.api.getProfessionalStyleList;
  108. params.title = this.keyword || '';
  109. break;
  110. case 1:
  111. listFunc = this.$u.api.getRestaurantList;
  112. params.name = this.keyword || '';
  113. params.regionId = this.areaCode || '';
  114. break;
  115. case 2:
  116. listFunc = this.$u.api.getDishList;
  117. params.name = this.keyword || '';
  118. params.regionId = this.areaCode || '';
  119. break;
  120. case 3:
  121. listFunc = this.$u.api.getSnacksList;
  122. params.name = this.keyword || '';
  123. params.regionId = this.areaCode || '';
  124. break;
  125. default:
  126. return;
  127. break;
  128. }
  129. //
  130. listFunc(this.page.current, this.page.size, params).then(res => {
  131. if (res.data.records && res.data.records.length > 0) {
  132. this.list.push(...res.data.records)
  133. }
  134. this.page.total = res.data.total || 0;
  135. if (this.page.size * this.page.current >= res.data.total) {
  136. this.page.status = 'nomore'
  137. } else {
  138. this.page.status = 'loadmore'
  139. }
  140. })
  141. },
  142. toDetail(id) {
  143. switch (this.currentTab) {
  144. case 0:
  145. uni.navigateTo({
  146. url: "/pages/yuecai/professional_style/detail/index?id=" + id,
  147. })
  148. break;
  149. case 1:
  150. uni.navigateTo({
  151. url: "/pages/yuecai/restaurant/detail/index?id=" + id,
  152. })
  153. break;
  154. case 2:
  155. uni.navigateTo({
  156. url: "/pages/yuecai/dish/detail/index?id=" + id,
  157. })
  158. break;
  159. case 3:
  160. uni.navigateTo({
  161. url: "/pages/yuecai/snacks/detail/index?id=" + id,
  162. })
  163. break;
  164. default:
  165. return;
  166. break;
  167. }
  168. },
  169. },
  170. }
  171. </script>
  172. <style scoped lang="scss">
  173. .search-left-btn {
  174. width: 35px;
  175. min-width: 35px;
  176. height: 35px;
  177. margin-right: 5px;
  178. box-sizing: border-box;
  179. }
  180. .icon-circle {
  181. border-radius: 50%;
  182. border: 4rpx solid #65371b;
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. }
  187. .nav-btns {
  188. border-bottom: 1rpx solid #65371b;
  189. margin-bottom: 20rpx;
  190. padding-bottom: 50rpx;
  191. .nav-btn {
  192. width: 150rpx;
  193. .nav-btn-icon {
  194. margin: auto;
  195. width: 110rpx;
  196. height: 110rpx;
  197. }
  198. .nav-btn-text {
  199. width: 100%;
  200. color: #65371b;
  201. margin-top: 5rpx;
  202. font-weight: bolder;
  203. text-align: center;
  204. }
  205. }
  206. }
  207. .info-list {
  208. height: calc(100% - 95px);
  209. overflow: auto;
  210. background-color: #f4f6f8;
  211. .info-item {
  212. padding: 20rpx;
  213. border-bottom: 2rpx solid white;
  214. .info-pic {
  215. width: 175rpx;
  216. height: 175rpx;
  217. background: bisque;
  218. }
  219. .info-view {
  220. width: calc(100% - 205rpx);
  221. .info-title {
  222. height: 75px;
  223. word-break: break-all;
  224. color: #65371b;
  225. font-size: 24rpx;
  226. font-weight: 300;
  227. line-height: 47rpx;
  228. word-spacing: 2rpx;
  229. overflow: hidden;
  230. text-overflow: -o-ellipsis-lastline;
  231. overflow: hidden;
  232. text-overflow: ellipsis;
  233. display: -webkit-box;
  234. -webkit-line-clamp: 3;
  235. line-clamp: 3;
  236. -webkit-box-orient: vertical;
  237. }
  238. .info-bottom {
  239. color: #7f7f7f;
  240. font-size: 24rpx;
  241. margin-top: 10rpx;
  242. }
  243. }
  244. }
  245. }
  246. </style>