feat: 名片开发
This commit is contained in:
parent
7f47745b0e
commit
0e8fcfdc3b
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<full-page>
|
||||
<full-page v-if="businessCard">
|
||||
<view class="card-page">
|
||||
<view class="card-service-container">
|
||||
<BusinessCard :card="businessCard" />
|
||||
@ -95,7 +95,7 @@
|
||||
<image class="edit-icon" src="/static/card/edit-card.png" mode="aspectFit"></image>
|
||||
<text class="edit-text">加好友</text>
|
||||
</button>
|
||||
<button class="share-btn" @click="goToSave">
|
||||
<button class="share-btn" open-type="share">
|
||||
<text class="share-text">转发名片</text>
|
||||
</button>
|
||||
</view>
|
||||
@ -240,15 +240,22 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onShareAppMessage } from "@dcloudio/uni-app";
|
||||
import api from '@/utils/api';
|
||||
import useGuard from '@/hooks/useGuard';
|
||||
import { toast } from '@/utils/widget.js';
|
||||
import useAccount from '@/store/account';
|
||||
|
||||
import BusinessCard from './components/BusinessCard.vue'
|
||||
import fullPage from '@/components/full-page.vue'
|
||||
import TeamsPopup from './components/teams-popup.vue'
|
||||
|
||||
const { useShow, useLoad } = useGuard();
|
||||
const wxAccountStore = useAccount();
|
||||
const { account } = storeToRefs(useAccount());
|
||||
const env = __VITE_ENV__;
|
||||
const shareAppVersion = env.MP_SHARE_WX_APP_VERSION;
|
||||
|
||||
const corpId = ref('');
|
||||
const userid = ref('')
|
||||
@ -279,6 +286,9 @@ function setClipboardData(data) {
|
||||
async function getCard() {
|
||||
const res = await api('getBusinessCard', { userid: userid.value, corpId: corpId.value })
|
||||
businessCard.value = res && res.data ? res.data : null;
|
||||
if (businessCard.value) {
|
||||
recordBusinessCardVisit()
|
||||
}
|
||||
}
|
||||
|
||||
async function displayPhone() {
|
||||
@ -297,6 +307,41 @@ async function showTeams() {
|
||||
}
|
||||
}
|
||||
|
||||
async function recordBusinessCardVisit() {
|
||||
try {
|
||||
const account = await getVisitorAccount();
|
||||
let visitorExternalUserId = wxAccountStore.externalUserId || "";
|
||||
if (!visitorExternalUserId && account && account.unionid && account.openid && corpId.value) {
|
||||
visitorExternalUserId = await wxAccountStore.getExternalUserId(corpId.value) || "";
|
||||
}
|
||||
|
||||
const response = await api('recordBusinessCardBehavior', {
|
||||
action: "visit",
|
||||
corpId: corpId.value,
|
||||
cardUserid: userid.value,
|
||||
cardDeptName: businessCard.value?.deptName || "",
|
||||
source: "team-wxapp",
|
||||
visitorOpenid: account?.openid || wxAccountStore.openid || uni.getStorageSync('openid') || "",
|
||||
visitorUnionid: account?.unionid || "",
|
||||
visitorMobile: account?.mobile || "",
|
||||
visitorExternalUserId,
|
||||
}, false);
|
||||
if (!response?.success) {
|
||||
console.warn("record business card visit failed", response?.message || response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("record business card visit failed", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function getVisitorAccount() {
|
||||
let account = wxAccountStore.account || uni.getStorageSync('account') || null;
|
||||
if (!account) {
|
||||
account = await wxAccountStore.login('', { silent: true });
|
||||
}
|
||||
return account || wxAccountStore.account || uni.getStorageSync('account') || null;
|
||||
}
|
||||
|
||||
useLoad((opt) => {
|
||||
corpId.value = opt.corpId
|
||||
userid.value = opt.userid
|
||||
@ -305,9 +350,20 @@ useLoad((opt) => {
|
||||
useShow(() => {
|
||||
getCard()
|
||||
})
|
||||
|
||||
onShareAppMessage((res) => {
|
||||
if (businessCard.value) {
|
||||
return {
|
||||
title: `【${businessCard.value.externalName || card.anotherName || ''}】电子名片`,
|
||||
type: shareAppVersion || 0, // 0 正式版本 | 1 开发版本 | 2 体验版本
|
||||
path: `/pages/team/business-card?corpId=${corpId.value}&userid=${userid.value}&shareOpenId=${account.value?.openid || ''}`
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const cardStore = ref({})
|
||||
const accountStore = ref({})
|
||||
useLoad()
|
||||
|
||||
// 获取账户信息
|
||||
const accountInfo = computed(() => accountStore.getAccountInfo || {})
|
||||
const institutionInfo = computed(() => accountStore.getInstitutionInfo || {})
|
||||
|
||||
@ -24,7 +24,7 @@ export default defineStore("accountStore", () => {
|
||||
});
|
||||
const teamsPromise = ref(null);
|
||||
|
||||
async function login(phoneCode = '') {
|
||||
async function login(phoneCode = '', options = {}) {
|
||||
if (loading.value) return;
|
||||
if (account.value && account.value.mobile) {
|
||||
return account.value
|
||||
@ -56,9 +56,9 @@ export default defineStore("accountStore", () => {
|
||||
return normalizedAccount
|
||||
}
|
||||
}
|
||||
toast('登录失败,请重新登录');
|
||||
if (!options.silent) toast('登录失败,请重新登录');
|
||||
} catch (e) {
|
||||
toast('登录失败,请重新登录');
|
||||
if (!options.silent) toast('登录失败,请重新登录');
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ const urlsConfig = {
|
||||
getResponsiblePerson: 'getTeamResponsiblePerson',
|
||||
relateWxappTeamByExternalUserId: 'relateWxappTeamByExternalUserId',
|
||||
getBusinessCard: 'getBusinessCard',
|
||||
recordBusinessCardBehavior: 'recordBusinessCardBehavior',
|
||||
getJoinedTeams: 'getJoinedTeams',
|
||||
},
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user