top.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <!-- 推荐的动态路由 -->
  2. <template>
  3. <view class="recommend">
  4. <view class="multiple">
  5. <view
  6. class="item-food"
  7. v-for="(item, index) in itemFood"
  8. :key="item.id"
  9. @click="footStyle(index, item)"
  10. :class="{ itemstyle: footIndex == index }"
  11. >
  12. <text class="alarm"># {{ item.title }}</text>
  13. </view>
  14. </view>
  15. <view class="waterfall"> </view>
  16. <waterfall
  17. v-if="flowList.length > 0"
  18. ref="wfp"
  19. :colunmNumber="colunmNumber"
  20. :flowList="flowList"
  21. :columnGap="10"
  22. :status="status"
  23. ></waterfall>
  24. <loadMore v-if="flowList.length > 0" :status="status"></loadMore>
  25. <nodata v-else :config="{ top: 15, content: '暂无数据~' }"></nodata>
  26. <view class="release" @click="gotorelease()">
  27. <image :src="imgUrl+'/pen.png'" mode=""></image>
  28. <view class="item"> 发布 </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import waterfall from "@/components/waterfall/waterfall";
  34. import nodata from "@/components/noData/nodata";
  35. import loadMore from "@/components/uni-load-more/uni-load-more";
  36. export default {
  37. data() {
  38. return {
  39. footIndex: -1, //点击切换food的样式,默认是第一个
  40. recommendIndex: 0, //点击切换头部样式,默认是第一个
  41. itemFood: [],
  42. colunmNumber: 2,
  43. index: 19,
  44. flowList: [],
  45. page: 1,
  46. limit: 10,
  47. themeId: null, //主题id
  48. status: "more",
  49. imgUrl: this.$mConfig.staticUrl
  50. };
  51. },
  52. props: {},
  53. comments: {
  54. waterfall,
  55. nodata,
  56. loadMore,
  57. },
  58. watch: {},
  59. mounted() {
  60. this.getTheme();
  61. },
  62. onShow() {
  63. this.getTheme();
  64. },
  65. methods: {
  66. isload() {
  67. this.page = 1;
  68. this.footIndex = -1;
  69. this.themeId = null;
  70. (this.flowList = []), this.getList();
  71. // this.itemFood=[],
  72. // this.getTheme()
  73. },
  74. loaderMore() {
  75. if (this.status == "more") {
  76. this.page++;
  77. this.getList(this.themeId);
  78. }
  79. },
  80. getTheme() {
  81. this.$http.get("/opus/theme/list", this.params).then((res) => {
  82. if (res && res.code == 200) {
  83. this.itemFood=(res.list);
  84. if (res.list.length > 0) {
  85. this.getList();
  86. }
  87. }
  88. });
  89. },
  90. gotorelease() {
  91. //跳转到发布页面
  92. let token = uni.getStorageSync("apiToken")
  93. if(!token){
  94. this.$mUtil.toast("请先登录")
  95. setTimeout(()=>{
  96. uni.navigateTo({
  97. url:"../register/login"
  98. })
  99. },1000)
  100. }else{
  101. uni.navigateTo({
  102. url: "./release",
  103. });
  104. }
  105. },
  106. getList(id) {
  107. this.$http
  108. .get("/opus/all-list", {
  109. themeId: id||"",
  110. page: this.page,
  111. limit: this.limit,
  112. })
  113. .then((res) => {
  114. if (res && res.code == 200) {
  115. this.flowList=(res.page.list);
  116. if (res.page.totalPage <= res.page.currPage) {
  117. this.status = "noMore";
  118. } else {
  119. this.status = "more";
  120. }
  121. }
  122. });
  123. },
  124. footStyle(index, item) {
  125. this.flowList=[]
  126. if(this.footIndex==index){
  127. this.footIndex = -1;
  128. this.themeId = null;
  129. this.page = 1;
  130. this.getList(this.themeId);
  131. }else{
  132. this.footIndex = index;
  133. this.themeId = item.id;
  134. this.page = 1;
  135. this.getList(this.themeId);
  136. }
  137. },
  138. },
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .release {
  143. background-color: #0B844A;
  144. width: 101rpx;
  145. height: 101rpx;
  146. border-radius: 999rpx;
  147. position: fixed;
  148. bottom: 259rpx;
  149. right: 30rpx;
  150. display: flex;
  151. align-items: center;
  152. flex-direction: column;
  153. image {
  154. width: 37rpx;
  155. height: 30rpx;
  156. margin-top: 15rpx;
  157. margin-bottom: 6rpx;
  158. }
  159. .item {
  160. color: #ffffff;
  161. font-weight: 400;
  162. font-size: 25rpx;
  163. }
  164. }
  165. .water-flow-box {
  166. background-color: #f5f5f5;
  167. border-radius: 40rpx;
  168. }
  169. .waterfall {
  170. background-color: #f5f5f5;
  171. border-radius: 40px;
  172. }
  173. .multiple {
  174. margin-top: 150rpx;
  175. color: #999999;
  176. padding-left: 30rpx;
  177. background: #ffffff;
  178. display: flex;
  179. align-items: center;
  180. white-space: nowrap;
  181. overflow-x: auto;
  182. -webkit-overflow-scrolling: touch;
  183. .item-food {
  184. padding-bottom: 30rpx;
  185. margin-right: 30rpx;
  186. box-sizing: border-box;
  187. line-height: 50rpx;
  188. display: flex;
  189. font-size: 28rpx;
  190. font-weight: 500;
  191. .alarm {
  192. padding-top: 32rpx;
  193. margin-right: 20rpx;
  194. display: block;
  195. }
  196. }
  197. .item-food:last-child{
  198. padding-right: 10rpx;
  199. }
  200. .itemstyle {
  201. border-bottom: 1rpx solid #0B844A;
  202. color: #0B844A;
  203. border-radius: 1rpx;
  204. font-size: 32rpx;
  205. font-weight: 700;
  206. }
  207. }
  208. .top {
  209. z-index: 1;
  210. width: 100%;
  211. height: 88rpx;
  212. position: fixed;
  213. background-color: #0B844A;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. color: rgba(255, 255, 255, 1);
  218. .recommend {
  219. padding-bottom: 24rpx;
  220. padding-top: 14rpx;
  221. font-size: 36rpx;
  222. font-weight: 500;
  223. margin-right: 104rpx;
  224. box-sizing: border-box;
  225. height: 86rpx;
  226. }
  227. .recommendtwo {
  228. border-bottom: 4rpx #ffffff solid;
  229. border-radius: 1rpx;
  230. }
  231. }
  232. .recommend {
  233. overflow: hidden;
  234. }
  235. </style>