index.vue 8.2 KB

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