开始

左边是一张图片,右边分为了3行。 底部还有横线
image.png

构造布局

image.png

列表左边是图片
image.png
右边是一个view里面再嵌套3个view
image.png

  1. <view class="topic-new">
  2. <view class="">最近更新</view>
  3. <view class="topic-list">
  4. <image src="../../static/demo/topicpic/13.jpeg"
  5. mode="widthFix" lazy-load="true"></image>
  6. <view class="">
  7. <view class="">#话题名称</view>
  8. <view class="">我是话题描述</view>
  9. <view class="">动态 10 今日 5</view>
  10. </view>
  11. </view>
  12. </view>

css

image.png

  1. .topic-new{
  2. padding: 20upx;
  3. }
  4. .topic-new>view:first-child{
  5. padding-bottom: 10upx;
  6. }

列表和上下也有边距。上下为10 左右为0
image.png

image.png
最近更新字体放大
image.png

  1. .topic-new>view:first-child{
  2. padding-bottom: 10upx;
  3. font-size: 32upx;
  4. }

图片圆角居左。
image.png
右边加点间距
image.png

  1. .topic-list image{
  2. width: 150upx;
  3. height: 150upx;
  4. border-radius: 10upx;
  5. margin-right: 10upx;
  6. }

flex布局
image.png

image.png
图片和右边间距增大
image.png
最下面有一条线
image.png

image.png

  1. .topic-list{
  2. padding: 10upx 0;
  3. border-bottom: 1upx solid #EEEEEE;
  4. }

标题字体要大一些
image.png

取色灰色的字体
image.png
然后是标题自己,自定义字体的颜色
image.png

  1. .topic-list>view>view{
  2. color: #A4A4A4;
  3. }
  4. .topic-list>view>view:first-child{
  5. color: #333333;
  6. font-size: 32upx;
  7. }

image.png

本节代码

