index.vue 7.9 KB

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