Files
oa_app/pages/chat/setting.vue
T
2026-09-23 16:52:48 +08:00

120 lines
4.0 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 v-if="peer" class="card head" @click="goPeer">
<image v-if="peer.avatar" class="av img" :src="peer.avatar" mode="aspectFill" />
<view v-else class="av">{{ (peer.name || '?').slice(0, 1) }}</view>
<view class="meta">
<text class="n">{{ peer.name }}</text>
<text class="s">{{ peer.department }}{{ peer.title ? ' · ' + peer.title : '' }}</text>
</view>
<text class="arr"></text>
</view>
<view class="card">
<view class="row" @click="goHistory">
<text>查找聊天记录</text>
<text class="arr"></text>
</view>
</view>
<view class="card">
<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" @click="call(false)">
<text>语音通话</text>
<text class="arr"></text>
</view>
<view class="row" @click="call(true)">
<text>视频通话</text>
<text class="arr"></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'
import { toast } from '../../utils/format.js'
export default {
components: { FyHeader },
data() {
return { sid: '', pinned: false, muted: false, peer: null }
},
onLoad(q) {
this.sid = decodeURIComponent(q.sid || '')
},
onShow() { this.pull() },
methods: {
pull() {
const c = store.findConv(this.sid)
this.pinned = !!(c && c.pinned)
this.muted = !!(c && c.muted)
this.peer = c && c.peerId ? store.person(c.peerId) : null
if (!this.peer && c) this.peer = { name: c.name, avatar: c.avatar, department: '', title: '' }
},
toggle(field) {
const c = store.findConv(this.sid)
if (!c) return
store.setSession(c, { [field]: !c[field] })
this.pull()
},
goPeer() {
const c = store.findConv(this.sid)
if (c && c.peerId) uni.navigateTo({ url: '/pages/contact/detail?id=' + encodeURIComponent(c.peerId) })
},
goHistory() {
uni.navigateTo({ url: '/pages/chat/history?sid=' + encodeURIComponent(this.sid) })
},
call(video) {
const c = store.findConv(this.sid)
if (!c || !c.peerId) return
store.startCall(c.peerId, { video }).catch((e) => toast((e && e.message) || '无法发起通话'))
},
clear() {
const c = store.findConv(this.sid)
if (!c) return
uni.showModal({
title: '清空聊天记录',
content: '将清空本机该会话的聊天记录。',
success: (r) => {
if (!r.confirm) return
store.clearHistory(c)
toast('已清空')
}
})
}
}
}
</script>
<style scoped>
.head { margin: 24rpx; padding: 28rpx; display: flex; align-items: center; }
.av { width: 96rpx; height: 96rpx; border-radius: 12rpx; background: #004ac6; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 36rpx; font-weight: 700; overflow: hidden; }
.av.img { width: 96rpx; height: 96rpx; }
.meta { flex: 1; margin-left: 20rpx; }
.n { display: block; font-size: 32rpx; font-weight: 700; }
.s { font-size: 22rpx; color: #737686; }
.arr { color: #c3c6d7; }
.card { margin: 0 24rpx 24rpx; overflow: hidden; }
.row { display: flex; justify-content: space-between; padding: 28rpx 24rpx; font-size: 28rpx; border-bottom: 1rpx solid #f0f0f0; }
.sw { color: #737686; }
.sw.on { color: #07c160; font-weight: 600; }
.danger { color: #fa5151; justify-content: center; border-bottom: none; }
</style>