121 lines
4.0 KiB
Vue
121 lines
4.0 KiB
Vue
<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: 22rpx; background: #E8F1FF; color: #1677FF; 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: #6B7280; }
|
||
.arr { color: #D1D5DB; }
|
||
.card { margin: 0 24rpx 24rpx; overflow: hidden; }
|
||
.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; }
|
||
.sw { color: #9CA3AF; }
|
||
.sw.on { color: #1677FF; font-weight: 600; }
|
||
.danger { color: #DC2626; justify-content: center; }
|
||
</style>
|