瑶都万能墙
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.

488 lines
12 KiB

1 year ago
1 year ago
8 months ago
8 months ago
8 months ago
8 months ago
11 months ago
1 year ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
8 months ago
8 months ago
8 months ago
1 year ago
8 months ago
8 months ago
8 months ago
1 year ago
11 months ago
11 months ago
8 months ago
11 months ago
1 year ago
  1. <template>
  2. <view class="page">
  3. <navbar title="同城群"/>
  4. <!-- 顶部操作栏 -->
  5. <view class="top-actions">
  6. <view class="search-container">
  7. <uv-search
  8. v-model="searchKeyword"
  9. placeholder="搜索群组名称"
  10. @search="onSearch"
  11. @clear="onClear"
  12. bgColor="#f5f5f5"
  13. :showAction="false"
  14. ></uv-search>
  15. </view>
  16. <view class="create-btn" @click="createGroup">
  17. <uv-icon name="plus" size="30rpx" color="#fff"></uv-icon>
  18. <text>创建群组</text>
  19. </view>
  20. </view>
  21. <!-- 城市分类标签 -->
  22. <view class="city-tabs-container">
  23. <uv-tabs
  24. :list="categoryList"
  25. :current="currentCityTabIndex"
  26. :activeStyle="{color: '#5baaff', fontWeight: 600}"
  27. lineColor="#5baaff"
  28. lineHeight="6rpx"
  29. lineWidth="40rpx"
  30. keyName="name"
  31. @click="onCategoryClick"
  32. />
  33. </view>
  34. <!-- 群组列表 -->
  35. <view class="group-list">
  36. <groupItem
  37. :key="index"
  38. v-for="(item, index) in groupList"
  39. :item="item"
  40. @click="onGroupClick(item)"
  41. />
  42. </view>
  43. <!-- 空状态 -->
  44. <view v-if="groupList.length === 0 && !loading" class="empty-state">
  45. <uv-empty
  46. mode="list"
  47. text="暂无群组"
  48. iconSize="120"
  49. ></uv-empty>
  50. </view>
  51. <!-- 加载状态 -->
  52. <view v-if="loading" class="loading-state">
  53. <uv-loading-icon size="40"></uv-loading-icon>
  54. <text>加载中...</text>
  55. </view>
  56. <tabber select="2" />
  57. </view>
  58. </template>
  59. <script>
  60. import tabber from '@/components/base/tabbar.vue'
  61. import groupItem from '@/components/list/group/groupItem.vue'
  62. import { mapState } from 'vuex'
  63. export default {
  64. components : {
  65. tabber,
  66. groupItem,
  67. },
  68. data() {
  69. return {
  70. searchKeyword: '',
  71. loading: false,
  72. currentCityTabIndex: 0, // uv-tabs当前选中的城市索引
  73. queryParams: {
  74. cityId: null
  75. },
  76. groupList: [],
  77. }
  78. },
  79. computed: {
  80. ...mapState(['cityList']),
  81. // 城市分类列表(包含"全部"选项)
  82. categoryList() {
  83. const allTab = { name: '全部', value: null }
  84. const cityTabs = this.cityList.map(city => ({
  85. name: city.name || city.cityName || city.title,
  86. value: city.id || city.cityId
  87. }))
  88. return [allTab, ...cityTabs]
  89. }
  90. },
  91. onLoad() {
  92. // 获取城市列表
  93. this.$store.commit('getCityList')
  94. // 页面加载时初始化数据
  95. this.loadStaticGroupData()
  96. },
  97. onShow() {
  98. // 页面显示时刷新数据
  99. if (this.groupList.length === 0) {
  100. this.loadStaticGroupData()
  101. }
  102. },
  103. methods: {
  104. // 加载静态群组数据
  105. loadStaticGroupData(){
  106. console.log('开始加载静态群组数据')
  107. this.loading = true
  108. // 模拟加载延迟
  109. setTimeout(() => {
  110. this.loading = false
  111. console.log('加载完成,开始筛选数据')
  112. // 根据分类筛选静态数据
  113. this.filterGroupListByCategory()
  114. }, 500)
  115. },
  116. // 根据分类筛选群组列表
  117. filterGroupListByCategory() {
  118. const allGroups = [
  119. {
  120. id: 1,
  121. name: '江华同城交流群',
  122. description: '江华本地生活交流,分享美食、租房、工作信息',
  123. avatar: '/static/image/logo.jpg',
  124. memberCount: 1280,
  125. type: '同城群',
  126. category: 'local',
  127. qrCode: '/static/image/qr/group1.jpg',
  128. lastMessage: '有人知道江华哪里有好的租房信息吗?',
  129. lastMessageTime: '2小时前'
  130. },
  131. {
  132. id: 2,
  133. name: '江华美食分享群',
  134. description: '发现江华本地美食,分享美食攻略',
  135. avatar: '/static/image/logo.jpg',
  136. memberCount: 856,
  137. type: '兴趣群',
  138. category: 'interest',
  139. qrCode: '/static/image/qr/group2.jpg',
  140. lastMessage: '推荐一家新开的火锅店,味道不错',
  141. lastMessageTime: '1小时前'
  142. },
  143. {
  144. id: 3,
  145. name: '江华租房信息群',
  146. description: '江华租房信息发布与交流',
  147. avatar: '/static/image/logo.jpg',
  148. memberCount: 2341,
  149. type: '同城群',
  150. category: 'local',
  151. qrCode: '/static/image/qr/group3.jpg',
  152. lastMessage: '有单间出租,位置好,价格实惠',
  153. lastMessageTime: '30分钟前'
  154. },
  155. {
  156. id: 4,
  157. name: '江华求职招聘群',
  158. description: '江华本地求职招聘信息发布',
  159. avatar: '/static/image/logo.jpg',
  160. memberCount: 1567,
  161. type: '工作群',
  162. category: 'work',
  163. qrCode: '/static/image/qr/group4.jpg',
  164. lastMessage: '招聘销售员,待遇优厚',
  165. lastMessageTime: '1天前'
  166. },
  167. {
  168. id: 5,
  169. name: '江华旅游攻略群',
  170. description: '江华旅游景点推荐,攻略分享',
  171. avatar: '/static/image/logo.jpg',
  172. memberCount: 623,
  173. type: '兴趣群',
  174. category: 'interest',
  175. qrCode: '/static/image/qr/group5.jpg',
  176. lastMessage: '周末去瑶族文化园玩,有一起的吗?',
  177. lastMessageTime: '3小时前'
  178. },
  179. {
  180. id: 6,
  181. name: '江华学习交流群',
  182. description: '江华本地学习交流,分享学习资源',
  183. avatar: '/static/image/logo.jpg',
  184. memberCount: 445,
  185. type: '学习群',
  186. category: 'study',
  187. qrCode: '/static/image/qr/group6.jpg',
  188. lastMessage: '有人一起学习英语吗?',
  189. lastMessageTime: '2天前'
  190. },
  191. {
  192. id: 7,
  193. name: '江华二手交易群',
  194. description: '江华本地二手物品交易',
  195. avatar: '/static/image/logo.jpg',
  196. memberCount: 1890,
  197. type: '同城群',
  198. category: 'local',
  199. qrCode: '/static/image/qr/group7.jpg',
  200. lastMessage: '出售一台九成新的洗衣机',
  201. lastMessageTime: '1小时前'
  202. },
  203. {
  204. id: 8,
  205. name: '江华宠物交流群',
  206. description: '江华宠物爱好者交流群',
  207. avatar: '/static/image/logo.jpg',
  208. memberCount: 567,
  209. type: '兴趣群',
  210. category: 'interest',
  211. qrCode: '/static/image/qr/group8.jpg',
  212. lastMessage: '有人知道江华哪里有好的宠物医院吗?',
  213. lastMessageTime: '4小时前'
  214. },
  215. {
  216. id: 9,
  217. name: '江华汽车交流群',
  218. description: '江华汽车爱好者交流,分享用车心得',
  219. avatar: '/static/image/logo.jpg',
  220. memberCount: 892,
  221. type: '兴趣群',
  222. category: 'interest',
  223. qrCode: '/static/image/qr/group9.jpg',
  224. lastMessage: '有人知道江华哪里有好的汽车维修店吗?',
  225. lastMessageTime: '5小时前'
  226. },
  227. {
  228. id: 10,
  229. name: '江华宝妈交流群',
  230. description: '江华宝妈育儿经验分享',
  231. avatar: '/static/image/logo.jpg',
  232. memberCount: 1234,
  233. type: '同城群',
  234. category: 'local',
  235. qrCode: '/static/image/qr/group10.jpg',
  236. lastMessage: '推荐江华最好的儿童医院',
  237. lastMessageTime: '6小时前'
  238. },
  239. {
  240. id: 11,
  241. name: '江华IT技术交流群',
  242. description: '江华IT从业者技术交流',
  243. avatar: '/static/image/logo.jpg',
  244. memberCount: 345,
  245. type: '工作群',
  246. category: 'work',
  247. qrCode: '/static/image/qr/group11.jpg',
  248. lastMessage: '有前端开发的工作机会吗?',
  249. lastMessageTime: '1天前'
  250. },
  251. {
  252. id: 12,
  253. name: '江华健身运动群',
  254. description: '江华健身爱好者交流群',
  255. avatar: '/static/image/logo.jpg',
  256. memberCount: 678,
  257. type: '兴趣群',
  258. category: 'interest',
  259. qrCode: '/static/image/qr/group12.jpg',
  260. lastMessage: '有人一起去健身房吗?',
  261. lastMessageTime: '2小时前'
  262. },
  263. {
  264. id: 13,
  265. name: '江华摄影爱好者群',
  266. description: '江华摄影爱好者交流群',
  267. avatar: '/static/image/logo.jpg',
  268. memberCount: 456,
  269. type: '兴趣群',
  270. category: 'interest',
  271. qrCode: '/static/image/qr/group13.jpg',
  272. lastMessage: '分享一张江华夜景照片',
  273. lastMessageTime: '1天前'
  274. },
  275. {
  276. id: 14,
  277. name: '江华创业交流群',
  278. description: '江华创业者交流平台',
  279. avatar: '/static/image/logo.jpg',
  280. memberCount: 789,
  281. type: '工作群',
  282. category: 'work',
  283. qrCode: '/static/image/qr/group14.jpg',
  284. lastMessage: '寻找创业合作伙伴',
  285. lastMessageTime: '3天前'
  286. },
  287. {
  288. id: 15,
  289. name: '江华医疗健康群',
  290. description: '江华医疗健康咨询交流',
  291. avatar: '/static/image/logo.jpg',
  292. memberCount: 1123,
  293. type: '同城群',
  294. category: 'local',
  295. qrCode: '/static/image/qr/group15.jpg',
  296. lastMessage: '推荐江华最好的牙科医院',
  297. lastMessageTime: '4小时前'
  298. },
  299. {
  300. id: 16,
  301. name: '江华读书会',
  302. description: '江华读书爱好者交流群',
  303. avatar: '/static/image/logo.jpg',
  304. memberCount: 234,
  305. type: '学习群',
  306. category: 'study',
  307. qrCode: '/static/image/qr/group16.jpg',
  308. lastMessage: '推荐一本好书《江华瑶族文化》',
  309. lastMessageTime: '1周前'
  310. },
  311. {
  312. id: 17,
  313. name: '江华音乐爱好者群',
  314. description: '江华音乐爱好者交流群',
  315. avatar: '/static/image/logo.jpg',
  316. memberCount: 567,
  317. type: '兴趣群',
  318. category: 'interest',
  319. qrCode: '/static/image/qr/group17.jpg',
  320. lastMessage: '有人会弹吉他吗?想学',
  321. lastMessageTime: '2天前'
  322. },
  323. {
  324. id: 18,
  325. name: '江华电商交流群',
  326. description: '江华电商从业者交流群',
  327. avatar: '/static/image/logo.jpg',
  328. memberCount: 890,
  329. type: '工作群',
  330. category: 'work',
  331. qrCode: '/static/image/qr/group18.jpg',
  332. lastMessage: '分享电商运营经验',
  333. lastMessageTime: '1周前'
  334. },
  335. {
  336. id: 19,
  337. name: '江华园艺爱好者群',
  338. description: '江华园艺爱好者交流群',
  339. avatar: '/static/image/logo.jpg',
  340. memberCount: 345,
  341. type: '兴趣群',
  342. category: 'interest',
  343. qrCode: '/static/image/qr/group19.jpg',
  344. lastMessage: '推荐江华最好的花店',
  345. lastMessageTime: '3天前'
  346. },
  347. {
  348. id: 20,
  349. name: '江华法律咨询群',
  350. description: '江华法律咨询服务交流',
  351. avatar: '/static/image/logo.jpg',
  352. memberCount: 678,
  353. type: '同城群',
  354. category: 'local',
  355. qrCode: '/static/image/qr/group20.jpg',
  356. lastMessage: '免费法律咨询服务',
  357. lastMessageTime: '5天前'
  358. }
  359. ]
  360. this.groupList = allGroups
  361. // 强制更新视图
  362. this.$forceUpdate()
  363. },
  364. // 搜索群组
  365. onSearch(keyword) {
  366. this.searchKeyword = keyword
  367. this.filterGroups()
  368. },
  369. // 清除搜索
  370. onClear() {
  371. this.searchKeyword = ''
  372. this.filterGroups()
  373. },
  374. // 分类点击
  375. onCategoryClick(item) {
  376. this.currentCityTabIndex = item.index
  377. if (item.value) {
  378. // 使用城市ID作为筛选条件
  379. this.queryParams.cityId = item.value
  380. delete this.queryParams.category // 清除原有的分类参数
  381. } else {
  382. // 选择"全部"时清除城市筛选
  383. delete this.queryParams.cityId
  384. delete this.queryParams.category
  385. }
  386. this.loadStaticGroupData()
  387. },
  388. // 群组点击
  389. onGroupClick(item) {
  390. // 跳转到群组详情页
  391. this.$utils.navigateTo('/pages_order/group/groupDetail?id=' + item.id)
  392. },
  393. // 过滤群组
  394. filterGroups() {
  395. if (!this.searchKeyword) {
  396. return
  397. }
  398. // 这里可以实现搜索过滤逻辑
  399. },
  400. // 创建群组
  401. createGroup() {
  402. this.$utils.navigateTo('/pages_order/group/createGroup')
  403. }
  404. }
  405. }
  406. </script>
  407. <style scoped lang="scss">
  408. .page{
  409. background-color: #f5f5f5;
  410. min-height: 100vh;
  411. .top-actions {
  412. background-color: #fff;
  413. padding: 20rpx;
  414. display: flex;
  415. align-items: center;
  416. gap: 20rpx;
  417. .search-container {
  418. flex: 1;
  419. }
  420. .create-btn {
  421. display: flex;
  422. align-items: center;
  423. background-color: #5baaff;
  424. color: #fff;
  425. padding: 15rpx 20rpx;
  426. border-radius: 30rpx;
  427. font-size: 26rpx;
  428. text {
  429. margin-left: 8rpx;
  430. }
  431. }
  432. }
  433. .category-tabs {
  434. background-color: #fff;
  435. margin-bottom: 20rpx;
  436. }
  437. .group-list {
  438. padding-bottom: 120rpx;
  439. }
  440. .empty-state {
  441. padding: 100rpx 0;
  442. text-align: center;
  443. }
  444. .loading-state {
  445. display: flex;
  446. flex-direction: column;
  447. align-items: center;
  448. justify-content: center;
  449. padding: 100rpx 0;
  450. text {
  451. margin-top: 20rpx;
  452. color: #999;
  453. font-size: 28rpx;
  454. }
  455. }
  456. }
  457. </style>