主要更新uniapp相关功能
This commit is contained in:
1 parent
aa92ca40a2
commit
5b4dbb2b46
65 files changed
+8532
-1921
No files matched your search
@@ -0,0 +1,408 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<scroll-view class="body" scroll-y :show-scrollbar="false">
|
||||
<view class="body-inner">
|
||||
<view v-if="loading" class="state-box">
|
||||
<text class="state-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="!contact" class="state-box">
|
||||
<FaIcon name="circle-exclamation" color="#c0c4cc" :size="40" />
|
||||
<text class="state-text">联系人不存在或无权查看</text>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="hero-card">
|
||||
<view class="hero-avatar">
|
||||
<image v-if="contact.avatar" class="hero-avatar-img" :src="contact.avatar" mode="aspectFill" />
|
||||
<text v-else class="hero-avatar-text">{{ firstChar(contact.contact_name) }}</text>
|
||||
</view>
|
||||
<view class="hero-info">
|
||||
<view class="hero-name-row">
|
||||
<text class="hero-name">{{ contact.contact_name }}</text>
|
||||
<text class="type-tag" :class="contact.contact_type === 1 ? 'inner' : 'outer'">
|
||||
{{ getContactTypeLabel(contact.contact_type) }}
|
||||
</text>
|
||||
</view>
|
||||
<text class="hero-sub">{{ heroSub }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="mobilesText || contact.work_phone || contact.email" class="group-card">
|
||||
<view class="group-head">
|
||||
<view class="group-bar" />
|
||||
<text class="group-title">联系方式</text>
|
||||
</view>
|
||||
<view v-if="mobilesText" class="row">
|
||||
<text class="row-label">手机号</text>
|
||||
<text class="row-text">{{ mobilesText }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(mobilesText)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="contact.work_phone" class="row">
|
||||
<text class="row-label">工作电话</text>
|
||||
<text class="row-text">{{ contact.work_phone }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.work_phone)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="contact.email" class="row">
|
||||
<text class="row-label">邮箱</text>
|
||||
<text class="row-text">{{ contact.email }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.email)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="group-card">
|
||||
<view class="group-head">
|
||||
<view class="group-bar" />
|
||||
<text class="group-title">更多信息</text>
|
||||
</view>
|
||||
<view v-if="contact.company_name" class="row">
|
||||
<text class="row-label">公司</text>
|
||||
<text class="row-text">{{ contact.company_name }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.company_name)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="deptText" class="row">
|
||||
<text class="row-label">部门</text>
|
||||
<text class="row-text">{{ deptText }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(deptText)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="contact.position_title" class="row">
|
||||
<text class="row-label">职位</text>
|
||||
<text class="row-text">{{ contact.position_title }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.position_title)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="contact.wechat" class="row">
|
||||
<text class="row-label">微信</text>
|
||||
<text class="row-text">{{ contact.wechat }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.wechat)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="contact.qq" class="row">
|
||||
<text class="row-label">QQ</text>
|
||||
<text class="row-text">{{ contact.qq }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.qq)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="contact.address" class="row">
|
||||
<text class="row-label">地址</text>
|
||||
<text class="row-text">{{ contact.address }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.address)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="contact.remark" class="row">
|
||||
<text class="row-label">备注</text>
|
||||
<text class="row-text">{{ contact.remark }}</text>
|
||||
<view class="copy-btn" @tap.stop="copy(contact.remark)">
|
||||
<FaIcon name="copy" color="#2563eb" :size="13" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<view class="bottom-space" />
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view v-if="contact && callPhone" class="action-bar">
|
||||
<view class="call-action" @tap="call">
|
||||
<FaIcon name="phone" color="#ffffff" :size="16" />
|
||||
<text>拨打电话</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getContact, getContactTypeLabel, formatMobiles, primaryPhone } from '@/api/contact.js'
|
||||
import { isLoggedIn } from '@/utils/auth.js'
|
||||
|
||||
const id = ref(0)
|
||||
const contact = ref(null)
|
||||
const loading = ref(true)
|
||||
|
||||
const mobilesText = computed(() => {
|
||||
if (!contact.value) return ''
|
||||
const text = formatMobiles(contact.value.mobiles)
|
||||
if (text) return text
|
||||
return String(contact.value.phone || '').trim()
|
||||
})
|
||||
|
||||
const deptText = computed(() => {
|
||||
if (!contact.value) return ''
|
||||
return contact.value.org_name || contact.value.dept_name || ''
|
||||
})
|
||||
|
||||
const heroSub = computed(() => {
|
||||
const parts = []
|
||||
if (contact.value && contact.value.position_title) parts.push(contact.value.position_title)
|
||||
if (deptText.value) parts.push(deptText.value)
|
||||
return parts.length ? parts.join(' · ') : '公司内部通讯录'
|
||||
})
|
||||
|
||||
const callPhone = computed(() => (contact.value ? primaryPhone(contact.value) : ''))
|
||||
|
||||
onLoad((options) => {
|
||||
if (!isLoggedIn()) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
id.value = Number((options && options.id) || 0)
|
||||
loadDetail()
|
||||
})
|
||||
|
||||
async function loadDetail() {
|
||||
if (!id.value) {
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
contact.value = await getContact(id.value)
|
||||
} catch (e) {
|
||||
contact.value = null
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function firstChar(name) {
|
||||
return String(name || '?').charAt(0)
|
||||
}
|
||||
|
||||
function call() {
|
||||
if (!callPhone.value) return
|
||||
uni.makePhoneCall({ phoneNumber: callPhone.value })
|
||||
}
|
||||
|
||||
function copy(text) {
|
||||
const data = String(text || '').trim()
|
||||
if (!data) return
|
||||
uni.setClipboardData({
|
||||
data,
|
||||
success() {
|
||||
uni.showToast({ title: '已复制', icon: 'none' })
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/src/styles/page-common.scss';
|
||||
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
background: $color-bg-page;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.body-inner {
|
||||
padding: 24rpx $page-padding-x 0;
|
||||
}
|
||||
|
||||
.hero-card {
|
||||
@include card;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
padding: 36rpx 30rpx;
|
||||
background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
|
||||
box-shadow: $shadow-float;
|
||||
}
|
||||
|
||||
.hero-avatar {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: $radius-lg;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
background: rgba(255, 255, 255, 0.22);
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.35);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.hero-avatar-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.hero-avatar-text {
|
||||
font-size: 48rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.hero-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.hero-name-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.hero-name {
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.type-tag {
|
||||
flex-shrink: 0;
|
||||
padding: 2rpx 14rpx;
|
||||
font-size: 21rpx;
|
||||
border-radius: $radius-sm;
|
||||
color: #ffffff;
|
||||
background: rgba(255, 255, 255, 0.24);
|
||||
}
|
||||
|
||||
.hero-sub {
|
||||
display: block;
|
||||
margin-top: 12rpx;
|
||||
font-size: 25rpx;
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.group-card {
|
||||
@include card;
|
||||
margin-top: 20rpx;
|
||||
padding: 24rpx 28rpx;
|
||||
}
|
||||
|
||||
.group-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.group-bar {
|
||||
width: 6rpx;
|
||||
height: 26rpx;
|
||||
border-radius: 3rpx;
|
||||
background: $color-primary;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 29rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 24rpx;
|
||||
min-width: 0;
|
||||
padding: 22rpx 0;
|
||||
border-bottom: 1rpx solid $color-divider;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.row-label {
|
||||
flex-shrink: 0;
|
||||
font-size: 27rpx;
|
||||
color: $color-text-secondary;
|
||||
}
|
||||
|
||||
.row-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 27rpx;
|
||||
color: $color-text;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
flex-shrink: 0;
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: $radius-sm;
|
||||
background: $color-primary-bg;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
flex-shrink: 0;
|
||||
padding: 20rpx $page-padding-x calc(20rpx + env(safe-area-inset-bottom, 0px));
|
||||
background: $color-card;
|
||||
box-shadow: 0 -2rpx 12rpx rgba(15, 23, 42, 0.05);
|
||||
}
|
||||
|
||||
.call-action {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12rpx;
|
||||
height: 88rpx;
|
||||
border-radius: $radius-full;
|
||||
background: $color-primary;
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
|
||||
&:active {
|
||||
background: $color-primary-dark;
|
||||
}
|
||||
}
|
||||
|
||||
.state-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 160rpx 48rpx;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.state-text {
|
||||
font-size: 26rpx;
|
||||
color: $color-text-muted;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bottom-space {
|
||||
height: 40rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user