Files
oa_app/pages/chat/group.vue
T
2026-09-24 14:19:36 +08:00

126 lines
4.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="page">
<fy-header title="群聊设置" back />
<view class="card head">
<view class="grid">
<view v-for="p in members.slice(0, 4)" :key="p.id" class="cell">{{ (p.name || '?').slice(0, 1) }}</view>
</view>
<view class="meta">
<text class="gn">{{ title }}</text>
<text class="gc">{{ members.length }} 人 · 协同进行中</text>
</view>
</view>
<view class="card">
<view class="cap">
<text>群成员 ({{ members.length }})</text>
</view>
<view class="mems">
<view v-for="p in members" :key="p.id" class="mem" @click="open(p)">
<view class="mav">{{ (p.name || '?').slice(0, 1) }}</view>
<text class="mn">{{ p.name }}</text>
</view>
</view>
</view>
<view class="card">
<view class="row" @click="goHistory">
<text>查找聊天记录</text>
<text class="val">›</text>
</view>
</view>
<view class="card">
<view class="row">
<text>群名称</text>
<text class="val">{{ title }}</text>
</view>
<view class="row" @click="toggle('pinned')">
<text>置顶聊天</text>
<text class="sw" :class="{ on: pinned }">{{ pinned ? '开' : '关' }}</text>
</view>
<view class="row" @click="toggle('muted')">
<text>消息免打扰</text>
<text class="sw" :class="{ on: muted }">{{ muted ? '开' : '关' }}</text>
</view>
</view>
<view class="card">
<view class="row danger" @click="clear">清空聊天记录</view>
</view>
</view>
</template>
<script>
import FyHeader from '../../components/fy-header.vue'
import { store } from '../../utils/store.js'
export default {
components: { FyHeader },
data() {
return { sid: '', title: '群聊', members: [], pinned: false, muted: false }
},
onLoad(q) {
this.sid = decodeURIComponent(q.sid || '')
},
onShow() {
this.pull()
},
methods: {
pull() {
const c = store.findConv(this.sid)
this.title = (c && c.name) || '群聊'
this.pinned = !!(c && c.pinned)
this.muted = !!(c && c.muted)
const ids = (c && c.memberIds) || []
this.members = ids.map((id) => store.person(id) || { id, name: id, title: '', department: '' })
},
open(p) {
uni.navigateTo({ url: '/pages/contact/detail?id=' + encodeURIComponent(p.id) })
},
toggle(field) {
const c = store.findConv(this.sid)
if (!c) return
store.setSession(c, { [field]: !c[field] })
this.pull()
},
goHistory() {
uni.navigateTo({ url: '/pages/chat/history?sid=' + encodeURIComponent(this.sid) })
},
clear() {
const c = store.findConv(this.sid)
if (!c) return
uni.showModal({
title: '清空聊天记录',
content: '将清空本机该群的聊天记录。',
success: (r) => {
if (!r.confirm) return
store.clearHistory(c)
}
})
}
}
}
</script>
<style scoped>
.head { margin: 24rpx; padding: 28rpx; display: flex; align-items: center; }
.grid { width: 96rpx; height: 96rpx; background: #E8F1FF; border-radius: 22rpx; display: flex; flex-wrap: wrap; padding: 8rpx; box-sizing: border-box; }
.cell { width: 36rpx; height: 36rpx; margin: 2rpx; background: #fff; color: #1677FF; font-size: 18rpx; font-weight: 700; display: flex; align-items: center; justify-content: center; border-radius: 8rpx; }
.meta { margin-left: 20rpx; }
.gn { font-size: 32rpx; font-weight: 700; display: block; }
.gc { font-size: 22rpx; color: #6B7280; }
.card { margin: 0 24rpx 24rpx; overflow: hidden; }
.cap { padding: 20rpx 24rpx 8rpx; font-size: 26rpx; font-weight: 700; }
.mems { display: flex; flex-wrap: wrap; padding: 8rpx 16rpx 24rpx; }
.mem { width: 20%; display: flex; flex-direction: column; align-items: center; margin-bottom: 16rpx; }
.mav { width: 80rpx; height: 80rpx; border-radius: 18rpx; background: #E8F1FF; color: #1677FF; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.mn { font-size: 20rpx; margin-top: 8rpx; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 28rpx 24rpx; font-size: 28rpx; border-bottom: 1rpx solid #F0F2F5; }
.row:last-child { border-bottom: none; }
.val { color: #6B7280; }
.sw { color: #9CA3AF; }
.sw.on { color: #1677FF; font-weight: 600; }
.danger { color: #DC2626; justify-content: center; }
</style>