Compare commits

...
3 Commits
5 changed files with 190 additions and 15 deletions

No files matched your search

+5 -1
View File
@@ -35,10 +35,14 @@ export function loginUAC(data) {
/** 统一认证:选择/切换企业(一人多企业) */
export function switchTenant(data) {
let clientId = 'yz-uniapp'
// #ifdef MP-WEIXIN
clientId = 'yz-miniapp'
// #endif
return request({
url: '/auth/switch-tenant',
method: 'POST',
data: Object.assign({ client_id: 'yz-uniapp' }, data)
data: Object.assign({ client_id: clientId }, data)
})
}
+10
View File
@@ -0,0 +1,10 @@
import { request } from '@/api/request.js'
/** 读取平台端维护的法律单页内容。路径不包含前导斜杠。 */
export function fetchLegalDocument(path) {
return request({
url: `/platform/website/page/path/${encodeURIComponent(path)}`,
method: 'GET',
silent: true
})
}
+102
View File
@@ -0,0 +1,102 @@
<template>
<view class="page">
<view v-if="loading" class="state"><text>正在加载内容…</text></view>
<view v-else-if="error" class="state error" @tap="load"><text>{{ error }},点此重试</text></view>
<view v-else-if="!document" class="state"><text>暂未发布此内容,请联系管理员</text></view>
<scroll-view v-else class="content-scroll" scroll-y>
<view class="article">
<text class="title">{{ document.title || pageTitle }}</text>
<rich-text class="rich-content" :nodes="document.content || ''" />
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { fetchLegalDocument } from '@/api/legal.js'
const pageTitle = ref('法律条款')
const path = ref('')
const loading = ref(true)
const error = ref('')
const document = ref(null)
onLoad((options = {}) => {
path.value = String(options.path || '')
pageTitle.value = String(options.title || '法律条款')
uni.setNavigationBarTitle({ title: pageTitle.value })
load()
})
async function load() {
if (!path.value) {
loading.value = false
error.value = '内容地址无效'
return
}
loading.value = true
error.value = ''
try {
const result = await fetchLegalDocument(path.value)
const data = result && (result.data || result)
document.value = data && data.id ? data : null
} catch (err) {
error.value = (err && err.message) || '内容加载失败'
} finally {
loading.value = false
}
}
</script>
<style lang="scss" scoped>
@import '@/src/styles/page-common.scss';
.page {
min-height: 100vh;
background: #f4f8fc;
}
.content-scroll {
height: 100vh;
box-sizing: border-box;
padding: 24rpx;
}
.article {
padding: 36rpx 30rpx 52rpx;
border-radius: 24rpx;
background: #fff;
box-shadow: 0 8rpx 32rpx rgba(47, 91, 130, 0.06);
}
.title {
display: block;
margin-bottom: 28rpx;
font-size: 36rpx;
font-weight: 700;
line-height: 1.5;
color: #203c57;
}
.rich-content {
font-size: 28rpx;
line-height: 1.9;
color: #43586c;
word-break: break-word;
}
.state {
min-height: 70vh;
padding: 48rpx;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-size: 26rpx;
color: #8094a8;
}
.error { color: #d94841; }
</style>
+34 -14
View File
@@ -191,6 +191,7 @@
<FaIcon name="shield-halved" color="#94a3b8" :size="12" />
<text class="foot-tip-text">全程加密传输 · 账号安全可控</text>
</view>
</view>
</template>
@@ -555,11 +556,8 @@ async function onGetPhoneNumber(e) {
uni.showToast({ title: '你已取消手机号授权', icon: 'none' })
return
}
// 认证中 / 未开通手机号能力:拿不到动态 code 时降级为「按已绑定 openid 登录」
// 手机号授权码可能不可用;仍继续尝试按已绑定的 openid 登录
const phoneCode = detail.code && errMsg.indexOf('fail') === -1 ? detail.code : ''
if (!phoneCode) {
uni.showToast({ title: '手机号能力暂不可用,按已绑定账号登录', icon: 'none' })
}
if (!agreed.value) {
const ok = await confirmAgreement()
if (!ok) {
@@ -586,12 +584,11 @@ function handleMiniError(err) {
const reason = err && err.response && err.response.reason
if (reason === 'identity_not_found') {
uni.showModal({
title: '尚未绑定云泽账号',
content: '当前微信未绑定云泽账号,且手机号能力暂不可用。请先用账号密码登录一次(会自动完成微信绑定),之后即可一键登录。',
title: '暂无使用权限',
content: '您没有该程序使用权,请联系企业管理员。也可以使用已有账号登录。',
showCancel: true,
cancelText: '知道了',
// 微信小程序 showModal 的 confirmText 上限为 4 个汉字,超限会导致 API 失败、弹窗不显示
confirmText: '去登录',
confirmText: '账号登录',
confirmColor: '#2563eb',
success: (res) => {
if (res.confirm) goAccount()
@@ -640,9 +637,8 @@ function toggleAgree() {
if (agreed.value) showAgreementTip.value = false
}
/** 协议占位:正式接入条款页后改为跳转条款页 */
function showAgreement() {
uni.showToast({ title: '条款内容待接入', icon: 'none' })
function openLegal(path, title) {
uni.navigateTo({ url: `/pages/legal/document?path=${encodeURIComponent(path)}&title=${encodeURIComponent(title)}` })
}
/**
@@ -848,9 +844,10 @@ function goForget() {
.panel-title {
display: block;
font-size: 40rpx;
font-weight: 600;
color: $color-text;
font-size: 42rpx;
font-weight: 700;
letter-spacing: 1rpx;
color: #183b63;
}
.panel-sub {
@@ -902,6 +899,7 @@ function goForget() {
border: 1rpx solid $color-border;
border-radius: $radius-md;
padding: 0 20rpx;
box-shadow: inset 0 2rpx 8rpx rgba(104, 158, 202, 0.05);
}
.field-input {
@@ -1056,6 +1054,26 @@ function goForget() {
color: $color-text-muted;
}
/* 弱化入口:切换账号密码登录 */
.alt-entry {
display: flex;
align-items: center;
justify-content: center;
gap: 10rpx;
margin-top: 44rpx;
}
.alt-line {
width: 80rpx;
height: 1rpx;
background: $color-border;
}
.alt-text {
font-size: 26rpx;
color: $color-text-muted;
}
.back-row {
display: flex;
align-items: center;
@@ -1130,6 +1148,8 @@ function goForget() {
/* ---------- 协议 ---------- */
.agreement {
position: relative;
z-index: 1;
display: flex;
align-items: flex-start;
gap: 12rpx;
+39
View File
@@ -135,6 +135,8 @@ async function load(force = false) {
try {
const data = await fetchHome(force)
user.value = data.user || {}
tenants.value = getTenants()
currentTid.value = getTid()
modules.value = Array.isArray(data.modules) ? data.modules : []
menus.value = Array.isArray(data.menus) ? data.menus : []
loadError.value = ''
@@ -204,6 +206,43 @@ function enter(card) {
uni.showToast({ title: card.name + '暂未开放', icon: 'none' })
}
function openTenantPicker() {
if (tenants.value.length < 2) return
tenantPickerVisible.value = true
}
function closeTenantPicker() {
if (!switchingTenant.value) tenantPickerVisible.value = false
}
async function changeTenant(item) {
const tid = Number(item && item.tid)
if (!tid || tid === currentTid.value || switchingTenant.value) {
tenantPickerVisible.value = false
return
}
switchingTenant.value = true
uni.showLoading({ title: '正在切换...', mask: true })
try {
const result = await switchTenant({ tid })
if (!result || !result.tokens) throw new Error((result && result.msg) || '切换公司失败')
setAuthTokens(result.tokens)
setTid(tid)
const tenantName = item.tenant_name || `企业${tid}`
setTenantName(tenantName)
user.value = Object.assign({}, user.value, { tenant: tenantName, tid })
currentTid.value = tid
tenantPickerVisible.value = false
await load(true)
uni.showToast({ title: '已切换公司', icon: 'success' })
} catch (err) {
uni.showToast({ title: (err && err.message) || '切换公司失败', icon: 'none' })
} finally {
uni.hideLoading()
switchingTenant.value = false
}
}
/* ==================== 生命周期 ==================== */
onMounted(() => {