Compare commits
6 Commits
7bc3e9e4c8
...
d41bb6cf51
| Author | SHA1 | Date | |
|---|---|---|---|
| d41bb6cf51 | |||
| f0722190c0 | |||
|
|
87e9cde197 | ||
| cda2954924 | |||
| cd95054b4c | |||
|
|
64c36a3d60 |
@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<view class="full-page" :style="pageStyle">
|
||||
<view class="full-page" :class="pageClass" :style="pageStyle">
|
||||
<view v-if="hasHeader" class="page-header">
|
||||
<slot name="header"></slot>
|
||||
</view>
|
||||
<view class="page-main" :style="mainStyle">
|
||||
<view class="page-main" :class="mainClass" :style="mainStyle">
|
||||
<view v-if="customScroll" class="page-scroll">
|
||||
<slot></slot>
|
||||
</view>
|
||||
@ -21,9 +21,7 @@
|
||||
<view v-if="hasFooter" class="page-footer">
|
||||
<slot name="footer"></slot>
|
||||
</view>
|
||||
<!-- #ifdef MP-->
|
||||
<!-- <view class="safeareaBottom"></view> -->
|
||||
<!-- #endif -->
|
||||
<view v-if="showSafeArea" class="safeareaBottom"></view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
@ -33,8 +31,11 @@ import useDebounce from "@/utils/useDebounce";
|
||||
const emits = defineEmits(["reachBottom"]);
|
||||
const props = defineProps({
|
||||
customScroll: { type: Boolean, default: false },
|
||||
mainStyle: { default: "" },
|
||||
pageStyle: { default: "" },
|
||||
mainClass: { type: String, default: "" },
|
||||
mainStyle: { default: '' },
|
||||
pageClass: { type: String, default: "" },
|
||||
pageStyle: { default: '' },
|
||||
showSafeArea: { type: Boolean, default: true },
|
||||
});
|
||||
const slots = useSlots();
|
||||
const hasHeader = computed(() => !!slots.header);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<view class="flex flex-col items-center justify-center rounded-circle overflow-hidden bg-gray border"
|
||||
<view :class="['flex', 'flex-col', 'items-center', 'justify-center', 'overflow-hidden', 'bg-gray', 'border', { 'rounded-circle': classType === 'circle' }]"
|
||||
:style="`width:${size.lg}rpx; height: ${size.lg}rpx;`" @click="reGenerate()">
|
||||
<view v-for="(item, index) in groups.list" :key="index" class="flex justify-center">
|
||||
<image v-for="(url, idx) in item" :key="idx" :src="url" :style="groups.style"></image>
|
||||
@ -17,6 +17,11 @@ const props = defineProps({
|
||||
type: Array,
|
||||
default: () => []
|
||||
// default: ()=>new Array(9).fill('https://picsum.photos/300/300')
|
||||
},
|
||||
classType: {
|
||||
type: String,
|
||||
default: 'circle',
|
||||
validator: (value) => ['circle', 'square'].includes(value)
|
||||
}
|
||||
})
|
||||
|
||||
@ -52,7 +57,7 @@ const groups = computed(() => {
|
||||
style: `width: ${size.value.md}rpx; height: ${size.value.md}rpx;`
|
||||
}
|
||||
}
|
||||
return { list: [list.value.slice(0, 1)], style: `width: ${size.value.lg}rpx; height: ${size.lg}rpx;` }
|
||||
return { list: [list.value.slice(0, 1)], style: `width: ${size.value.lg}rpx; height: ${size.value.lg}rpx;` }
|
||||
})
|
||||
|
||||
function reGenerate() {
|
||||
|
||||
334
pages.json
334
pages.json
@ -1,165 +1,171 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/home/home",
|
||||
"style": {
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/article/article-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的宣教"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/survey/survey-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的问卷"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/message/message",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/message/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "聊天",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "柚健康"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/redirect-page",
|
||||
"style": {
|
||||
"navigationBarTitleText": "柚健康"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/archive/archive-manage",
|
||||
"style": {
|
||||
"navigationBarTitleText": "档案管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/archive/edit-archive",
|
||||
"style": {
|
||||
"navigationBarTitleText": "新增档案"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/health/list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "健康信息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/health/record",
|
||||
"style": {
|
||||
"navigationBarTitleText": "健康信息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/library/diagnosis-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "选择诊断"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/team/team-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "团队介绍"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/team/homepage",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人主页"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/team/friend",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加好友"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/web-view/web-view",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mine/mine",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mine/contact",
|
||||
"style": {
|
||||
"navigationBarTitleText": "联系客服"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/privacy",
|
||||
"style": {
|
||||
"navigationBarTitleText": "隐私政策"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/agreement",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/article/article-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "宣教文章"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#065bd6",
|
||||
"backgroundColor": "#065bd6"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#666666",
|
||||
"selectedColor": "#007aff",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "white",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/home/home",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home_selected.png",
|
||||
"text": "消息"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/message/message",
|
||||
"iconPath": "static/tabbar/consult.png",
|
||||
"selectedIconPath": "static/tabbar/consult_selected.png",
|
||||
"text": "咨询"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mine/mine",
|
||||
"iconPath": "static/tabbar/mine.png",
|
||||
"selectedIconPath": "static/tabbar/mine_selected.png",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/home/home",
|
||||
"style": {
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/article/article-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的宣教"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/survey/survey-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的问卷"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/message/message",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/message/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "聊天",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "柚健康"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/redirect-page",
|
||||
"style": {
|
||||
"navigationBarTitleText": "柚健康"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/archive/archive-manage",
|
||||
"style": {
|
||||
"navigationBarTitleText": "档案管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/archive/edit-archive",
|
||||
"style": {
|
||||
"navigationBarTitleText": "新增档案"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/archive/archive-result",
|
||||
"style": {
|
||||
"navigationBarTitleText": "团队服务"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/health/list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "健康信息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/health/record",
|
||||
"style": {
|
||||
"navigationBarTitleText": "健康信息"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/library/diagnosis-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "选择诊断"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/team/team-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "团队介绍"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/team/homepage",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人主页"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/team/friend",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加好友"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/web-view/web-view",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mine/mine",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/mine/contact",
|
||||
"style": {
|
||||
"navigationBarTitleText": "联系客服"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/privacy",
|
||||
"style": {
|
||||
"navigationBarTitleText": "隐私政策"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/agreement",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/article/article-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "宣教文章"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "uni-app",
|
||||
"navigationBarBackgroundColor": "#065bd6",
|
||||
"backgroundColor": "#065bd6"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#666666",
|
||||
"selectedColor": "#007aff",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "white",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/home/home",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home_selected.png",
|
||||
"text": "消息"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/message/message",
|
||||
"iconPath": "static/tabbar/consult.png",
|
||||
"selectedIconPath": "static/tabbar/consult_selected.png",
|
||||
"text": "咨询"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mine/mine",
|
||||
"iconPath": "static/tabbar/mine.png",
|
||||
"selectedIconPath": "static/tabbar/mine_selected.png",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"uniIdRouter": {}
|
||||
}
|
||||
|
||||
142
pages/archive/archive-result.vue
Normal file
142
pages/archive/archive-result.vue
Normal file
@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<full-page mainClass="bg-white">
|
||||
<template #header>
|
||||
<view class="mb-10 py-30 flex items-center justify-center bg-white shadow-lg">
|
||||
<icon class="mr-5" type="success" size="24" />
|
||||
<view class="text-lg font-semibold">建档成功</view>
|
||||
</view>
|
||||
</template>
|
||||
<view v-if="friends.length" class="px-15">
|
||||
<view class="py-12 text-base tont-semibold text-dark">
|
||||
您可以加以下人员为好友, 随时提供一对一服务。
|
||||
</view>
|
||||
<template v-if="friends.length > 1">
|
||||
<view v-for="i in friends" :key="i.userid"
|
||||
class="flex items-center mb-10 overflow-hidden border-primary rounded" @click="toFriend(i.userid)">
|
||||
<view class="flex-shrink-0 p-10">
|
||||
<image class="avatar" :src="i.avatar || '/static/default-avatar.png'"></image>
|
||||
</view>
|
||||
<view class="flex-grow w-0 py-10 align-stretch">
|
||||
<view class="truncate">
|
||||
<text class="mr-5 text-lg text-dark font-semibold">{{ i.anotherName }}</text>
|
||||
<text class="text-base text-gray"> {{ memberJob[i.userid] }}</text>
|
||||
</view>
|
||||
<view class="mt-5 text-base line-clamp-2 leading-normal">
|
||||
{{ i.memberTroduce || '暂无简介' }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="px-15 flex items-center align-stretch bg-primary text-base text-white text-center">
|
||||
加好友
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else-if="friends.length === 1 && qrcode">
|
||||
<view class="mt-15 px-15">
|
||||
<view class="flex">
|
||||
<image class="mr-10 avatar" :src="member.avatar || '/static/default-avatar.png'"></image>
|
||||
<view class="w-0 flex-grow leading-normal">
|
||||
<view class="flex items-center">
|
||||
<view class="mr-5 text-lg font-semibold text-dark">{{ member.anotherName }}</view>
|
||||
<view class="text-base text-warning">@企业微信</view>
|
||||
</view>
|
||||
<view class="truncate text-base text-dark">{{ memberJob[member.userid] }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-12 border-primary qrcode p-15 mx-auto rounded" @click="previewImage()">
|
||||
<image v-if="qrcode" class="h-full w-full" :src="qrcode"></image>
|
||||
</view>
|
||||
<view class="mt-12 text-base text-center text-dark">
|
||||
点击识别下方二维码,加我为好友
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</full-page>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useGuard from '@/hooks/useGuard';
|
||||
import useJob from '@/hooks/useJob';
|
||||
import useAccount from '@/store/account';
|
||||
import api from '@/utils/api';
|
||||
|
||||
import FullPage from '@/components/full-page.vue';
|
||||
|
||||
const team = ref(null);
|
||||
const { useLoad } = useGuard();
|
||||
const { account } = storeToRefs(useAccount());
|
||||
const { memberJob, memberList: list } = useJob();
|
||||
const qrcode = ref('');
|
||||
|
||||
const friends = computed(() => {
|
||||
const memberList = Array.isArray(team.value?.memberList) ? team.value.memberList : [];
|
||||
const friendlyMembers = Array.isArray(team.value?.friendlyMembers) ? team.value.friendlyMembers : [];
|
||||
return memberList.filter(i => i && i.userid && friendlyMembers.includes(i.userid))
|
||||
})
|
||||
const member = computed(() => friends.value[0])
|
||||
|
||||
function previewImage() {
|
||||
if (!qrcode.value) return;
|
||||
uni.previewImage({
|
||||
urls: [qrcode.value]
|
||||
})
|
||||
}
|
||||
|
||||
function toFriend(userid) {
|
||||
uni.navigateTo({ url: `/pages/team/friend?corpId=${account.value?.corpId}&userid=${userid}` })
|
||||
}
|
||||
|
||||
async function getQrcode(userid) {
|
||||
const res = await api('addContactWay', { corpUserId: userid, corpId: account.value?.corpId, unionid: account.value?.openid });
|
||||
if (res && res.data) {
|
||||
qrcode.value = res.data;
|
||||
}
|
||||
}
|
||||
|
||||
async function getTeam(corpId, teamId) {
|
||||
const res = await api('getTeamData', { teamId, corpId });
|
||||
if (res && res.data) {
|
||||
team.value = res.data;
|
||||
} else {
|
||||
toast(res?.message || '获取团队信息失败')
|
||||
}
|
||||
}
|
||||
|
||||
useLoad(options => {
|
||||
if (options.teamId && options.corpId) {
|
||||
getTeam(options.corpId, options.teamId);
|
||||
}
|
||||
})
|
||||
|
||||
watch(friends, n => {
|
||||
list.value = Array.isArray(n) ? n : [];
|
||||
if (n.length === 1) {
|
||||
getQrcode(n[0].userid)
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
<style>
|
||||
.py-30 {
|
||||
padding-top: 60rpx;
|
||||
padding-bottom: 60rpx
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 120rpx;
|
||||
height: 128rpx;
|
||||
}
|
||||
|
||||
.align-stretch {
|
||||
align-self: stretch
|
||||
}
|
||||
|
||||
.mt-5 {
|
||||
margin-top: 10rpx
|
||||
}
|
||||
|
||||
.qrcode {
|
||||
width: 560rpx;
|
||||
height: 560rpx;
|
||||
}
|
||||
</style>
|
||||
@ -11,7 +11,7 @@
|
||||
</view>
|
||||
|
||||
<template #footer>
|
||||
<button-footer confirmText="新增档案" :showCancel="false" @confirm="confirm()" />
|
||||
<button-footer confirmText="保存" :showCancel="false" @confirm="confirm()" />
|
||||
</template>
|
||||
</full-page>
|
||||
<bind-popup :customers="customers" :corpName="corpName" :visible="visible" @close="visible = false"
|
||||
@ -38,7 +38,8 @@ import formTemplate from '@/components/form-template/index.vue';
|
||||
|
||||
const empty = ref(false)
|
||||
const { useLoad } = useGuard();
|
||||
const { account } = storeToRefs(useAccount());
|
||||
const { account, externalUserId } = storeToRefs(useAccount());
|
||||
const { getExternalUserId } = useAccount()
|
||||
const corpId = ref('');
|
||||
const corpName = ref('');
|
||||
const customer = ref({});
|
||||
@ -56,15 +57,6 @@ const visible = ref(false);
|
||||
|
||||
const formData = computed(() => ({ ...customer.value, ...form.value }));
|
||||
|
||||
function back() {
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
uni.redirectTo({ url: `/pages/home/home?corpId=${corpId.value}&teamId=${teamId.value}` })
|
||||
}
|
||||
}
|
||||
|
||||
function change({ title, value }) {
|
||||
if (title) {
|
||||
form.value[title] = value;
|
||||
@ -80,7 +72,7 @@ function change({ title, value }) {
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
if (!tempRef.value.verify() || Object.keys(form.value).length === 0) return;
|
||||
if (!tempRef.value.verify()) return;
|
||||
if (customerId.value) {
|
||||
updateArchive();
|
||||
} else {
|
||||
@ -97,12 +89,15 @@ async function addArchive() {
|
||||
teamId: teamId.value,
|
||||
corpId: corpId.value,
|
||||
mobile: account.value.mobile,
|
||||
miniAppId: account.value.openid
|
||||
miniAppId: account.value.openid,
|
||||
externalUserId: externalUserId.value,
|
||||
}
|
||||
loading.value = false;
|
||||
const res = await api('addCustomer', { params });
|
||||
if (res && res.success) {
|
||||
back()
|
||||
uni.redirectTo({
|
||||
url: `/pages/archive/archive-result?corpId=${corpId.value}&teamId=${teamId.value}`
|
||||
})
|
||||
} else {
|
||||
toast(res?.message || '新增档案失败');
|
||||
}
|
||||
@ -122,12 +117,15 @@ async function bindArchive(customerId) {
|
||||
|
||||
async function init() {
|
||||
if (customerId.value) {
|
||||
await getCustomer()
|
||||
await getCustomer();
|
||||
} else {
|
||||
const res = await getArchives();
|
||||
if (res.length > 0) {
|
||||
visible.value = true;
|
||||
}
|
||||
if (!externalUserId.value) {
|
||||
getExternalUserId();
|
||||
}
|
||||
}
|
||||
await getBaseForm();
|
||||
}
|
||||
@ -166,6 +164,32 @@ async function getCustomer() {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateArchive() {
|
||||
if (Object.keys(form.value).length > 0) {
|
||||
const res = await api('updateCustomer', { id: customerId.value, ...form.value });
|
||||
if (res && res.success) {
|
||||
await toast('修改成功');
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
toast(res?.message || '修改失败');
|
||||
}
|
||||
} else {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
|
||||
// async updateCustomer() {
|
||||
// if (Object.keys(this.form).length === 0) return this.editMemberId;
|
||||
// const { success, message } = await updateCustomer(
|
||||
// this.editMemberId,
|
||||
// this.form
|
||||
// );
|
||||
// if (success) return this.editMemberId;
|
||||
// this.widget.hideLoading();
|
||||
// this.widget.toast(message);
|
||||
// return Promise.reject();
|
||||
// },
|
||||
|
||||
onLoad(options => {
|
||||
customerId.value = options.id || '';
|
||||
uni.setNavigationBarTitle({ title: customerId.value ? '编辑档案' : '新增档案' })
|
||||
|
||||
@ -3,38 +3,70 @@
|
||||
<view :style="{ height: statusBarHeight }" class="status-bar"></view>
|
||||
<view class="relative z-3 flex items-center px-15 py-12 header-bar">
|
||||
<view class="flex-shrink-0 mr-5">
|
||||
<group-avatar :size="120" :avatarList="currentTeam ? currentTeam.avatarList : []" />
|
||||
<group-avatar
|
||||
:size="120"
|
||||
:avatarList="currentTeam ? currentTeam.avatarList : []"
|
||||
/>
|
||||
</view>
|
||||
<view class="w-0 flex-grow ">
|
||||
<view class="w-0 flex-grow">
|
||||
<view class="flex items-center mb-10">
|
||||
<view class="team-name flex-shrink-0">{{ team.name }}</view>
|
||||
<view v-if="teams.length > 1" class="flex-shrink-0 flex items-center switch-btn ml-10"
|
||||
@click="showDropDown = true">
|
||||
<image class="switch-icon" src="/static/home/switch-team.png" mode="aspectFit"></image>
|
||||
<view
|
||||
v-if="teams.length > 1"
|
||||
class="flex-shrink-0 flex items-center switch-btn ml-10"
|
||||
@click="showDropDown = true"
|
||||
>
|
||||
<image
|
||||
class="switch-icon"
|
||||
src="/static/home/switch-team.png"
|
||||
mode="aspectFit"
|
||||
></image>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="currentTeam" class="text-base text-white truncate">{{ currentTeam.corpName }}</view>
|
||||
<view v-if="currentTeam" class="text-base text-white truncate">{{
|
||||
currentTeam.corpName
|
||||
}}</view>
|
||||
</view>
|
||||
<view v-if="menuButtonInfo && menuButtonInfo.width > 0" class="flex-shrink-0"
|
||||
:style="{ width: menuButtonInfo.width + 'px', height: menuButtonInfo.height + 'px' }">
|
||||
<view
|
||||
v-if="menuButtonInfo && menuButtonInfo.width > 0"
|
||||
class="flex-shrink-0"
|
||||
:style="{
|
||||
width: menuButtonInfo.width + 'px',
|
||||
height: menuButtonInfo.height + 'px',
|
||||
}"
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="relative">
|
||||
<view v-if="showDropDown" class="team-dropdown py-12 bg-white shadow-lg">
|
||||
<scroll-view scroll-y="true" style="max-height: 50vh;">
|
||||
<scroll-view scroll-y="true" style="max-height: 50vh">
|
||||
<view class="px-15">
|
||||
<view v-for="item in teams" :key="item.teamId" class="mb-10 p-10 flex items-center bg-gray rounded-sm"
|
||||
@click="select(item)">
|
||||
<view class="flex-shrink-0 mr-5">
|
||||
<view
|
||||
v-for="item in teams"
|
||||
:key="item.teamId"
|
||||
class="mb-10 p-10 flex items-center bg-gray rounded-sm"
|
||||
@click="select(item)"
|
||||
>
|
||||
<view class="flex-shrink-0 mr-5 rounded-circle">
|
||||
<group-avatar :size="96" :avatarList="item.avatarList" />
|
||||
</view>
|
||||
<view class="w-0 flex-grow mr-5">
|
||||
<view class="mb-5 text-lg font-semibold text-dark">{{ item.name }}</view>
|
||||
<view class="text-base text-gray leading-normal">{{ item.corpName }}</view>
|
||||
<view class="mb-5 text-lg font-semibold text-dark">{{
|
||||
item.name
|
||||
}}</view>
|
||||
<view class="text-base text-gray leading-normal">{{
|
||||
item.corpName
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="flex">
|
||||
<image class="check-icon"
|
||||
:src="team && team.teamId === item.teamId ? '/static/form/checked.svg' : '/static/form/unchecked.svg'">
|
||||
<image
|
||||
class="check-icon"
|
||||
:src="
|
||||
team && team.teamId === item.teamId
|
||||
? '/static/form/checked.svg'
|
||||
: '/static/form/unchecked.svg'
|
||||
"
|
||||
>
|
||||
</image>
|
||||
</view>
|
||||
</view>
|
||||
@ -48,54 +80,71 @@
|
||||
<view class="triangle-wrapper">
|
||||
<view class="team-triangle"></view>
|
||||
</view>
|
||||
<image class="laba-icon flex-shrink-0" src="/static/home/speaker-intro.png" mode="aspectFit"></image>
|
||||
<view class="introduce-text flex-grow line-clamp-2">{{ team.teamTroduce }}</view>
|
||||
<image
|
||||
class="laba-icon flex-shrink-0"
|
||||
src="/static/home/speaker-intro.png"
|
||||
mode="aspectFit"
|
||||
></image>
|
||||
<view class="introduce-text flex-grow line-clamp-2">{{
|
||||
team.teamTroduce
|
||||
}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="showDropDown" class="mask" @click="showDropDown = false"></view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed, ref, onMounted, watch } from 'vue';
|
||||
import { computed, ref, onMounted, watch } from "vue";
|
||||
|
||||
import groupAvatar from '@/components/group-avatar.vue';
|
||||
import groupAvatar from "@/components/group-avatar.vue";
|
||||
|
||||
const statusBarHeight = ref('50px');
|
||||
const statusBarHeight = ref("50px");
|
||||
const menuButtonInfo = ref(null);
|
||||
const showDropDown = ref(false)
|
||||
const showDropDown = ref(false);
|
||||
|
||||
const emits = defineEmits(['changeTeam']);
|
||||
const emits = defineEmits(["changeTeam"]);
|
||||
const props = defineProps({
|
||||
team: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
default: () => ({}),
|
||||
},
|
||||
teams: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const currentTeam = computed(() => props.teams.find(i => props.team && i.teamId === props.team.teamId))
|
||||
const currentTeam = computed(() =>
|
||||
props.teams.find((i) => props.team && i.teamId === props.team.teamId)
|
||||
);
|
||||
|
||||
function select(team) {
|
||||
emits('changeTeam', team)
|
||||
showDropDown.value = false
|
||||
emits("changeTeam", team);
|
||||
showDropDown.value = false;
|
||||
}
|
||||
|
||||
watch(() => props.teams, (teams) => {
|
||||
if (teams.length && !(currentTeam.value && teams.some(i => i.teamId === currentTeam.value.teamId))) {
|
||||
emits('changeTeam', teams[0])
|
||||
watch(
|
||||
() => props.teams,
|
||||
(teams) => {
|
||||
if (
|
||||
teams.length &&
|
||||
!(
|
||||
currentTeam.value &&
|
||||
teams.some((i) => i.teamId === currentTeam.value.teamId)
|
||||
)
|
||||
) {
|
||||
emits("changeTeam", teams[0]);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
const win = uni.getWindowInfo();
|
||||
if (win && win.statusBarHeight > 0) {
|
||||
statusBarHeight.value = win.statusBarHeight + 'px';
|
||||
statusBarHeight.value = win.statusBarHeight + "px";
|
||||
}
|
||||
menuButtonInfo.value = uni.getMenuButtonBoundingClientRect();
|
||||
})
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
.status-bar {
|
||||
@ -146,7 +195,11 @@ onMounted(() => {
|
||||
width: 690rpx;
|
||||
min-height: 111rpx;
|
||||
box-sizing: border-box;
|
||||
background: linear-gradient(186deg, rgba(255, 255, 255, 0.4) 13.34%, rgba(255, 255, 255, 0.6) 99.17%);
|
||||
background: linear-gradient(
|
||||
186deg,
|
||||
rgba(255, 255, 255, 0.4) 13.34%,
|
||||
rgba(255, 255, 255, 0.6) 99.17%
|
||||
);
|
||||
border-radius: 16rpx;
|
||||
padding: 20rpx 20rpx 20rpx 0;
|
||||
position: relative;
|
||||
@ -170,7 +223,11 @@ onMounted(() => {
|
||||
bottom: -10rpx;
|
||||
width: 16rpx;
|
||||
height: 16rpx;
|
||||
background: linear-gradient(186deg, rgba(255, 255, 255, 0.4) 13.34%, rgba(255, 255, 255, 0.6) 99.17%);
|
||||
background: linear-gradient(
|
||||
186deg,
|
||||
rgba(255, 255, 255, 0.4) 13.34%,
|
||||
rgba(255, 255, 255, 0.6) 99.17%
|
||||
);
|
||||
transform: translateX(-50%) rotate(45deg);
|
||||
}
|
||||
|
||||
@ -223,4 +280,8 @@ onMounted(() => {
|
||||
border-bottom-left-radius: 16rpx;
|
||||
border-bottom-right-radius: 16rpx;
|
||||
}
|
||||
|
||||
.rounded-circle {
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
@ -17,8 +17,8 @@
|
||||
手机号快捷登录
|
||||
</button>
|
||||
<!-- <button v-if="checked" class="login-btn" type="primary" @click="getPhoneNumber()">
|
||||
手机号快捷登录
|
||||
</button> -->
|
||||
手机号快捷登录
|
||||
</button> -->
|
||||
<button v-else class="login-btn" type="primary" @click="remind()">
|
||||
手机号快捷登录
|
||||
</button>
|
||||
@ -35,6 +35,7 @@
|
||||
import { ref } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import useAccountStore from "@/store/account";
|
||||
import api from '@/utils/api';
|
||||
import { get } from "@/utils/cache";
|
||||
import { toast } from "@/utils/widget";
|
||||
|
||||
@ -71,16 +72,27 @@ function remind() {
|
||||
}
|
||||
|
||||
function toHome() {
|
||||
uni.navigateTo({
|
||||
uni.switchTab({
|
||||
url: "/pages/home/home",
|
||||
});
|
||||
}
|
||||
|
||||
async function checkTeamArchive(account) {
|
||||
const res = await api('getWxAppCustomerCount', { miniAppId: account.openid, corpId: account.corpId, teamId: '1nYlVrNXGT173674701967643308' || team.value.teamId });
|
||||
if (res && res.data > 0) {
|
||||
toHome();
|
||||
} else {
|
||||
attempToPage(redirectUrl.value)
|
||||
}
|
||||
}
|
||||
|
||||
async function getPhoneNumber(e) {
|
||||
const phoneCode = e && e.detail && e.detail.code;
|
||||
if (e && !phoneCode) return;
|
||||
// if (e && !phoneCode) return;
|
||||
const res = await login(phoneCode);
|
||||
if (res && redirectUrl.value) {
|
||||
if (res && team.value) {
|
||||
checkTeamArchive(res)
|
||||
} else if (res && redirectUrl.value) {
|
||||
await attempToPage(redirectUrl.value);
|
||||
} else if (res) {
|
||||
toHome();
|
||||
@ -99,7 +111,6 @@ onLoad((opts) => {
|
||||
if (opts.source === "teamInvite") {
|
||||
team.value = get("invite-team-info");
|
||||
redirectUrl.value = `/pages/archive/edit-archive?teamId=${team.value.teamId}&corpId=${team.value.corpId}`;
|
||||
console.log("redirectUrl", redirectUrl.value);
|
||||
return;
|
||||
}
|
||||
redirectUrl.value = opts.redirectUrl || "";
|
||||
|
||||
@ -15,13 +15,13 @@ const corpId = ref("");
|
||||
const loading = ref(false);
|
||||
const team = ref(null);
|
||||
|
||||
async function changeTeam({ teamId, corpId, corpName }) {
|
||||
async function changeTeam({ teamId, corpId }) {
|
||||
loading.value = true;
|
||||
const res = await api("getTeamData", { teamId, corpId, withCorpName: true });
|
||||
loading.value = false;
|
||||
if (res && res.data) {
|
||||
team.value = res.data;
|
||||
team.value.corpName = corpName;
|
||||
team.value.corpName = res.data.corpName;
|
||||
set("invite-team-info", {
|
||||
corpId: team.value.corpId,
|
||||
teamId: team.value.teamId,
|
||||
@ -45,9 +45,7 @@ onLoad((options) => {
|
||||
typeof options.q === "string" ? decodeURIComponent(options.q) : "";
|
||||
const [, url = ""] = href.split("?");
|
||||
const data = url.split("&").reduce((acc, cur) => {
|
||||
console.log(cur);
|
||||
const [key, value] = cur.split("=");
|
||||
console.log(key, "=====", value);
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
107
pages/message/hooks/use-group-avatars.js
Normal file
107
pages/message/hooks/use-group-avatars.js
Normal file
@ -0,0 +1,107 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import api from '@/utils/api.js'
|
||||
import useTeamStore from '@/store/team.js'
|
||||
|
||||
/**
|
||||
* 群聊头像管理hook - 为消息列表中的每个群聊获取成员头像
|
||||
* 用于在消息列表中显示群聊的group-avatar组件
|
||||
*/
|
||||
export default function useGroupAvatars() {
|
||||
const groupAvatarMap = ref({}) // { groupID: [avatarUrl1, avatarUrl2, ...] }
|
||||
const teamStore = useTeamStore()
|
||||
const patientDefaultAvatar = '/static/default-avatar.png'
|
||||
|
||||
/**
|
||||
* 获取单个群聊的头像列表
|
||||
* @param {string} groupID 群组ID
|
||||
* @param {string} teamId 团队ID
|
||||
* @param {string} patientId 患者ID
|
||||
* @returns {Promise<Array>} 头像URL数组
|
||||
*/
|
||||
async function getGroupAvatarList(groupID, teamId, patientId) {
|
||||
try {
|
||||
if (!teamId) {
|
||||
console.warn(`群聊 ${groupID} 没有 teamId,无法获取头像`)
|
||||
return [patientDefaultAvatar]
|
||||
}
|
||||
|
||||
// 获取团队成员的头像和名称
|
||||
const memberMap = await teamStore.getTeamMemberAvatarsAndName(teamId)
|
||||
|
||||
if (!memberMap || Object.keys(memberMap).length === 0) {
|
||||
console.warn(`群聊 ${groupID} 的团队成员为空`)
|
||||
return [patientDefaultAvatar]
|
||||
}
|
||||
|
||||
// 提取头像列表(过滤掉空头像,使用默认头像替代)
|
||||
const avatarList = Object.values(memberMap)
|
||||
.map(member => {
|
||||
// 如果成员有头像且不为空,使用成员头像;否则使用默认头像
|
||||
return (member.avatar && member.avatar.trim() !== '')
|
||||
? member.avatar
|
||||
: patientDefaultAvatar
|
||||
})
|
||||
|
||||
// 添加患者默认头像
|
||||
avatarList.push(patientDefaultAvatar)
|
||||
|
||||
console.log(`群聊 ${groupID} 的头像列表已加载,共 ${avatarList.length} 个头像`)
|
||||
return avatarList
|
||||
} catch (error) {
|
||||
console.error(`获取群聊 ${groupID} 的头像列表失败:`, error)
|
||||
return [patientDefaultAvatar]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取多个群聊的头像列表
|
||||
* @param {Array} conversationList 会话列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function loadGroupAvatars(conversationList) {
|
||||
if (!conversationList || conversationList.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 并发加载所有群聊的头像
|
||||
const promises = conversationList.map(async (conversation) => {
|
||||
const avatarList = await getGroupAvatarList(
|
||||
conversation.groupID,
|
||||
conversation.teamId,
|
||||
conversation.patientId
|
||||
)
|
||||
groupAvatarMap.value[conversation.groupID] = avatarList
|
||||
})
|
||||
|
||||
await Promise.all(promises)
|
||||
console.log('所有群聊头像加载完成')
|
||||
} catch (error) {
|
||||
console.error('批量加载群聊头像失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定群聊的头像列表
|
||||
* @param {string} groupID 群组ID
|
||||
* @returns {Array} 头像URL数组
|
||||
*/
|
||||
function getAvatarList(groupID) {
|
||||
return groupAvatarMap.value[groupID] || [patientDefaultAvatar]
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
function clearCache() {
|
||||
groupAvatarMap.value = {}
|
||||
}
|
||||
|
||||
return {
|
||||
groupAvatarMap,
|
||||
getGroupAvatarList,
|
||||
loadGroupAvatars,
|
||||
getAvatarList,
|
||||
clearCache
|
||||
}
|
||||
}
|
||||
@ -24,10 +24,10 @@
|
||||
@click="handleClickConversation(conversation)"
|
||||
>
|
||||
<view class="avatar-container">
|
||||
<image
|
||||
class="avatar"
|
||||
:src="conversation.avatar || '/static/default-avatar.png'"
|
||||
mode="aspectFill"
|
||||
<GroupAvatar
|
||||
:avatarList="getAvatarList(conversation.groupID)"
|
||||
:size="96"
|
||||
classType="square"
|
||||
/>
|
||||
<view v-if="conversation.unreadCount > 0" class="unread-badge">
|
||||
<text class="unread-text">{{
|
||||
@ -81,6 +81,8 @@ import { storeToRefs } from "pinia";
|
||||
import useAccountStore from "@/store/account.js";
|
||||
import { globalTimChatManager } from "@/utils/tim-chat.js";
|
||||
import { mergeConversationWithGroupDetails } from "@/utils/conversation-merger.js";
|
||||
import useGroupAvatars from "./hooks/use-group-avatars.js";
|
||||
import GroupAvatar from "@/components/group-avatar.vue";
|
||||
|
||||
// 获取登录状态
|
||||
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
||||
@ -93,6 +95,9 @@ const loadingMore = ref(false);
|
||||
const hasMore = ref(false);
|
||||
const refreshing = ref(false);
|
||||
|
||||
// 群聊头像管理
|
||||
const { loadGroupAvatars, getAvatarList } = useGroupAvatars();
|
||||
|
||||
// 初始化IM
|
||||
const initIM = async () => {
|
||||
console.log("=== message.vue initIM 开始 ===");
|
||||
@ -184,7 +189,14 @@ const loadConversationList = async () => {
|
||||
conversationList.value = await mergeConversationWithGroupDetails(
|
||||
result.groupList
|
||||
);
|
||||
console.log("群聊列表加载成功,共", conversationList.value, "个会话");
|
||||
console.log(
|
||||
"群聊列表加载成功,共",
|
||||
conversationList.value.length,
|
||||
"个会话"
|
||||
);
|
||||
|
||||
// 加载所有群聊的头像
|
||||
await loadGroupAvatars(conversationList.value);
|
||||
} else {
|
||||
console.error("加载群聊列表失败:", result);
|
||||
uni.showToast({
|
||||
@ -291,7 +303,10 @@ const setupConversationListener = () => {
|
||||
// 保持原有头像,避免闪动
|
||||
avatar: existing.avatar || conversationData.avatar,
|
||||
// 保留较大的未读数(避免被后端数据覆盖)
|
||||
unreadCount: Math.max(existing.unreadCount || 0, conversationData.unreadCount || 0)
|
||||
unreadCount: Math.max(
|
||||
existing.unreadCount || 0,
|
||||
conversationData.unreadCount || 0
|
||||
),
|
||||
};
|
||||
needSort = true;
|
||||
console.log(
|
||||
@ -331,11 +346,11 @@ const setupConversationListener = () => {
|
||||
// 检查当前页面栈,判断用户是否正在查看该会话的聊天详情页
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
|
||||
|
||||
// 获取当前页面的 groupID 参数(如果在聊天详情页)
|
||||
const currentGroupID = currentPage?.options?.groupID;
|
||||
const isViewingThisConversation =
|
||||
currentPage?.route === "pages/message/index" &&
|
||||
const isViewingThisConversation =
|
||||
currentPage?.route === "pages/message/index" &&
|
||||
currentGroupID === conversation.groupID;
|
||||
|
||||
// 如果用户正在查看这个具体的会话,不增加未读数
|
||||
@ -533,6 +548,7 @@ onHide(() => {
|
||||
.avatar-container {
|
||||
position: relative;
|
||||
margin-right: 24rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
|
||||
@ -14,13 +14,18 @@
|
||||
<view class="mt-12 border-primary qrcode p-15 mx-auto rounded" @click="previewImage()">
|
||||
<image v-if="qrcode" class="h-full w-full" :src="qrcode"></image>
|
||||
</view>
|
||||
<view class="mt-12 text-base text-center text-dark">
|
||||
点击识别下方二维码,加我为好友
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import useJob from '@/hooks/useJob';
|
||||
import useAccount from '@/store/account';
|
||||
import api from '@/utils/api';
|
||||
import { toast } from '@/utils/widget';
|
||||
|
||||
@ -29,6 +34,7 @@ const userid = ref('');
|
||||
const qrcode = ref('')
|
||||
const member = ref(null);
|
||||
const { memberJob, memberList } = useJob();
|
||||
const { account } = storeToRefs(useAccount());
|
||||
|
||||
function previewImage() {
|
||||
if (!qrcode.value) return;
|
||||
@ -50,7 +56,7 @@ async function getMember() {
|
||||
}
|
||||
|
||||
async function getQrcode() {
|
||||
const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value });
|
||||
const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value, unionid: account.value?.openid });
|
||||
if (res && res.data) {
|
||||
qrcode.value = res.data;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
</view>
|
||||
<view v-if="qrcode" class="p-15 mt-12 leading-normal bg-white shadow-lg">
|
||||
<view class="text-lg font-semibold text-center text-dark">
|
||||
点击下方二维码,加我为好友
|
||||
点击识别下方二维码,加我为好友
|
||||
</view>
|
||||
<view class="mt-12 border-primary qrcode p-15 mx-auto rounded" @click="previewImage()">
|
||||
<image :src="qrcode" class="h-full w-full"></image>
|
||||
@ -128,7 +128,7 @@ async function getMember() {
|
||||
}
|
||||
|
||||
async function getQrcode() {
|
||||
const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value });
|
||||
const res = await api('addContactWay', { corpUserId: userid.value, corpId: corpId.value, unionid: account.value?.openid });
|
||||
if (res && res.data) {
|
||||
qrcode.value = res.data;
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="team.teamTroduce" class="mt-12 text-base text-dark leading-normal break-all">
|
||||
<view v-if="team.teamTroduce" class="mt-12 text-base text-dark leading-normal break-all pre-wrap">
|
||||
{{ team.teamTroduce }}
|
||||
</view>
|
||||
<template v-if="teammate.leaders.length">
|
||||
@ -152,4 +152,8 @@ page {
|
||||
width: 120rpx;
|
||||
height: 128rpx;
|
||||
}
|
||||
|
||||
.pre-wrap {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
@ -20,6 +20,10 @@ export default [
|
||||
path: 'pages/archive/edit-archive',
|
||||
meta: { title: '新增档案', login: true }
|
||||
},
|
||||
{
|
||||
path: 'pages/archive/archive-result',
|
||||
meta: { title: '团队服务' }
|
||||
},
|
||||
{
|
||||
path: 'pages/article/article-list',
|
||||
meta: { title: '健康宣教', login: true }
|
||||
|
||||
0
static/doctor-avatar.png
Normal file
0
static/doctor-avatar.png
Normal file
@ -1,11 +1,10 @@
|
||||
import { ref } from "vue";
|
||||
import { ref, watch } from "vue";
|
||||
import { defineStore } from "pinia";
|
||||
import api from '@/utils/api';
|
||||
import { toast } from '@/utils/widget';
|
||||
import { initGlobalTIM, globalTimChatManager } from "@/utils/tim-chat.js";
|
||||
const env = __VITE_ENV__;
|
||||
|
||||
|
||||
export default defineStore("accountStore", () => {
|
||||
const appid = env.MP_WX_APP_ID;
|
||||
const corpId = env.MP_CORP_ID;
|
||||
@ -13,11 +12,11 @@ export default defineStore("accountStore", () => {
|
||||
const loading = ref(false)
|
||||
const isIMInitialized = ref(false);
|
||||
const openid = ref("");
|
||||
async function login(phoneCode = '') {
|
||||
const externalUserId = ref('');
|
||||
|
||||
async function login(phoneCode = '') {
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const { code } = await uni.login({
|
||||
appid,
|
||||
@ -26,20 +25,20 @@ export default defineStore("accountStore", () => {
|
||||
});
|
||||
if (code) {
|
||||
const res = await api('wxAppLogin', {
|
||||
appId:appid,
|
||||
appId: appid,
|
||||
phoneCode,
|
||||
code,
|
||||
corpId
|
||||
corpId
|
||||
});
|
||||
loading.value = false
|
||||
if (res.success && res.data && res.data.mobile) {
|
||||
account.value = res.data;
|
||||
openid.value = res.data.openid;
|
||||
|
||||
|
||||
// 保存账户信息和 openId 到本地存储
|
||||
uni.setStorageSync('account', res.data);
|
||||
uni.setStorageSync('openid', res.data.openid);
|
||||
|
||||
|
||||
initIMAfterLogin(openid.value)
|
||||
return res.data
|
||||
}
|
||||
@ -62,21 +61,21 @@ export default defineStore("accountStore", () => {
|
||||
console.error('无法获取 openid,IM 初始化失败');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
console.log('开始初始化 IM,userID:', userID);
|
||||
const success = await initGlobalTIM(userID);
|
||||
|
||||
|
||||
if (!success) {
|
||||
console.error('initGlobalTIM 返回失败');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 验证 TIM 实例是否真正创建成功
|
||||
if (!globalTimChatManager || !globalTimChatManager.tim) {
|
||||
console.error('IM 初始化后 TIM 实例不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
isIMInitialized.value = true;
|
||||
console.log('IM 初始化成功');
|
||||
return true;
|
||||
@ -102,11 +101,26 @@ export default defineStore("accountStore", () => {
|
||||
account.value = null;
|
||||
openid.value = "";
|
||||
isIMInitialized.value = false;
|
||||
|
||||
|
||||
// 清除本地存储
|
||||
uni.removeStorageSync('account');
|
||||
uni.removeStorageSync('openid');
|
||||
}
|
||||
|
||||
return { account, login, initIMAfterLogin, logout, openid, isIMInitialized }
|
||||
async function getExternalUserId() {
|
||||
const corpId = account.value?.corpId;
|
||||
const unionid = account.value?.unionid;
|
||||
const openid = account.value?.openid;
|
||||
if (!(corpId && unionid && openid) || externalUserId.value) return;
|
||||
const res = await api('getUnionidToExternalUserid', { unionid, openid, corpId }, false);
|
||||
if (res && res.success && typeof res.data === 'string' && res.data.trim()) {
|
||||
externalUserId.value = res.data.trim();
|
||||
}
|
||||
}
|
||||
|
||||
watch(account, n => {
|
||||
getExternalUserId()
|
||||
}, { immediate: true })
|
||||
|
||||
return { account, login, initIMAfterLogin, logout, openid, isIMInitialized, externalUserId, getExternalUserId }
|
||||
})
|
||||
@ -46,6 +46,9 @@ const urlsConfig = {
|
||||
getMedicalRecordById: 'getMedicalRecordById',
|
||||
unbindMiniAppArchive: 'unbindMiniAppArchive',
|
||||
updateMedicalRecord: 'updateMedicalRecord',
|
||||
getUnionidToExternalUserid: 'getUnionidToExternalUserid',
|
||||
getWxAppCustomerCount: "getWxAppCustomerCount",
|
||||
updateCustomer: 'update'
|
||||
},
|
||||
wecom: {
|
||||
addContactWay: 'addContactWay'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user