Merge commit 'c452ea29e926b75d6a9d05f6f885216659b3efba' into dev-wdb

This commit is contained in:
wangdongbo 2026-02-04 18:50:39 +08:00
commit 19a70f1134
19 changed files with 655 additions and 201 deletions

View File

@ -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);

View File

@ -57,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() {

View File

@ -56,6 +56,12 @@
"navigationBarTitleText": "新增档案"
}
},
{
"path": "pages/archive/archive-result",
"style": {
"navigationBarTitleText": "团队服务"
}
},
{
"path": "pages/health/list",
"style": {
@ -168,4 +174,4 @@
]
},
"uniIdRouter": {}
}
}

View 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>

View File

@ -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 ? '编辑档案' : '新增档案' })

View File

@ -28,8 +28,11 @@
import { onLoad } from "@dcloudio/uni-app";
import api from "@/utils/api.js";
import { ref } from "vue";
import { storeToRefs } from "pinia";
import useAccountStore from "@/store/account.js";
const env = __VITE_ENV__;
const corpId = env.MP_CORP_ID;
const { account } = storeToRefs(useAccountStore());
const loading = ref(true);
const error = ref("");
const articleData = ref({
@ -40,6 +43,16 @@ const articleData = ref({
let articleId = "";
const markArticleRead = async () => {
const unionid = account.value?.unionid;
if (!unionid || !articleId) return;
try {
await api("addArticleReadRecord", { corpId, articleId, unionid }, false);
} catch (err) {
console.warn("markArticleRead failed:", err?.message || err);
}
};
// 使
const processRichTextContent = (html) => {
if (!html) return "";
@ -107,6 +120,7 @@ const loadArticle = async () => {
onLoad((options) => {
if (options.id) {
articleId = options.id;
markArticleRead();
loadArticle();
} else {
error.value = "文章信息不完整";

View File

@ -11,16 +11,25 @@
? 'bg-orange-100 text-orange-500 border-orange-500'
: 'bg-white text-gray-600 border-gray-200'
]"
@click="activeTab = tab.value"
@click="selectTab(tab.value)"
>
{{ tab.name }}
</view>
</scroll-view>
<!-- Article List -->
<view class="p-15">
<view v-if="loading && articles.length === 0" class="loading-container">
<uni-icons type="spinner-cycle" size="30" color="#999" />
<text class="loading-text">加载中...</text>
</view>
<view v-else-if="!loading && articles.length === 0" class="empty-container">
<empty-data text="暂无文章" />
</view>
<view v-else class="p-15">
<view
v-for="item in filteredArticles"
v-for="item in articles"
:key="item._id"
class="bg-white rounded-lg p-15 mb-15 shadow-sm"
@click="goToDetail(item)"
@ -30,7 +39,7 @@
<view class="flex items-start flex-1 mr-10 relative">
<!-- Tag -->
<view class="text-xs text-green-600 border border-green-600 px-5 rounded mr-5 flex-shrink-0 mt-1 tag-box">
{{ item.type }}
宣教文章
</view>
<!-- Title -->
<view class="text-base font-bold text-gray-800 leading-normal line-clamp-2">
@ -44,86 +53,168 @@
class="text-sm mr-2"
:class="item.status === 'UNREAD' ? 'text-red-500' : 'text-gray-400'"
>
{{ item.status === 'UNREAD' ? '未阅读' : '查看' }}
{{ item.status === 'UNREAD' ? '未阅读' : '已阅读' }}
</text>
<uni-icons type="right" size="14" :color="item.status === 'UNREAD' ? '#ef4444' : '#9ca3af'"></uni-icons>
</view>
</view>
<!-- Content -->
<!-- Person -->
<view class="text-sm text-gray-600 mb-5 flex items-center">
<text class="text-gray-400 mr-2">人员:</text>
<text>{{ item.person }}</text>
<view class="text-sm text-gray-600 mb-5 flex items-start">
<text class="text-gray-400 mr-2 field-label">人员:</text>
<text>{{ item.person || '-' }}</text>
</view>
<!-- Team -->
<view class="text-sm text-gray-600 mb-10 pb-10 border-b border-gray-100 flex items-center">
<text class="text-gray-400 mr-2">团队:</text>
<text>{{ item.team }}</text>
<view class="text-sm text-gray-600 mb-10 pb-10 border-b border-gray-100 flex items-start">
<text class="text-gray-400 mr-2 field-label">团队:</text>
<text>{{ item.team || '-' }}</text>
</view>
<!-- Footer -->
<view class="text-sm text-gray-400">
发送时间: {{ item.time }}
发送时间: {{ item.time || '-' }}
</view>
</view>
<view v-if="loading && articles.length > 0" class="loading-more">
<uni-icons type="spinner-cycle" size="20" color="#999" />
<text>加载中...</text>
</view>
<view v-if="!loading && articles.length >= total" class="no-more">
没有更多了
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { ref } from "vue";
import { onShow, onReachBottom } from "@dcloudio/uni-app";
import { storeToRefs } from "pinia";
import dayjs from "dayjs";
import api from "@/utils/api.js";
import useAccountStore from "@/store/account.js";
import EmptyData from "@/components/empty-data.vue";
// Mock Data
const tabs = [
{ name: '全部', value: 'ALL' },
{ name: '李珊珊 女 37岁', value: '1' },
{ name: '罗小小 女 17岁', value: '2' },
];
const env = __VITE_ENV__;
const corpId = env.MP_CORP_ID;
const { account, openid } = storeToRefs(useAccountStore());
const activeTab = ref('ALL');
const tabs = ref([{ name: "全部", value: "" }]);
const activeTab = ref("");
const articles = ref([
{
_id: 1,
type: '宣教文章',
title: '妊糖管理期注意事项!',
status: 'UNREAD',
person: '李珊珊 女 36岁',
team: '妊糖管理服务团队',
time: '2026-01-09 15:23',
ownerId: '1'
},
{
_id: 2,
type: '宣教文章',
title: '妊糖管理期注意事项!妊糖管理期注意事项!妊糖管理期注意事项......',
status: 'READ',
person: '李珊珊 女 36岁',
team: '妊糖管理服务团队',
time: '2026-01-09 15:23',
ownerId: '1'
},
{
_id: 3,
type: '宣教文章',
title: '妊糖管理期注意事项!',
status: 'READ',
person: '罗小小 女 16岁',
team: '妊糖管理服务团队',
time: '2026-01-09 15:23',
ownerId: '2'
const articles = ref([]);
const total = ref(0);
const page = ref(1);
const pageSize = 20;
const loading = ref(false);
const inited = ref(false);
const selectTab = async (customerId) => {
if (activeTab.value === customerId) return;
activeTab.value = customerId;
await loadArticleList(true);
};
const loadCustomers = async () => {
const miniAppId = openid.value || uni.getStorageSync("openid");
if (!miniAppId) return;
try {
const res = await api("getMiniAppCustomers", { miniAppId, corpId });
if (res && res.success) {
const list = Array.isArray(res.data) ? res.data : [];
tabs.value = [
{ name: "全部", value: "" },
...list.map((c) => ({ name: c.name || "未命名", value: c._id })),
];
} else {
uni.showToast({ title: res?.message || "获取档案失败", icon: "none" });
}
} catch (err) {
console.error("loadCustomers failed:", err);
uni.showToast({ title: "获取档案失败", icon: "none" });
}
]);
};
const filteredArticles = computed(() => {
if (activeTab.value === 'ALL') return articles.value;
return articles.value.filter(item => item.ownerId === activeTab.value);
});
const mapRowToView = (row) => {
const sendTime = row?.sendTime ? dayjs(row.sendTime).format("YYYY-MM-DD HH:mm") : "";
return {
_id: row?._id,
articleId: row?.articleId,
title: row?.articleInfo?.title || "宣教文章",
status: row?.status || "UNREAD",
person: row?.customer?.name || "",
team: row?.team?.name || "-",
time: sendTime,
};
};
const loadArticleList = async (reset = false) => {
if (loading.value) return;
const unionid = account.value?.unionid;
const miniAppId = openid.value || uni.getStorageSync("openid");
if (!unionid && !miniAppId) {
uni.showToast({ title: "未获取到用户信息,请重新登录", icon: "none" });
return;
}
if (reset) {
page.value = 1;
articles.value = [];
total.value = 0;
}
loading.value = true;
try {
const params = {
corpId,
unionid,
miniAppId,
page: page.value,
pageSize,
};
if (activeTab.value) params.customerId = activeTab.value;
const res = await api("getMiniAppReceivedArticleList", params);
if (res && res.success) {
const list = Array.isArray(res.list) ? res.list : [];
total.value = Number(res.total) || 0;
const mapped = list.map(mapRowToView);
if (page.value === 1) articles.value = mapped;
else articles.value = [...articles.value, ...mapped];
} else {
uni.showToast({ title: res?.message || "获取文章失败", icon: "none" });
}
} catch (err) {
console.error("loadArticleList failed:", err);
uni.showToast({ title: "加载失败,请重试", icon: "none" });
} finally {
loading.value = false;
}
};
function goToDetail(item) {
console.log('Navigate to detail', item);
if (!item?.articleId) return;
uni.navigateTo({ url: `/pages/article/article-detail?id=${item.articleId}` });
}
onShow(async () => {
if (!inited.value) {
await loadCustomers();
await loadArticleList(true);
inited.value = true;
return;
}
await loadArticleList(true);
});
onReachBottom(() => {
if (loading.value) return;
if (articles.value.length >= total.value) return;
page.value += 1;
loadArticleList(false);
});
</script>
<style scoped>
@ -206,4 +297,35 @@ function goToDetail(item) {
line-clamp: 2;
word-break: break-all;
}
.field-label {
flex-shrink: 0;
white-space: nowrap;
}
.loading-container,
.empty-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
}
.loading-text {
margin-top: 20rpx;
font-size: 28rpx;
color: #999;
}
.loading-more,
.no-more {
display: flex;
align-items: center;
justify-content: center;
padding: 30rpx 0;
font-size: 24rpx;
color: #999;
gap: 10rpx;
}
</style>

View File

@ -68,6 +68,8 @@ watch(articleIds, n => {
margin: 0 30rpx;
margin-top: 24rpx;
padding-bottom: 40rpx;
width: calc(100% - 60rpx);
box-sizing: border-box;
}
.arrow-icon {
@ -91,6 +93,8 @@ watch(articleIds, n => {
min-height: 188rpx;
padding: 20rpx;
align-items: flex-start;
width: 100%;
box-sizing: border-box;
}
.article-card:active {

View File

@ -24,20 +24,10 @@
{{ i.relationship }}
</view>
<view class="flex flex-col items-center">
<view class="customer-name text-lg leading-normal font-semibold whitespace-nowrap mb-8"
<view class="customer-name text-lg leading-normal font-semibold whitespace-nowrap "
:class="current && i._id === current._id ? 'text-primary' : 'text-dark'">
{{ i.name }}
</view>
<view class="flex items-center mb-5">
<image
v-if="i.sex"
class="sex-icon mr-5"
:src="i.sex === '男' ? '/static/home/male.svg' : '/static/home/female.svg'"
/>
<view class="customer-age text-base leading-normal text-gray">
{{ i.age > 0 ? i.age + '岁' : '' }}
</view>
</view>
</view>
<!-- 选中状态底部条和三角 -->
<view v-if="current && i._id === current._id" class="active-indicator">
@ -203,7 +193,7 @@ watch(() => props.corpId, n => {
.customer-card {
width: 160rpx;
height: 160rpx;
height: 110rpx;
display: flex;
align-items: center;
justify-content: center;
@ -219,9 +209,6 @@ watch(() => props.corpId, n => {
border: 2rpx solid #065BD6;
}
.customer-name {
margin-top: 12rpx;
}
.relationship-tag {
position: absolute;
@ -307,10 +294,6 @@ watch(() => props.corpId, n => {
margin-bottom: 12rpx;
}
.sex-icon {
width: 32rpx;
height: 32rpx;
}
.info-card-new {
position: relative;

View File

@ -259,7 +259,7 @@ onMounted(() => {
.mask {
position: fixed;
z-index: 2;
z-index: 99;
left: 0;
top: 0;
right: 0;
@ -268,7 +268,7 @@ onMounted(() => {
}
.z-3 {
z-index: 3;
z-index: 101;
}
.team-dropdown {
@ -276,7 +276,7 @@ onMounted(() => {
left: 0;
right: 0;
top: 0;
z-index: 3;
z-index: 100;
border-bottom-left-radius: 16rpx;
border-bottom-right-radius: 16rpx;
}

View File

@ -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 || "";

View File

@ -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;
}, {});

View File

@ -11,16 +11,25 @@
? 'bg-orange-100 text-orange-500 border-orange-500'
: 'bg-white text-gray-600 border-gray-200'
]"
@click="activeTab = tab.value"
@click="selectTab(tab.value)"
>
{{ tab.name }}
</view>
</scroll-view>
<!-- Survey List -->
<view class="p-15">
<view v-if="loading && surveys.length === 0" class="loading-container">
<uni-icons type="spinner-cycle" size="30" color="#999" />
<text class="loading-text">加载中...</text>
</view>
<view v-else-if="!loading && surveys.length === 0" class="empty-container">
<empty-data text="暂无问卷" />
</view>
<view v-else class="p-15">
<view
v-for="item in filteredSurveys"
v-for="item in surveys"
:key="item._id"
class="bg-white rounded-lg p-15 mb-15 shadow-sm"
@click="goToDetail(item)"
@ -30,7 +39,7 @@
<view class="flex items-start flex-1 mr-10 relative">
<!-- Tag -->
<view class="text-xs text-green-600 border border-green-600 px-5 rounded mr-5 flex-shrink-0 mt-1 tag-box">
{{ item.type }}
问卷调查
</view>
<!-- Title -->
<view class="text-base font-bold text-gray-800 leading-normal line-clamp-2">
@ -38,93 +47,166 @@
</view>
</view>
<!-- Status -->
<!-- Status (暂不展示未填写/已填写) -->
<view class="flex items-center flex-shrink-0 ml-2">
<text
class="text-sm mr-2"
:class="item.status === 'UNFILLED' ? 'text-red-500' : 'text-gray-400'"
>
{{ item.status === 'UNFILLED' ? '未填写' : '查看' }}
</text>
<uni-icons type="right" size="14" :color="item.status === 'UNFILLED' ? '#ef4444' : '#9ca3af'"></uni-icons>
<text class="text-sm mr-2 text-gray-400">查看</text>
<uni-icons type="right" size="14" color="#9ca3af"></uni-icons>
</view>
</view>
<!-- Content -->
<!-- Person -->
<view class="text-sm text-gray-600 mb-5 flex items-center">
<text class="text-gray-400 mr-2">人员:</text>
<text>{{ item.person }}</text>
<view class="text-sm text-gray-600 mb-5 flex items-start">
<text class="text-gray-400 mr-2 field-label">人员:</text>
<text>{{ item.person || '-' }}</text>
</view>
<!-- Team -->
<view class="text-sm text-gray-600 mb-10 pb-10 border-b border-gray-100 flex items-center">
<text class="text-gray-400 mr-2">团队:</text>
<text>{{ item.team }}</text>
<view class="text-sm text-gray-600 mb-10 pb-10 border-b border-gray-100 flex items-start">
<text class="text-gray-400 mr-2 field-label">团队:</text>
<text>{{ item.team || '-' }}</text>
</view>
<!-- Footer -->
<view class="text-sm text-gray-400">
发送时间: {{ item.time }}
发送时间: {{ item.time || '-' }}
</view>
</view>
<view v-if="loading && surveys.length > 0" class="loading-more">
<uni-icons type="spinner-cycle" size="20" color="#999" />
<text>加载中...</text>
</view>
<view v-if="!loading && surveys.length >= total" class="no-more">
没有更多了
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { ref } from "vue";
import { onShow, onReachBottom } from "@dcloudio/uni-app";
import { storeToRefs } from "pinia";
import dayjs from "dayjs";
import api from "@/utils/api.js";
import useAccountStore from "@/store/account.js";
import EmptyData from "@/components/empty-data.vue";
// Mock Data
const tabs = [
{ name: '全部', value: 'ALL' },
{ name: '李珊珊 女 37岁', value: '1' },
{ name: '罗小小 女 17岁', value: '2' },
];
const env = __VITE_ENV__;
const corpId = env.MP_CORP_ID;
const { openid } = storeToRefs(useAccountStore());
const activeTab = ref('ALL');
const tabs = ref([{ name: "全部", value: "" }]);
const activeTab = ref("");
const surveys = ref([
{
_id: 1,
type: '问卷调查',
title: '门诊满意度调查问卷',
status: 'UNFILLED',
person: '李珊珊 女 36岁',
team: '妊糖管理服务团队',
time: '2026-01-09 15:23',
ownerId: '1'
},
{
_id: 2,
type: '问卷调查',
title: 'xxxx术后1周随访调查问卷',
status: 'FILLED',
person: '李珊珊 女 36岁',
team: '妊糖管理服务团队',
time: '2026-01-09 15:23',
ownerId: '1'
},
{
_id: 3,
type: '问卷调查',
title: 'xxxxx术后2周随访调查问卷',
status: 'FILLED',
person: '罗小小 女 16岁',
team: '妊糖管理服务团队',
time: '2026-01-09 15:23',
ownerId: '2'
const surveys = ref([]);
const total = ref(0);
const page = ref(1);
const pageSize = 20;
const loading = ref(false);
const inited = ref(false);
const selectTab = async (memberId) => {
if (activeTab.value === memberId) return;
activeTab.value = memberId;
await loadSurveyList(true);
};
const loadCustomers = async () => {
const miniAppId = openid.value || uni.getStorageSync("openid");
if (!miniAppId) return;
try {
const res = await api("getMiniAppCustomers", { miniAppId, corpId });
if (res && res.success) {
const list = Array.isArray(res.data) ? res.data : [];
tabs.value = [
{ name: "全部", value: "" },
...list.map((c) => ({ name: c.name || "未命名", value: c._id })),
];
} else {
uni.showToast({ title: res?.message || "获取档案失败", icon: "none" });
}
} catch (err) {
console.error("loadCustomers failed:", err);
uni.showToast({ title: "获取档案失败", icon: "none" });
}
]);
};
const filteredSurveys = computed(() => {
if (activeTab.value === 'ALL') return surveys.value;
return surveys.value.filter(item => item.ownerId === activeTab.value);
const mapRowToView = (row) => {
const sendTime = row?.createTime ? dayjs(row.createTime).format("YYYY-MM-DD HH:mm") : "";
return {
_id: row?._id,
surveryId: row?.surveryId,
title: row?.name || "问卷调查",
person: row?.customer?.name || "",
team: row?.team?.name || "-",
time: sendTime,
status: row?.status || "",
};
};
const loadSurveyList = async (reset = false) => {
if (loading.value) return;
const miniAppId = openid.value || uni.getStorageSync("openid");
if (!miniAppId) {
uni.showToast({ title: "未获取到用户信息,请重新登录", icon: "none" });
return;
}
if (reset) {
page.value = 1;
surveys.value = [];
total.value = 0;
}
loading.value = true;
try {
const params = {
corpId,
miniAppId,
page: page.value,
pageSize,
};
if (activeTab.value) params.memberId = activeTab.value;
const res = await api("getMiniAppReceivedSurveryList", params);
if (res && res.success) {
const list = Array.isArray(res.list) ? res.list : [];
total.value = Number(res.total) || 0;
const mapped = list.map(mapRowToView);
if (page.value === 1) surveys.value = mapped;
else surveys.value = [...surveys.value, ...mapped];
} else {
uni.showToast({ title: res?.message || "获取问卷失败", icon: "none" });
}
} catch (err) {
console.error("loadSurveyList failed:", err);
uni.showToast({ title: "加载失败,请重试", icon: "none" });
} finally {
loading.value = false;
}
};
function goToDetail() {
uni.showToast({ title: "详情暂未接入", icon: "none" });
}
onShow(async () => {
if (!inited.value) {
await loadCustomers();
await loadSurveyList(true);
inited.value = true;
return;
}
await loadSurveyList(true);
});
function goToDetail(item) {
console.log('Navigate to detail', item);
// Add actual navigation logic here later
}
onReachBottom(() => {
if (loading.value) return;
if (surveys.value.length >= total.value) return;
page.value += 1;
loadSurveyList(false);
});
</script>
<style scoped>
@ -207,4 +289,35 @@ function goToDetail(item) {
line-clamp: 2;
word-break: break-all;
}
</style>
.field-label {
flex-shrink: 0;
white-space: nowrap;
}
.loading-container,
.empty-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 0;
}
.loading-text {
margin-top: 20rpx;
font-size: 28rpx;
color: #999;
}
.loading-more,
.no-more {
display: flex;
align-items: center;
justify-content: center;
padding: 30rpx 0;
font-size: 24rpx;
color: #999;
gap: 10rpx;
}
</style>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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>

View File

@ -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 }

View 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('无法获取 openidIM 初始化失败');
return false;
}
console.log('开始初始化 IMuserID:', 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 }
})

View File

@ -31,7 +31,9 @@ const urlsConfig = {
getArticleCateList: 'getArticleCateList',
getArticleList: 'getArticleList',
getArticle: 'getArticle',
addArticleSendRecord: 'addArticleSendRecord'
addArticleSendRecord: 'addArticleSendRecord',
addArticleReadRecord: 'addArticleReadRecord',
getMiniAppReceivedArticleList: 'getMiniAppReceivedArticleList'
},
member: {
addCustomer: 'add',
@ -46,6 +48,9 @@ const urlsConfig = {
getMedicalRecordById: 'getMedicalRecordById',
unbindMiniAppArchive: 'unbindMiniAppArchive',
updateMedicalRecord: 'updateMedicalRecord',
getUnionidToExternalUserid: 'getUnionidToExternalUserid',
getWxAppCustomerCount: "getWxAppCustomerCount",
updateCustomer: 'update'
},
wecom: {
addContactWay: 'addContactWay'
@ -60,6 +65,9 @@ const urlsConfig = {
createConsultGroup: "createConsultGroup",
cancelConsultApplication: "cancelConsultApplication",
getGroupList: "getGroupList"
},
survery: {
getMiniAppReceivedSurveryList: 'getMiniAppReceivedSurveryList'
}
}
const urls = Object.keys(urlsConfig).reduce((acc, path) => {