index.vue 8.9 KB

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