group.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="tab-page group">
  3. <nav-bar add search @add="onCreateNewGroup" @search="showSearch = !showSearch">群聊</nav-bar>
  4. <view class="nav-bar" v-if="showSearch">
  5. <view class="nav-search">
  6. <uni-search-bar v-model="searchText" cancelButton="none" radius="100"
  7. placeholder="点击搜索群聊"></uni-search-bar>
  8. </view>
  9. </view>
  10. <view class="group-tip" v-if="!hasGroups">
  11. <view class="tip-icon">
  12. <text class="iconfont icon-create-group"></text>
  13. </view>
  14. <view class="tip-title">还没有群聊</view>
  15. <view class="tip-content">创建或加入群聊,与朋友们一起畅聊吧</view>
  16. <button type="primary" @click="onCreateNewGroup">创建群聊</button>
  17. </view>
  18. <view class="group-items" v-else>
  19. <scroll-view class="scroll-bar" scroll-with-animation="true" scroll-y="true">
  20. <view v-for="group in groupStore.groups" :key="group.id">
  21. <group-item v-if="!group.quit && group.showGroupName.includes(searchText)"
  22. :group="group"></group-item>
  23. </view>
  24. </scroll-view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. showSearch: false,
  33. searchText: ""
  34. }
  35. },
  36. methods: {
  37. onFocusSearch() {
  38. },
  39. onCreateNewGroup() {
  40. uni.navigateTo({
  41. url: "/pages/group/group-edit"
  42. })
  43. }
  44. },
  45. computed: {
  46. hasGroups() {
  47. return this.groupStore.groups.some((g) => !g.quit);
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .group {
  54. position: relative;
  55. display: flex;
  56. flex-direction: column;
  57. .group-tip {
  58. position: absolute;
  59. top: 50%;
  60. left: 50%;
  61. transform: translate(-50%, -50%);
  62. display: flex;
  63. flex-direction: column;
  64. align-items: center;
  65. padding: 60rpx 40rpx;
  66. text-align: center;
  67. width: 80%;
  68. max-width: 500rpx;
  69. .tip-icon {
  70. width: 120rpx;
  71. height: 120rpx;
  72. background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  73. border-radius: 50%;
  74. display: flex;
  75. align-items: center;
  76. justify-content: center;
  77. margin-bottom: 40rpx;
  78. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  79. border: 2rpx solid $im-bg-active;
  80. .iconfont {
  81. font-size: 56rpx;
  82. color: #6c757d;
  83. opacity: 0.8;
  84. }
  85. }
  86. .tip-title {
  87. font-size: $im-font-size-large;
  88. color: $im-text-color;
  89. font-weight: 500;
  90. margin-bottom: 20rpx;
  91. }
  92. .tip-content {
  93. font-size: $im-font-size-smaller;
  94. color: $im-text-color-lighter;
  95. line-height: 1.6;
  96. margin-bottom: 50rpx;
  97. }
  98. }
  99. .group-items {
  100. flex: 1;
  101. padding: 0;
  102. overflow: hidden;
  103. position: relative;
  104. .scroll-bar {
  105. height: 100%;
  106. }
  107. }
  108. }
  109. </style>