news.vue

  1. <template>
  2. <view>
  3. <news-nav-bar :tabBars="tabBars" :tabIndex="tabIndex" @change-tab="changeTab"></news-nav-bar>
  4. <view>
  5. <swiper class="swiper-box" :style="{height: swiperheight+'px'}" :current="tabIndex" :change="tabChange">
  6. <!-- 关注 -->
  7. <swiper-item>
  8. <scroll-view scroll-y class="list" @scrolltolower="loadmore(index)" @scroll="scroll"
  9. :scroll-top="srcollTopValue" :style="{height: swiperheight+'px'}">
  10. <!-- 列表 -->
  11. <block v-for="(item,index) in guanzhu.list" :ket="index">
  12. <common-list :item="item" :index="index"></common-list>
  13. </block>
  14. <!-- 上拉加载 -->
  15. <load-more :loadtext="guanzhu.loadtext"></load-more>
  16. </scroll-view>
  17. </swiper-item>
  18. <!-- 话题 -->
  19. <swiper-item>
  20. <scroll-view scroll-y class="list">
  21. <!-- 搜索框 -->
  22. <view class="search-input">
  23. <input class="uni-input" placeholder-class="icon iconfont icon-sousuo topic-search"
  24. placeholder="搜索内容" />
  25. </view>
  26. <!-- 轮播图 -->
  27. <swiper class="topic-swiper" :indicator-dots="true" :autoplay="true" :interval="3000"
  28. :duration="1000">
  29. <block v-for="(item,index) in topic.swiper" :key="index">
  30. <swiper-item>
  31. <image :src="item.src" mode="widthFix" lazy-load="true"></image>
  32. </swiper-item>
  33. </block>
  34. </swiper>
  35. <!-- 热门分类 -->
  36. <topic-nav :nav="topic.nav"></topic-nav>
  37. <!-- 最近更新 -->
  38. <view class="topic-new">
  39. <view class="">最近更新</view>
  40. <view class="topic-list u-f">
  41. <image src="../../static/demo/topicpic/13.jpeg"
  42. mode="widthFix" lazy-load="true"></image>
  43. <view class="">
  44. <view class="">#话题名称</view>
  45. <view class="">我是话题描述</view>
  46. <view class="">动态 10 今日 5</view>
  47. </view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </swiper-item>
  52. </swiper>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import commonList from '@/components/common/common-list.vue';
  58. import newsNavBar from '@/components/news/news-nav-bar.vue';
  59. import loadMore from '@/components/common/load-more.vue';
  60. import topicNav from '@/components/news/topic-nav.vue';
  61. export default {
  62. components: {
  63. commonList,
  64. newsNavBar,
  65. loadMore,
  66. topicNav
  67. },
  68. data() {
  69. return {
  70. swiperheight: 500,
  71. srcollTopValue: 0, // 默认是0
  72. tabIndex: 1,
  73. tabBars: [{
  74. name: '关注',
  75. id: 'guanzhu'
  76. },
  77. {
  78. name: '话题',
  79. id: 'toppic'
  80. },
  81. ],
  82. guanzhu: {
  83. loadtext: "上拉加载更多",
  84. list: [
  85. // 文字
  86. {
  87. userpic: "../../static/demo/userpic/12.jpg",
  88. username: "哈哈",
  89. sex: 0, //0 男 1 女
  90. age: 25,
  91. isguanzhu: false,
  92. title: "我是标题",
  93. titlepic: "",
  94. video: false,
  95. share: false,
  96. path: "深圳 龙岗",
  97. sharenum: 20,
  98. commentnum: 30,
  99. goodnum: 20
  100. },
  101. // 图文
  102. {
  103. userpic: "../../static/demo/userpic/12.jpg",
  104. username: "哈哈",
  105. sex: 0, //0 男 1 女
  106. age: 25,
  107. isguanzhu: false,
  108. title: "我是标题",
  109. titlepic: "../../static/demo/datapic/13.jpg",
  110. video: false,
  111. share: false,
  112. path: "深圳 龙岗",
  113. sharenum: 20,
  114. commentnum: 30,
  115. goodnum: 20
  116. },
  117. // 视频
  118. {
  119. userpic: "../../static/demo/userpic/12.jpg",
  120. username: "哈哈",
  121. sex: 0, //0 男 1 女
  122. age: 25,
  123. isguanzhu: false,
  124. title: "我是标题",
  125. titlepic: "../../static/demo/datapic/13.jpg",
  126. video: {
  127. looknum: "20w",
  128. long: "2:47"
  129. },
  130. share: false,
  131. path: "深圳 龙岗",
  132. sharenum: 20,
  133. commentnum: 30,
  134. goodnum: 20
  135. },
  136. // 分享
  137. {
  138. userpic: "../../static/demo/userpic/12.jpg",
  139. username: "哈哈",
  140. sex: 0, //0 男 1 女
  141. age: 25,
  142. isguanzhu: false,
  143. title: "我是标题",
  144. titlepic: "",
  145. video: false,
  146. share: {
  147. title: "我是分享的标题",
  148. titlepic: "../../static/demo/datapic/14.jpg"
  149. },
  150. path: "深圳 龙岗",
  151. sharenum: 20,
  152. commentnum: 30,
  153. goodnum: 20
  154. },
  155. ]
  156. },
  157. topic: {
  158. swiper: [{
  159. src: "../../static/demo/banner1.jpg"
  160. },
  161. {
  162. src: "../../static/demo/banner2.jpg"
  163. },
  164. {
  165. src: "../../static/demo/banner3.jpg"
  166. },
  167. ],
  168. nav: [{
  169. name: "最新"
  170. },
  171. {
  172. name: "游戏"
  173. },
  174. {
  175. name: "打卡"
  176. },
  177. {
  178. name: "情感"
  179. },
  180. {
  181. name: "故事"
  182. },
  183. {
  184. name: "喜爱"
  185. },
  186. ]
  187. }
  188. }
  189. },
  190. onLoad() {
  191. uni.getSystemInfo({
  192. success: (res) => {
  193. console.log('当前window高度和窗口高度');
  194. console.log(res.windowHeight);
  195. console.log(res.screenHeight);
  196. let height = res.windowHeight - uni.upx2px(100)
  197. this.swiperheight = height;
  198. }
  199. });
  200. },
  201. methods: {
  202. scroll(e) {
  203. // console.log('scroll事件',e);
  204. this.scrollTopValue = e.detail.scrollTop;
  205. },
  206. // 点击切换
  207. changeTab(index) {
  208. console.log('父页面点击:', index);
  209. this.tabIndex = index;
  210. },
  211. // 滑动事件
  212. tabChange(e) {
  213. this.tabIndex = e.details.current
  214. },
  215. // 上拉加载
  216. loadmore() {
  217. if (this.guanzhu.loadtext != "上拉加载更多") {
  218. return;
  219. }
  220. // 修改状态
  221. this.guanzhu.loadtext = "加载中...";
  222. // 获取数据
  223. setTimeout(() => {
  224. //获取完成
  225. let obj = {
  226. userpic: "../../static/demo/userpic/12.jpg",
  227. username: "哈哈",
  228. sex: 0, //0 男 1 女
  229. age: 25,
  230. isguanzhu: false,
  231. title: "我是标题",
  232. titlepic: "../../static/demo/datapic/13.jpg",
  233. video: false,
  234. share: false,
  235. path: "深圳 龙岗",
  236. sharenum: 20,
  237. commentnum: 30,
  238. goodnum: 20
  239. };
  240. this.guanzhu.list.push(obj);
  241. this.guanzhu.loadtext = "上拉加载更多";
  242. }, 1000);
  243. // this.guanzhu.loadtext="没有更多数据了";
  244. }
  245. }
  246. }
  247. </script>
  248. <style>
  249. .search-input {
  250. /* border: 1upx solid; */
  251. padding: 20upx;
  252. }
  253. .search-input>input {
  254. /* border: 1upx solid; */
  255. background: #F4F4F4;
  256. border-radius: 10upx;
  257. }
  258. .topic-search {
  259. display: flex;
  260. justify-content: center;
  261. font-size: 27upx;
  262. }
  263. .topic-swiper {
  264. padding: 0 20upx 20upx 20upx;
  265. }
  266. .topic-swiper image {
  267. width: 100%;
  268. border-radius: 10upx;
  269. }
  270. .topic-new{
  271. padding: 20upx;
  272. }
  273. .topic-new>view:first-child{
  274. padding-bottom: 10upx;
  275. font-size: 32upx;
  276. }
  277. .topic-list{
  278. padding: 10upx 0;
  279. border-bottom: 1upx solid #EEEEEE;
  280. }
  281. .topic-list>view>view{
  282. color: #A4A4A4;
  283. }
  284. .topic-list>view>view:first-child{
  285. color: #333333;
  286. font-size: 32upx;
  287. }
  288. .topic-list image{
  289. width: 150upx;
  290. height: 150upx;
  291. border-radius: 10upx;
  292. margin-right: 20upx;
  293. }
  294. </style>

结束