feat: 页面调整

This commit is contained in:
huxuejian 2026-01-21 10:35:08 +08:00
parent 6144eecd89
commit 1fe97b4897
13 changed files with 147 additions and 75 deletions

View File

@ -1,10 +1,15 @@
<script>
import dbStore from '@/store/db';
export default {
onLaunch: function () {
console.log('App Launch: ')
},
onShow: function () {
console.log('App Show')
const db = dbStore();
if(db && typeof db.getJobs === 'function'){
db.getJobs();
}
},
onHide: function () {
console.log('App Hide')

16
hooks/useJob.js Normal file
View File

@ -0,0 +1,16 @@
import { ref, computed } from 'vue';
import { storeToRefs } from 'pinia';
import dbStore from '@/store/db';
export default function useJob() {
const { jobMap } = storeToRefs(dbStore());
const memberList = ref([]);
const memberJob = computed(() => memberList.value.reduce((acc, item) => {
const jobs = item && Array.isArray(item.job) ? item.job : [];
const jobStr = jobs.map(jobId => jobMap.value[jobId]).filter(Boolean).join('、 ');
acc[item.userid] = jobStr;
return acc;
}, {}))
return { memberJob, memberList }
}

View File

@ -38,7 +38,7 @@
<view class="mr-5 w-0 flex-grow text-base text-white">
该档案还未授权本服务团队点击右侧授权按钮我们将更精准的为您服务
</view>
<view class="px-12 py-5 text-base rounded-sm text-dark bg-white">
<view class="px-12 py-5 text-base rounded-sm text-dark bg-white" @click="auth()">
授权
</view>
</view>
@ -69,7 +69,7 @@ import { computed, ref, watch } from 'vue';
import { storeToRefs } from 'pinia'
import useAccount from '@/store/account';
import api from '@/utils/api';
import { toast } from '@/utils/widget';
import { toast, confirm } from '@/utils/widget';
const props = defineProps({
corpId: {
@ -127,10 +127,23 @@ function toManagePage() {
uni.navigateTo({ url: `/pages/archive/archive-manage?corpId=${props.corpId}&teamId=${props.team.teamId}` })
}
async function auth() {
await confirm(`是否授权${props.team.name}提供服务`);
const res = await api('authCustomerToTeam', { corpId: props.corpId, teamId: props.team.teamId, id: current.value._id });
if (res && res.success) {
await toast('授权成功');
getCustomers()
} else {
toast(res?.message || '授权失败');
}
}
async function getCustomers() {
const res = await api('getMiniAppCustomers', { miniAppId: account.value.openid, corpId: props.corpId });
if (res && res.success) {
customers.value = res && Array.isArray(res.data) ? res.data : [];
const customer = customers.value.find(i => current.value && i._id === current.value._id);
current.value = customer || customers.value[0] || null;
} else {
toast(res.message || '获取档案失败');
}
@ -144,14 +157,6 @@ watch(() => props.corpId, n => {
}
}, { immediate: true });
watch(customers, n => {
if (n.length && !(current.value && n.some(i => i._id === current.value._id))) {
toggle(n[0]);
} else {
current.value = null;
}
})
</script>
<style scoped>
.h-80 {

View File

@ -52,11 +52,11 @@ async function getTeams() {
loading.value = true;
const res = await api('queryWxJoinedTeams', { openid: account.value.openid });
teams.value = res && Array.isArray(res.data) ? res.data : [];
const valid = team.value && teams.value.some(item => item.teamId === team.value.teamId);
if (teams.value.length) {
changeTeam(teams.value[0])
const validTeam = teams.value.find(item => team.value && item.teamId === team.value.teamId) || teams.value[0];
if (validTeam) {
changeTeam(validTeam)
return
} else if (!valid) {
} else {
team.value = null;
}
loading.value = false

View File

@ -24,7 +24,8 @@
<view v-if="showDropDown" class="team-dropdown py-12 bg-white shadow-lg">
<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">
<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">
<group-avatar :size="96" :avatarList="item.avatarList" />
</view>
@ -72,6 +73,11 @@ const props = defineProps({
const currentTeam = computed(() => props.teams.find(i => props.team && i.teamId === props.team.teamId))
function select(team) {
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])
@ -84,7 +90,6 @@ onMounted(() => {
statusBarHeight.value = win.statusBarHeight + 'px';
}
menuButtonInfo.value = uni.getMenuButtonBoundingClientRect();
console.log(win, menuButtonInfo.value)
})
</script>
<style scoped>

View File

@ -14,11 +14,11 @@
@click="toHomePage(i)">
<image class="flex-shrink-0 avatar mr-5" :src="i.avatar || '/static/default-avatar.png'" />
<view class="flex-grow flex flex-col">
<view class="text-lg font-semibold text-dark whitespace-nowrap">
<view class="leading-normal h-24 text-lg font-semibold text-dark whitespace-nowrap">
{{ i.anotherName }}
</view>
<view class="text-base text-gray truncate">
医生
<view class="max-w-100 h-21 leading-normal text-base text-gray truncate">
{{ memberJob[i.userid] }}
</view>
<view v-if="i.canAddFriend" class="w-80 text-base leading-none border text-center text-dark rounded-full"
@click.stop="toQrcode(i)">
@ -31,8 +31,8 @@
</view>
</template>
<script setup>
import { computed } from 'vue'
import { computed, watch } from 'vue'
import useJob from '@/hooks/useJob';
const props = defineProps({
team: {
type: Object,
@ -40,6 +40,8 @@ const props = defineProps({
}
})
const { memberJob, memberList } = useJob();
const teamates = computed(() => {
const friendlyMembers = props.team && Array.isArray(props.team.friendlyMembers) ? props.team.friendlyMembers : [];
const memberList = props.team && Array.isArray(props.team.memberList) ? props.team.memberList : [];
@ -47,7 +49,7 @@ const teamates = computed(() => {
})
function toHomePage(item) {
uni.navigateTo({ url: `/pages/team/homepage?userid=${item.userid}&corpId=${item.corpId}` })
uni.navigateTo({ url: `/pages/team/homepage?userid=${item.userid}&corpId=${item.corpId}&showQrcode=${item.canAddFriend ? 'YES' : ''}` })
}
function toQrcode(item) {
@ -58,6 +60,11 @@ function toTeamDetail() {
uni.navigateTo({ url: `/pages/team/team-detail?teamId=${props.team.teamId}&corpId=${props.team.corpId}&corpName=${encodeURIComponent(props.team.corpName)}` })
}
watch(teamates, val => {
console.log(val)
memberList.value = val;
}, { immediate: true })
</script>
<style scoped>
.avatar {
@ -65,10 +72,22 @@ function toTeamDetail() {
height: 128rpx;
}
.h-24 {
height: 48rpx;
}
.h-21 {
height: 42rpx;
}
.min-w-120 {
min-width: 240rpx;
}
.max-w-100 {
max-width: 200rpx;
}
.w-80 {
width: 160rpx;
}

View File

@ -1,13 +1,11 @@
<template>
<view v-if="team" class="pt-lg px-15 flex flex-col items-center text-center">
<group-avatar :avatarList="team.avatars" />
<view class="mt-15 text-base font-semibold text-dark">{{
team.teamName
}}</view>
<view class="mt-15 text-base font-semibold text-dark">
{{ team.teamName }}
</view>
<view class="mt-12 text-sm text-gray">{{ team.corpName }}</view>
<view class="mt-15 text-lg text-dark font-semibold"
>为您提供团队个性化专属服务</view
>
<view class="mt-15 text-lg text-dark font-semibold">为您提供团队个性化专属服务</view>
</view>
<view v-else class="pt-lg px-15 flex flex-col items-center text-center">
<image src="/static/logo-plain.png" class="logo"></image>
@ -15,13 +13,7 @@
<view class="mt-12 text-base text-dark">生命全周期健康管理伙伴</view>
</view>
<view class="login-btn-wrap">
<button
v-if="checked"
class="login-btn"
type="primary"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
<button v-if="checked" class="login-btn" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
手机号快捷登录
</button>
<!-- <button v-if="checked" class="login-btn" type="primary" @click="getPhoneNumber()">
@ -31,10 +23,7 @@
手机号快捷登录
</button>
</view>
<view
class="flex items-center justify-center mt-12 px-15"
@click="checked = !checked"
>
<view class="flex items-center justify-center mt-12 px-15" @click="checked = !checked">
<checkbox :checked="checked" style="transform: scale(0.7)" />
<view class="text-sm text-gray">我已阅读并同意</view>
<view class="text-sm text-primary">用户协议</view>
@ -51,7 +40,7 @@ import { toast } from "@/utils/widget";
import groupAvatar from "@/components/group-avatar.vue";
const team = ref(true);
const team = ref(null);
const checked = ref(false);
const redirectUrl = ref("");
const { login } = useAccountStore();

View File

@ -8,7 +8,7 @@
<view class="mr-5 text-lg font-semibold text-dark">{{ member.anotherName }}</view>
<view class="text-base text-warning">@企业微信</view>
</view>
<view class="text-base text-dark">咨询师</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()">
@ -18,8 +18,9 @@
</view>
</template>
<script setup>
import { computed, ref } from 'vue';
import { ref, watch } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import useJob from '@/hooks/useJob';
import api from '@/utils/api';
import { toast } from '@/utils/widget';
@ -27,16 +28,7 @@ const corpId = ref('');
const userid = ref('');
const qrcode = ref('')
const member = ref(null);
const corpNames = computed(() => {
const corpNames = member.value && Array.isArray(member.value.corpNames) ? member.value.corpNames : [];
return corpNames.join('、');
})
const deptNames = computed(() => {
const deptNames = member.value && Array.isArray(member.value.deptNames) ? member.value.deptNames : [];
return deptNames.join('、');
})
const { memberJob, memberList } = useJob();
function previewImage() {
if (!qrcode.value) return;
@ -75,6 +67,10 @@ onShow(() => {
}
})
watch(member, n => {
memberList.value = [n].filter(Boolean)
}, { immedate: true })
</script>
<style scoped>
.business-card {

View File

@ -1,9 +1,9 @@
<template>
<view v-if="member" class="flex p-15 bg-whtie shadow-lg">
<view class="flex-grow w-0 mr-10 leading-normal">
<view>
<text class="mr-5 text-xl text-dark font-semibold">{{ member.anotherName }}</text>
<text class="text-base text-gray">医生</text>
<view class="flex items-center">
<view class="mr-5 flex-shrink-0 text-xl text-dark font-semibold">{{ member.anotherName }}</view>
<view class="w-0 flex-grow truncate text-base text-gray">{{ memberJob[member.userid] }}</view>
</view>
<view class="flex">
<view class="flex-shrink-0 text-base text-gray">机构部门</view>
@ -61,6 +61,7 @@
<script setup>
import { computed, ref, watch } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import useJob from '@/hooks/useJob';
import api from '@/utils/api';
import { toast } from '@/utils/widget';
@ -70,6 +71,7 @@ const showQrcode = ref(false);
const qrcode = ref('')
const member = ref(null);
const expand = ref(false);
const { memberJob, memberList } = useJob();
const corpNames = computed(() => {
const corpNames = member.value && Array.isArray(member.value.corpNames) ? member.value.corpNames : [];
@ -116,7 +118,7 @@ async function getQrcode() {
onLoad((options) => {
corpId.value = options.corpId;
userid.value = options.userid;
showQrcode.value = options.showQrcode;
showQrcode.value = options.showQrcode === 'YES';
});
onShow(() => {
@ -125,6 +127,12 @@ onShow(() => {
}
})
watch(member, n => {
if (n) {
memberList.value = [n];
}
}, { immediate: true })
</script>
<style>
page {

View File

@ -23,12 +23,12 @@
<image class="flex-shrink-0 mr-10 avatar" :src="i.avatar || '/static/default-avatar.png'"></image>
<view class="w-0 flex-grow leading-normal">
<view class="flex items-center justify-between">
<view class="flex-grow w-0">
<text class="mr-5 text-lg text-dark font-semibold">{{ i.anotherName }}</text>
<text class="text-base text-dark">医生</text>
<view class="flex-shrink-0 mr-5 view-lg text-dark font-semibold">{{ i.anotherName }}</view>
<view class="w-0 flex-grow truncate text-base text-dark">
{{ memberJob[i.userid] }}
</view>
<view v-if="friendlyMember[i.userid]"
class="px-10 leading-normal text-sm border-auto text-primary rounded-full"
class="flex-shrink-0 px-10 leading-normal text-sm border-auto text-primary rounded-full"
@click.stop="toFriend(i.userid)">
添加好友
</view>
@ -48,12 +48,12 @@
<image class="flex-shrink-0 mr-10 avatar" :src="i.avatar || '/static/default-avatar.png'"></image>
<view class="w-0 flex-grow leading-normal">
<view class="flex items-center justify-between">
<view class="flex-grow w-0">
<text class="mr-5 text-lg text-dark font-semibold">{{ i.anotherName }}</text>
<text class="text-base text-dark">医生</text>
<view class="flex-shrink-0 mr-5 view-lg text-dark font-semibold">{{ i.anotherName }}</view>
<view class="w-0 flex-grow truncate text-base text-dark">
{{ memberJob[i.userid] }}
</view>
<view v-if="friendlyMember[i.userid]"
class="px-10 leading-normal text-sm border-auto text-primary rounded-full"
class="flex-shrink-0 px-10 leading-normal text-sm border-auto text-primary rounded-full"
@click.stop="toFriend(i.userid)">
添加好友
</view>
@ -68,8 +68,9 @@
</view>
</template>
<script setup>
import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import useJob from '@/hooks/useJob';
import api from '@/utils/api';
import groupAvatar from '@/components/group-avatar.vue';
@ -78,7 +79,7 @@ const corpId = ref('');
const teamId = ref('');
const team = ref(null);
const corpName = ref('');
const { memberJob, memberList: list } = useJob();
const memberList = computed(() => team.value && Array.isArray(team.value.memberList) ? team.value.memberList : [])
@ -109,7 +110,7 @@ function toFriend(userid) {
}
function toHomePage(userid) {
uni.navigateTo({ url: `/pages/team/homepage?corpId=${corpId.value}&userid=${userid}&showQrcode=${friendlyMember[userid] ? 'YES' : ''}` })
uni.navigateTo({ url: `/pages/team/homepage?corpId=${corpId.value}&userid=${userid}&showQrcode=${friendlyMember.value[userid] ? 'YES' : ''}` })
}
async function getTeam() {
@ -132,6 +133,10 @@ onShow(() => {
}
});
watch(memberList, n => {
list.value = n
}, { immediate: true })
</script>
<style>
page {

View File

@ -20,14 +20,12 @@ export default defineStore("accountStore", () => {
provider: "weixin",
scope: "snsapi_base",
});
console.log('logincode: ', code)
if (code) {
const res = await api('wxAppLogin', {
phoneCode,
code,
});
loading.value = false
console.log(res)
if (res.success && res.data && res.data.mobile) {
account.value = res.data;
return res.data

24
store/db.js Normal file
View File

@ -0,0 +1,24 @@
import { ref } from "vue";
import { defineStore } from "pinia";
import api from '@/utils/api';
export default defineStore("dbStore", () => {
const jobMap = ref({})
async function getJobs() {
const res = await api('getCorpMemberJob', {}, false);
if (res && res.success) {
const arr = Array.isArray(res.data) ? res.data : [];
jobMap.value = arr.reduce((map, item) => {
if (item.name && item.value) {
map[item.value] = item.name
}
return map
}, {})
}
console.log(jobMap.value)
}
return { jobMap, getJobs }
})

View File

@ -9,6 +9,7 @@ const urlsConfig = {
wxAppLogin: 'wxAppLogin',
getTeamHealthTemplate: 'getTeamHealthTemplate',
getTeamHealthTemps: "getTeamHealthTemps",
getCorpMemberJob: "getCorpMemberJob"
},
knowledgeBase: {
@ -18,6 +19,7 @@ const urlsConfig = {
member: {
addCustomer: 'add',
addMedicalRecord: 'addMedicalRecord',
authCustomerToTeam: 'authCustomerToTeam', // 授权客户到团队
bindMiniAppArchive: "bindMiniAppArchive",
getCustomerByCustomerId: 'getCustomerByCustomerId',
getMiniAppCustomers: 'getMiniAppCustomers',
@ -26,7 +28,7 @@ const urlsConfig = {
getCustomerMedicalRecord: 'getCustomerMedicalRecord',
getMedicalRecordById: 'getMedicalRecordById',
unbindMiniAppArchive: 'unbindMiniAppArchive',
updateMedicalRecord: 'updateMedicalRecord'
updateMedicalRecord: 'updateMedicalRecord',
},
wecom: {
addContactWay: 'addContactWay'
@ -46,7 +48,7 @@ const urls = Object.keys(urlsConfig).reduce((acc, path) => {
return acc
}, {})
export default async function api(urlId, data) {
export default async function api(urlId, data = {}, loading = true) {
const config = urls[urlId];
if (!config) {
throw new Error(`Unknown URL ID: ${urlId}`);
@ -58,5 +60,5 @@ export default async function api(urlId, data) {
...data,
type,
}
})
}, loading)
}