国外MOSE官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

360 lines
8.0 KiB

2 days ago
  1. <template>
  2. <view class="community-page">
  3. <!-- 顶部图片 -->
  4. <view class="banner-section">
  5. <image class="banner-image" src="/static/bannerImage.png" mode="aspectFill"></image>
  6. </view>
  7. <!-- Tab切换区域 -->
  8. <view class="tab-section">
  9. <view class="tab-container">
  10. <view
  11. class="tab-item"
  12. :class="{ active: currentTab === 'current' }"
  13. @click="switchTab('current')"
  14. >
  15. <text class="tab-text">木邻说</text>
  16. <view class="tab-line" v-if="currentTab === 'current'"></view>
  17. </view>
  18. <view
  19. class="tab-item"
  20. :class="{ active: currentTab === 'past' }"
  21. @click="switchTab('past')"
  22. >
  23. <text class="tab-text">木邻见</text>
  24. <view class="tab-line" v-if="currentTab === 'past'"></view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 动态列表 -->
  29. <view class="post-list">
  30. <view
  31. class="post-item"
  32. v-for="(item, index) in filteredPosts"
  33. :key="index"
  34. @click="goToPostDetail(item)"
  35. >
  36. <!-- 用户信息 -->
  37. <view class="user-info">
  38. <image class="user-avatar" :src="item.avatar" mode="aspectFill"></image>
  39. <view class="user-details">
  40. <text class="username">{{ item.username }}</text>
  41. <text class="post-time">发布时间{{ item.time }}</text>
  42. </view>
  43. </view>
  44. <!-- 动态内容 -->
  45. <view class="post-content">
  46. <text class="post-text">{{ item.content }}</text>
  47. <!-- 图片列表 -->
  48. <view class="image-grid" v-if="item.images && item.images.length > 0">
  49. <image
  50. class="post-image"
  51. v-for="(img, imgIndex) in item.images"
  52. :key="imgIndex"
  53. :src="img"
  54. mode="aspectFill"
  55. @click.stop="previewImage(img, item.images)"
  56. ></image>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 随手拍/我要留言按钮 -->
  62. <view class="action-btn" :class="currentTab === 'current' ? 'current-btn' : 'photo'" @click="openAction">
  63. <uv-icon name="edit-pen-fill" size="20" color="white"></uv-icon>
  64. <text class="action-text">{{ actionButtonText }}</text>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. name: 'CommunityPage',
  71. data() {
  72. return {
  73. currentTab: 'current', // current: 木邻说, past: 木邻见
  74. postList: [
  75. {
  76. id: 1,
  77. username: '猫小姐',
  78. avatar: '/static/默认头像.png',
  79. time: '2023-12-10 14:15:26',
  80. content: '建议社区草地修剪一下,杂草太多了!',
  81. images: ['/static/bannerImage.png', '/static/bannerImage.png', '/static/bannerImage.png'],
  82. type: 'current'
  83. },
  84. {
  85. id: 2,
  86. username: '猫小姐',
  87. avatar: '/static/默认头像.png',
  88. time: '2023-12-10 14:15:26',
  89. content: '建议社区草地修剪一下,杂草太多了!',
  90. images: ['/static/bannerImage.png', '/static/bannerImage.png', '/static/bannerImage.png'],
  91. type: 'current'
  92. },
  93. {
  94. id: 3,
  95. username: '邻居小王',
  96. avatar: '/static/默认头像.png',
  97. time: '2023-12-09 16:30:15',
  98. content: '今天在小区里捡到一只小猫,有人丢失了吗?',
  99. images: ['/static/bannerImage.png'],
  100. type: 'past'
  101. },
  102. {
  103. id: 4,
  104. username: '李阿姨',
  105. avatar: '/static/默认头像.png',
  106. time: '2023-12-08 09:20:30',
  107. content: '分享一下我种的花,希望大家喜欢!',
  108. images: ['/static/bannerImage.png', '/static/bannerImage.png'],
  109. type: 'past'
  110. }
  111. ]
  112. }
  113. },
  114. computed: {
  115. filteredPosts() {
  116. return this.postList.filter(post => post.type === this.currentTab)
  117. },
  118. actionButtonText() {
  119. return this.currentTab === 'current' ? '我要留言' : '随手拍'
  120. }
  121. },
  122. methods: {
  123. switchTab(tab) {
  124. this.currentTab = tab
  125. },
  126. goToPostDetail(post) {
  127. // 跳转到动态详情页面
  128. uni.navigateTo({
  129. url: `/subPages/community/postDetail?id=${post.id}`
  130. })
  131. },
  132. previewImage(current, urls) {
  133. uni.previewImage({
  134. current: current,
  135. urls: urls
  136. })
  137. },
  138. openAction() {
  139. if (this.currentTab === 'current') {
  140. // 我要留言功能
  141. this.goToComment()
  142. } else {
  143. // 随手拍功能
  144. // this.goToComment()
  145. this.takePhoto()
  146. }
  147. },
  148. takePhoto() {
  149. // uni.chooseMedia({
  150. // count: 9,
  151. // mediaType: ['image'],
  152. // sourceType: ['album', 'camera'],
  153. // success: (res) => {
  154. // // 处理拍照结果
  155. // uni.navigateTo({
  156. // url: '/subPages/community/publishPost'
  157. // })
  158. // }
  159. // })
  160. uni.navigateTo({
  161. url: '/subPages/community/publishPost?page=photo'
  162. })
  163. },
  164. goToComment() {
  165. uni.navigateTo({
  166. url: '/subPages/community/publishPost'
  167. })
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .community-page {
  174. min-height: 100vh;
  175. background-color: #f8f9fa;
  176. position: relative;
  177. padding-bottom: 120rpx;
  178. }
  179. // 横幅样式
  180. .banner-section {
  181. height: 400rpx;
  182. overflow: hidden;
  183. }
  184. .banner-image {
  185. width: 100%;
  186. height: 100%;
  187. }
  188. // Tab切换区域
  189. .tab-section {
  190. background: white;
  191. padding: 0 40rpx;
  192. border-bottom: 1rpx solid #f0f0f0;
  193. box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
  194. }
  195. .tab-container {
  196. display: flex;
  197. // gap: 60rpx;
  198. justify-content: space-evenly;
  199. }
  200. .tab-item {
  201. position: relative;
  202. padding: 30rpx 0;
  203. .tab-text {
  204. font-size: 32rpx;
  205. color: #666;
  206. font-weight: 500;
  207. transition: color 0.3s ease;
  208. }
  209. &.active {
  210. .tab-text {
  211. color: #007AFF;
  212. font-weight: bold;
  213. }
  214. }
  215. }
  216. .tab-line {
  217. position: absolute;
  218. bottom: 0;
  219. left: 50%;
  220. transform: translateX(-50%);
  221. width: 40rpx;
  222. height: 6rpx;
  223. background: #007AFF;
  224. border-radius: 3rpx;
  225. animation: slideIn 0.3s ease;
  226. }
  227. @keyframes slideIn {
  228. from {
  229. width: 0;
  230. }
  231. to {
  232. width: 40rpx;
  233. }
  234. }
  235. // 动态列表样式
  236. .post-list {
  237. // padding: 20rpx;
  238. }
  239. .post-item {
  240. background-color: white;
  241. border-radius: 16rpx;
  242. // margin-bottom: 24rpx;
  243. padding: 32rpx;
  244. box-shadow: 0 2rpx 16rpx rgba(0, 0, 0, 0.06);
  245. border: 1rpx solid #f5f5f5;
  246. transition: transform 0.2s ease, box-shadow 0.2s ease;
  247. &:active {
  248. transform: scale(0.98);
  249. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
  250. }
  251. }
  252. .user-info {
  253. display: flex;
  254. align-items: center;
  255. margin-bottom: 24rpx;
  256. }
  257. .user-avatar {
  258. width: 88rpx;
  259. height: 88rpx;
  260. border-radius: 50%;
  261. margin-right: 24rpx;
  262. border: 2rpx solid #f0f0f0;
  263. }
  264. .user-details {
  265. flex: 1;
  266. }
  267. .username {
  268. font-size: 30rpx;
  269. font-weight: bold;
  270. color: #333;
  271. display: block;
  272. margin-bottom: 8rpx;
  273. }
  274. .post-time {
  275. font-size: 24rpx;
  276. color: #999;
  277. }
  278. .post-content {
  279. .post-text {
  280. font-size: 30rpx;
  281. color: #333;
  282. line-height: 1.6;
  283. display: block;
  284. margin-bottom: 24rpx;
  285. }
  286. }
  287. .image-grid {
  288. display: flex;
  289. flex-wrap: wrap;
  290. gap: 12rpx;
  291. }
  292. .post-image {
  293. width: 200rpx;
  294. height: 200rpx;
  295. border-radius: 12rpx;
  296. border: 1rpx solid #f0f0f0;
  297. }
  298. // 随手拍/我要留言按钮样式
  299. .action-btn {
  300. position: fixed;
  301. bottom: 120rpx;
  302. right: 30rpx;
  303. width: 120rpx;
  304. height: 120rpx;
  305. background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  306. border-radius: 50%;
  307. display: flex;
  308. flex-direction: column;
  309. align-items: center;
  310. justify-content: center;
  311. box-shadow: 0 8rpx 24rpx rgba(0, 122, 255, 0.4);
  312. z-index: 100;
  313. transition: transform 0.2s ease, box-shadow 0.2s ease;
  314. &:active {
  315. transform: scale(0.95);
  316. box-shadow: 0 4rpx 16rpx rgba(0, 122, 255, 0.6);
  317. }
  318. &.photo {
  319. background: linear-gradient(135deg, #FF6666 0%, #CC3333 100%);
  320. }
  321. }
  322. .action-text {
  323. font-size: 20rpx;
  324. color: white;
  325. margin-top: 8rpx;
  326. font-weight: bold;
  327. }
  328. </style>