diff --git a/components/full-page.vue b/components/full-page.vue index 59465cb..a4d4135 100644 --- a/components/full-page.vue +++ b/components/full-page.vue @@ -1,9 +1,9 @@ + diff --git a/pages/archive/edit-archive.vue b/pages/archive/edit-archive.vue index 7d1bbf5..159734c 100644 --- a/pages/archive/edit-archive.vue +++ b/pages/archive/edit-archive.vue @@ -11,7 +11,7 @@ ({ ...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 ? '编辑档案' : '新增档案' }) diff --git a/pages/login/login.vue b/pages/login/login.vue index b99e2ad..00897cf 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -17,8 +17,8 @@ 手机号快捷登录 + 手机号快捷登录 + --> @@ -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 || ""; diff --git a/pages/login/redirect-page.vue b/pages/login/redirect-page.vue index 98d2a73..8e74c0d 100644 --- a/pages/login/redirect-page.vue +++ b/pages/login/redirect-page.vue @@ -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; }, {}); diff --git a/pages/team/friend.vue b/pages/team/friend.vue index 56ba737..085a936 100644 --- a/pages/team/friend.vue +++ b/pages/team/friend.vue @@ -14,13 +14,18 @@ + + 点击识别下方二维码,加我为好友 +