index.vue 9.4 KB

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