feat:财务和合同
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
VITE_API_BASE_URL=http://192.168.0.206:8080
|
# 主站与账号/邮箱统一走 175
|
||||||
|
VITE_API_BASE_URL=http://192.168.0.175:8080
|
||||||
|
VITE_REQUIREMENT_DRAFT_API_BASE_URL=http://192.168.0.175:8080
|
||||||
|
VITE_ACCOUNT_API_BASE_URL=http://192.168.0.175:8080
|
||||||
# APP 端 OAuth 客户端 ID(与 Web 端区分)
|
# APP 端 OAuth 客户端 ID(与 Web 端区分)
|
||||||
VITE_AUTH_CLIENT_ID=428a8310cd442757ae699df5d894f051
|
VITE_AUTH_CLIENT_ID=428a8310cd442757ae699df5d894f051
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
100
src/api/account.ts
Normal file
100
src/api/account.ts
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
import type {
|
||||||
|
AppAccountSecurityPageVo,
|
||||||
|
AppAccountSecurityVo,
|
||||||
|
AppBindEmailBo,
|
||||||
|
AppChangePhoneBo,
|
||||||
|
AppProfileVo,
|
||||||
|
AppSendEmailCodeBo,
|
||||||
|
AppUpdatePasswordBo,
|
||||||
|
AppUpdateProfileBo,
|
||||||
|
} from '@/types/account-api'
|
||||||
|
import { ACCOUNT_API_BASE_URL, API_BASE_URL } from '@/constants/config'
|
||||||
|
import { del, get, post, put } from '@/utils/request'
|
||||||
|
|
||||||
|
const ACCOUNT_API = {
|
||||||
|
security: '/app/account/security',
|
||||||
|
info: '/app/account/security/info',
|
||||||
|
profile: '/app/account/security/profile',
|
||||||
|
password: '/app/account/security/password',
|
||||||
|
phone: '/app/account/security/phone',
|
||||||
|
email: '/app/account/security/email',
|
||||||
|
emailCode: '/app/account/security/email/code',
|
||||||
|
securityPage: (code: string) => `/app/account/security/page/${encodeURIComponent(code)}`,
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeApiBase(url: string) {
|
||||||
|
return url.replace(/\/$/, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
function accountRequestOptions(options?: {
|
||||||
|
showErrorToast?: boolean
|
||||||
|
unauthorizedMode?: 'logout' | 'toast'
|
||||||
|
}) {
|
||||||
|
const accountBase = normalizeApiBase(ACCOUNT_API_BASE_URL)
|
||||||
|
const primaryBase = normalizeApiBase(API_BASE_URL)
|
||||||
|
|
||||||
|
if (accountBase === primaryBase)
|
||||||
|
return options
|
||||||
|
|
||||||
|
return {
|
||||||
|
baseURL: ACCOUNT_API_BASE_URL,
|
||||||
|
// 与主站不同机时,避免副机 401 清掉主站登录态
|
||||||
|
unauthorizedMode: options?.unauthorizedMode ?? 'toast',
|
||||||
|
showErrorToast: options?.showErrorToast ?? true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取账号与安全信息:GET /app/account/security */
|
||||||
|
export function getAccountSecurity(options?: { showErrorToast?: boolean }) {
|
||||||
|
return get<AppAccountSecurityVo>(ACCOUNT_API.security, undefined, accountRequestOptions(options))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取个人资料:GET /app/account/security/info */
|
||||||
|
export function getAccountProfile(options?: { showErrorToast?: boolean }) {
|
||||||
|
return get<AppProfileVo>(ACCOUNT_API.info, undefined, accountRequestOptions(options))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改昵称与头像:PUT /app/account/security/profile */
|
||||||
|
export function updateAccountProfile(data: AppUpdateProfileBo) {
|
||||||
|
return put<void>(ACCOUNT_API.profile, data, accountRequestOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改登录密码:PUT /app/account/security/password */
|
||||||
|
export function changeLoginPassword(
|
||||||
|
data: AppUpdatePasswordBo,
|
||||||
|
options?: { showErrorToast?: boolean },
|
||||||
|
) {
|
||||||
|
return put<void>(ACCOUNT_API.password, data, accountRequestOptions(options))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 换绑手机号:PUT /app/account/security/phone */
|
||||||
|
export function changeAccountPhone(data: AppChangePhoneBo) {
|
||||||
|
return put<void>(ACCOUNT_API.phone, data, accountRequestOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发送绑定/换绑邮箱验证码:POST /app/account/security/email/code */
|
||||||
|
export function sendAccountEmailCode(data: AppSendEmailCodeBo) {
|
||||||
|
return post<void>(ACCOUNT_API.emailCode, data, accountRequestOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 绑定或换绑邮箱:PUT /app/account/security/email */
|
||||||
|
export function bindAccountEmail(data: AppBindEmailBo) {
|
||||||
|
return put<void>(ACCOUNT_API.email, data, accountRequestOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解绑邮箱:DELETE /app/account/security/email */
|
||||||
|
export function unbindAccountEmail() {
|
||||||
|
return del<void>(ACCOUNT_API.email, undefined, accountRequestOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 协议 / 关于我们等内容:GET /app/account/security/page/{code} */
|
||||||
|
export function getAccountSecurityPage(
|
||||||
|
code: string,
|
||||||
|
options?: { showErrorToast?: boolean },
|
||||||
|
) {
|
||||||
|
return get<AppAccountSecurityPageVo>(
|
||||||
|
ACCOUNT_API.securityPage(code),
|
||||||
|
undefined,
|
||||||
|
accountRequestOptions(options),
|
||||||
|
)
|
||||||
|
}
|
||||||
41
src/api/address.ts
Normal file
41
src/api/address.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import type { UserAddressBo, UserAddressVo } from '@/types/address-api'
|
||||||
|
import { del, get, post, put } from '@/utils/request'
|
||||||
|
|
||||||
|
const ADDRESS_API = {
|
||||||
|
list: '/app/address/list',
|
||||||
|
detail: (id: string | number) => `/app/address/${id}`,
|
||||||
|
create: '/app/address',
|
||||||
|
update: (id: string | number) => `/app/address/${id}`,
|
||||||
|
remove: (id: string | number) => `/app/address/${id}`,
|
||||||
|
setDefault: (id: string | number) => `/app/address/${id}/default`,
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询当前用户地址列表:GET /app/address/list */
|
||||||
|
export function getAddressList() {
|
||||||
|
return get<UserAddressVo[]>(ADDRESS_API.list)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询地址详情:GET /app/address/{id} */
|
||||||
|
export function getAddressDetail(id: string | number) {
|
||||||
|
return get<UserAddressVo>(ADDRESS_API.detail(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增收货地址:POST /app/address */
|
||||||
|
export function createAddress(data: UserAddressBo) {
|
||||||
|
return post<UserAddressVo>(ADDRESS_API.create, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改收货地址:PUT /app/address/{id} */
|
||||||
|
export function updateAddress(id: string | number, data: UserAddressBo) {
|
||||||
|
return put<void>(ADDRESS_API.update(id), data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除收货地址:DELETE /app/address/{id} */
|
||||||
|
export function deleteAddress(id: string | number) {
|
||||||
|
return del<void>(ADDRESS_API.remove(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设为默认地址:PUT /app/address/{id}/default */
|
||||||
|
export function setDefaultAddress(id: string | number) {
|
||||||
|
return put<void>(ADDRESS_API.setDefault(id))
|
||||||
|
}
|
||||||
95
src/api/bill.ts
Normal file
95
src/api/bill.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import { API_BASE_URL } from '@/constants/config'
|
||||||
|
import type {
|
||||||
|
BillExportQuery,
|
||||||
|
BillGenerateBo,
|
||||||
|
BillPageQuery,
|
||||||
|
BillPageResult,
|
||||||
|
FinanceBillQuery,
|
||||||
|
FinanceBillStatisticsVo,
|
||||||
|
FinanceBillVo,
|
||||||
|
} from '@/types/bill-api'
|
||||||
|
import { ensureAuthClientId } from '@/utils/auth-storage'
|
||||||
|
import { get, post } from '@/utils/request'
|
||||||
|
|
||||||
|
const BILL_API = {
|
||||||
|
page: '/app/bill/page',
|
||||||
|
statistics: '/app/bill/statistics',
|
||||||
|
detail: (id: string | number) => `/app/bill/${id}`,
|
||||||
|
export: '/app/bill/export',
|
||||||
|
generate: '/app/bill/generate',
|
||||||
|
}
|
||||||
|
|
||||||
|
function compactBillQuery(params?: FinanceBillQuery): FinanceBillQuery {
|
||||||
|
const next: FinanceBillQuery = {}
|
||||||
|
if (params?.status?.trim())
|
||||||
|
next.status = params.status.trim()
|
||||||
|
if (params?.keyword?.trim())
|
||||||
|
next.keyword = params.keyword.trim()
|
||||||
|
if (params?.bizType?.trim())
|
||||||
|
next.bizType = params.bizType.trim()
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
|
||||||
|
function appendQuery(url: string, query: Record<string, string | number | undefined>) {
|
||||||
|
const parts: string[] = []
|
||||||
|
Object.entries(query).forEach(([key, value]) => {
|
||||||
|
if (value == null || value === '')
|
||||||
|
return
|
||||||
|
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
|
||||||
|
})
|
||||||
|
if (!parts.length)
|
||||||
|
return url
|
||||||
|
return `${url}${url.includes('?') ? '&' : '?'}${parts.join('&')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 账单分页列表:GET /app/bill/page */
|
||||||
|
export function getBillPage(params?: BillPageQuery) {
|
||||||
|
const { pageNum = 1, pageSize = 10, orderByColumn, isAsc, ...filters } = params || {}
|
||||||
|
return get<BillPageResult>(BILL_API.page, {
|
||||||
|
pageNum,
|
||||||
|
pageSize,
|
||||||
|
...(orderByColumn ? { orderByColumn } : {}),
|
||||||
|
...(isAsc ? { isAsc } : {}),
|
||||||
|
...compactBillQuery(filters),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 账单列表顶部统计:GET /app/bill/statistics
|
||||||
|
* 总金额 / 总笔数 / 待支付笔数,筛选条件与列表一致(status / keyword / bizType)
|
||||||
|
*/
|
||||||
|
export function getBillStatistics(params?: FinanceBillQuery) {
|
||||||
|
return get<FinanceBillStatisticsVo>(BILL_API.statistics, compactBillQuery(params))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 账单详情:GET /app/bill/{id} */
|
||||||
|
export function getBillDetail(id: string | number) {
|
||||||
|
return get<FinanceBillVo>(BILL_API.detail(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拼装导出地址:GET /app/bill/export(文件流,format 默认 excel) */
|
||||||
|
export function buildBillExportUrl(params?: BillExportQuery) {
|
||||||
|
const filters = compactBillQuery(params)
|
||||||
|
const clientId = ensureAuthClientId()
|
||||||
|
const base = `${API_BASE_URL.replace(/\/$/, '')}${BILL_API.export}`
|
||||||
|
|
||||||
|
return appendQuery(base, {
|
||||||
|
...filters,
|
||||||
|
format: params?.format === 'pdf' ? 'pdf' : 'excel',
|
||||||
|
...(clientId ? { clientid: clientId } : {}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成账单(手动建账):POST /app/bill/generate
|
||||||
|
* 需 finance 角色;sourceType 固定 MANUAL;传 contractId + periodName 时幂等防重
|
||||||
|
* @returns 新建账单 id
|
||||||
|
*/
|
||||||
|
export function generateBill(data: BillGenerateBo) {
|
||||||
|
return post<number | string>(BILL_API.generate, {
|
||||||
|
...data,
|
||||||
|
sourceType: 'MANUAL',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export { BILL_API, compactBillQuery }
|
||||||
77
src/api/chat.ts
Normal file
77
src/api/chat.ts
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import type {
|
||||||
|
CsCallRecordQuery,
|
||||||
|
CsHotlineConfig,
|
||||||
|
CsMessage,
|
||||||
|
CsSendMessageBo,
|
||||||
|
CsSession,
|
||||||
|
CsSessionInitQuery,
|
||||||
|
CsSessionPreviewVo,
|
||||||
|
} from '@/types/chat-api'
|
||||||
|
import { get, post } from '@/utils/request'
|
||||||
|
|
||||||
|
const CHAT_API = {
|
||||||
|
sessionInit: '/app/chat/session/init',
|
||||||
|
sessionPreview: '/app/chat/session/preview',
|
||||||
|
message: '/app/chat/message',
|
||||||
|
messageList: '/app/chat/message/list',
|
||||||
|
callConfig: '/app/chat/call/config',
|
||||||
|
callRecord: '/app/chat/call/record',
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildQuery(params?: Record<string, string | undefined>) {
|
||||||
|
if (!params)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
const parts: string[] = []
|
||||||
|
Object.entries(params).forEach(([key, value]) => {
|
||||||
|
const text = value?.trim()
|
||||||
|
if (!text)
|
||||||
|
return
|
||||||
|
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(text)}`)
|
||||||
|
})
|
||||||
|
return parts.length ? `?${parts.join('&')}` : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建会话:POST /app/chat/session/init
|
||||||
|
* 客服工作台展示用:昵称/头像/联系电话取自用户资料,contact 可覆盖电话
|
||||||
|
*/
|
||||||
|
export function initChatSession(params?: CsSessionInitQuery) {
|
||||||
|
const query = buildQuery({
|
||||||
|
chatType: params?.chatType,
|
||||||
|
contact: params?.contact,
|
||||||
|
})
|
||||||
|
return post<CsSession>(`${CHAT_API.sessionInit}${query}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 消息中心「在线客服」卡片预览:GET /app/chat/session/preview */
|
||||||
|
export function getChatSessionPreview(options?: { showErrorToast?: boolean }) {
|
||||||
|
return get<CsSessionPreviewVo>(CHAT_API.sessionPreview, undefined, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 客户发送消息:POST /app/chat/message */
|
||||||
|
export function sendChatMessage(data: CsSendMessageBo) {
|
||||||
|
return post<CsMessage>(CHAT_API.message, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拉取会话消息(加载即标记客户已读):GET /app/chat/message/list */
|
||||||
|
export function getChatMessageList(sessionId: string | number) {
|
||||||
|
return get<CsMessage[]>(CHAT_API.messageList, { sessionId })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** APP 客服热线页配置:GET /app/chat/call/config */
|
||||||
|
export function getChatHotlineConfig(options?: { showErrorToast?: boolean }) {
|
||||||
|
return get<CsHotlineConfig>(CHAT_API.callConfig, undefined, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 客户拨打热线上报通话记录:POST /app/chat/call/record */
|
||||||
|
export function saveChatCallRecord(params: CsCallRecordQuery) {
|
||||||
|
const query = buildQuery({
|
||||||
|
dialedNumber: params.dialedNumber,
|
||||||
|
userPhone: params.userPhone,
|
||||||
|
status: params.status,
|
||||||
|
})
|
||||||
|
return post<void>(`${CHAT_API.callRecord}${query}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { CHAT_API }
|
||||||
70
src/api/contract.ts
Normal file
70
src/api/contract.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import type {
|
||||||
|
ContractPageQuery,
|
||||||
|
ContractPageResult,
|
||||||
|
ContractPreviewVo,
|
||||||
|
ContractSignConfirmBo,
|
||||||
|
ContractSignProgressVo,
|
||||||
|
ContractSignSmsBo,
|
||||||
|
ContractSignStartBo,
|
||||||
|
ContractVo,
|
||||||
|
} from '@/types/contract-api'
|
||||||
|
import { get, post } from '@/utils/request'
|
||||||
|
|
||||||
|
const CONTRACT_API = {
|
||||||
|
page: '/app/contract/page',
|
||||||
|
detail: (id: string | number) => `/app/contract/${id}`,
|
||||||
|
byProject: (projectNo: string) => `/app/contract/project/${encodeURIComponent(projectNo)}`,
|
||||||
|
preview: (id: string | number) => `/app/contract/preview/${id}`,
|
||||||
|
download: (id: string | number) => `/app/contract/download/${id}`,
|
||||||
|
signInit: (id: string | number) => `/app/contract/sign/init/${id}`,
|
||||||
|
signVerifyCode: (id: string | number) => `/app/contract/sign/verify-code/${id}`,
|
||||||
|
signConfirm: (id: string | number) => `/app/contract/sign/confirm/${id}`,
|
||||||
|
signProgress: (id: string | number) => `/app/contract/sign/progress/${id}`,
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 合同分页列表:GET /app/contract/page */
|
||||||
|
export function getContractPage(params: ContractPageQuery) {
|
||||||
|
return get<ContractPageResult>(CONTRACT_API.page, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 合同详情:GET /app/contract/{id} */
|
||||||
|
export function getContractDetail(id: string | number) {
|
||||||
|
return get<ContractVo>(CONTRACT_API.detail(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按项目编号查合同列表:GET /app/contract/project/{projectNo} */
|
||||||
|
export function getContractsByProjectNo(projectNo: string) {
|
||||||
|
return get<ContractVo[]>(CONTRACT_API.byProject(projectNo))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 合同预览:GET /app/contract/preview/{id} */
|
||||||
|
export function getContractPreview(id: string | number) {
|
||||||
|
return get<ContractPreviewVo>(CONTRACT_API.preview(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 合同 PDF 下载地址:GET /app/contract/download/{id}(仅已签署) */
|
||||||
|
export function getContractDownloadUrl(id: string | number) {
|
||||||
|
return get<string>(CONTRACT_API.download(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发起签署:POST /app/contract/sign/init/{id},返回 signId */
|
||||||
|
export function initContractSign(id: string | number, data: ContractSignStartBo) {
|
||||||
|
return post<number | string>(CONTRACT_API.signInit(id), data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 发送签署短信验证码:POST /app/contract/sign/verify-code/{id} */
|
||||||
|
export function sendContractSignSmsCode(id: string | number, data: ContractSignSmsBo) {
|
||||||
|
return post<void>(CONTRACT_API.signVerifyCode(id), data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 确认签署:POST /app/contract/sign/confirm/{id} */
|
||||||
|
export function confirmContractSign(id: string | number, data: ContractSignConfirmBo) {
|
||||||
|
return post<ContractSignProgressVo>(CONTRACT_API.signConfirm(id), data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 签署进度:GET /app/contract/sign/progress/{id} */
|
||||||
|
export function getContractSignProgress(id: string | number) {
|
||||||
|
return get<ContractSignProgressVo>(CONTRACT_API.signProgress(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
export { CONTRACT_API }
|
||||||
11
src/api/feedback.ts
Normal file
11
src/api/feedback.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import type { FeedbackSubmitBo, FeedbackVo } from '@/types/feedback-api'
|
||||||
|
import { post } from '@/utils/request'
|
||||||
|
|
||||||
|
const FEEDBACK_API = {
|
||||||
|
submit: '/app/feedback',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交意见反馈:POST /app/feedback */
|
||||||
|
export function submitFeedback(data: FeedbackSubmitBo) {
|
||||||
|
return post<FeedbackVo>(FEEDBACK_API.submit, data)
|
||||||
|
}
|
||||||
16
src/api/finance.ts
Normal file
16
src/api/finance.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import type { FinanceSummaryQuery, FinanceSummaryVo } from '@/types/finance-api'
|
||||||
|
import { get } from '@/utils/request'
|
||||||
|
|
||||||
|
const FINANCE_API = {
|
||||||
|
summary: '/app/finance/summary',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 财务中心首页统计:GET /app/finance/summary(dimension 默认 YEAR) */
|
||||||
|
export function getFinanceSummary(params?: FinanceSummaryQuery) {
|
||||||
|
return get<FinanceSummaryVo>(FINANCE_API.summary, {
|
||||||
|
dimension: 'YEAR',
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export { FINANCE_API }
|
||||||
@@ -1,6 +1,18 @@
|
|||||||
|
import { get } from '@/utils/request'
|
||||||
|
import { uploadFile } from '@/utils/upload-file'
|
||||||
|
|
||||||
export interface OssFileItem {
|
export interface OssFileItem {
|
||||||
ossId?: number | string
|
ossId?: number | string
|
||||||
url?: string
|
url?: string
|
||||||
|
fileName?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 系统 OSS 上传结果:POST /resource/oss/upload */
|
||||||
|
export interface SysOssUploadVo {
|
||||||
|
url?: string
|
||||||
|
fileName?: string
|
||||||
|
/** 文档定义为 string,避免雪花 ID 精度丢失 */
|
||||||
|
ossId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOssListByIds(ossIds: Array<string | number>) {
|
export function getOssListByIds(ossIds: Array<string | number>) {
|
||||||
@@ -12,3 +24,12 @@ export function getOssListByIds(ossIds: Array<string | number>) {
|
|||||||
showErrorToast: false,
|
showErrorToast: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 上传到系统 OSS:POST /resource/oss/upload(字段名 file) */
|
||||||
|
export function uploadOssFile(filePath: string) {
|
||||||
|
return uploadFile<SysOssUploadVo>({
|
||||||
|
url: '/resource/oss/upload',
|
||||||
|
filePath,
|
||||||
|
fieldName: 'file',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
82
src/api/pay.ts
Normal file
82
src/api/pay.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import type {
|
||||||
|
FinanceBatchPayBo,
|
||||||
|
FinancePayBo,
|
||||||
|
FinancePayQueryVo,
|
||||||
|
FinancePayResultVo,
|
||||||
|
FinanceRefundBo,
|
||||||
|
FinanceRefundPageQuery,
|
||||||
|
FinanceRefundPageResult,
|
||||||
|
PayChannelVo,
|
||||||
|
} from '@/types/pay-api'
|
||||||
|
import { get, post } from '@/utils/request'
|
||||||
|
|
||||||
|
const PAY_API = {
|
||||||
|
channels: '/app/pay/channels',
|
||||||
|
bill: '/app/pay/bill',
|
||||||
|
billBatch: '/app/pay/bill/batch',
|
||||||
|
query: (outTradeNo: string) => `/app/pay/query/${encodeURIComponent(outTradeNo)}`,
|
||||||
|
refund: '/app/pay/refund',
|
||||||
|
refundPage: '/app/pay/refund/page',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 可用支付通道列表:GET /app/pay/channels */
|
||||||
|
export function getPayChannels() {
|
||||||
|
return get<PayChannelVo[]>(PAY_API.channels)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单笔支付:POST /app/pay/bill
|
||||||
|
* 校验归属与待支付状态,生成订单与流水,返回调起参数;防重复提交
|
||||||
|
*/
|
||||||
|
export function payBill(data: FinancePayBo) {
|
||||||
|
return post<FinancePayResultVo>(PAY_API.bill, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多账单合并支付:POST /app/pay/bill/batch
|
||||||
|
* 逐张校验后合并为一笔支付订单,返回合并金额与调起参数;防重复提交
|
||||||
|
*/
|
||||||
|
export function payBillBatch(data: FinanceBatchPayBo) {
|
||||||
|
return post<FinancePayResultVo>(PAY_API.billBatch, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询支付结果:GET /app/pay/query/{outTradeNo} */
|
||||||
|
export function queryPayResult(outTradeNo: string) {
|
||||||
|
return get<FinancePayQueryVo>(PAY_API.query(outTradeNo))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请退款:POST /app/pay/refund
|
||||||
|
* 校验已支付、金额上限、无处理中退款单,生成待审核退款单;防重复提交
|
||||||
|
* @returns 退款单 id
|
||||||
|
*/
|
||||||
|
export function applyRefund(data: FinanceRefundBo) {
|
||||||
|
return post<number | string>(PAY_API.refund, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 我的退款分页列表:GET /app/pay/refund/page(可按 status 筛选) */
|
||||||
|
export function getRefundPage(params?: FinanceRefundPageQuery) {
|
||||||
|
const {
|
||||||
|
pageNum = 1,
|
||||||
|
pageSize = 10,
|
||||||
|
orderByColumn,
|
||||||
|
isAsc,
|
||||||
|
billId,
|
||||||
|
amount,
|
||||||
|
reason,
|
||||||
|
status,
|
||||||
|
} = params || {}
|
||||||
|
|
||||||
|
return get<FinanceRefundPageResult>(PAY_API.refundPage, {
|
||||||
|
pageNum,
|
||||||
|
pageSize,
|
||||||
|
...(orderByColumn ? { orderByColumn } : {}),
|
||||||
|
...(isAsc ? { isAsc } : {}),
|
||||||
|
...(billId != null && String(billId) ? { billId } : {}),
|
||||||
|
...(amount != null ? { amount } : {}),
|
||||||
|
...(reason?.trim() ? { reason: reason.trim() } : {}),
|
||||||
|
...(status?.trim() ? { status: status.trim() } : {}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export { PAY_API }
|
||||||
77
src/api/qualification.ts
Normal file
77
src/api/qualification.ts
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import type {
|
||||||
|
DictDataDTO,
|
||||||
|
UserQualificationBo,
|
||||||
|
UserQualificationVo,
|
||||||
|
} from '@/types/qualification-api'
|
||||||
|
import { del, get, post, put } from '@/utils/request'
|
||||||
|
|
||||||
|
const QUALIFICATION_API = {
|
||||||
|
types: '/app/qualification/types',
|
||||||
|
list: '/app/qualification/list',
|
||||||
|
detail: (id: string | number) => `/app/qualification/${id}`,
|
||||||
|
setDefault: (id: string | number) => `/app/qualification/${id}/default`,
|
||||||
|
submit: '/app/qualification',
|
||||||
|
draft: '/app/qualification/draft',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 资质类型下拉:GET /app/qualification/types(字典 vm_qual_type) */
|
||||||
|
export function getQualificationTypes(options?: { showErrorToast?: boolean }) {
|
||||||
|
return get<DictDataDTO[]>(QUALIFICATION_API.types, undefined, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 当前用户资质列表:GET /app/qualification/list */
|
||||||
|
export function getQualificationList(options?: { showErrorToast?: boolean }) {
|
||||||
|
return get<UserQualificationVo[]>(QUALIFICATION_API.list, undefined, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 资质详情:GET /app/qualification/{id} */
|
||||||
|
export function getQualificationDetail(id: string | number) {
|
||||||
|
return get<UserQualificationVo>(QUALIFICATION_API.detail(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交认证:POST /app/qualification */
|
||||||
|
export function submitQualification(data: UserQualificationBo) {
|
||||||
|
return post<UserQualificationVo>(QUALIFICATION_API.submit, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 保存草稿:POST /app/qualification/draft */
|
||||||
|
export function saveQualificationDraft(data: UserQualificationBo) {
|
||||||
|
return post<UserQualificationVo>(QUALIFICATION_API.draft, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除资质:DELETE /app/qualification/{id} */
|
||||||
|
export function deleteQualification(id: string | number) {
|
||||||
|
return del<void>(QUALIFICATION_API.detail(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 设为默认资质:PUT /app/qualification/{id}/default */
|
||||||
|
export function setDefaultQualification(id: string | number) {
|
||||||
|
return put<void>(QUALIFICATION_API.setDefault(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交成功后清理残留草稿。
|
||||||
|
* 保留本次提交返回的记录(若仍误标为 DRAFT 则不删),其余 DRAFT 全部删除。
|
||||||
|
*/
|
||||||
|
export async function clearQualificationDrafts(options?: {
|
||||||
|
keepId?: string | number | null
|
||||||
|
showErrorToast?: boolean
|
||||||
|
}) {
|
||||||
|
const keepId = options?.keepId != null ? String(options.keepId).trim() : ''
|
||||||
|
const rows = await getQualificationList({
|
||||||
|
showErrorToast: options?.showErrorToast ?? false,
|
||||||
|
})
|
||||||
|
|
||||||
|
const draftIds = (rows ?? [])
|
||||||
|
.filter(item => String(item.status || '').trim().toUpperCase() === 'DRAFT')
|
||||||
|
.map(item => (item.id != null ? String(item.id).trim() : ''))
|
||||||
|
.filter(id => id && id !== keepId)
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
draftIds.map(id =>
|
||||||
|
deleteQualification(id).catch(() => undefined),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { QUALIFICATION_API }
|
||||||
126
src/api/requirement.ts
Normal file
126
src/api/requirement.ts
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
import type {
|
||||||
|
AppOngoingOverviewVo,
|
||||||
|
ProjectRequirementActionBo,
|
||||||
|
ProjectRequirementSubmitBo,
|
||||||
|
ProjectRequirementVo,
|
||||||
|
RequirementDraftBo,
|
||||||
|
RequirementDraftQuery,
|
||||||
|
RequirementDraftVo,
|
||||||
|
RequirementListQuery,
|
||||||
|
RequirementOngoingQuery,
|
||||||
|
RequirementOssUploadVo,
|
||||||
|
RequirementPageResult,
|
||||||
|
} from '@/types/requirement-api'
|
||||||
|
import { API_BASE_URL, REQUIREMENT_DRAFT_API_BASE_URL } from '@/constants/config'
|
||||||
|
import { get, post } from '@/utils/request'
|
||||||
|
import { uploadFile } from '@/utils/upload-file'
|
||||||
|
|
||||||
|
const REQUIREMENT_API = {
|
||||||
|
businessTypes: '/app/requirement/businessTypes',
|
||||||
|
list: '/app/requirement/list',
|
||||||
|
detail: (id: string | number) => `/app/requirement/${id}`,
|
||||||
|
submit: '/app/requirement',
|
||||||
|
draftRead: '/app/requirement/draft',
|
||||||
|
draftSave: '/app/requirement/drafts',
|
||||||
|
ossUpload: '/app/requirement/oss/upload',
|
||||||
|
ongoing: '/app/requirement/ongoing',
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeApiBase(url: string) {
|
||||||
|
return url.replace(/\/$/, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
function draftRequestOptions() {
|
||||||
|
const draftBase = normalizeApiBase(REQUIREMENT_DRAFT_API_BASE_URL)
|
||||||
|
const primaryBase = normalizeApiBase(API_BASE_URL)
|
||||||
|
|
||||||
|
if (draftBase === primaryBase)
|
||||||
|
return { showErrorToast: false }
|
||||||
|
|
||||||
|
return {
|
||||||
|
baseURL: REQUIREMENT_DRAFT_API_BASE_URL,
|
||||||
|
unauthorizedMode: 'toast' as const,
|
||||||
|
showErrorToast: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取需求业务类型筛选项:GET /app/requirement/businessTypes */
|
||||||
|
export function getRequirementBusinessTypes() {
|
||||||
|
return get<Array<Record<string, string>> | string[]>(REQUIREMENT_API.businessTypes)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 当前用户的需求列表:GET /app/requirement/list */
|
||||||
|
export function getRequirementList(params: RequirementListQuery) {
|
||||||
|
return get<RequirementPageResult>(REQUIREMENT_API.list, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 需求详情:GET /app/requirement/{id} */
|
||||||
|
export function getRequirementDetail(id: string | number) {
|
||||||
|
return get<ProjectRequirementVo>(REQUIREMENT_API.detail(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交需求:POST /app/requirement */
|
||||||
|
export function submitRequirement(data: ProjectRequirementSubmitBo) {
|
||||||
|
return post<void>(REQUIREMENT_API.submit, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickUploadResult(data: RequirementOssUploadVo | RequirementOssUploadVo[]): RequirementOssUploadVo {
|
||||||
|
if (Array.isArray(data))
|
||||||
|
return data[0] ?? {}
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 需求附件上传:POST /app/requirement/oss/upload(multipart 字段名 files) */
|
||||||
|
export function uploadRequirementAttachment(filePath: string) {
|
||||||
|
return uploadFile<RequirementOssUploadVo | RequirementOssUploadVo[]>({
|
||||||
|
url: REQUIREMENT_API.ossUpload,
|
||||||
|
filePath,
|
||||||
|
fieldName: 'files',
|
||||||
|
}).then(pickUploadResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 读取指定业务类型草稿:GET /app/requirement/draft?businessType=&newFlag= */
|
||||||
|
export function getRequirementDraft(params: RequirementDraftQuery) {
|
||||||
|
return get<RequirementDraftVo | null>(REQUIREMENT_API.draftRead, params, draftRequestOptions())
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 保存需求草稿:POST /app/requirement/drafts */
|
||||||
|
export function saveRequirementDraft(data: RequirementDraftBo) {
|
||||||
|
const options = draftRequestOptions()
|
||||||
|
if (options.baseURL)
|
||||||
|
return post<number | string | void>(REQUIREMENT_API.draftSave, data, options)
|
||||||
|
|
||||||
|
return post<number | string | void>(REQUIREMENT_API.draftSave, data, {
|
||||||
|
showErrorToast: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 在办项目统计与最近更新:GET /app/requirement/ongoing */
|
||||||
|
export function getRequirementOngoing(params?: RequirementOngoingQuery) {
|
||||||
|
return get<AppOngoingOverviewVo>(REQUIREMENT_API.ongoing, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交需求售后申请:POST /app/requirement/{id}/after-sale */
|
||||||
|
export function submitRequirementAfterSale(
|
||||||
|
id: string | number,
|
||||||
|
data: ProjectRequirementActionBo,
|
||||||
|
) {
|
||||||
|
return post<void>(`${REQUIREMENT_API.detail(id)}/after-sale`, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 撤回需求售后申请:POST /app/requirement/{id}/after-sale/withdraw */
|
||||||
|
export function withdrawRequirementAfterSale(
|
||||||
|
id: string | number,
|
||||||
|
data?: ProjectRequirementActionBo,
|
||||||
|
) {
|
||||||
|
const normalizedId = /^\d+$/.test(String(id)) ? Number(id) : id
|
||||||
|
const body: ProjectRequirementActionBo = {
|
||||||
|
id: normalizedId,
|
||||||
|
...data,
|
||||||
|
}
|
||||||
|
if (body.id === undefined || body.id === '')
|
||||||
|
body.id = normalizedId
|
||||||
|
|
||||||
|
return post<void>(`${REQUIREMENT_API.detail(id)}/after-sale/withdraw`, body)
|
||||||
|
}
|
||||||
@@ -1,22 +1,5 @@
|
|||||||
import type { AccountSecurityItem } from '@/types/account-security'
|
import type { AccountSecurityItem } from '@/types/account-security'
|
||||||
|
import { buildAccountSecurityItems } from '@/utils/map-account-security'
|
||||||
|
|
||||||
export const ACCOUNT_SECURITY_ITEMS: AccountSecurityItem[] = [
|
/** 未拉取到接口数据时的占位展示(非真实账号信息) */
|
||||||
{
|
export const ACCOUNT_SECURITY_PLACEHOLDER_ITEMS: AccountSecurityItem[] = buildAccountSecurityItems(null)
|
||||||
key: 'password',
|
|
||||||
title: '修改密码',
|
|
||||||
subtitle: '上次修改:15天前',
|
|
||||||
status: '已设置',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'phone',
|
|
||||||
title: '绑定手机',
|
|
||||||
subtitle: '186****9618',
|
|
||||||
status: '已绑定',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'email',
|
|
||||||
title: '绑定邮箱',
|
|
||||||
subtitle: 'yongzh******4@163.com',
|
|
||||||
status: '已绑定',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -1,20 +1 @@
|
|||||||
import type { AddressItem } from '@/types/address'
|
export const ADDRESS_PHONE_PATTERN = /^1[3-9]\d{9}$/
|
||||||
|
|
||||||
export const ADDRESS_LIST: AddressItem[] = [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: '张三',
|
|
||||||
phone: '15588888000',
|
|
||||||
region: '山东省日照市东港区',
|
|
||||||
detail: '科技园南路99号',
|
|
||||||
isDefault: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: '张三',
|
|
||||||
phone: '15588888000',
|
|
||||||
region: '山东省日照市东港区',
|
|
||||||
detail: '科技园南路99号',
|
|
||||||
isDefault: false,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -1,54 +1,40 @@
|
|||||||
import { PROJECT_CENTER_LIST } from '@/constants/project-center'
|
import type { BillItem, BillListSummary, BillStatus } from '@/types/bill'
|
||||||
import { getProjectDetail } from '@/constants/project-detail'
|
import type { BillType } from '@/types/bill-api'
|
||||||
import type { BillItem, BillListSummary } from '@/types/bill'
|
|
||||||
|
|
||||||
const PAID_BILL_META: Record<string, { paidAt: string, paidMethod: 'wechat' | 'alipay', transactionNo: string }> = {
|
export const BILL_PAGE_SIZE = 10
|
||||||
'1-1': {
|
|
||||||
paidAt: '2026-01-21 15:00:00',
|
export const BILL_STATUS_LABEL: Record<BillStatus, string> = {
|
||||||
paidMethod: 'wechat',
|
paid: '已支付',
|
||||||
transactionNo: 'T20260819153035678K2M001',
|
pending: '待支付',
|
||||||
},
|
not_due: '未到期',
|
||||||
|
cancelled: '已作废',
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildBillList(): BillItem[] {
|
/** 手动建账-账单类型 */
|
||||||
const bills: BillItem[] = []
|
export const BILL_TYPE_OPTIONS: Array<{ label: string, value: BillType }> = [
|
||||||
|
{ label: '预付款', value: 'ADVANCE' },
|
||||||
|
{ label: '进度款', value: 'PROGRESS' },
|
||||||
|
{ label: '尾款', value: 'FINAL' },
|
||||||
|
{ label: '其他', value: 'OTHER' },
|
||||||
|
]
|
||||||
|
|
||||||
PROJECT_CENTER_LIST.forEach((project) => {
|
/** 手动建账-业务类型(字典值) */
|
||||||
const detail = getProjectDetail(project.id)
|
export const BILL_BIZ_TYPE_OPTIONS: Array<{ label: string, value: string }> = [
|
||||||
if (!detail)
|
{ label: '互联网软件', value: 'internet_software' },
|
||||||
return
|
{ label: '硬件电路', value: 'hardware_circuit' },
|
||||||
|
{ label: '物联网全案', value: 'iot_solution' },
|
||||||
|
{ label: '生产制造', value: 'manufacturing' },
|
||||||
|
]
|
||||||
|
|
||||||
detail.paymentPlans.forEach((plan) => {
|
export const EMPTY_BILL_SUMMARY: BillListSummary = {
|
||||||
const metaKey = `${project.id}-${plan.id}`
|
totalCount: 0,
|
||||||
const paidMeta = PAID_BILL_META[metaKey]
|
totalAmount: '0.00',
|
||||||
|
pendingCount: 0,
|
||||||
bills.push({
|
|
||||||
...plan,
|
|
||||||
projectId: project.id,
|
|
||||||
billNo: ['1', '2', '3'].includes(plan.id) && project.id === '1'
|
|
||||||
? '20260813ZZ251245'
|
|
||||||
: plan.billNo,
|
|
||||||
transactionNo: paidMeta?.transactionNo
|
|
||||||
|| (['2', '3'].includes(plan.id) && project.id === '1'
|
|
||||||
? 'T20260819153035678K2M001'
|
|
||||||
: plan.transactionNo),
|
|
||||||
paidAt: paidMeta?.paidAt,
|
|
||||||
paidMethod: paidMeta?.paidMethod,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return bills
|
|
||||||
}
|
|
||||||
|
|
||||||
export const BILL_LIST: BillItem[] = buildBillList()
|
|
||||||
|
|
||||||
export const BILL_LIST_SUMMARY: BillListSummary = {
|
|
||||||
totalCount: 10,
|
|
||||||
totalAmount: '40.0万',
|
|
||||||
pendingCount: 3,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated 详情页改接接口前的本地查找兜底 */
|
||||||
export function getBill(projectId: string, planId: string): BillItem | null {
|
export function getBill(projectId: string, planId: string): BillItem | null {
|
||||||
return BILL_LIST.find(bill => bill.projectId === projectId && bill.id === planId) || null
|
void projectId
|
||||||
|
void planId
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
|
/** 需求业务类型字典(读取草稿 businessType 仅允许此 4 项) */
|
||||||
export const BUSINESS_TYPE_OPTIONS = [
|
export const BUSINESS_TYPE_OPTIONS = [
|
||||||
'互联网软件',
|
'互联网软件',
|
||||||
'硬件电路',
|
'硬件电路',
|
||||||
'物联网全案',
|
'物联网全案',
|
||||||
'生产制造',
|
'生产制造',
|
||||||
]
|
] as const
|
||||||
|
|
||||||
|
export type RequirementBusinessType = typeof BUSINESS_TYPE_OPTIONS[number]
|
||||||
|
|
||||||
|
const BUSINESS_TYPE_SET = new Set<string>(BUSINESS_TYPE_OPTIONS)
|
||||||
|
|
||||||
|
export function isRequirementBusinessType(value: string) {
|
||||||
|
return BUSINESS_TYPE_SET.has(value.trim())
|
||||||
|
}
|
||||||
|
|
||||||
export const BUSINESS_TYPE_DETAIL_ID: Record<string, string> = {
|
export const BUSINESS_TYPE_DETAIL_ID: Record<string, string> = {
|
||||||
互联网软件: 'software',
|
互联网软件: 'software',
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
/** 后端服务地址 */
|
/** 后端服务地址 */
|
||||||
export const API_HOST = '192.168.0.206'
|
export const API_HOST = '192.168.0.175'
|
||||||
|
|
||||||
export const API_PORT = 8080
|
export const API_PORT = 8080
|
||||||
|
|
||||||
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || `http://${API_HOST}:${API_PORT}`
|
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || `http://${API_HOST}:${API_PORT}`
|
||||||
|
|
||||||
|
/** 需求草稿服务(默认同主站) */
|
||||||
|
export const REQUIREMENT_DRAFT_API_BASE_URL =
|
||||||
|
import.meta.env.VITE_REQUIREMENT_DRAFT_API_BASE_URL || API_BASE_URL
|
||||||
|
|
||||||
|
/** 账号安全 / 邮箱验证码服务(默认同主站;开发环境可指向邮件已配置的机器) */
|
||||||
|
export const ACCOUNT_API_BASE_URL =
|
||||||
|
import.meta.env.VITE_ACCOUNT_API_BASE_URL || API_BASE_URL
|
||||||
|
|
||||||
/** 接口请求超时(毫秒) */
|
/** 接口请求超时(毫秒) */
|
||||||
export const API_TIMEOUT = 15000
|
export const API_TIMEOUT = 15000
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ContractItem, ContractTab } from '@/types/contract'
|
import type { ContractTab } from '@/types/contract'
|
||||||
|
|
||||||
export const CONTRACT_TABS: Array<{ value: ContractTab, label: string }> = [
|
export const CONTRACT_TABS: Array<{ value: ContractTab, label: string }> = [
|
||||||
{ value: 'all', label: '全部' },
|
{ value: 'all', label: '全部' },
|
||||||
@@ -6,69 +6,4 @@ export const CONTRACT_TABS: Array<{ value: ContractTab, label: string }> = [
|
|||||||
{ value: 'signed', label: '已签署' },
|
{ value: 'signed', label: '已签署' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const CONTRACT_DETAIL_BASE = {
|
export const CONTRACT_PAGE_SIZE = 10
|
||||||
contractName: '社区康养智能服务系统开发合同',
|
|
||||||
contractType: '互联网软件开发',
|
|
||||||
contractNo: 'C8K2M202408001',
|
|
||||||
signDate: '2024-10-15',
|
|
||||||
effectiveDate: '2024-10-15',
|
|
||||||
expiryDate: '2024-10-15',
|
|
||||||
relatedProject: '社区康养智能服务系统',
|
|
||||||
contractStatus: '履行中',
|
|
||||||
projectId: '1',
|
|
||||||
fileName: '需求文档.pdf',
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CONTRACT_LIST: ContractItem[] = [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
contractNo: CONTRACT_DETAIL_BASE.contractNo,
|
|
||||||
title: '社区康养智慧系统',
|
|
||||||
type: '软件开发',
|
|
||||||
relatedLabel: '关联合同',
|
|
||||||
relatedValue: '20260814ZZZ151245',
|
|
||||||
signStatus: 'signed',
|
|
||||||
badges: [
|
|
||||||
{ type: 'signed', label: '已签署' },
|
|
||||||
{ type: 'in_progress', label: '履行中' },
|
|
||||||
],
|
|
||||||
showDownload: true,
|
|
||||||
showSign: false,
|
|
||||||
...CONTRACT_DETAIL_BASE,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
contractNo: CONTRACT_DETAIL_BASE.contractNo,
|
|
||||||
title: '社区康养智慧系统',
|
|
||||||
type: '软件开发',
|
|
||||||
relatedLabel: '关联项目',
|
|
||||||
relatedValue: '社区康养智慧系统',
|
|
||||||
signStatus: 'pending',
|
|
||||||
badges: [
|
|
||||||
{ type: 'pending_sign', label: '待签署' },
|
|
||||||
],
|
|
||||||
showDownload: false,
|
|
||||||
showSign: true,
|
|
||||||
...CONTRACT_DETAIL_BASE,
|
|
||||||
contractStatus: '待签署',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
contractNo: CONTRACT_DETAIL_BASE.contractNo,
|
|
||||||
title: '社区康养智慧系统',
|
|
||||||
type: '软件开发',
|
|
||||||
relatedLabel: '关联项目',
|
|
||||||
relatedValue: '社区康养智慧系统',
|
|
||||||
signStatus: 'signed',
|
|
||||||
badges: [
|
|
||||||
{ type: 'signed', label: '已签署' },
|
|
||||||
],
|
|
||||||
showDownload: false,
|
|
||||||
showSign: false,
|
|
||||||
...CONTRACT_DETAIL_BASE,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export function getContract(id: string): ContractItem | null {
|
|
||||||
return CONTRACT_LIST.find(item => item.id === id) || null
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
export const FEEDBACK_DESCRIPTION_MAX_LENGTH = 500
|
export const FEEDBACK_DESCRIPTION_MAX_LENGTH = 500
|
||||||
|
|
||||||
|
export const FEEDBACK_ATTACHMENT_MAX_COUNT = 5
|
||||||
|
|||||||
@@ -1,15 +1,39 @@
|
|||||||
import type { FinanceQuickAction } from '@/types/finance-center'
|
import type { FinanceQuickAction } from '@/types/finance-center'
|
||||||
|
import type { FinanceSummaryDimension } from '@/types/finance-api'
|
||||||
import iconBillDetails from '@/static/icon/bill-details.svg'
|
import iconBillDetails from '@/static/icon/bill-details.svg'
|
||||||
import iconPendingPayment from '@/static/icon/pending-payment.svg'
|
import iconPendingPayment from '@/static/icon/pending-payment.svg'
|
||||||
import iconInvoiceApply from '@/static/icon/invoice-apply.svg'
|
import iconInvoiceApply from '@/static/icon/invoice-apply.svg'
|
||||||
import iconReportExport from '@/static/icon/report-export.svg'
|
import iconReportExport from '@/static/icon/report-export.svg'
|
||||||
|
|
||||||
export const FINANCE_CENTER_TOTAL = 4000000
|
export interface FinanceDimensionOption {
|
||||||
|
label: string
|
||||||
|
dimension: FinanceSummaryDimension
|
||||||
|
}
|
||||||
|
|
||||||
export const FINANCE_MONTH_OPTIONS = [
|
/** 统计维度(对应接口 dimension,默认 YEAR) */
|
||||||
'2026年1月',
|
export const FINANCE_DIMENSION_OPTIONS: FinanceDimensionOption[] = [
|
||||||
'2025年12月',
|
{ label: '按年', dimension: 'YEAR' },
|
||||||
'2025年11月',
|
{ label: '按月', dimension: 'MONTH' },
|
||||||
|
{ label: '按季', dimension: 'QUARTER' },
|
||||||
|
]
|
||||||
|
|
||||||
|
export const FINANCE_DISTRIBUTION_COLORS = [
|
||||||
|
'#2563EB',
|
||||||
|
'#38BDF8',
|
||||||
|
'#F59E0B',
|
||||||
|
'#10B981',
|
||||||
|
'#8B5CF6',
|
||||||
|
'#F43F5E',
|
||||||
|
]
|
||||||
|
|
||||||
|
/** 业务类型混合图配色(柱 + 折线,对齐设计稿) */
|
||||||
|
export const FINANCE_CHART_SERIES_COLORS = [
|
||||||
|
'#3B82C4',
|
||||||
|
'#7038B0',
|
||||||
|
'#8FBF4A',
|
||||||
|
'#E8A93A',
|
||||||
|
'#38BDF8',
|
||||||
|
'#F43F5E',
|
||||||
]
|
]
|
||||||
|
|
||||||
export const FINANCE_QUICK_ACTIONS: FinanceQuickAction[] = [
|
export const FINANCE_QUICK_ACTIONS: FinanceQuickAction[] = [
|
||||||
@@ -23,13 +47,19 @@ export const FINANCE_QUICK_ACTIONS: FinanceQuickAction[] = [
|
|||||||
key: 'pending',
|
key: 'pending',
|
||||||
label: '待支付',
|
label: '待支付',
|
||||||
icon: iconPendingPayment,
|
icon: iconPendingPayment,
|
||||||
path: '/pages/project-center/bill-list/index',
|
path: '/pages/project-center/bill-list/index?status=PENDING',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'invoice',
|
key: 'invoice',
|
||||||
label: '发票申请',
|
label: '发票申请',
|
||||||
icon: iconInvoiceApply,
|
icon: iconInvoiceApply,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'refund',
|
||||||
|
label: '退款记录',
|
||||||
|
icon: iconPendingPayment,
|
||||||
|
path: '/pages/project-center/refund-list/index',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'export',
|
key: 'export',
|
||||||
label: '报表导出',
|
label: '报表导出',
|
||||||
|
|||||||
@@ -7,12 +7,6 @@ export const INVOICE_RECORD_TABS: Array<{ value: InvoiceRecordStatus, label: str
|
|||||||
{ value: 'invoicing', label: '开票中' },
|
{ value: 'invoicing', label: '开票中' },
|
||||||
]
|
]
|
||||||
|
|
||||||
export const INVOICE_RECORD_STATUS_LABEL: Record<InvoiceRecordItem['status'], string> = {
|
|
||||||
invoiced: '已开票',
|
|
||||||
not_invoiced: '未开票',
|
|
||||||
invoicing: '开票中',
|
|
||||||
}
|
|
||||||
|
|
||||||
export const INVOICE_RECORD_LIST: InvoiceRecordItem[] = [
|
export const INVOICE_RECORD_LIST: InvoiceRecordItem[] = [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export const PERSONAL_CENTER_PROFILE: PersonalCenterProfile = {
|
|||||||
|
|
||||||
export const PERSONAL_CENTER_MENU: PersonalCenterMenuItem[] = [
|
export const PERSONAL_CENTER_MENU: PersonalCenterMenuItem[] = [
|
||||||
{ key: 'security', label: '账号安全', icon: iconSecurity, path: '/pages/personal-center/account-security/index' },
|
{ key: 'security', label: '账号安全', icon: iconSecurity, path: '/pages/personal-center/account-security/index' },
|
||||||
{ key: 'message-push', label: '消息推送', icon: iconMessagePush },
|
{ key: 'message-push', label: '消息推送', icon: iconMessagePush, path: '/pages/message-center/index' },
|
||||||
{ key: 'feedback', label: '意见反馈', icon: iconFeedback, path: '/pages/personal-center/feedback/index' },
|
{ key: 'feedback', label: '意见反馈', icon: iconFeedback, path: '/pages/personal-center/feedback/index' },
|
||||||
{ key: 'contract-list', label: '合同列表', icon: iconContractList, path: '/pages/contract-center/index' },
|
{ key: 'contract-list', label: '合同列表', icon: iconContractList, path: '/pages/contract-center/index' },
|
||||||
{ key: 'finance', label: '财务中心', icon: iconFinance, path: '/pages/personal-center/finance/index' },
|
{ key: 'finance', label: '财务中心', icon: iconFinance, path: '/pages/personal-center/finance/index' },
|
||||||
@@ -30,7 +30,12 @@ export const PERSONAL_CENTER_MENU: PersonalCenterMenuItem[] = [
|
|||||||
{ key: 'favorites', label: '收藏列表', icon: iconFavorites, path: '/pages/case-library/favorites/index' },
|
{ key: 'favorites', label: '收藏列表', icon: iconFavorites, path: '/pages/case-library/favorites/index' },
|
||||||
{ key: 'qualification', label: '资质列表', icon: iconQualification, path: '/pages/personal-center/qualification-list/index' },
|
{ key: 'qualification', label: '资质列表', icon: iconQualification, path: '/pages/personal-center/qualification-list/index' },
|
||||||
{ key: 'help', label: '帮助中心', icon: iconHelp },
|
{ key: 'help', label: '帮助中心', icon: iconHelp },
|
||||||
{ key: 'about', label: '关于我们', icon: iconAbout },
|
{
|
||||||
|
key: 'about',
|
||||||
|
label: '关于我们',
|
||||||
|
icon: iconAbout,
|
||||||
|
path: '/pages/Login/user-agreement/index?code=about',
|
||||||
|
},
|
||||||
{ key: 'service-hotline', label: '专属客服热线', icon: iconServiceHotline, path: '/pages/personal-center/service-hotline/index' },
|
{ key: 'service-hotline', label: '专属客服热线', icon: iconServiceHotline, path: '/pages/personal-center/service-hotline/index' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export const PROJECT_CATEGORIES: ProjectCategory[] = [
|
|||||||
'生产制造',
|
'生产制造',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const PROJECT_PAGE_SIZE = 10
|
||||||
|
|
||||||
export const PROJECT_CENTER_LIST: ProjectCenterItem[] = [
|
export const PROJECT_CENTER_LIST: ProjectCenterItem[] = [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
import type { QualificationItem, QualificationStatus } from '@/types/qualification'
|
import type { QualificationStatus } from '@/types/qualification'
|
||||||
|
|
||||||
export const QUALIFICATION_TYPE_OPTIONS = [
|
|
||||||
'营业执照',
|
|
||||||
'高新技术企业证书',
|
|
||||||
'ISO 质量管理体系认证',
|
|
||||||
'软件企业认定证书',
|
|
||||||
]
|
|
||||||
|
|
||||||
export const QUALIFICATION_STATUS_LABEL: Record<QualificationStatus, string> = {
|
export const QUALIFICATION_STATUS_LABEL: Record<QualificationStatus, string> = {
|
||||||
reviewing: '审核中',
|
reviewing: '审核中',
|
||||||
@@ -13,26 +6,3 @@ export const QUALIFICATION_STATUS_LABEL: Record<QualificationStatus, string> = {
|
|||||||
rejected: '已驳回',
|
rejected: '已驳回',
|
||||||
draft: '草稿',
|
draft: '草稿',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const QUALIFICATION_LIST: QualificationItem[] = [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
type: '营业执照',
|
|
||||||
certificateName: '山东日照有限公司',
|
|
||||||
certificateNo: '344683434513543543545535',
|
|
||||||
issuer: '山东省政务局',
|
|
||||||
validFrom: '2024-10-10',
|
|
||||||
validTo: '2027-10-10',
|
|
||||||
status: 'reviewing',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
type: '营业执照',
|
|
||||||
certificateName: '山东日照有限公司',
|
|
||||||
certificateNo: '344683434513543543545535',
|
|
||||||
issuer: '山东省政务局',
|
|
||||||
validFrom: '2024-10-10',
|
|
||||||
validTo: '2027-10-10',
|
|
||||||
status: 'reviewing',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|||||||
26
src/constants/refund.ts
Normal file
26
src/constants/refund.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import type { FinanceRefundStatus } from '@/types/pay-api'
|
||||||
|
|
||||||
|
export const REFUND_PAGE_SIZE = 10
|
||||||
|
|
||||||
|
export const REFUND_STATUS_LABEL: Record<string, string> = {
|
||||||
|
APPLYING: '待审核',
|
||||||
|
APPROVED: '已通过',
|
||||||
|
REJECTED: '已驳回',
|
||||||
|
REFUNDING: '退款中',
|
||||||
|
SUCCESS: '退款成功',
|
||||||
|
FAILED: '退款失败',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RefundStatusTab {
|
||||||
|
key: '' | FinanceRefundStatus
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const REFUND_STATUS_TABS: RefundStatusTab[] = [
|
||||||
|
{ key: '', label: '全部' },
|
||||||
|
{ key: 'APPLYING', label: '待审核' },
|
||||||
|
{ key: 'REFUNDING', label: '退款中' },
|
||||||
|
{ key: 'SUCCESS', label: '已成功' },
|
||||||
|
{ key: 'REJECTED', label: '已驳回' },
|
||||||
|
{ key: 'FAILED', label: '失败' },
|
||||||
|
]
|
||||||
48
src/constants/security-page.ts
Normal file
48
src/constants/security-page.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
export type SecurityPageCode = 'userAgreement' | 'privacyPolicy' | 'about' | 'customTerms'
|
||||||
|
|
||||||
|
export interface SecurityPageMeta {
|
||||||
|
apiCode: string
|
||||||
|
navTitle: string
|
||||||
|
defaultDocTitle: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SECURITY_PAGE_META: Record<SecurityPageCode, SecurityPageMeta> = {
|
||||||
|
userAgreement: {
|
||||||
|
apiCode: 'userAgreement',
|
||||||
|
navTitle: '用户协议',
|
||||||
|
defaultDocTitle: '用户协议',
|
||||||
|
},
|
||||||
|
privacyPolicy: {
|
||||||
|
apiCode: 'privacyPolicy',
|
||||||
|
navTitle: '隐私政策',
|
||||||
|
defaultDocTitle: '隐私政策',
|
||||||
|
},
|
||||||
|
about: {
|
||||||
|
apiCode: 'about',
|
||||||
|
navTitle: '关于我们',
|
||||||
|
defaultDocTitle: '关于我们',
|
||||||
|
},
|
||||||
|
customTerms: {
|
||||||
|
apiCode: 'customTerms',
|
||||||
|
navTitle: '定制条款',
|
||||||
|
defaultDocTitle: '定制条款',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const PAGE_KEY_BY_API_CODE = Object.fromEntries(
|
||||||
|
Object.entries(SECURITY_PAGE_META).map(([key, meta]) => [meta.apiCode, key as SecurityPageCode]),
|
||||||
|
) as Record<string, SecurityPageCode>
|
||||||
|
|
||||||
|
export function resolveSecurityPageCode(input?: string): SecurityPageCode {
|
||||||
|
if (!input)
|
||||||
|
return 'userAgreement'
|
||||||
|
|
||||||
|
const trimmed = input.trim()
|
||||||
|
if (trimmed in SECURITY_PAGE_META)
|
||||||
|
return trimmed as SecurityPageCode
|
||||||
|
|
||||||
|
if (PAGE_KEY_BY_API_CODE[trimmed])
|
||||||
|
return PAGE_KEY_BY_API_CODE[trimmed]
|
||||||
|
|
||||||
|
return 'userAgreement'
|
||||||
|
}
|
||||||
@@ -1,16 +1,84 @@
|
|||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { QUALIFICATION_LIST } from '@/constants/qualification'
|
import { getQualificationList, getQualificationTypes } from '@/api/qualification'
|
||||||
import type { QualificationItem } from '@/types/qualification'
|
import type { QualificationItem } from '@/types/qualification'
|
||||||
|
import {
|
||||||
|
filterSubmittedQualifications,
|
||||||
|
mapQualificationTypeOptions,
|
||||||
|
mapUserQualificationsToItems,
|
||||||
|
pickLatestQualificationDraft,
|
||||||
|
type QualificationTypeOption,
|
||||||
|
} from '@/utils/map-qualification'
|
||||||
|
|
||||||
const qualifications = ref<QualificationItem[]>(QUALIFICATION_LIST.map(item => ({ ...item })))
|
/** 接口原始列表(含草稿) */
|
||||||
|
const allQualifications = ref<QualificationItem[]>([])
|
||||||
|
const typeOptions = ref<QualificationTypeOption[]>([])
|
||||||
|
const listLoading = ref(false)
|
||||||
|
const typesLoading = ref(false)
|
||||||
|
|
||||||
|
/** 列表页只展示非草稿 */
|
||||||
|
const qualifications = computed(() => filterSubmittedQualifications(allQualifications.value))
|
||||||
|
|
||||||
export function useQualifications() {
|
export function useQualifications() {
|
||||||
function getQualificationById(id: string) {
|
function getQualificationById(id: string) {
|
||||||
return qualifications.value.find(item => item.id === id) || null
|
return allQualifications.value.find(item => item.id === id) || null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadQualificationTypes(force = false) {
|
||||||
|
if (typesLoading.value)
|
||||||
|
return typeOptions.value
|
||||||
|
if (!force && typeOptions.value.length)
|
||||||
|
return typeOptions.value
|
||||||
|
|
||||||
|
typesLoading.value = true
|
||||||
|
try {
|
||||||
|
const rows = await getQualificationTypes({ showErrorToast: false })
|
||||||
|
typeOptions.value = mapQualificationTypeOptions(rows ?? [])
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
if (!typeOptions.value.length)
|
||||||
|
typeOptions.value = []
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
typesLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeOptions.value
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadQualificationList() {
|
||||||
|
if (listLoading.value)
|
||||||
|
return allQualifications.value
|
||||||
|
|
||||||
|
listLoading.value = true
|
||||||
|
try {
|
||||||
|
const rows = await getQualificationList()
|
||||||
|
allQualifications.value = mapUserQualificationsToItems(rows ?? [])
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
allQualifications.value = []
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
listLoading.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return allQualifications.value
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增资质时回填:最近一份草稿 */
|
||||||
|
async function loadLatestDraft() {
|
||||||
|
const rows = await loadQualificationList()
|
||||||
|
return pickLatestQualificationDraft(rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
qualifications,
|
qualifications,
|
||||||
|
allQualifications,
|
||||||
|
typeOptions,
|
||||||
|
listLoading,
|
||||||
|
typesLoading,
|
||||||
getQualificationById,
|
getQualificationById,
|
||||||
|
loadQualificationTypes,
|
||||||
|
loadQualificationList,
|
||||||
|
loadLatestDraft,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
src/hooks/use-requirement-business-types.ts
Normal file
37
src/hooks/use-requirement-business-types.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { ref } from 'vue'
|
||||||
|
import { getRequirementBusinessTypes } from '@/api/requirement'
|
||||||
|
import { buildBusinessTypeIdLabelMap, normalizeBusinessTypeOptions } from '@/utils/normalize-business-types'
|
||||||
|
import { registerBusinessTypeIdMap } from '@/utils/format-business-type'
|
||||||
|
|
||||||
|
const businessTypes = ref<string[]>([])
|
||||||
|
let loading = false
|
||||||
|
let loaded = false
|
||||||
|
|
||||||
|
export function useRequirementBusinessTypes() {
|
||||||
|
async function loadRequirementBusinessTypes(force = false) {
|
||||||
|
if ((loaded || loading) && !force)
|
||||||
|
return businessTypes.value
|
||||||
|
|
||||||
|
loading = true
|
||||||
|
try {
|
||||||
|
const data = await getRequirementBusinessTypes()
|
||||||
|
registerBusinessTypeIdMap(buildBusinessTypeIdLabelMap(data))
|
||||||
|
businessTypes.value = normalizeBusinessTypeOptions(data)
|
||||||
|
loaded = true
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
if (!businessTypes.value.length)
|
||||||
|
businessTypes.value = []
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return businessTypes.value
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
businessTypes,
|
||||||
|
loadRequirementBusinessTypes,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,9 @@
|
|||||||
"autoclose": true,
|
"autoclose": true,
|
||||||
"delay": 0
|
"delay": 0
|
||||||
},
|
},
|
||||||
"modules": {},
|
"modules": {
|
||||||
|
"Speech": {}
|
||||||
|
},
|
||||||
"distribute": {
|
"distribute": {
|
||||||
"android": {
|
"android": {
|
||||||
"usesCleartextTraffic": true,
|
"usesCleartextTraffic": true,
|
||||||
@@ -31,6 +33,8 @@
|
|||||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||||
@@ -40,8 +44,20 @@
|
|||||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ios": {},
|
"ios": {
|
||||||
"sdkConfigs": {}
|
"privacyDescription": {
|
||||||
|
"NSMicrophoneUsageDescription": "用于语音转文字输入客服消息"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sdkConfigs": {
|
||||||
|
"speech": {
|
||||||
|
"baidu": {
|
||||||
|
"appid": "",
|
||||||
|
"apikey": "",
|
||||||
|
"secretkey": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"h5": {
|
"h5": {
|
||||||
|
|||||||
@@ -145,6 +145,24 @@
|
|||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/project-center/bill-generate/index",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/project-center/refund-list/index",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/project-center/refund-apply/index",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/project-center/after-sales-apply/index",
|
"path": "pages/project-center/after-sales-apply/index",
|
||||||
"style": {
|
"style": {
|
||||||
|
|||||||
@@ -84,3 +84,18 @@
|
|||||||
color: $color-text-primary;
|
color: $color-text-primary;
|
||||||
text-align: justify;
|
text-align: justify;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-agreement-page__rich {
|
||||||
|
display: block;
|
||||||
|
margin-top: 24rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-agreement-page__status {
|
||||||
|
padding: 80rpx 24rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,59 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { getAccountSecurityPage } from '@/api/account'
|
||||||
|
import {
|
||||||
|
SECURITY_PAGE_META,
|
||||||
|
resolveSecurityPageCode,
|
||||||
|
type SecurityPageCode,
|
||||||
|
} from '@/constants/security-page'
|
||||||
|
import { mapSecurityPageView } from '@/utils/map-security-page'
|
||||||
|
|
||||||
|
const pageCode = ref<SecurityPageCode>('userAgreement')
|
||||||
|
const navTitle = ref(SECURITY_PAGE_META.userAgreement.navTitle)
|
||||||
|
const docTitle = ref(SECURITY_PAGE_META.userAgreement.defaultDocTitle)
|
||||||
|
const content = ref('')
|
||||||
|
const updateDate = ref('')
|
||||||
|
const isHtml = ref(false)
|
||||||
|
const loading = ref(true)
|
||||||
|
const loadError = ref('')
|
||||||
|
|
||||||
|
async function loadPageContent() {
|
||||||
|
const meta = SECURITY_PAGE_META[pageCode.value]
|
||||||
|
navTitle.value = meta.navTitle
|
||||||
|
docTitle.value = meta.defaultDocTitle
|
||||||
|
content.value = ''
|
||||||
|
updateDate.value = ''
|
||||||
|
loadError.value = ''
|
||||||
|
loading.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
const vo = await getAccountSecurityPage(meta.apiCode, { showErrorToast: false })
|
||||||
|
const mapped = mapSecurityPageView(vo, meta.defaultDocTitle)
|
||||||
|
docTitle.value = mapped.title
|
||||||
|
content.value = mapped.content
|
||||||
|
updateDate.value = mapped.updateDate
|
||||||
|
isHtml.value = mapped.isHtml
|
||||||
|
|
||||||
|
if (mapped.disabled)
|
||||||
|
loadError.value = '内容暂不可用'
|
||||||
|
else if (!mapped.content)
|
||||||
|
loadError.value = '暂无内容,请稍后再试'
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : '加载失败'
|
||||||
|
loadError.value = message
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad((query) => {
|
||||||
|
pageCode.value = resolveSecurityPageCode(typeof query?.code === 'string' ? query.code : undefined)
|
||||||
|
loadPageContent()
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
@@ -18,7 +73,7 @@ function handleBack() {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<text class="user-agreement-page__navbar-title">
|
<text class="user-agreement-page__navbar-title">
|
||||||
帮助中心
|
{{ navTitle }}
|
||||||
</text>
|
</text>
|
||||||
<view class="user-agreement-page__navbar-placeholder" />
|
<view class="user-agreement-page__navbar-placeholder" />
|
||||||
</view>
|
</view>
|
||||||
@@ -28,42 +83,44 @@ function handleBack() {
|
|||||||
scroll-y
|
scroll-y
|
||||||
>
|
>
|
||||||
<view class="user-agreement-page__content">
|
<view class="user-agreement-page__content">
|
||||||
<text class="user-agreement-page__doc-title">
|
<view
|
||||||
【平台名称】用户协议
|
v-if="loading"
|
||||||
</text>
|
class="user-agreement-page__status"
|
||||||
|
>
|
||||||
|
加载中...
|
||||||
|
</view>
|
||||||
|
|
||||||
<text class="user-agreement-page__date">
|
<view
|
||||||
更新日期:【YYYY】年【MM】月【DD】日
|
v-else-if="loadError"
|
||||||
</text>
|
class="user-agreement-page__status"
|
||||||
<text class="user-agreement-page__date">
|
>
|
||||||
生效日期:【YYYY】年【MM】月【DD】日
|
{{ loadError }}
|
||||||
</text>
|
</view>
|
||||||
|
|
||||||
<text class="user-agreement-page__section-title">
|
<template v-else>
|
||||||
导言
|
<text class="user-agreement-page__doc-title">
|
||||||
</text>
|
{{ docTitle }}
|
||||||
<text class="user-agreement-page__paragraph">
|
</text>
|
||||||
欢迎您使用【平台名称】!本平台由【公司全称】(以下简称"我们")运营,为您提供硬件电路设计、物联网全案服务、软件设计等一站式研发服务。在您注册成为本平台用户前,请您务必审慎阅读、充分理解本协议各条款内容,特别是以加粗或下划线标识的免除或限制责任的条款、知识产权条款、法律适用和争议解决条款。当您按照注册页面提示填写信息、阅读并同意本协议且完成全部注册程序后,即表示您已充分阅读、理解并接受本协议的全部内容。
|
|
||||||
</text>
|
|
||||||
|
|
||||||
<text class="user-agreement-page__section-title">
|
<text
|
||||||
第一条 定义
|
v-if="updateDate"
|
||||||
</text>
|
class="user-agreement-page__date"
|
||||||
<text class="user-agreement-page__paragraph">
|
>
|
||||||
1.1 本平台:指由【公司全称】运营的网站、移动应用程序及相关服务,包括但不限于【平台名称】官方网站及客户端。
|
更新日期:{{ updateDate }}
|
||||||
</text>
|
</text>
|
||||||
<text class="user-agreement-page__paragraph">
|
|
||||||
1.2 用户:指完成本平台注册程序,使用本平台服务的自然人、法人或其他组织。
|
<rich-text
|
||||||
</text>
|
v-if="isHtml && content"
|
||||||
<text class="user-agreement-page__paragraph">
|
class="user-agreement-page__rich"
|
||||||
1.3 企业认证:指用户向本平台提交营业执照等企业资质材料,经平台审核通过的企业身份认证流程。
|
:nodes="content"
|
||||||
</text>
|
/>
|
||||||
<text class="user-agreement-page__paragraph">
|
<text
|
||||||
1.4 项目:指用户在本平台发起的服务需求,包括但不限于硬件设计、软件开发、物联网方案等研发类任务。
|
v-else-if="content"
|
||||||
</text>
|
class="user-agreement-page__paragraph"
|
||||||
<text class="user-agreement-page__paragraph">
|
>
|
||||||
1.5 电子合同:指用户通过本平台在线签署的电子协议,与纸质合同具有同等法律效力。
|
{{ content }}
|
||||||
</text>
|
</text>
|
||||||
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import PasswordStrength from '@/pages/Login/user-register/components/PasswordStr
|
|||||||
import { getPasswordStrength } from '@/utils/password-strength'
|
import { getPasswordStrength } from '@/utils/password-strength'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
import { navigateToSecurityPage } from '@/utils/navigate-security-page'
|
||||||
import { validatePhone } from '@/utils/sms-code'
|
import { validatePhone } from '@/utils/sms-code'
|
||||||
import CodeInput from './components/CodeInput.vue'
|
import CodeInput from './components/CodeInput.vue'
|
||||||
import ForgotInput from './components/ForgotInput.vue'
|
import ForgotInput from './components/ForgotInput.vue'
|
||||||
@@ -18,7 +19,16 @@ const agreed = ref(false)
|
|||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
|
|
||||||
function toggleAgreed() {
|
function toggleAgreed() {
|
||||||
agreed.value = !agreed.value
|
uni.showModal({
|
||||||
|
title: '服务协议及隐私保护',
|
||||||
|
content: '为了更好地保障您的合法权益,请您阅读并同意《用户协议》《隐私政策》以及《定制条款》',
|
||||||
|
confirmText: '同意',
|
||||||
|
cancelText: '不同意',
|
||||||
|
confirmColor: '#2563EB',
|
||||||
|
success: (res) => {
|
||||||
|
agreed.value = !!res.confirm
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
@@ -70,9 +80,15 @@ function handleLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleUserAgreement() {
|
function handleUserAgreement() {
|
||||||
uni.navigateTo({
|
navigateToSecurityPage('userAgreement')
|
||||||
url: '/pages/Login/user-agreement/index',
|
}
|
||||||
})
|
|
||||||
|
function handlePrivacyPolicy() {
|
||||||
|
navigateToSecurityPage('privacyPolicy')
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCustomTerms() {
|
||||||
|
navigateToSecurityPage('customTerms')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -147,13 +163,19 @@ function handleUserAgreement() {
|
|||||||
<text class="forgot-page__agreement-normal">
|
<text class="forgot-page__agreement-normal">
|
||||||
和
|
和
|
||||||
</text>
|
</text>
|
||||||
<text class="forgot-page__agreement-link">
|
<text
|
||||||
|
class="forgot-page__agreement-link"
|
||||||
|
@tap.stop="handlePrivacyPolicy"
|
||||||
|
>
|
||||||
隐私政策
|
隐私政策
|
||||||
</text>
|
</text>
|
||||||
<text class="forgot-page__agreement-normal">
|
<text class="forgot-page__agreement-normal">
|
||||||
以及
|
以及
|
||||||
</text>
|
</text>
|
||||||
<text class="forgot-page__agreement-link">
|
<text
|
||||||
|
class="forgot-page__agreement-link"
|
||||||
|
@tap.stop="handleCustomTerms"
|
||||||
|
>
|
||||||
定制条款
|
定制条款
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ref } from 'vue'
|
|||||||
import { loginByPassword } from '@/api/auth'
|
import { loginByPassword } from '@/api/auth'
|
||||||
import { saveAuthSession, setLoginPhoneNumber } from '@/utils/auth-storage'
|
import { saveAuthSession, setLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
import { navigateToSecurityPage } from '@/utils/navigate-security-page'
|
||||||
import { validatePhone } from '@/utils/sms-code'
|
import { validatePhone } from '@/utils/sms-code'
|
||||||
import LoginInput from './components/LoginInput.vue'
|
import LoginInput from './components/LoginInput.vue'
|
||||||
|
|
||||||
@@ -12,7 +13,16 @@ const agreed = ref(false)
|
|||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
|
|
||||||
function toggleAgreed() {
|
function toggleAgreed() {
|
||||||
agreed.value = !agreed.value
|
uni.showModal({
|
||||||
|
title: '服务协议及隐私保护',
|
||||||
|
content: '为了更好地保障您的合法权益,请您阅读并同意《用户协议》《隐私政策》以及《定制条款》',
|
||||||
|
confirmText: '同意',
|
||||||
|
cancelText: '不同意',
|
||||||
|
confirmColor: '#2563EB',
|
||||||
|
success: (res) => {
|
||||||
|
agreed.value = !!res.confirm
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldNavigateToRegister(msg: string) {
|
function shouldNavigateToRegister(msg: string) {
|
||||||
@@ -44,7 +54,7 @@ async function handleLogin() {
|
|||||||
}, { showErrorToast: false })
|
}, { showErrorToast: false })
|
||||||
|
|
||||||
if (result.access_token)
|
if (result.access_token)
|
||||||
saveAuthSession(result.access_token, result.client_id)
|
saveAuthSession(result.access_token)
|
||||||
|
|
||||||
setLoginPhoneNumber(phone.value.trim())
|
setLoginPhoneNumber(phone.value.trim())
|
||||||
|
|
||||||
@@ -85,9 +95,15 @@ function handleRegister() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleUserAgreement() {
|
function handleUserAgreement() {
|
||||||
uni.navigateTo({
|
navigateToSecurityPage('userAgreement')
|
||||||
url: '/pages/Login/user-agreement/index',
|
}
|
||||||
})
|
|
||||||
|
function handlePrivacyPolicy() {
|
||||||
|
navigateToSecurityPage('privacyPolicy')
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCustomTerms() {
|
||||||
|
navigateToSecurityPage('customTerms')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -153,13 +169,19 @@ function handleUserAgreement() {
|
|||||||
<text class="login-page__agreement-normal">
|
<text class="login-page__agreement-normal">
|
||||||
和
|
和
|
||||||
</text>
|
</text>
|
||||||
<text class="login-page__agreement-link">
|
<text
|
||||||
|
class="login-page__agreement-link"
|
||||||
|
@tap.stop="handlePrivacyPolicy"
|
||||||
|
>
|
||||||
隐私政策
|
隐私政策
|
||||||
</text>
|
</text>
|
||||||
<text class="login-page__agreement-normal">
|
<text class="login-page__agreement-normal">
|
||||||
以及
|
以及
|
||||||
</text>
|
</text>
|
||||||
<text class="login-page__agreement-link">
|
<text
|
||||||
|
class="login-page__agreement-link"
|
||||||
|
@tap.stop="handleCustomTerms"
|
||||||
|
>
|
||||||
定制条款
|
定制条款
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ onLoad((options) => {
|
|||||||
pageType.value = 'resetPassword'
|
pageType.value = 'resetPassword'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (type === 'passwordChanged') {
|
||||||
|
pageType.value = 'passwordChanged'
|
||||||
|
return
|
||||||
|
}
|
||||||
if (type === 'loginFailed') {
|
if (type === 'loginFailed') {
|
||||||
pageType.value = 'loginFailed'
|
pageType.value = 'loginFailed'
|
||||||
return
|
return
|
||||||
@@ -63,9 +67,18 @@ onMounted(() => {
|
|||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
timer = null
|
timer = null
|
||||||
}
|
}
|
||||||
uni.redirectTo({
|
const url = redirectUrl.value
|
||||||
url: redirectUrl.value,
|
// 改密 / 找回密码 / 注册等需回登录页:用 reLaunch 清空页面栈,避免返回继续操作
|
||||||
})
|
if (
|
||||||
|
pageType.value === 'passwordChanged'
|
||||||
|
|| pageType.value === 'resetPassword'
|
||||||
|
|| pageType.value === 'register'
|
||||||
|
) {
|
||||||
|
uni.reLaunch({ url })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.redirectTo({ url })
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { register } from '@/api/auth'
|
|||||||
import { getPasswordStrength } from '@/utils/password-strength'
|
import { getPasswordStrength } from '@/utils/password-strength'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
import { navigateToSecurityPage } from '@/utils/navigate-security-page'
|
||||||
import CodeInput from './components/CodeInput.vue'
|
import CodeInput from './components/CodeInput.vue'
|
||||||
import PasswordField from './components/PasswordField.vue'
|
import PasswordField from './components/PasswordField.vue'
|
||||||
import PasswordStrength from './components/PasswordStrength.vue'
|
import PasswordStrength from './components/PasswordStrength.vue'
|
||||||
@@ -17,7 +18,16 @@ const agreed = ref(false)
|
|||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
|
|
||||||
function toggleAgreed() {
|
function toggleAgreed() {
|
||||||
agreed.value = !agreed.value
|
uni.showModal({
|
||||||
|
title: '服务协议及隐私保护',
|
||||||
|
content: '为了更好地保障您的合法权益,请您阅读并同意《用户协议》《隐私政策》以及《定制条款》',
|
||||||
|
confirmText: '同意',
|
||||||
|
cancelText: '不同意',
|
||||||
|
confirmColor: '#2563EB',
|
||||||
|
success: (res) => {
|
||||||
|
agreed.value = !!res.confirm
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleRegister() {
|
async function handleRegister() {
|
||||||
@@ -67,9 +77,15 @@ function handleLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleUserAgreement() {
|
function handleUserAgreement() {
|
||||||
uni.navigateTo({
|
navigateToSecurityPage('userAgreement')
|
||||||
url: '/pages/Login/user-agreement/index',
|
}
|
||||||
})
|
|
||||||
|
function handlePrivacyPolicy() {
|
||||||
|
navigateToSecurityPage('privacyPolicy')
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCustomTerms() {
|
||||||
|
navigateToSecurityPage('customTerms')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -145,13 +161,19 @@ function handleUserAgreement() {
|
|||||||
<text class="register-page__agreement-normal">
|
<text class="register-page__agreement-normal">
|
||||||
和
|
和
|
||||||
</text>
|
</text>
|
||||||
<text class="register-page__agreement-link">
|
<text
|
||||||
|
class="register-page__agreement-link"
|
||||||
|
@tap.stop="handlePrivacyPolicy"
|
||||||
|
>
|
||||||
隐私政策
|
隐私政策
|
||||||
</text>
|
</text>
|
||||||
<text class="register-page__agreement-normal">
|
<text class="register-page__agreement-normal">
|
||||||
以及
|
以及
|
||||||
</text>
|
</text>
|
||||||
<text class="register-page__agreement-link">
|
<text
|
||||||
|
class="register-page__agreement-link"
|
||||||
|
@tap.stop="handleCustomTerms"
|
||||||
|
>
|
||||||
定制条款
|
定制条款
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { loginBySms } from '@/api/auth'
|
|||||||
import { saveAuthSession, setLoginPhoneNumber } from '@/utils/auth-storage'
|
import { saveAuthSession, setLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
import { navigateToSecurityPage } from '@/utils/navigate-security-page'
|
||||||
import { validatePhone } from '@/utils/sms-code'
|
import { validatePhone } from '@/utils/sms-code'
|
||||||
import CodeInput from './components/CodeInput.vue'
|
import CodeInput from './components/CodeInput.vue'
|
||||||
import LoginInput from './components/LoginInput.vue'
|
import LoginInput from './components/LoginInput.vue'
|
||||||
@@ -14,7 +15,16 @@ const agreed = ref(false)
|
|||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
|
|
||||||
function toggleAgreed() {
|
function toggleAgreed() {
|
||||||
agreed.value = !agreed.value
|
uni.showModal({
|
||||||
|
title: '服务协议及隐私保护',
|
||||||
|
content: '为了更好地保障您的合法权益,请您阅读并同意《用户协议》《隐私政策》以及《定制条款》',
|
||||||
|
confirmText: '同意',
|
||||||
|
cancelText: '不同意',
|
||||||
|
confirmColor: '#2563EB',
|
||||||
|
success: (res) => {
|
||||||
|
agreed.value = !!res.confirm
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldNavigateToRegister(msg: string) {
|
function shouldNavigateToRegister(msg: string) {
|
||||||
@@ -46,7 +56,7 @@ async function handleLogin() {
|
|||||||
}, { showErrorToast: false })
|
}, { showErrorToast: false })
|
||||||
|
|
||||||
if (result.access_token)
|
if (result.access_token)
|
||||||
saveAuthSession(result.access_token, result.client_id)
|
saveAuthSession(result.access_token)
|
||||||
|
|
||||||
setLoginPhoneNumber(phone.value.trim())
|
setLoginPhoneNumber(phone.value.trim())
|
||||||
|
|
||||||
@@ -79,9 +89,15 @@ function handleRegister() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleUserAgreement() {
|
function handleUserAgreement() {
|
||||||
uni.navigateTo({
|
navigateToSecurityPage('userAgreement')
|
||||||
url: '/pages/Login/user-agreement/index',
|
}
|
||||||
})
|
|
||||||
|
function handlePrivacyPolicy() {
|
||||||
|
navigateToSecurityPage('privacyPolicy')
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCustomTerms() {
|
||||||
|
navigateToSecurityPage('customTerms')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -140,13 +156,19 @@ function handleUserAgreement() {
|
|||||||
<text class="sms-login-page__agreement-normal">
|
<text class="sms-login-page__agreement-normal">
|
||||||
和
|
和
|
||||||
</text>
|
</text>
|
||||||
<text class="sms-login-page__agreement-link">
|
<text
|
||||||
|
class="sms-login-page__agreement-link"
|
||||||
|
@tap.stop="handlePrivacyPolicy"
|
||||||
|
>
|
||||||
隐私政策
|
隐私政策
|
||||||
</text>
|
</text>
|
||||||
<text class="sms-login-page__agreement-normal">
|
<text class="sms-login-page__agreement-normal">
|
||||||
以及
|
以及
|
||||||
</text>
|
</text>
|
||||||
<text class="sms-login-page__agreement-link">
|
<text
|
||||||
|
class="sms-login-page__agreement-link"
|
||||||
|
@tap.stop="handleCustomTerms"
|
||||||
|
>
|
||||||
定制条款
|
定制条款
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -15,12 +15,15 @@ import {
|
|||||||
removeFilterTag,
|
removeFilterTag,
|
||||||
} from '@/utils/case-filter'
|
} from '@/utils/case-filter'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
cases: CaseFilterTarget[]
|
cases: CaseFilterTarget[]
|
||||||
value: CaseFilterValues
|
value: CaseFilterValues
|
||||||
industries: string[]
|
industries: string[]
|
||||||
}>()
|
industryLabel?: string
|
||||||
|
}>(), {
|
||||||
|
industryLabel: '行业',
|
||||||
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
close: []
|
close: []
|
||||||
@@ -181,7 +184,7 @@ function handleConfirm() {
|
|||||||
>
|
>
|
||||||
<view class="case-filter-panel__section">
|
<view class="case-filter-panel__section">
|
||||||
<text class="case-filter-panel__section-title">
|
<text class="case-filter-panel__section-title">
|
||||||
行业
|
{{ industryLabel }}
|
||||||
</text>
|
</text>
|
||||||
<view class="case-filter-panel__chips">
|
<view class="case-filter-panel__chips">
|
||||||
<text
|
<text
|
||||||
|
|||||||
@@ -77,21 +77,6 @@
|
|||||||
color: $color-text-placeholder;
|
color: $color-text-placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
.case-favorites__favorite-btn {
|
|
||||||
display: flex;
|
|
||||||
flex-shrink: 0;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 72rpx;
|
|
||||||
height: 72rpx;
|
|
||||||
margin-left: 16rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.case-favorites__favorite-btn-icon {
|
|
||||||
width: 40rpx;
|
|
||||||
height: 40rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.case-favorites__tabs {
|
.case-favorites__tabs {
|
||||||
margin-top: 24rpx;
|
margin-top: 24rpx;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import filterIcon from '@/static/icons/icon-filter.svg'
|
|||||||
import { ensureLoggedIn } from '@/utils/auth-guard'
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { cloneCaseFilter, matchCaseFilter } from '@/utils/case-filter'
|
import { cloneCaseFilter, matchCaseFilter } from '@/utils/case-filter'
|
||||||
|
import { ensureCaseBusinessTypeMap } from '@/utils/ensure-case-business-type-map'
|
||||||
import { mapProjectCasesToCaseItems } from '@/utils/map-case-library'
|
import { mapProjectCasesToCaseItems } from '@/utils/map-case-library'
|
||||||
import CaseCard from '../components/CaseCard.vue'
|
import CaseCard from '../components/CaseCard.vue'
|
||||||
import CaseFilterPanel from '../components/CaseFilterPanel.vue'
|
import CaseFilterPanel from '../components/CaseFilterPanel.vue'
|
||||||
@@ -64,6 +65,7 @@ async function fetchFavoriteList(reset = false) {
|
|||||||
loadingMore.value = true
|
loadingMore.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
await ensureCaseBusinessTypeMap()
|
||||||
const result = await getCaseLibraryFavoriteList({
|
const result = await getCaseLibraryFavoriteList({
|
||||||
pageNum: pageNum.value,
|
pageNum: pageNum.value,
|
||||||
pageSize: CASE_PAGE_SIZE,
|
pageSize: CASE_PAGE_SIZE,
|
||||||
@@ -226,13 +228,6 @@ function showTimePicker() {
|
|||||||
placeholder-class="case-favorites__search-placeholder"
|
placeholder-class="case-favorites__search-placeholder"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
<view class="case-favorites__favorite-btn">
|
|
||||||
<image
|
|
||||||
class="case-favorites__favorite-btn-icon"
|
|
||||||
src="/static/icons/icon-heart.svg"
|
|
||||||
mode="aspectFit"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view
|
<scroll-view
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ import type { CaseCategory, CaseFilterValues, CaseItem } from '@/types/case-libr
|
|||||||
import { ensureLoggedIn } from '@/utils/auth-guard'
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
import { buildCaseLibraryQuery } from '@/utils/build-case-library-query'
|
import { buildCaseLibraryQuery } from '@/utils/build-case-library-query'
|
||||||
import { cloneCaseFilter } from '@/utils/case-filter'
|
import { cloneCaseFilter } from '@/utils/case-filter'
|
||||||
|
import { ensureCaseBusinessTypeMap } from '@/utils/ensure-case-business-type-map'
|
||||||
|
import { fetchCaseLibraryByBusinessTypes } from '@/utils/fetch-case-library-by-types'
|
||||||
|
import { resolveBusinessTypeFilterValues } from '@/utils/format-business-type'
|
||||||
import { mapProjectCasesToCaseItems } from '@/utils/map-case-library'
|
import { mapProjectCasesToCaseItems } from '@/utils/map-case-library'
|
||||||
import filterIcon from '@/static/icons/icon-filter.svg'
|
import filterIcon from '@/static/icons/icon-filter.svg'
|
||||||
import CaseCard from './components/CaseCard.vue'
|
import CaseCard from './components/CaseCard.vue'
|
||||||
@@ -53,6 +56,8 @@ async function fetchCaseList(reset = false) {
|
|||||||
loadingMore.value = true
|
loadingMore.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
await ensureCaseBusinessTypeMap()
|
||||||
|
|
||||||
const params = buildCaseLibraryQuery({
|
const params = buildCaseLibraryQuery({
|
||||||
keyword: keyword.value,
|
keyword: keyword.value,
|
||||||
activeCategory: activeCategory.value,
|
activeCategory: activeCategory.value,
|
||||||
@@ -61,7 +66,13 @@ async function fetchCaseList(reset = false) {
|
|||||||
pageSize: CASE_PAGE_SIZE,
|
pageSize: CASE_PAGE_SIZE,
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await getCaseLibraryList(params)
|
const typeValues = activeCategory.value === '全部'
|
||||||
|
? []
|
||||||
|
: resolveBusinessTypeFilterValues(activeCategory.value)
|
||||||
|
|
||||||
|
const result = typeValues.length
|
||||||
|
? await fetchCaseLibraryByBusinessTypes(params, typeValues)
|
||||||
|
: await getCaseLibraryList(params)
|
||||||
const rows = result?.rows ?? []
|
const rows = result?.rows ?? []
|
||||||
const mapped = await mapProjectCasesToCaseItems(rows)
|
const mapped = await mapProjectCasesToCaseItems(rows)
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,18 @@
|
|||||||
height: 64rpx;
|
height: 64rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.contract-detail__loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 120rpx 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-detail__loading-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.contract-detail__scroll {
|
.contract-detail__scroll {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: 0;
|
height: 0;
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { getContract } from '@/constants/contract'
|
import { getContractDetail } from '@/api/contract'
|
||||||
import type { ContractItem } from '@/types/contract'
|
import type { ContractItem } from '@/types/contract'
|
||||||
import pdfIcon from '@/static/icons/PDF.png'
|
import pdfIcon from '@/static/icons/PDF.png'
|
||||||
|
import { openContractPreview } from '@/utils/contract-preview'
|
||||||
|
import { mapContractVoToItem } from '@/utils/map-contract'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const contract = ref<ContractItem | null>(null)
|
const contract = ref<ContractItem | null>(null)
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
const infoRows = [
|
const infoRows = [
|
||||||
{ label: '合同名称', key: 'contractName' as const },
|
{ label: '合同名称', key: 'contractName' as const },
|
||||||
@@ -19,15 +22,31 @@ const infoRows = [
|
|||||||
{ label: '合同状态', key: 'contractStatus' as const },
|
{ label: '合同状态', key: 'contractStatus' as const },
|
||||||
]
|
]
|
||||||
|
|
||||||
onLoad((options) => {
|
async function loadDetail(id: string) {
|
||||||
const rawId = options?.id
|
if (!id) {
|
||||||
const id = rawId ? decodeURIComponent(String(rawId)) : '1'
|
|
||||||
contract.value = getContract(id)
|
|
||||||
|
|
||||||
if (!contract.value) {
|
|
||||||
uni.showToast({ title: '合同不存在', icon: 'none' })
|
uni.showToast({ title: '合同不存在', icon: 'none' })
|
||||||
setTimeout(() => uni.navigateBack(), 1500)
|
setTimeout(() => uni.navigateBack(), 1500)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const vo = await getContractDetail(id)
|
||||||
|
contract.value = mapContractVoToItem(vo)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
contract.value = null
|
||||||
|
setTimeout(() => uni.navigateBack(), 1500)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
const rawId = options?.id
|
||||||
|
const id = rawId ? decodeURIComponent(String(rawId)) : ''
|
||||||
|
loadDetail(id)
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
@@ -35,20 +54,23 @@ function handleBack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleViewProject() {
|
function handleViewProject() {
|
||||||
if (!contract.value)
|
if (!contract.value?.projectId)
|
||||||
return
|
return
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/project-center/detail/index?id=${encodeURIComponent(contract.value.projectId)}`,
|
url: `/pages/project-center/detail/index?id=${encodeURIComponent(contract.value.projectId)}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handlePreviewFile() {
|
||||||
|
if (!contract.value?.id)
|
||||||
|
return
|
||||||
|
openContractPreview(contract.value.id)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view
|
<view class="contract-detail">
|
||||||
v-if="contract"
|
|
||||||
class="contract-detail"
|
|
||||||
>
|
|
||||||
<view class="contract-detail__navbar">
|
<view class="contract-detail__navbar">
|
||||||
<view
|
<view
|
||||||
class="contract-detail__back"
|
class="contract-detail__back"
|
||||||
@@ -66,7 +88,17 @@ function handleViewProject() {
|
|||||||
<view class="contract-detail__navbar-placeholder" />
|
<view class="contract-detail__navbar-placeholder" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-if="loading && !contract"
|
||||||
|
class="contract-detail__loading"
|
||||||
|
>
|
||||||
|
<text class="contract-detail__loading-text">
|
||||||
|
加载中...
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<scroll-view
|
<scroll-view
|
||||||
|
v-else-if="contract"
|
||||||
class="contract-detail__scroll"
|
class="contract-detail__scroll"
|
||||||
scroll-y
|
scroll-y
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
@@ -92,7 +124,10 @@ function handleViewProject() {
|
|||||||
<text class="contract-detail__section-title">
|
<text class="contract-detail__section-title">
|
||||||
合同文件
|
合同文件
|
||||||
</text>
|
</text>
|
||||||
<view class="contract-detail__file">
|
<view
|
||||||
|
class="contract-detail__file"
|
||||||
|
@tap="handlePreviewFile"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="contract-detail__file-icon"
|
class="contract-detail__file-icon"
|
||||||
:src="pdfIcon"
|
:src="pdfIcon"
|
||||||
|
|||||||
@@ -227,3 +227,15 @@
|
|||||||
background: $color-primary;
|
background: $color-primary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.contract-center__empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 120rpx 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-center__empty-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,28 +1,85 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { CONTRACT_LIST, CONTRACT_TABS } from '@/constants/contract'
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { getContractPage } from '@/api/contract'
|
||||||
|
import { CONTRACT_PAGE_SIZE, CONTRACT_TABS } from '@/constants/contract'
|
||||||
import type { ContractItem, ContractTab } from '@/types/contract'
|
import type { ContractItem, ContractTab } from '@/types/contract'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { downloadContractPdf, openContractPreview } from '@/utils/contract-preview'
|
||||||
|
import { mapContractTabToSignStatus, mapContractVosToItems } from '@/utils/map-contract'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
import LoadMoreFooter from '../case-library/components/LoadMoreFooter.vue'
|
||||||
|
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const activeTab = ref<ContractTab>('all')
|
const activeTab = ref<ContractTab>('all')
|
||||||
const contractList = ref(CONTRACT_LIST.map(item => ({ ...item })))
|
const contractList = ref<ContractItem[]>([])
|
||||||
|
const totalCount = ref(0)
|
||||||
|
const pageNum = ref(1)
|
||||||
|
const loadingList = ref(false)
|
||||||
|
const loadingMore = ref(false)
|
||||||
|
|
||||||
const filteredContracts = computed(() => {
|
let keywordTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
const text = keyword.value.trim()
|
|
||||||
|
|
||||||
return contractList.value.filter((item) => {
|
const hasMore = computed(() => contractList.value.length < totalCount.value)
|
||||||
const matchTab = activeTab.value === 'all'
|
const loadFinished = computed(() => !hasMore.value && contractList.value.length > 0)
|
||||||
|| (activeTab.value === 'pending' && item.signStatus === 'pending')
|
|
||||||
|| (activeTab.value === 'signed' && item.signStatus === 'signed')
|
|
||||||
const matchKeyword = !text
|
|
||||||
|| item.title.includes(text)
|
|
||||||
|| item.type.includes(text)
|
|
||||||
|| item.contractNo.includes(text)
|
|
||||||
|| item.relatedValue.includes(text)
|
|
||||||
|
|
||||||
return matchTab && matchKeyword
|
async function fetchContractList(reset = false) {
|
||||||
})
|
if (reset) {
|
||||||
|
pageNum.value = 1
|
||||||
|
contractList.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadingList.value || loadingMore.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (reset)
|
||||||
|
loadingList.value = true
|
||||||
|
else
|
||||||
|
loadingMore.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await getContractPage({
|
||||||
|
keyword: keyword.value.trim() || undefined,
|
||||||
|
signStatus: mapContractTabToSignStatus(activeTab.value),
|
||||||
|
pageNum: pageNum.value,
|
||||||
|
pageSize: CONTRACT_PAGE_SIZE,
|
||||||
|
})
|
||||||
|
const rows = result?.rows ?? []
|
||||||
|
const mapped = mapContractVosToItems(rows)
|
||||||
|
|
||||||
|
totalCount.value = Number(result?.total ?? 0)
|
||||||
|
contractList.value = reset
|
||||||
|
? mapped
|
||||||
|
: [...contractList.value, ...mapped]
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
if (reset) {
|
||||||
|
contractList.value = []
|
||||||
|
totalCount.value = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loadingList.value = false
|
||||||
|
loadingMore.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(keyword, () => {
|
||||||
|
if (keywordTimer)
|
||||||
|
clearTimeout(keywordTimer)
|
||||||
|
keywordTimer = setTimeout(() => {
|
||||||
|
fetchContractList(true)
|
||||||
|
}, 400)
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(activeTab, () => {
|
||||||
|
fetchContractList(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
fetchContractList(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
@@ -33,6 +90,13 @@ function badgeClass(type: ContractItem['badges'][number]['type']) {
|
|||||||
return `contract-center__badge--${type}`
|
return `contract-center__badge--${type}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleLoadMore() {
|
||||||
|
if (!hasMore.value || loadingList.value || loadingMore.value)
|
||||||
|
return
|
||||||
|
pageNum.value += 1
|
||||||
|
fetchContractList(false)
|
||||||
|
}
|
||||||
|
|
||||||
function handleViewDetail(item: ContractItem) {
|
function handleViewDetail(item: ContractItem) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/contract-center/detail/index?id=${encodeURIComponent(item.id)}`,
|
url: `/pages/contract-center/detail/index?id=${encodeURIComponent(item.id)}`,
|
||||||
@@ -40,11 +104,11 @@ function handleViewDetail(item: ContractItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handlePreview(item: ContractItem) {
|
function handlePreview(item: ContractItem) {
|
||||||
uni.showToast({ title: `预览${item.contractNo}开发中`, icon: 'none' })
|
openContractPreview(item.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDownload(item: ContractItem) {
|
function handleDownload(item: ContractItem) {
|
||||||
uni.showToast({ title: `下载${item.contractNo}开发中`, icon: 'none' })
|
downloadContractPdf(item.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSign(item: ContractItem) {
|
function handleSign(item: ContractItem) {
|
||||||
@@ -83,7 +147,7 @@ function handleSign(item: ContractItem) {
|
|||||||
<input
|
<input
|
||||||
v-model="keyword"
|
v-model="keyword"
|
||||||
class="contract-center__search-input"
|
class="contract-center__search-input"
|
||||||
placeholder="搜索项目标题、类型..."
|
placeholder="搜索合同编号、标题、项目..."
|
||||||
placeholder-class="contract-center__search-placeholder"
|
placeholder-class="contract-center__search-placeholder"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
@@ -107,10 +171,29 @@ function handleSign(item: ContractItem) {
|
|||||||
class="contract-center__scroll"
|
class="contract-center__scroll"
|
||||||
scroll-y
|
scroll-y
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
|
@scrolltolower="handleLoadMore"
|
||||||
>
|
>
|
||||||
<view class="contract-center__list">
|
<view class="contract-center__list">
|
||||||
<view
|
<view
|
||||||
v-for="item in filteredContracts"
|
v-if="loadingList && !contractList.length"
|
||||||
|
class="contract-center__empty"
|
||||||
|
>
|
||||||
|
<text class="contract-center__empty-text">
|
||||||
|
加载中...
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else-if="!contractList.length"
|
||||||
|
class="contract-center__empty"
|
||||||
|
>
|
||||||
|
<text class="contract-center__empty-text">
|
||||||
|
暂无合同
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-for="item in contractList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="contract-center__card"
|
class="contract-center__card"
|
||||||
>
|
>
|
||||||
@@ -172,6 +255,13 @@ function handleSign(item: ContractItem) {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<LoadMoreFooter
|
||||||
|
:loading="loadingMore"
|
||||||
|
:has-more="hasMore"
|
||||||
|
:finished="loadFinished"
|
||||||
|
@load-more="handleLoadMore"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -79,6 +79,12 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sign-success__hero-time {
|
||||||
|
margin-top: 12rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.sign-success__card {
|
.sign-success__card {
|
||||||
padding: 28rpx 24rpx;
|
padding: 28rpx 24rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
@@ -148,6 +154,11 @@
|
|||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sign-success__signature-empty {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.sign-success__footer {
|
.sign-success__footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 20rpx;
|
gap: 20rpx;
|
||||||
|
|||||||
@@ -5,13 +5,16 @@ import {
|
|||||||
CONTRACT_SIGN_PAYMENT_INFO,
|
CONTRACT_SIGN_PAYMENT_INFO,
|
||||||
CONTRACT_SIGN_SIGNATURE_STORAGE_KEY,
|
CONTRACT_SIGN_SIGNATURE_STORAGE_KEY,
|
||||||
} from '@/constants/contract-sign'
|
} from '@/constants/contract-sign'
|
||||||
import { getContract } from '@/constants/contract'
|
import { getContractDetail, getContractSignProgress } from '@/api/contract'
|
||||||
import type { ContractItem } from '@/types/contract'
|
import type { ContractItem } from '@/types/contract'
|
||||||
import successIcon from '@/static/icons/icon-register-success.png'
|
import successIcon from '@/static/icons/icon-register-success.png'
|
||||||
|
import { mapContractVoToItem } from '@/utils/map-contract'
|
||||||
|
import { pickPartyBSignatureImg } from '@/utils/map-contract-sign'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const contract = ref<ContractItem | null>(null)
|
const contract = ref<ContractItem | null>(null)
|
||||||
const signaturePreview = ref('')
|
const signaturePreview = ref('')
|
||||||
|
const signedAt = ref('')
|
||||||
|
|
||||||
const paymentInfo = CONTRACT_SIGN_PAYMENT_INFO
|
const paymentInfo = CONTRACT_SIGN_PAYMENT_INFO
|
||||||
|
|
||||||
@@ -21,10 +24,9 @@ const successSubtitle = computed(() => {
|
|||||||
return `您已成功签署《${contract.value.contractName}》`
|
return `您已成功签署《${contract.value.contractName}》`
|
||||||
})
|
})
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad(async (options) => {
|
||||||
const rawId = options?.id
|
const rawId = options?.id
|
||||||
const id = rawId ? decodeURIComponent(String(rawId)) : '2'
|
const id = rawId ? decodeURIComponent(String(rawId)) : ''
|
||||||
contract.value = getContract(id)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stored = uni.getStorageSync(CONTRACT_SIGN_SIGNATURE_STORAGE_KEY)
|
const stored = uni.getStorageSync(CONTRACT_SIGN_SIGNATURE_STORAGE_KEY)
|
||||||
@@ -35,9 +37,30 @@ onLoad((options) => {
|
|||||||
// ignore storage read errors
|
// ignore storage read errors
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!contract.value) {
|
if (!id) {
|
||||||
uni.showToast({ title: '合同不存在', icon: 'none' })
|
uni.showToast({ title: '合同不存在', icon: 'none' })
|
||||||
setTimeout(() => uni.navigateBack(), 1500)
|
setTimeout(() => uni.navigateBack(), 1500)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [vo, progress] = await Promise.all([
|
||||||
|
getContractDetail(id),
|
||||||
|
getContractSignProgress(id).catch(() => null),
|
||||||
|
])
|
||||||
|
contract.value = mapContractVoToItem(vo)
|
||||||
|
|
||||||
|
const remoteSignature = pickPartyBSignatureImg(progress)
|
||||||
|
if (remoteSignature)
|
||||||
|
signaturePreview.value = remoteSignature
|
||||||
|
|
||||||
|
const partyB = progress?.parties?.find(item => item.signerType === 'PARTY_B')
|
||||||
|
if (partyB?.signTime)
|
||||||
|
signedAt.value = partyB.signTime.replace('T', ' ').slice(0, 19)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
contract.value = null
|
||||||
|
setTimeout(() => uni.navigateBack(), 1500)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -105,6 +128,12 @@ function handleViewDetail() {
|
|||||||
<text class="sign-success__hero-subtitle">
|
<text class="sign-success__hero-subtitle">
|
||||||
{{ successSubtitle }}
|
{{ successSubtitle }}
|
||||||
</text>
|
</text>
|
||||||
|
<text
|
||||||
|
v-if="signedAt"
|
||||||
|
class="sign-success__hero-time"
|
||||||
|
>
|
||||||
|
签署时间:{{ signedAt }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
@@ -157,6 +186,12 @@ function handleViewDetail() {
|
|||||||
:src="signaturePreview"
|
:src="signaturePreview"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
|
<text
|
||||||
|
v-else
|
||||||
|
class="sign-success__signature-empty"
|
||||||
|
>
|
||||||
|
暂无签名图片
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ function handleClose() {
|
|||||||
class="signature-pad__action-btn"
|
class="signature-pad__action-btn"
|
||||||
@tap="handleConfirm"
|
@tap="handleConfirm"
|
||||||
>
|
>
|
||||||
确认签署
|
完成签名
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|||||||
@@ -142,12 +142,25 @@
|
|||||||
background: $color-bg-page;
|
background: $color-bg-page;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contract-sign__body {
|
.contract-sign__preview-card {
|
||||||
display: block;
|
display: flex;
|
||||||
font-size: 26rpx;
|
flex-direction: column;
|
||||||
line-height: 1.8;
|
gap: 12rpx;
|
||||||
|
padding: 28rpx 24rpx;
|
||||||
|
background: #f8fafc;
|
||||||
|
border: 1rpx solid #e5e7eb;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__preview-title {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
color: $color-text-primary;
|
color: $color-text-primary;
|
||||||
white-space: pre-wrap;
|
}
|
||||||
|
|
||||||
|
.contract-sign__preview-desc {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: $color-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contract-sign__signature-row {
|
.contract-sign__signature-row {
|
||||||
@@ -168,7 +181,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.contract-sign__signature-box {
|
.contract-sign__signature-box {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
height: 160rpx;
|
height: 160rpx;
|
||||||
|
overflow: hidden;
|
||||||
background: #f3f4f6;
|
background: #f3f4f6;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
|
|
||||||
@@ -178,6 +195,109 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.contract-sign__signature-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__form {
|
||||||
|
margin-top: 36rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__field {
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__field-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__input {
|
||||||
|
width: 100%;
|
||||||
|
height: 88rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-primary;
|
||||||
|
background: #f8fafc;
|
||||||
|
border: 1rpx solid #e5e7eb;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
&--code {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__placeholder {
|
||||||
|
color: $color-text-placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__code-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 16rpx;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__code-btn {
|
||||||
|
display: flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 200rpx;
|
||||||
|
height: 88rpx;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: $color-primary;
|
||||||
|
background: #eff6ff;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
color: $color-text-secondary;
|
||||||
|
background: #f3f4f6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__agreement {
|
||||||
|
display: flex;
|
||||||
|
gap: 12rpx;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-top: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__checkbox {
|
||||||
|
display: flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 32rpx;
|
||||||
|
height: 32rpx;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
border: 2rpx solid #c5cdd8;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&--checked {
|
||||||
|
background: $color-primary;
|
||||||
|
border-color: $color-primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__checkmark {
|
||||||
|
font-size: 20rpx;
|
||||||
|
line-height: 1;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contract-sign__agreement-text {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 24rpx;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.contract-sign__footer {
|
.contract-sign__footer {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
|
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
|
||||||
@@ -195,4 +315,8 @@
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
background: $color-primary;
|
background: $color-primary;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,97 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { computed, onUnmounted, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import {
|
import {
|
||||||
CONTRACT_SIGN_BODY,
|
confirmContractSign,
|
||||||
CONTRACT_SIGN_SIGNATURE_STORAGE_KEY,
|
getContractDetail,
|
||||||
CONTRACT_SIGN_STEPS,
|
getContractPreview,
|
||||||
} from '@/constants/contract-sign'
|
getContractSignProgress,
|
||||||
import { getContract } from '@/constants/contract'
|
initContractSign,
|
||||||
|
sendContractSignSmsCode,
|
||||||
|
} from '@/api/contract'
|
||||||
|
import { uploadRequirementAttachment } from '@/api/requirement'
|
||||||
|
import { CONTRACT_SIGN_SIGNATURE_STORAGE_KEY } from '@/constants/contract-sign'
|
||||||
import type { ContractItem } from '@/types/contract'
|
import type { ContractItem } from '@/types/contract'
|
||||||
|
import type { ContractSignProgressVo } from '@/types/contract-api'
|
||||||
|
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
|
import { openContractPreview } from '@/utils/contract-preview'
|
||||||
|
import { mapContractVoToItem } from '@/utils/map-contract'
|
||||||
|
import {
|
||||||
|
mapContractSignStatusLabel,
|
||||||
|
mapContractSignSteps,
|
||||||
|
pickPartyBSignId,
|
||||||
|
} from '@/utils/map-contract-sign'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
import { validatePhone } from '@/utils/sms-code'
|
||||||
import SignaturePad from './components/SignaturePad.vue'
|
import SignaturePad from './components/SignaturePad.vue'
|
||||||
|
|
||||||
const contract = ref<ContractItem | null>(null)
|
const contract = ref<ContractItem | null>(null)
|
||||||
const signSteps = CONTRACT_SIGN_STEPS
|
const progress = ref<ContractSignProgressVo | null>(null)
|
||||||
const contractBody = CONTRACT_SIGN_BODY
|
const previewTitle = ref('')
|
||||||
|
const previewReady = ref(false)
|
||||||
|
const previewOpened = ref(false)
|
||||||
const signaturePadVisible = ref(false)
|
const signaturePadVisible = ref(false)
|
||||||
const partyBSignaturePreview = ref(false)
|
const signatureLocalPath = ref('')
|
||||||
|
const signaturePreview = ref(false)
|
||||||
|
const agreed = ref(false)
|
||||||
|
const mobile = ref('')
|
||||||
|
const smsCode = ref('')
|
||||||
|
const signId = ref('')
|
||||||
|
const countdown = ref(0)
|
||||||
|
const sendingCode = ref(false)
|
||||||
|
const submitting = ref(false)
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
onLoad((options) => {
|
const signSteps = computed(() => mapContractSignSteps(progress.value))
|
||||||
|
const signStatusLabel = computed(() => mapContractSignStatusLabel(
|
||||||
|
progress.value?.signStatus || (contract.value?.signStatus === 'signed' ? 'SIGNED' : 'PENDING'),
|
||||||
|
))
|
||||||
|
const alreadySigned = computed(() => progress.value?.signStatus === 'SIGNED')
|
||||||
|
|
||||||
|
onLoad(async (options) => {
|
||||||
const rawId = options?.id
|
const rawId = options?.id
|
||||||
const id = rawId ? decodeURIComponent(String(rawId)) : '2'
|
const id = rawId ? decodeURIComponent(String(rawId)) : ''
|
||||||
contract.value = getContract(id)
|
if (!id) {
|
||||||
|
|
||||||
if (!contract.value) {
|
|
||||||
uni.showToast({ title: '合同不存在', icon: 'none' })
|
uni.showToast({ title: '合同不存在', icon: 'none' })
|
||||||
setTimeout(() => uni.navigateBack(), 1500)
|
setTimeout(() => uni.navigateBack(), 1500)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mobile.value = getLoginPhoneNumber()?.trim() || ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [vo, preview, signProgress] = await Promise.all([
|
||||||
|
getContractDetail(id),
|
||||||
|
getContractPreview(id),
|
||||||
|
getContractSignProgress(id).catch(() => null),
|
||||||
|
])
|
||||||
|
contract.value = mapContractVoToItem(vo)
|
||||||
|
previewTitle.value = preview.title || vo.title || '合同正文'
|
||||||
|
previewReady.value = Boolean(preview.file)
|
||||||
|
progress.value = signProgress
|
||||||
|
const existingSignId = pickPartyBSignId(signProgress)
|
||||||
|
if (existingSignId)
|
||||||
|
signId.value = existingSignId
|
||||||
|
|
||||||
|
if (signProgress?.signStatus === 'SIGNED') {
|
||||||
|
uni.showToast({ title: '合同已签署', icon: 'none' })
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/contract-center/sign-success/index?id=${encodeURIComponent(id)}`,
|
||||||
|
})
|
||||||
|
}, 800)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
contract.value = null
|
||||||
|
setTimeout(() => uni.navigateBack(), 1500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -32,7 +99,17 @@ function handleBack() {
|
|||||||
navigateBackWithFallback('/pages/contract-center/index')
|
navigateBackWithFallback('/pages/contract-center/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleOpenFullContract() {
|
||||||
|
if (!contract.value)
|
||||||
|
return
|
||||||
|
const result = await openContractPreview(contract.value.id)
|
||||||
|
if (result)
|
||||||
|
previewOpened.value = true
|
||||||
|
}
|
||||||
|
|
||||||
function openSignaturePad() {
|
function openSignaturePad() {
|
||||||
|
if (alreadySigned.value)
|
||||||
|
return
|
||||||
signaturePadVisible.value = true
|
signaturePadVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,25 +117,146 @@ function closeSignaturePad() {
|
|||||||
signaturePadVisible.value = false
|
signaturePadVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSignConfirm(imagePath: string) {
|
function handleSignatureConfirm(imagePath: string) {
|
||||||
|
signatureLocalPath.value = imagePath
|
||||||
|
signaturePreview.value = Boolean(imagePath)
|
||||||
|
signaturePadVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCountdown() {
|
||||||
|
countdown.value = 60
|
||||||
|
if (timer)
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = setInterval(() => {
|
||||||
|
countdown.value -= 1
|
||||||
|
if (countdown.value <= 0 && timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ensureSignInit() {
|
||||||
if (!contract.value)
|
if (!contract.value)
|
||||||
|
throw new Error('合同不存在')
|
||||||
|
if (signId.value)
|
||||||
|
return signId.value
|
||||||
|
|
||||||
|
const mobileValue = mobile.value.trim()
|
||||||
|
const id = await initContractSign(contract.value.id, {
|
||||||
|
signType: 'sms',
|
||||||
|
mobile: mobileValue,
|
||||||
|
})
|
||||||
|
signId.value = String(id)
|
||||||
|
const latest = await getContractSignProgress(contract.value.id).catch(() => null)
|
||||||
|
if (latest)
|
||||||
|
progress.value = latest
|
||||||
|
return signId.value
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSendCode() {
|
||||||
|
if (!contract.value || countdown.value > 0 || sendingCode.value || alreadySigned.value)
|
||||||
return
|
return
|
||||||
|
|
||||||
partyBSignaturePreview.value = true
|
if (!validatePhone(mobile.value))
|
||||||
signaturePadVisible.value = false
|
return
|
||||||
|
|
||||||
if (imagePath) {
|
sendingCode.value = true
|
||||||
try {
|
try {
|
||||||
uni.setStorageSync(CONTRACT_SIGN_SIGNATURE_STORAGE_KEY, imagePath)
|
await ensureSignInit()
|
||||||
}
|
await sendContractSignSmsCode(contract.value.id, {
|
||||||
catch {
|
mobile: mobile.value.trim(),
|
||||||
// ignore storage write errors
|
})
|
||||||
}
|
uni.showToast({ title: '验证码已发送', icon: 'none' })
|
||||||
|
startCountdown()
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
sendingCode.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadSignatureUrl() {
|
||||||
|
if (!signatureLocalPath.value)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
const uploaded = await uploadRequirementAttachment(signatureLocalPath.value)
|
||||||
|
const url = uploaded.url?.trim() || ''
|
||||||
|
if (!url)
|
||||||
|
throw new Error('签名上传失败')
|
||||||
|
if (url.length > 255)
|
||||||
|
throw new Error('签名地址过长,请重试')
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
if (!contract.value || submitting.value || alreadySigned.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!previewReady.value) {
|
||||||
|
uni.showToast({ title: '暂无合同文件,无法签署', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!previewOpened.value) {
|
||||||
|
uni.showToast({ title: '请先查看完整合同', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!agreed.value) {
|
||||||
|
uni.showToast({ title: '请勾选电子签服务协议', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!validatePhone(mobile.value))
|
||||||
|
return
|
||||||
|
if (!smsCode.value.trim()) {
|
||||||
|
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.redirectTo({
|
submitting.value = true
|
||||||
url: `/pages/contract-center/sign-success/index?id=${encodeURIComponent(contract.value.id)}`,
|
uni.showLoading({ title: '签署中...', mask: true })
|
||||||
})
|
try {
|
||||||
|
const currentSignId = await ensureSignInit()
|
||||||
|
let signatureImg = ''
|
||||||
|
try {
|
||||||
|
signatureImg = await uploadSignatureUrl()
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : '签名上传失败'
|
||||||
|
uni.showToast({ title: message, icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (signatureLocalPath.value) {
|
||||||
|
try {
|
||||||
|
uni.setStorageSync(CONTRACT_SIGN_SIGNATURE_STORAGE_KEY, signatureLocalPath.value)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await confirmContractSign(contract.value.id, {
|
||||||
|
signId: currentSignId,
|
||||||
|
code: smsCode.value.trim(),
|
||||||
|
agreementFlag: true,
|
||||||
|
signatureImg: signatureImg || undefined,
|
||||||
|
signPosition: '乙方签字处',
|
||||||
|
})
|
||||||
|
progress.value = result
|
||||||
|
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/contract-center/sign-success/index?id=${encodeURIComponent(contract.value.id)}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -89,7 +287,7 @@ function handleSignConfirm(imagePath: string) {
|
|||||||
{{ contract.contractName }}
|
{{ contract.contractName }}
|
||||||
</text>
|
</text>
|
||||||
<text class="contract-sign__status">
|
<text class="contract-sign__status">
|
||||||
待签署
|
{{ signStatusLabel }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -135,9 +333,17 @@ function handleSignConfirm(imagePath: string) {
|
|||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
>
|
>
|
||||||
<view class="contract-sign__content">
|
<view class="contract-sign__content">
|
||||||
<text class="contract-sign__body">
|
<view
|
||||||
{{ contractBody }}
|
class="contract-sign__preview-card"
|
||||||
</text>
|
@tap="handleOpenFullContract"
|
||||||
|
>
|
||||||
|
<text class="contract-sign__preview-title">
|
||||||
|
{{ previewTitle || '合同正文' }}
|
||||||
|
</text>
|
||||||
|
<text class="contract-sign__preview-desc">
|
||||||
|
{{ previewReady ? (previewOpened ? '已查看,可再次打开' : '点击查看完整合同(签署前必读)') : '暂无合同预览文件' }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="contract-sign__signature-row">
|
<view class="contract-sign__signature-row">
|
||||||
<view class="contract-sign__signature-col">
|
<view class="contract-sign__signature-col">
|
||||||
@@ -152,9 +358,77 @@ function handleSignConfirm(imagePath: string) {
|
|||||||
</text>
|
</text>
|
||||||
<view
|
<view
|
||||||
class="contract-sign__signature-box"
|
class="contract-sign__signature-box"
|
||||||
:class="{ 'contract-sign__signature-box--done': partyBSignaturePreview }"
|
:class="{ 'contract-sign__signature-box--done': signaturePreview }"
|
||||||
@tap="openSignaturePad"
|
@tap="openSignaturePad"
|
||||||
/>
|
>
|
||||||
|
<image
|
||||||
|
v-if="signatureLocalPath"
|
||||||
|
class="contract-sign__signature-image"
|
||||||
|
:src="signatureLocalPath"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="contract-sign__form">
|
||||||
|
<view class="contract-sign__field">
|
||||||
|
<text class="contract-sign__field-label">
|
||||||
|
签署手机号
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="mobile"
|
||||||
|
class="contract-sign__input"
|
||||||
|
type="number"
|
||||||
|
maxlength="11"
|
||||||
|
placeholder="请输入注册手机号"
|
||||||
|
placeholder-class="contract-sign__placeholder"
|
||||||
|
:disabled="alreadySigned"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="contract-sign__field">
|
||||||
|
<text class="contract-sign__field-label">
|
||||||
|
短信验证码
|
||||||
|
</text>
|
||||||
|
<view class="contract-sign__code-row">
|
||||||
|
<input
|
||||||
|
v-model="smsCode"
|
||||||
|
class="contract-sign__input contract-sign__input--code"
|
||||||
|
type="number"
|
||||||
|
maxlength="6"
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
placeholder-class="contract-sign__placeholder"
|
||||||
|
:disabled="alreadySigned"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
class="contract-sign__code-btn"
|
||||||
|
:class="{ 'contract-sign__code-btn--disabled': countdown > 0 || sendingCode || alreadySigned }"
|
||||||
|
@tap="handleSendCode"
|
||||||
|
>
|
||||||
|
{{ countdown > 0 ? `${countdown}s` : '获取验证码' }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
class="contract-sign__agreement"
|
||||||
|
@tap="agreed = !agreed"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
class="contract-sign__checkbox"
|
||||||
|
:class="{ 'contract-sign__checkbox--checked': agreed }"
|
||||||
|
>
|
||||||
|
<text
|
||||||
|
v-if="agreed"
|
||||||
|
class="contract-sign__checkmark"
|
||||||
|
>
|
||||||
|
✓
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<text class="contract-sign__agreement-text">
|
||||||
|
我已阅读并同意电子签服务协议,确认签署本合同
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -163,16 +437,17 @@ function handleSignConfirm(imagePath: string) {
|
|||||||
<view class="contract-sign__footer">
|
<view class="contract-sign__footer">
|
||||||
<view
|
<view
|
||||||
class="contract-sign__submit-btn"
|
class="contract-sign__submit-btn"
|
||||||
@tap="openSignaturePad"
|
:class="{ 'contract-sign__submit-btn--disabled': submitting || alreadySigned }"
|
||||||
|
@tap="handleSubmit"
|
||||||
>
|
>
|
||||||
立即签署
|
{{ alreadySigned ? '已签署' : '确认签署' }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<SignaturePad
|
<SignaturePad
|
||||||
:visible="signaturePadVisible"
|
:visible="signaturePadVisible"
|
||||||
@close="closeSignaturePad"
|
@close="closeSignaturePad"
|
||||||
@confirm="handleSignConfirm"
|
@confirm="handleSignatureConfirm"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ function handleSubmit() {
|
|||||||
return
|
return
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/home-index/requirement-submit/index?businessType=${encodeURIComponent(detail.value.title)}&detailId=${detail.value.id}`,
|
url: `/pages/home-index/requirement-submit/index?businessType=${encodeURIComponent(detail.value.title)}&detailId=${detail.value.id}&newFlag=false`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
function handleQuickSubmit() {
|
function handleQuickSubmit() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/home-index/requirement-submit/index',
|
url: '/pages/home-index/requirement-submit/index?newFlag=true',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,25 @@
|
|||||||
import type { ProjectItem } from '@/types/home'
|
import type { ProjectItem } from '@/types/home'
|
||||||
import cardBg from '@/static/icons/new-card.png'
|
import cardBg from '@/static/icons/new-card.png'
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
item: ProjectItem
|
item: ProjectItem
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
detail: [id: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
function handleTap() {
|
||||||
|
if (props.item.id)
|
||||||
|
emit('detail', props.item.id)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="project-card">
|
<view
|
||||||
|
class="project-card"
|
||||||
|
@tap="handleTap"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="project-card__bg"
|
class="project-card__bg"
|
||||||
:src="cardBg"
|
:src="cardBg"
|
||||||
|
|||||||
@@ -7,10 +7,6 @@
|
|||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
&--with-illus {
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--blue {
|
&--blue {
|
||||||
background: linear-gradient(180deg, #D3E1FC 0%, #FFFFFF 100%);
|
background: linear-gradient(180deg, #D3E1FC 0%, #FFFFFF 100%);
|
||||||
}
|
}
|
||||||
@@ -34,12 +30,13 @@
|
|||||||
|
|
||||||
.service-card__illus {
|
.service-card__illus {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -36rpx;
|
top: 16rpx;
|
||||||
right: -10rpx;
|
right: 16rpx;
|
||||||
z-index: 2;
|
z-index: 0;
|
||||||
width: 152rpx;
|
width: 88rpx;
|
||||||
height: 152rpx;
|
height: 88rpx;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
opacity: 0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.service-card__content {
|
.service-card__content {
|
||||||
@@ -64,8 +61,13 @@
|
|||||||
color: #666666;
|
color: #666666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.service-card--with-illus .service-card__title,
|
||||||
.service-card--with-illus .service-card__desc {
|
.service-card--with-illus .service-card__desc {
|
||||||
margin-top: 28rpx;
|
max-width: calc(100% - 100rpx);
|
||||||
|
}
|
||||||
|
|
||||||
|
.service-card--with-illus .service-card__desc {
|
||||||
|
margin-top: 12rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.service-card__link {
|
.service-card__link {
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onShow } from '@dcloudio/uni-app'
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { getBannerList } from '@/api/banner'
|
import { getBannerList } from '@/api/banner'
|
||||||
import { getProjectSubmissionList } from '@/api/project-submission'
|
import { getProjectSubmissionList } from '@/api/project-submission'
|
||||||
|
import { getRequirementOngoing } from '@/api/requirement'
|
||||||
import AppTabBar from '@/components/AppTabBar.vue'
|
import AppTabBar from '@/components/AppTabBar.vue'
|
||||||
import { useGreeting } from '@/hooks/use-greeting'
|
import { useGreeting } from '@/hooks/use-greeting'
|
||||||
import { useQuickEntries } from '@/hooks/use-quick-entries'
|
import { useQuickEntries } from '@/hooks/use-quick-entries'
|
||||||
import type { BannerItem } from '@/types/banner'
|
import type { BannerItem } from '@/types/banner'
|
||||||
import type { ProjectItem, QuickEntryItem, ServiceItem } from '@/types/home'
|
import type { ProjectItem, QuickEntryItem, ServiceItem } from '@/types/home'
|
||||||
import { ensureLoggedIn } from '@/utils/auth-guard'
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { mapOngoingOverviewToHome } from '@/utils/map-ongoing-overview'
|
||||||
import { mapProjectSubmissionsToServices } from '@/utils/map-project-submission'
|
import { mapProjectSubmissionsToServices } from '@/utils/map-project-submission'
|
||||||
import { navigateQuickEntry } from '@/utils/quick-entry-navigate'
|
import { navigateQuickEntry } from '@/utils/quick-entry-navigate'
|
||||||
import headerBg from '@/static/icons/1.png'
|
import headerBg from '@/static/icons/1.png'
|
||||||
@@ -31,6 +33,9 @@ const {
|
|||||||
|
|
||||||
const banners = ref<BannerItem[]>([])
|
const banners = ref<BannerItem[]>([])
|
||||||
const services = ref<ServiceItem[]>([])
|
const services = ref<ServiceItem[]>([])
|
||||||
|
const ongoingCount = ref(0)
|
||||||
|
const todoCount = ref(0)
|
||||||
|
const ongoingProjects = ref<ProjectItem[]>([])
|
||||||
|
|
||||||
async function loadBanners() {
|
async function loadBanners() {
|
||||||
try {
|
try {
|
||||||
@@ -54,11 +59,27 @@ async function loadProjectSubmissions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadOngoingProjects() {
|
||||||
|
try {
|
||||||
|
const overview = await getRequirementOngoing({ limit: 5 })
|
||||||
|
const mapped = mapOngoingOverviewToHome(overview)
|
||||||
|
ongoingCount.value = mapped.ongoingCount
|
||||||
|
todoCount.value = mapped.todoCount
|
||||||
|
ongoingProjects.value = mapped.projects
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
ongoingCount.value = 0
|
||||||
|
todoCount.value = 0
|
||||||
|
ongoingProjects.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
if (!ensureLoggedIn())
|
if (!ensureLoggedIn())
|
||||||
return
|
return
|
||||||
loadBanners()
|
loadBanners()
|
||||||
loadProjectSubmissions()
|
loadProjectSubmissions()
|
||||||
|
loadOngoingProjects()
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleQuickEntryTap(entry: QuickEntryItem) {
|
function handleQuickEntryTap(entry: QuickEntryItem) {
|
||||||
@@ -69,28 +90,21 @@ function handleViewAllProjects() {
|
|||||||
navigateQuickEntry('project', '项目中心')
|
navigateQuickEntry('project', '项目中心')
|
||||||
}
|
}
|
||||||
|
|
||||||
const projects: ProjectItem[] = [
|
function handleOngoingProjectDetail(id: string) {
|
||||||
{
|
uni.navigateTo({
|
||||||
id: '1',
|
url: `/pages/project-center/detail/index?id=${encodeURIComponent(id)}`,
|
||||||
title: '社区康养智能服务系统',
|
})
|
||||||
category: '互联网软件',
|
}
|
||||||
projectNo: '20260813RJ251545',
|
|
||||||
progress: 65,
|
function handleOpenMessageCenter() {
|
||||||
status: '进行中',
|
uni.redirectTo({ url: '/pages/message-center/index' })
|
||||||
updateTime: '2026-8-13 11:04:12',
|
}
|
||||||
tagTheme: 'orange',
|
|
||||||
},
|
const ongoingSubtitle = computed(() => {
|
||||||
{
|
if (ongoingCount.value <= 0)
|
||||||
id: '2',
|
return '暂无进行中的项目'
|
||||||
title: '社区康养智能服务系统',
|
return `今天有${ongoingCount.value}个项目正在进行`
|
||||||
category: '生产制造',
|
})
|
||||||
projectNo: '20260813RJ251545',
|
|
||||||
progress: 65,
|
|
||||||
status: '进行中',
|
|
||||||
updateTime: '2026-8-13 11:04:12',
|
|
||||||
tagTheme: 'orange',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -113,7 +127,10 @@ const projects: ProjectItem[] = [
|
|||||||
虫子智造研发一体化平台
|
虫子智造研发一体化平台
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="home__message-btn">
|
<view
|
||||||
|
class="home__message-btn"
|
||||||
|
@tap="handleOpenMessageCenter"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="home__message-icon"
|
class="home__message-icon"
|
||||||
src="/static/icons/icon-message.png"
|
src="/static/icons/icon-message.png"
|
||||||
@@ -135,7 +152,7 @@ const projects: ProjectItem[] = [
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="home__subtitle">
|
<text class="home__subtitle">
|
||||||
今天有2个项目正在进行
|
{{ ongoingSubtitle }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -218,7 +235,7 @@ const projects: ProjectItem[] = [
|
|||||||
<view class="home__stat-card home__stat-card--blue">
|
<view class="home__stat-card home__stat-card--blue">
|
||||||
<view class="home__stat-value">
|
<view class="home__stat-value">
|
||||||
<text class="home__stat-num">
|
<text class="home__stat-num">
|
||||||
3
|
{{ ongoingCount }}
|
||||||
</text>
|
</text>
|
||||||
<text class="home__stat-unit">
|
<text class="home__stat-unit">
|
||||||
个项目
|
个项目
|
||||||
@@ -231,7 +248,7 @@ const projects: ProjectItem[] = [
|
|||||||
<view class="home__stat-card home__stat-card--orange">
|
<view class="home__stat-card home__stat-card--orange">
|
||||||
<view class="home__stat-value">
|
<view class="home__stat-value">
|
||||||
<text class="home__stat-num">
|
<text class="home__stat-num">
|
||||||
3
|
{{ todoCount }}
|
||||||
</text>
|
</text>
|
||||||
<text class="home__stat-unit">
|
<text class="home__stat-unit">
|
||||||
项待办
|
项待办
|
||||||
@@ -248,10 +265,17 @@ const projects: ProjectItem[] = [
|
|||||||
</text>
|
</text>
|
||||||
|
|
||||||
<ProjectCard
|
<ProjectCard
|
||||||
v-for="item in projects"
|
v-for="item in ongoingProjects"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:item="item"
|
:item="item"
|
||||||
|
@detail="handleOngoingProjectDetail"
|
||||||
/>
|
/>
|
||||||
|
<text
|
||||||
|
v-if="!ongoingProjects.length"
|
||||||
|
class="home__service-empty"
|
||||||
|
>
|
||||||
|
暂无最近更新项目
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ async function loadDetail(id: string) {
|
|||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
const id = options?.id as string
|
const id = options?.id as string
|
||||||
if (!id) {
|
if (!id) {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
uni.showToast({ title: '参数错误', icon: 'none' })
|
uni.showToast({ title: '参数错误', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ function handleSubmit() {
|
|||||||
|
|
||||||
const businessType = detail.value.businessType || detail.value.title
|
const businessType = detail.value.businessType || detail.value.title
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/home-index/requirement-submit/index?submissionId=${detail.value.id}&businessType=${encodeURIComponent(businessType)}`,
|
url: `/pages/home-index/requirement-submit/index?submissionId=${detail.value.id}&businessType=${encodeURIComponent(businessType)}&newFlag=false`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,37 +1,154 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
import { BUSINESS_TYPE_DETAIL_ID, BUSINESS_TYPE_OPTIONS } from '@/constants/business-types'
|
import { getRequirementDraft, saveRequirementDraft, submitRequirement, uploadRequirementAttachment } from '@/api/requirement'
|
||||||
|
import { BUSINESS_TYPE_DETAIL_ID, isRequirementBusinessType } from '@/constants/business-types'
|
||||||
|
import { useRequirementBusinessTypes } from '@/hooks/use-requirement-business-types'
|
||||||
import { ensureLoggedIn } from '@/utils/auth-guard'
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
|
import { isDraftForBusinessType, mapRequirementDraftToForm } from '@/utils/apply-requirement-draft'
|
||||||
|
import { buildRequirementDraftPayload } from '@/utils/build-requirement-draft-payload'
|
||||||
|
import { buildRequirementSubmitPayload } from '@/utils/build-requirement-submit-payload'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
import { validatePhone } from '@/utils/sms-code'
|
||||||
|
import {
|
||||||
|
chooseLocalFiles,
|
||||||
|
REQUIREMENT_ATTACHMENT_MAX_COUNT,
|
||||||
|
} from '@/utils/choose-local-files'
|
||||||
import deleteIcon from '@/static/icons/X.png'
|
import deleteIcon from '@/static/icons/X.png'
|
||||||
import pdfIcon from '@/static/icons/PDF.png'
|
import pdfIcon from '@/static/icons/PDF.png'
|
||||||
import pngIcon from '@/static/icons/PNG.png'
|
import pngIcon from '@/static/icons/PNG.png'
|
||||||
|
|
||||||
|
const { businessTypes, loadRequirementBusinessTypes } = useRequirementBusinessTypes()
|
||||||
|
|
||||||
const businessType = ref('')
|
const businessType = ref('')
|
||||||
const detailId = ref('software')
|
const detailId = ref('software')
|
||||||
const businessTypeDropdownVisible = ref(false)
|
const businessTypeDropdownVisible = ref(false)
|
||||||
const businessTypeOptions = BUSINESS_TYPE_OPTIONS
|
|
||||||
const projectName = ref('')
|
const projectName = ref('')
|
||||||
const description = ref('')
|
const description = ref('')
|
||||||
const budget = ref('')
|
const budget = ref('')
|
||||||
const cycle = ref('')
|
const cycle = ref('')
|
||||||
const userName = ref('王永志')
|
const userName = ref('')
|
||||||
const userPhone = ref('186****9618')
|
const userPhone = ref('')
|
||||||
const remark = ref('')
|
const remark = ref('')
|
||||||
|
const submitting = ref(false)
|
||||||
|
const savingDraft = ref(false)
|
||||||
|
const loadingDraft = ref(false)
|
||||||
|
/** 已加载草稿的业务类型,避免 onShow 重复覆盖表单 */
|
||||||
|
const loadedDraftBizType = ref('')
|
||||||
|
/** true=快捷填报,不读取历史草稿 */
|
||||||
|
const newFlag = ref(false)
|
||||||
|
const uploadingAttachment = ref(false)
|
||||||
|
|
||||||
const budgetOptions = ['1万以下', '1-5万', '5-10万', '10万+']
|
const budgetOptions = ['1万以下', '1-5万', '5-10万', '10万+']
|
||||||
|
|
||||||
const attachments = ref([
|
interface RequirementAttachmentItem {
|
||||||
{ id: '1', name: '需求文档.pdf', type: 'pdf', icon: pdfIcon },
|
id: string
|
||||||
{ id: '2', name: '参考图.png', type: 'png', icon: pdfIcon},
|
name: string
|
||||||
{ id: '3', name: '合同模板.pdf', type: 'pdf', icon: pngIcon },
|
type: string
|
||||||
])
|
icon: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const attachments = ref<RequirementAttachmentItem[]>([])
|
||||||
|
|
||||||
const descLength = computed(() => description.value.length)
|
const descLength = computed(() => description.value.length)
|
||||||
|
|
||||||
|
function resolveAttachmentIcon(name: string) {
|
||||||
|
const ext = name.split('.').pop()?.toLowerCase()
|
||||||
|
if (ext === 'png' || ext === 'jpg' || ext === 'jpeg')
|
||||||
|
return pngIcon
|
||||||
|
|
||||||
|
return pdfIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseNewFlag(options?: Record<string, string | undefined>) {
|
||||||
|
if (options?.newFlag === 'true' || options?.newFlag === '1' || options?.quick === '1')
|
||||||
|
return true
|
||||||
|
if (options?.newFlag === 'false' || options?.newFlag === '0')
|
||||||
|
return false
|
||||||
|
return !options?.businessType
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyDraftAttachments(ids: number[]) {
|
||||||
|
if (!ids.length) {
|
||||||
|
attachments.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
attachments.value = ids.map((id) => ({
|
||||||
|
id: String(id),
|
||||||
|
name: `附件${id}`,
|
||||||
|
type: 'file',
|
||||||
|
icon: pdfIcon,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyDraftForm(values: ReturnType<typeof mapRequirementDraftToForm>) {
|
||||||
|
if (!values)
|
||||||
|
return
|
||||||
|
|
||||||
|
projectName.value = values.projectName
|
||||||
|
description.value = values.description
|
||||||
|
budget.value = values.budget
|
||||||
|
cycle.value = values.cycle
|
||||||
|
remark.value = values.remark
|
||||||
|
if (values.userName)
|
||||||
|
userName.value = values.userName
|
||||||
|
if (values.userPhone)
|
||||||
|
userPhone.value = values.userPhone
|
||||||
|
applyDraftAttachments(values.attachmentIds)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 切换业务类型或重新拉草稿前清空,避免上一类型草稿残留在当前类型 */
|
||||||
|
function resetFormDraftFields() {
|
||||||
|
projectName.value = ''
|
||||||
|
description.value = ''
|
||||||
|
budget.value = ''
|
||||||
|
cycle.value = ''
|
||||||
|
remark.value = ''
|
||||||
|
attachments.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadRequirementDraftForm(force = false) {
|
||||||
|
if (newFlag.value || !businessType.value || loadingDraft.value)
|
||||||
|
return
|
||||||
|
if (!isRequirementBusinessType(businessType.value))
|
||||||
|
return
|
||||||
|
|
||||||
|
const targetBusinessType = businessType.value.trim()
|
||||||
|
if (!force && loadedDraftBizType.value === targetBusinessType)
|
||||||
|
return
|
||||||
|
|
||||||
|
resetFormDraftFields()
|
||||||
|
|
||||||
|
loadingDraft.value = true
|
||||||
|
try {
|
||||||
|
const draft = await getRequirementDraft({
|
||||||
|
businessType: targetBusinessType,
|
||||||
|
newFlag: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isDraftForBusinessType(draft, targetBusinessType)) {
|
||||||
|
const values = mapRequirementDraftToForm(draft)
|
||||||
|
if (values)
|
||||||
|
applyDraftForm(values)
|
||||||
|
}
|
||||||
|
|
||||||
|
loadedDraftBizType.value = targetBusinessType
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
loadedDraftBizType.value = targetBusinessType
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loadingDraft.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
|
loadedDraftBizType.value = ''
|
||||||
|
newFlag.value = parseNewFlag(options)
|
||||||
|
|
||||||
if (options?.detailId)
|
if (options?.detailId)
|
||||||
detailId.value = options.detailId as string
|
detailId.value = options.detailId as string
|
||||||
|
|
||||||
@@ -43,7 +160,16 @@ onLoad((options) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
ensureLoggedIn()
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
loadRequirementBusinessTypes()
|
||||||
|
|
||||||
|
const phone = getLoginPhoneNumber()
|
||||||
|
if (phone && !userPhone.value)
|
||||||
|
userPhone.value = phone
|
||||||
|
|
||||||
|
loadRequirementDraftForm()
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
@@ -60,8 +186,21 @@ function closeBusinessTypeDropdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSelectBusinessType(option: string) {
|
function handleSelectBusinessType(option: string) {
|
||||||
|
if (businessType.value === option) {
|
||||||
|
closeBusinessTypeDropdown()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
businessType.value = option
|
businessType.value = option
|
||||||
closeBusinessTypeDropdown()
|
closeBusinessTypeDropdown()
|
||||||
|
loadedDraftBizType.value = ''
|
||||||
|
|
||||||
|
if (newFlag.value) {
|
||||||
|
resetFormDraftFields()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loadRequirementDraftForm(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelectBudget(value: string) {
|
function handleSelectBudget(value: string) {
|
||||||
@@ -72,23 +211,118 @@ function handleRemoveAttachment(id: string) {
|
|||||||
attachments.value = attachments.value.filter(item => item.id !== id)
|
attachments.value = attachments.value.filter(item => item.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAddAttachment() {
|
async function handleAddAttachment() {
|
||||||
uni.showToast({ title: '附件上传开发中', icon: 'none' })
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (uploadingAttachment.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const remain = REQUIREMENT_ATTACHMENT_MAX_COUNT - attachments.value.length
|
||||||
|
if (remain <= 0) {
|
||||||
|
uni.showToast({ title: `最多上传${REQUIREMENT_ATTACHMENT_MAX_COUNT}个附件`, icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const files = await chooseLocalFiles(remain)
|
||||||
|
if (!files.length)
|
||||||
|
return
|
||||||
|
|
||||||
|
uploadingAttachment.value = true
|
||||||
|
uni.showLoading({ title: '上传中...', mask: true })
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
const uploaded = await uploadRequirementAttachment(file.path)
|
||||||
|
const ossId = uploaded.ossId ?? uploaded.id
|
||||||
|
if (ossId === undefined || ossId === null || ossId === '') {
|
||||||
|
uni.showToast({ title: '上传失败,未返回附件 ID', icon: 'none' })
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = uploaded.fileName || file.name
|
||||||
|
attachments.value.push({
|
||||||
|
id: String(ossId),
|
||||||
|
name,
|
||||||
|
type: name.split('.').pop()?.toLowerCase() || 'file',
|
||||||
|
icon: resolveAttachmentIcon(name),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : '上传失败'
|
||||||
|
if (!/cancel/i.test(message))
|
||||||
|
uni.showToast({ title: message, icon: 'none' })
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uploadingAttachment.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSaveDraft() {
|
function getFormInput() {
|
||||||
uni.showToast({ title: '草稿已保存', icon: 'none' })
|
const phone = userPhone.value.trim() || getLoginPhoneNumber() || ''
|
||||||
|
return {
|
||||||
|
businessType: businessType.value,
|
||||||
|
projectName: projectName.value,
|
||||||
|
description: description.value,
|
||||||
|
budget: budget.value,
|
||||||
|
cycle: cycle.value,
|
||||||
|
remark: remark.value,
|
||||||
|
contactName: userName.value.trim() || phone,
|
||||||
|
contactPhone: phone,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFormPayload() {
|
||||||
|
return buildRequirementSubmitPayload({
|
||||||
|
...getFormInput(),
|
||||||
|
attachmentOssIds: attachments.value.map(item => item.id),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDraftPayload() {
|
||||||
|
return buildRequirementDraftPayload({
|
||||||
|
...getFormInput(),
|
||||||
|
attachmentIds: attachments.value.map(item => item.id),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSaveDraft() {
|
||||||
|
if (savingDraft.value || submitting.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
savingDraft.value = true
|
||||||
|
uni.showLoading({ title: '保存中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await saveRequirementDraft(getDraftPayload())
|
||||||
|
uni.showToast({ title: '草稿已保存', icon: 'success' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 层已 toast
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
savingDraft.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleReset() {
|
function handleReset() {
|
||||||
projectName.value = ''
|
resetFormDraftFields()
|
||||||
description.value = ''
|
loadedDraftBizType.value = ''
|
||||||
budget.value = ''
|
|
||||||
cycle.value = ''
|
|
||||||
remark.value = ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
if (submitting.value || savingDraft.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
if (!businessType.value) {
|
if (!businessType.value) {
|
||||||
uni.showToast({ title: '请选择业务类型', icon: 'none' })
|
uni.showToast({ title: '请选择业务类型', icon: 'none' })
|
||||||
return
|
return
|
||||||
@@ -101,8 +335,28 @@ function handleSubmit() {
|
|||||||
uni.showToast({ title: '请填写核心需求描述', icon: 'none' })
|
uni.showToast({ title: '请填写核心需求描述', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!userName.value.trim()) {
|
||||||
|
uni.showToast({ title: '请输入用户名称', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!validatePhone(userPhone.value))
|
||||||
|
return
|
||||||
|
|
||||||
navigateToResultPage('submitSuccess')
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await submitRequirement(getFormPayload())
|
||||||
|
|
||||||
|
navigateToResultPage('submitSuccess')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 层已 toast
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -161,7 +415,7 @@ function handleSubmit() {
|
|||||||
@tap.stop
|
@tap.stop
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
v-for="option in businessTypeOptions"
|
v-for="option in businessTypes"
|
||||||
:key="option"
|
:key="option"
|
||||||
class="requirement-submit__dropdown-item"
|
class="requirement-submit__dropdown-item"
|
||||||
:class="{ 'requirement-submit__dropdown-item--active': businessType === option }"
|
:class="{ 'requirement-submit__dropdown-item--active': businessType === option }"
|
||||||
@@ -201,7 +455,7 @@ function handleSubmit() {
|
|||||||
class="requirement-submit__textarea"
|
class="requirement-submit__textarea"
|
||||||
placeholder="请详细描述您的核心需求,包括功能目标、使用场景、期望效果等"
|
placeholder="请详细描述您的核心需求,包括功能目标、使用场景、期望效果等"
|
||||||
placeholder-class="requirement-submit__placeholder"
|
placeholder-class="requirement-submit__placeholder"
|
||||||
maxlength="500"
|
:maxlength="500"
|
||||||
/>
|
/>
|
||||||
<text class="requirement-submit__counter">
|
<text class="requirement-submit__counter">
|
||||||
{{ descLength }}/500字
|
{{ descLength }}/500字
|
||||||
@@ -334,7 +588,7 @@ function handleSubmit() {
|
|||||||
<view class="requirement-submit__footer">
|
<view class="requirement-submit__footer">
|
||||||
<view
|
<view
|
||||||
class="requirement-submit__footer-btn requirement-submit__footer-btn--primary"
|
class="requirement-submit__footer-btn requirement-submit__footer-btn--primary"
|
||||||
@tap="handleSaveDraft"
|
@tap.stop="handleSaveDraft"
|
||||||
>
|
>
|
||||||
保存草稿
|
保存草稿
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-item__icon-wrap {
|
.message-item__icon-wrap {
|
||||||
|
position: relative;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-right: 24rpx;
|
margin-right: 24rpx;
|
||||||
}
|
}
|
||||||
@@ -23,6 +24,35 @@
|
|||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-item__badge {
|
||||||
|
position: absolute;
|
||||||
|
top: -4rpx;
|
||||||
|
right: -4rpx;
|
||||||
|
width: 16rpx;
|
||||||
|
height: 16rpx;
|
||||||
|
background: #ef4444;
|
||||||
|
border: 2rpx solid #ffffff;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
&--count {
|
||||||
|
top: -8rpx;
|
||||||
|
right: -8rpx;
|
||||||
|
width: auto;
|
||||||
|
min-width: 28rpx;
|
||||||
|
height: 28rpx;
|
||||||
|
padding: 0 8rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-item__badge-text {
|
||||||
|
display: block;
|
||||||
|
font-size: 18rpx;
|
||||||
|
line-height: 28rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.message-item__content {
|
.message-item__content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|||||||
@@ -21,6 +21,18 @@ const emit = defineEmits<{
|
|||||||
:src="item.icon"
|
:src="item.icon"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
|
<view
|
||||||
|
v-if="item.unread || (item.unreadCount && item.unreadCount > 0)"
|
||||||
|
class="message-item__badge"
|
||||||
|
:class="{ 'message-item__badge--count': item.unreadCount && item.unreadCount > 1 }"
|
||||||
|
>
|
||||||
|
<text
|
||||||
|
v-if="item.unreadCount && item.unreadCount > 1"
|
||||||
|
class="message-item__badge-text"
|
||||||
|
>
|
||||||
|
{{ item.unreadCount > 99 ? '99+' : item.unreadCount }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="message-item__content">
|
<view class="message-item__content">
|
||||||
|
|||||||
@@ -115,3 +115,14 @@
|
|||||||
color: $color-text-primary;
|
color: $color-text-primary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-message__read-status {
|
||||||
|
margin-top: 8rpx;
|
||||||
|
font-size: 20rpx;
|
||||||
|
line-height: 1;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
|
||||||
|
&--read {
|
||||||
|
color: $color-primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ const props = defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const messageType = computed(() => props.message.type || 'text')
|
const messageType = computed(() => props.message.type || 'text')
|
||||||
|
const showReadStatus = computed(() => props.message.role === 'user' && props.message.read !== undefined)
|
||||||
|
const readStatusText = computed(() => (props.message.read ? '已读' : '未读'))
|
||||||
|
|
||||||
function handlePreviewImage() {
|
function handlePreviewImage() {
|
||||||
if (!props.message.imageUrl)
|
if (!props.message.imageUrl)
|
||||||
@@ -88,6 +90,14 @@ function handleOpenFile() {
|
|||||||
{{ message.content }}
|
{{ message.content }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<text
|
||||||
|
v-if="showReadStatus"
|
||||||
|
class="chat-message__read-status"
|
||||||
|
:class="{ 'chat-message__read-status--read': message.read }"
|
||||||
|
>
|
||||||
|
{{ readStatusText }}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -52,6 +52,18 @@
|
|||||||
padding: 24rpx 24rpx 32rpx;
|
padding: 24rpx 24rpx 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.customer-service__empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 80rpx 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-service__empty-text {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.customer-service__footer {
|
.customer-service__footer {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
|
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
|
||||||
@@ -72,6 +84,11 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 64rpx;
|
width: 64rpx;
|
||||||
height: 64rpx;
|
height: 64rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&--active {
|
||||||
|
background: rgba(37, 99, 235, 0.12);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.customer-service__tool-icon {
|
.customer-service__tool-icon {
|
||||||
@@ -79,6 +96,43 @@
|
|||||||
height: 48rpx;
|
height: 48rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.customer-service__voice-mask {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 40;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 48rpx;
|
||||||
|
background: rgba(15, 23, 42, 0.45);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-service__voice-card {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 560rpx;
|
||||||
|
padding: 40rpx 36rpx;
|
||||||
|
text-align: center;
|
||||||
|
background: rgba(17, 24, 39, 0.92);
|
||||||
|
border-radius: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-service__voice-title {
|
||||||
|
display: block;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customer-service__voice-text {
|
||||||
|
display: block;
|
||||||
|
margin-top: 16rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: rgba(255, 255, 255, 0.82);
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
.customer-service__input {
|
.customer-service__input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: 72rpx;
|
height: 72rpx;
|
||||||
|
|||||||
@@ -1,18 +1,130 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { CUSTOMER_SERVICE_MESSAGES } from '@/constants/customer-service'
|
import { onHide, onShow, onUnload } from '@dcloudio/uni-app'
|
||||||
|
import {
|
||||||
|
getChatMessageList,
|
||||||
|
initChatSession,
|
||||||
|
sendChatMessage,
|
||||||
|
} from '@/api/chat'
|
||||||
|
import { uploadRequirementAttachment } from '@/api/requirement'
|
||||||
|
import type { CsContentType, CsSession } from '@/types/chat-api'
|
||||||
import type { ChatMessage } from '@/types/customer-service'
|
import type { ChatMessage } from '@/types/customer-service'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
|
import {
|
||||||
|
collectChatMediaIds,
|
||||||
|
mapCsMessageToChatMessage,
|
||||||
|
mapCsMessagesToChatMessages,
|
||||||
|
} from '@/utils/map-chat-message'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
import { resolveChatUserAvatar } from '@/utils/resolve-chat-avatar'
|
||||||
|
import { resolveOssUrlMap } from '@/utils/resolve-oss-media'
|
||||||
|
import {
|
||||||
|
isSpeechToTextSupported,
|
||||||
|
startSpeechToText,
|
||||||
|
stopSpeechToText,
|
||||||
|
} from '@/utils/speech-to-text'
|
||||||
import ChatMessageItem from './components/ChatMessage.vue'
|
import ChatMessageItem from './components/ChatMessage.vue'
|
||||||
|
|
||||||
const USER_AVATAR = '/static/icons/hi.png'
|
const DEFAULT_USER_AVATAR = '/static/icons/hi.png'
|
||||||
const USER_NICKNAME = '昵称'
|
const DEFAULT_USER_NICKNAME = '我'
|
||||||
|
|
||||||
const messages = ref<ChatMessage[]>(CUSTOMER_SERVICE_MESSAGES.map(item => ({ ...item })))
|
const session = ref<CsSession | null>(null)
|
||||||
|
const sessionLoading = ref(false)
|
||||||
|
const messagesLoading = ref(false)
|
||||||
|
const sending = ref(false)
|
||||||
|
const messages = ref<ChatMessage[]>([])
|
||||||
const inputValue = ref('')
|
const inputValue = ref('')
|
||||||
const panelVisible = ref(false)
|
const panelVisible = ref(false)
|
||||||
|
const voiceListening = ref(false)
|
||||||
|
const voicePartialText = ref('')
|
||||||
|
const inputBeforeVoice = ref('')
|
||||||
|
|
||||||
|
const userNickname = computed(() => session.value?.userName?.trim() || DEFAULT_USER_NICKNAME)
|
||||||
|
const userAvatar = computed(() => session.value?.userAvatar?.trim() || DEFAULT_USER_AVATAR)
|
||||||
|
const pageTitle = computed(() => {
|
||||||
|
const name = session.value?.csUserName?.trim()
|
||||||
|
return name ? `在线客服 · ${name}` : '在线客服'
|
||||||
|
})
|
||||||
|
|
||||||
|
async function enrichSessionAvatar() {
|
||||||
|
if (!session.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const resolved = await resolveChatUserAvatar(session.value.userAvatar)
|
||||||
|
if (resolved && resolved !== session.value.userAvatar)
|
||||||
|
session.value = { ...session.value, userAvatar: resolved }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadMessages() {
|
||||||
|
if (!session.value?.id || messagesLoading.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
messagesLoading.value = true
|
||||||
|
try {
|
||||||
|
const rows = await getChatMessageList(session.value.id)
|
||||||
|
const list = rows ?? []
|
||||||
|
const urlMap = await resolveOssUrlMap(collectChatMediaIds(list, session.value))
|
||||||
|
messages.value = mapCsMessagesToChatMessages(list, session.value, urlMap)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
messagesLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ensureChatSession(forceReloadMessages = false) {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (sessionLoading.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (session.value?.id) {
|
||||||
|
if (forceReloadMessages) {
|
||||||
|
await enrichSessionAvatar()
|
||||||
|
await loadMessages()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionLoading.value = true
|
||||||
|
try {
|
||||||
|
const contact = getLoginPhoneNumber()?.trim() || undefined
|
||||||
|
session.value = await initChatSession({
|
||||||
|
chatType: 'GENERAL',
|
||||||
|
contact,
|
||||||
|
})
|
||||||
|
await enrichSessionAvatar()
|
||||||
|
await loadMessages()
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
session.value = null
|
||||||
|
messages.value = []
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
sessionLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
ensureChatSession(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
onHide(() => {
|
||||||
|
stopSpeechToText()
|
||||||
|
voiceListening.value = false
|
||||||
|
voicePartialText.value = ''
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnload(() => {
|
||||||
|
stopSpeechToText()
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
|
stopSpeechToText()
|
||||||
navigateBackWithFallback('/pages/message-center/index')
|
navigateBackWithFallback('/pages/message-center/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,67 +132,216 @@ function togglePanel() {
|
|||||||
panelVisible.value = !panelVisible.value
|
panelVisible.value = !panelVisible.value
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSend() {
|
function applyVoiceText(text: string) {
|
||||||
const content = inputValue.value.trim()
|
const base = inputBeforeVoice.value.trim()
|
||||||
if (!content)
|
const next = text.trim()
|
||||||
|
if (!next)
|
||||||
|
return
|
||||||
|
inputValue.value = base ? `${base}${next}` : next
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleVoiceStart() {
|
||||||
|
if (sending.value || voiceListening.value)
|
||||||
return
|
return
|
||||||
|
|
||||||
appendTextMessage(content)
|
if (!isSpeechToTextSupported()) {
|
||||||
inputValue.value = ''
|
uni.showToast({ title: '当前环境不支持语音转文字', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
panelVisible.value = false
|
panelVisible.value = false
|
||||||
|
inputBeforeVoice.value = inputValue.value
|
||||||
|
voicePartialText.value = ''
|
||||||
|
voiceListening.value = true
|
||||||
|
|
||||||
|
startSpeechToText({
|
||||||
|
onPartial: (text) => {
|
||||||
|
voicePartialText.value = text
|
||||||
|
applyVoiceText(text)
|
||||||
|
},
|
||||||
|
onResult: (text) => {
|
||||||
|
voicePartialText.value = text
|
||||||
|
applyVoiceText(text)
|
||||||
|
},
|
||||||
|
onEnd: () => {
|
||||||
|
voiceListening.value = false
|
||||||
|
voicePartialText.value = ''
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
voiceListening.value = false
|
||||||
|
voicePartialText.value = ''
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendTextMessage(content: string) {
|
function handleVoiceEnd() {
|
||||||
messages.value.push({
|
if (!voiceListening.value)
|
||||||
id: `${Date.now()}-${messages.value.length}`,
|
return
|
||||||
|
stopSpeechToText()
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushLocalMessage(message: ChatMessage) {
|
||||||
|
messages.value.push(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function upsertServerMessage(serverMsg: Parameters<typeof mapCsMessageToChatMessage>[0]) {
|
||||||
|
const urlMap = await resolveOssUrlMap(collectChatMediaIds([serverMsg], session.value))
|
||||||
|
const mapped = mapCsMessageToChatMessage(serverMsg, session.value, urlMap)
|
||||||
|
// 自己发的消息优先用已解析的会话头像,避免后端未回填 senderAvatar
|
||||||
|
if (mapped.role === 'user' && userAvatar.value && userAvatar.value !== DEFAULT_USER_AVATAR)
|
||||||
|
mapped.avatar = userAvatar.value
|
||||||
|
|
||||||
|
const index = messages.value.findIndex(item => item.id === mapped.id)
|
||||||
|
if (index >= 0)
|
||||||
|
messages.value[index] = mapped
|
||||||
|
else
|
||||||
|
messages.value.push(mapped)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendMessagePayload(payload: {
|
||||||
|
contentType: CsContentType
|
||||||
|
content: string
|
||||||
|
fileUrl?: string
|
||||||
|
fileSize?: number | string
|
||||||
|
}) {
|
||||||
|
if (!session.value?.id) {
|
||||||
|
await ensureChatSession()
|
||||||
|
if (!session.value?.id) {
|
||||||
|
uni.showToast({ title: '会话创建失败,请稍后重试', icon: 'none' })
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sendChatMessage({
|
||||||
|
sessionId: session.value.id,
|
||||||
|
contentType: payload.contentType,
|
||||||
|
content: payload.content,
|
||||||
|
fileUrl: payload.fileUrl,
|
||||||
|
fileSize: payload.fileSize,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSend() {
|
||||||
|
const content = inputValue.value.trim()
|
||||||
|
if (!content || sending.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
sending.value = true
|
||||||
|
panelVisible.value = false
|
||||||
|
inputValue.value = ''
|
||||||
|
|
||||||
|
const tempId = `local-${Date.now()}`
|
||||||
|
pushLocalMessage({
|
||||||
|
id: tempId,
|
||||||
role: 'user',
|
role: 'user',
|
||||||
nickname: USER_NICKNAME,
|
nickname: userNickname.value,
|
||||||
content,
|
content,
|
||||||
type: 'text',
|
type: 'text',
|
||||||
avatar: USER_AVATAR,
|
avatar: userAvatar.value,
|
||||||
|
read: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await sendMessagePayload({
|
||||||
|
contentType: 'TEXT',
|
||||||
|
content,
|
||||||
|
})
|
||||||
|
if (!result)
|
||||||
|
return
|
||||||
|
|
||||||
|
messages.value = messages.value.filter(item => item.id !== tempId)
|
||||||
|
await upsertServerMessage(result)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
messages.value = messages.value.filter(item => item.id !== tempId)
|
||||||
|
inputValue.value = content
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
sending.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendImageMessage(imageUrl: string) {
|
async function uploadAndSendFile(options: {
|
||||||
messages.value.push({
|
filePath: string
|
||||||
id: `${Date.now()}-${messages.value.length}`,
|
contentType: 'IMAGE' | 'FILE'
|
||||||
role: 'user',
|
content: string
|
||||||
nickname: USER_NICKNAME,
|
previewUrl?: string
|
||||||
content: '[图片]',
|
fileName?: string
|
||||||
type: 'image',
|
}) {
|
||||||
imageUrl,
|
if (sending.value)
|
||||||
avatar: USER_AVATAR,
|
return
|
||||||
})
|
|
||||||
panelVisible.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function appendFileMessage(fileName: string, filePath: string) {
|
if (!session.value?.id) {
|
||||||
messages.value.push({
|
await ensureChatSession()
|
||||||
id: `${Date.now()}-${messages.value.length}`,
|
if (!session.value?.id) {
|
||||||
role: 'user',
|
uni.showToast({ title: '会话创建失败,请稍后重试', icon: 'none' })
|
||||||
nickname: USER_NICKNAME,
|
return
|
||||||
content: fileName,
|
}
|
||||||
type: 'file',
|
}
|
||||||
fileName,
|
|
||||||
filePath,
|
sending.value = true
|
||||||
avatar: USER_AVATAR,
|
|
||||||
})
|
|
||||||
panelVisible.value = false
|
panelVisible.value = false
|
||||||
|
const tempId = `local-${Date.now()}`
|
||||||
|
|
||||||
|
pushLocalMessage({
|
||||||
|
id: tempId,
|
||||||
|
role: 'user',
|
||||||
|
nickname: userNickname.value,
|
||||||
|
content: options.content,
|
||||||
|
type: options.contentType === 'IMAGE' ? 'image' : 'file',
|
||||||
|
imageUrl: options.contentType === 'IMAGE' ? (options.previewUrl || options.filePath) : undefined,
|
||||||
|
fileName: options.fileName,
|
||||||
|
filePath: options.contentType === 'FILE' ? options.filePath : undefined,
|
||||||
|
avatar: userAvatar.value,
|
||||||
|
read: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
uni.showLoading({ title: '发送中...', mask: true })
|
||||||
|
const uploaded = await uploadRequirementAttachment(options.filePath)
|
||||||
|
const fileUrl = uploaded.url?.trim()
|
||||||
|
if (!fileUrl)
|
||||||
|
throw new Error('上传失败')
|
||||||
|
|
||||||
|
const result = await sendMessagePayload({
|
||||||
|
contentType: options.contentType,
|
||||||
|
content: options.content,
|
||||||
|
fileUrl,
|
||||||
|
})
|
||||||
|
if (!result)
|
||||||
|
return
|
||||||
|
|
||||||
|
messages.value = messages.value.filter(item => item.id !== tempId)
|
||||||
|
await upsertServerMessage(result)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
messages.value = messages.value.filter(item => item.id !== tempId)
|
||||||
|
uni.showToast({ title: '发送失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
sending.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isChooseCanceled(errMsg?: string) {
|
function isChooseCanceled(errMsg?: string) {
|
||||||
return Boolean(errMsg?.includes('cancel') || errMsg?.includes('取消'))
|
return Boolean(errMsg?.includes('cancel') || errMsg?.includes('取消'))
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChooseImageSuccess(tempFilePaths: string[]) {
|
async function handleChooseImageSuccess(tempFilePaths: string[]) {
|
||||||
if (!tempFilePaths.length) {
|
if (!tempFilePaths.length) {
|
||||||
uni.showToast({ title: '未选择图片', icon: 'none' })
|
uni.showToast({ title: '未选择图片', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tempFilePaths.forEach((path) => {
|
for (const path of tempFilePaths) {
|
||||||
appendImageMessage(path)
|
await uploadAndSendFile({
|
||||||
})
|
filePath: path,
|
||||||
|
contentType: 'IMAGE',
|
||||||
|
content: '[图片]',
|
||||||
|
previewUrl: path,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChooseImages(sourceType: Array<'album' | 'camera'>) {
|
function handleChooseImages(sourceType: Array<'album' | 'camera'>) {
|
||||||
@@ -98,15 +359,20 @@ function handleChooseImages(sourceType: Array<'album' | 'camera'>) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChooseFilesSuccess(files: Array<{ name: string, path: string }>) {
|
async function handleChooseFilesSuccess(files: Array<{ name: string, path: string }>) {
|
||||||
if (!files.length) {
|
if (!files.length) {
|
||||||
uni.showToast({ title: '未选择文件', icon: 'none' })
|
uni.showToast({ title: '未选择文件', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
files.forEach((file) => {
|
for (const file of files) {
|
||||||
appendFileMessage(file.name, file.path)
|
await uploadAndSendFile({
|
||||||
})
|
filePath: file.path,
|
||||||
|
contentType: 'FILE',
|
||||||
|
content: file.name,
|
||||||
|
fileName: file.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChooseFiles() {
|
function handleChooseFiles() {
|
||||||
@@ -173,7 +439,7 @@ function handleAttachment(type: 'camera' | 'photo' | 'file') {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<text class="customer-service__title">
|
<text class="customer-service__title">
|
||||||
在线客服
|
{{ pageTitle }}
|
||||||
</text>
|
</text>
|
||||||
<view class="customer-service__navbar-placeholder" />
|
<view class="customer-service__navbar-placeholder" />
|
||||||
</view>
|
</view>
|
||||||
@@ -185,6 +451,24 @@ function handleAttachment(type: 'camera' | 'photo' | 'file') {
|
|||||||
:scroll-into-view="messages.length ? `msg-${messages[messages.length - 1].id}` : ''"
|
:scroll-into-view="messages.length ? `msg-${messages[messages.length - 1].id}` : ''"
|
||||||
>
|
>
|
||||||
<view class="customer-service__messages">
|
<view class="customer-service__messages">
|
||||||
|
<view
|
||||||
|
v-if="(sessionLoading || messagesLoading) && !messages.length"
|
||||||
|
class="customer-service__empty"
|
||||||
|
>
|
||||||
|
<text class="customer-service__empty-text">
|
||||||
|
加载中...
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else-if="!messages.length"
|
||||||
|
class="customer-service__empty"
|
||||||
|
>
|
||||||
|
<text class="customer-service__empty-text">
|
||||||
|
暂无消息,发送一条开始咨询
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-for="message in messages"
|
v-for="message in messages"
|
||||||
:id="`msg-${message.id}`"
|
:id="`msg-${message.id}`"
|
||||||
@@ -195,9 +479,32 @@ function handleAttachment(type: 'camera' | 'photo' | 'file') {
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-if="voiceListening"
|
||||||
|
class="customer-service__voice-mask"
|
||||||
|
>
|
||||||
|
<view class="customer-service__voice-card">
|
||||||
|
<text class="customer-service__voice-title">
|
||||||
|
正在听…
|
||||||
|
</text>
|
||||||
|
<text class="customer-service__voice-text">
|
||||||
|
{{ voicePartialText || '请说话,松手结束' }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="customer-service__footer">
|
<view class="customer-service__footer">
|
||||||
<view class="customer-service__input-row">
|
<view class="customer-service__input-row">
|
||||||
<view class="customer-service__tool-btn">
|
<view
|
||||||
|
class="customer-service__tool-btn"
|
||||||
|
:class="{ 'customer-service__tool-btn--active': voiceListening }"
|
||||||
|
@touchstart.prevent="handleVoiceStart"
|
||||||
|
@touchend.prevent="handleVoiceEnd"
|
||||||
|
@touchcancel.prevent="handleVoiceEnd"
|
||||||
|
@mousedown.prevent="handleVoiceStart"
|
||||||
|
@mouseup.prevent="handleVoiceEnd"
|
||||||
|
@mouseleave="handleVoiceEnd"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="customer-service__tool-icon"
|
class="customer-service__tool-icon"
|
||||||
src="/static/icons/icon-chat-voice.png"
|
src="/static/icons/icon-chat-voice.png"
|
||||||
@@ -211,6 +518,7 @@ function handleAttachment(type: 'camera' | 'photo' | 'file') {
|
|||||||
placeholder="请输入消息..."
|
placeholder="请输入消息..."
|
||||||
placeholder-class="customer-service__placeholder"
|
placeholder-class="customer-service__placeholder"
|
||||||
confirm-type="send"
|
confirm-type="send"
|
||||||
|
:disabled="sending || voiceListening"
|
||||||
@confirm="handleSend"
|
@confirm="handleSend"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,50 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { getChatSessionPreview } from '@/api/chat'
|
||||||
import AppTabBar from '@/components/AppTabBar.vue'
|
import AppTabBar from '@/components/AppTabBar.vue'
|
||||||
import { MESSAGE_LIST } from '@/constants/message-center'
|
import { MESSAGE_LIST } from '@/constants/message-center'
|
||||||
import type { MessageItem } from '@/types/message-center'
|
import type { MessageItem } from '@/types/message-center'
|
||||||
|
import { formatChatPreviewTime } from '@/utils/format-chat-preview-time'
|
||||||
|
import { isLoggedIn } from '@/utils/auth-guard'
|
||||||
import MessageItemCard from './components/MessageItem.vue'
|
import MessageItemCard from './components/MessageItem.vue'
|
||||||
|
|
||||||
const messageList = ref<MessageItem[]>(MESSAGE_LIST.map(item => ({ ...item })))
|
const messageList = ref<MessageItem[]>(MESSAGE_LIST.map(item => ({ ...item })))
|
||||||
|
|
||||||
|
async function refreshServicePreview() {
|
||||||
|
if (!isLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
try {
|
||||||
|
const preview = await getChatSessionPreview({ showErrorToast: false })
|
||||||
|
const unreadCount = Number(preview?.unreadCount ?? 0)
|
||||||
|
messageList.value = messageList.value.map((item) => {
|
||||||
|
if (item.type !== 'service')
|
||||||
|
return item
|
||||||
|
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
preview: preview?.latestMessage?.trim() || item.preview,
|
||||||
|
time: formatChatPreviewTime(preview?.latestTime) || item.time,
|
||||||
|
unread: unreadCount > 0,
|
||||||
|
unreadCount: unreadCount > 0 ? unreadCount : undefined,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 预览失败保留本地占位
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
refreshServicePreview()
|
||||||
|
})
|
||||||
|
|
||||||
function handleReadAll() {
|
function handleReadAll() {
|
||||||
messageList.value = messageList.value.map(item => ({
|
messageList.value = messageList.value.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
unread: false,
|
unread: false,
|
||||||
|
unreadCount: undefined,
|
||||||
}))
|
}))
|
||||||
uni.showToast({ title: '已全部标为已读', icon: 'none' })
|
uni.showToast({ title: '已全部标为已读', icon: 'none' })
|
||||||
}
|
}
|
||||||
@@ -18,7 +52,7 @@ function handleReadAll() {
|
|||||||
function handleMessageTap(item: MessageItem) {
|
function handleMessageTap(item: MessageItem) {
|
||||||
if (item.type === 'service') {
|
if (item.type === 'service') {
|
||||||
messageList.value = messageList.value.map(row =>
|
messageList.value = messageList.value.map(row =>
|
||||||
row.id === item.id ? { ...row, unread: false } : row,
|
row.id === item.id ? { ...row, unread: false, unreadCount: undefined } : row,
|
||||||
)
|
)
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
|
|||||||
@@ -1,11 +1,23 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ACCOUNT_SECURITY_ITEMS } from '@/constants/account-security'
|
import { ACCOUNT_SECURITY_PLACEHOLDER_ITEMS } from '@/constants/account-security'
|
||||||
import type { AccountSecurityItem } from '@/types/account-security'
|
import type { AccountSecurityItem } from '@/types/account-security'
|
||||||
|
import { fetchAndCacheAccountSecurity } from '@/utils/fetch-account-security'
|
||||||
|
import { buildAccountSecurityItems } from '@/utils/map-account-security'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { performLogout } from '@/utils/logout'
|
import { performLogout } from '@/utils/logout'
|
||||||
|
|
||||||
const securityItems = ACCOUNT_SECURITY_ITEMS
|
const securityItems = ref<AccountSecurityItem[]>(ACCOUNT_SECURITY_PLACEHOLDER_ITEMS)
|
||||||
|
|
||||||
|
async function refreshAccountSecurity() {
|
||||||
|
const vo = await fetchAndCacheAccountSecurity({ showErrorToast: true })
|
||||||
|
securityItems.value = buildAccountSecurityItems(vo)
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
refreshAccountSecurity()
|
||||||
|
})
|
||||||
const loggingOut = ref(false)
|
const loggingOut = ref(false)
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
@@ -24,7 +36,12 @@ function handleItemTap(item: AccountSecurityItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item.key === 'email') {
|
if (item.key === 'email') {
|
||||||
uni.navigateTo({ url: '/pages/personal-center/bind-email/index' })
|
const unbound = item.status === '未绑定'
|
||||||
|
uni.navigateTo({
|
||||||
|
url: unbound
|
||||||
|
? '/pages/personal-center/bind-email-change/index?scene=bindEmail'
|
||||||
|
: '/pages/personal-center/bind-email/index',
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,13 @@
|
|||||||
padding: 20rpx 24rpx calc(140rpx + env(safe-area-inset-bottom));
|
padding: 20rpx 24rpx calc(140rpx + env(safe-area-inset-bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.address-page__empty {
|
||||||
|
padding: 80rpx 24rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
.address-page__card {
|
.address-page__card {
|
||||||
padding: 28rpx 24rpx;
|
padding: 28rpx 24rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
|
|||||||
@@ -1,42 +1,86 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
import {
|
||||||
|
createAddress,
|
||||||
|
deleteAddress,
|
||||||
|
getAddressList,
|
||||||
|
setDefaultAddress,
|
||||||
|
updateAddress,
|
||||||
|
} from '@/api/address'
|
||||||
import BottomSheet from '@/components/BottomSheet.vue'
|
import BottomSheet from '@/components/BottomSheet.vue'
|
||||||
import { ADDRESS_LIST } from '@/constants/address'
|
import { ADDRESS_PHONE_PATTERN } from '@/constants/address'
|
||||||
import type { AddressItem } from '@/types/address'
|
import type { AddressItem } from '@/types/address'
|
||||||
|
import {
|
||||||
|
buildAddressBo,
|
||||||
|
formatAddressDisplay,
|
||||||
|
mapAddressList,
|
||||||
|
} from '@/utils/map-address'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const addressList = ref(ADDRESS_LIST.map(item => ({ ...item })))
|
const addressList = ref<AddressItem[]>([])
|
||||||
|
const loading = ref(false)
|
||||||
|
const submitting = ref(false)
|
||||||
const sheetVisible = ref(false)
|
const sheetVisible = ref(false)
|
||||||
const editingId = ref<string | null>(null)
|
const editingId = ref<string | null>(null)
|
||||||
const formName = ref('')
|
const formName = ref('')
|
||||||
const formPhone = ref('')
|
const formPhone = ref('')
|
||||||
const formRegion = ref('')
|
const formProvince = ref('')
|
||||||
|
const formCity = ref('')
|
||||||
|
const formDistrict = ref('')
|
||||||
const formDetail = ref('')
|
const formDetail = ref('')
|
||||||
|
|
||||||
const isEditing = computed(() => editingId.value !== null)
|
const isEditing = computed(() => editingId.value !== null)
|
||||||
const sheetTitle = computed(() => (isEditing.value ? '编辑地址' : '新增地址'))
|
const sheetTitle = computed(() => (isEditing.value ? '编辑地址' : '新增地址'))
|
||||||
const sheetSubmitText = computed(() => (isEditing.value ? '保存' : '+ 新增地址'))
|
const sheetSubmitText = computed(() => (isEditing.value ? '保存' : '+ 新增地址'))
|
||||||
|
|
||||||
function formatAddress(item: AddressItem) {
|
async function refreshAddressList() {
|
||||||
return `${item.region}${item.detail}`
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const list = await getAddressList()
|
||||||
|
addressList.value = mapAddressList(list)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
refreshAddressList()
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/index')
|
navigateBackWithFallback('/pages/personal-center/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSetDefault(item: AddressItem) {
|
async function handleSetDefault(item: AddressItem) {
|
||||||
addressList.value = addressList.value.map(row => ({
|
if (item.isDefault || submitting.value)
|
||||||
...row,
|
return
|
||||||
isDefault: row.id === item.id,
|
|
||||||
}))
|
submitting.value = true
|
||||||
|
try {
|
||||||
|
await setDefaultAddress(item.id)
|
||||||
|
await refreshAddressList()
|
||||||
|
uni.showToast({ title: '已设为默认', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEdit(item: AddressItem) {
|
function handleEdit(item: AddressItem) {
|
||||||
editingId.value = item.id
|
editingId.value = item.id
|
||||||
formName.value = item.name
|
formName.value = item.name
|
||||||
formPhone.value = item.phone
|
formPhone.value = item.phone
|
||||||
formRegion.value = item.region
|
formProvince.value = item.province
|
||||||
|
formCity.value = item.city
|
||||||
|
formDistrict.value = item.district
|
||||||
formDetail.value = item.detail
|
formDetail.value = item.detail
|
||||||
sheetVisible.value = true
|
sheetVisible.value = true
|
||||||
}
|
}
|
||||||
@@ -47,15 +91,22 @@ function handleDelete(item: AddressItem) {
|
|||||||
content: `确认删除「${item.name}」的地址吗?`,
|
content: `确认删除「${item.name}」的地址吗?`,
|
||||||
confirmText: '删除',
|
confirmText: '删除',
|
||||||
confirmColor: '#2563EB',
|
confirmColor: '#2563EB',
|
||||||
success: (res) => {
|
success: async (res) => {
|
||||||
if (!res.confirm)
|
if (!res.confirm || submitting.value)
|
||||||
return
|
return
|
||||||
|
|
||||||
addressList.value = addressList.value.filter(row => row.id !== item.id)
|
submitting.value = true
|
||||||
if (addressList.value.length && !addressList.value.some(row => row.isDefault))
|
try {
|
||||||
addressList.value[0].isDefault = true
|
await deleteAddress(item.id)
|
||||||
|
await refreshAddressList()
|
||||||
uni.showToast({ title: '已删除', icon: 'none' })
|
uni.showToast({ title: '已删除', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -64,7 +115,9 @@ function resetForm() {
|
|||||||
editingId.value = null
|
editingId.value = null
|
||||||
formName.value = ''
|
formName.value = ''
|
||||||
formPhone.value = ''
|
formPhone.value = ''
|
||||||
formRegion.value = ''
|
formProvince.value = ''
|
||||||
|
formCity.value = ''
|
||||||
|
formDistrict.value = ''
|
||||||
formDetail.value = ''
|
formDetail.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,17 +131,28 @@ function closeSheet() {
|
|||||||
editingId.value = null
|
editingId.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
if (submitting.value)
|
||||||
|
return
|
||||||
|
|
||||||
if (!formName.value.trim()) {
|
if (!formName.value.trim()) {
|
||||||
uni.showToast({ title: '请输入收货人姓名', icon: 'none' })
|
uni.showToast({ title: '请输入收货人姓名', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!formPhone.value.trim()) {
|
if (!ADDRESS_PHONE_PATTERN.test(formPhone.value.trim())) {
|
||||||
uni.showToast({ title: '请输入联系电话', icon: 'none' })
|
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!formRegion.value.trim()) {
|
if (!formProvince.value.trim()) {
|
||||||
uni.showToast({ title: '请输入所在地区', icon: 'none' })
|
uni.showToast({ title: '请输入省份', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!formCity.value.trim()) {
|
||||||
|
uni.showToast({ title: '请输入城市', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!formDistrict.value.trim()) {
|
||||||
|
uni.showToast({ title: '请输入区/县', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!formDetail.value.trim()) {
|
if (!formDetail.value.trim()) {
|
||||||
@@ -96,33 +160,43 @@ function handleSubmit() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = {
|
|
||||||
name: formName.value.trim(),
|
|
||||||
phone: formPhone.value.trim(),
|
|
||||||
region: formRegion.value.trim(),
|
|
||||||
detail: formDetail.value.trim(),
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editingId.value) {
|
|
||||||
addressList.value = addressList.value.map(row => (
|
|
||||||
row.id === editingId.value
|
|
||||||
? { ...row, ...payload }
|
|
||||||
: row
|
|
||||||
))
|
|
||||||
closeSheet()
|
|
||||||
uni.showToast({ title: '保存成功', icon: 'none' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const isFirst = addressList.value.length === 0
|
const isFirst = addressList.value.length === 0
|
||||||
addressList.value.push({
|
const editingItem = editingId.value
|
||||||
id: `${Date.now()}`,
|
? addressList.value.find(item => item.id === editingId.value)
|
||||||
...payload,
|
: undefined
|
||||||
isDefault: isFirst,
|
|
||||||
|
const body = buildAddressBo({
|
||||||
|
id: editingId.value,
|
||||||
|
name: formName.value,
|
||||||
|
phone: formPhone.value,
|
||||||
|
province: formProvince.value,
|
||||||
|
city: formCity.value,
|
||||||
|
district: formDistrict.value,
|
||||||
|
detail: formDetail.value,
|
||||||
|
isDefault: editingItem?.isDefault ?? isFirst,
|
||||||
})
|
})
|
||||||
|
|
||||||
closeSheet()
|
const editing = Boolean(editingId.value)
|
||||||
uni.showToast({ title: '新增成功', icon: 'none' })
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (editingId.value)
|
||||||
|
await updateAddress(editingId.value, body)
|
||||||
|
else
|
||||||
|
await createAddress(body)
|
||||||
|
|
||||||
|
closeSheet()
|
||||||
|
await refreshAddressList()
|
||||||
|
uni.showToast({ title: editing ? '保存成功' : '新增成功', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -151,6 +225,19 @@ function handleSubmit() {
|
|||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
>
|
>
|
||||||
<view class="address-page__content">
|
<view class="address-page__content">
|
||||||
|
<view
|
||||||
|
v-if="loading && !addressList.length"
|
||||||
|
class="address-page__empty"
|
||||||
|
>
|
||||||
|
加载中...
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-else-if="!addressList.length"
|
||||||
|
class="address-page__empty"
|
||||||
|
>
|
||||||
|
暂无收货地址
|
||||||
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-for="item in addressList"
|
v-for="item in addressList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -165,7 +252,7 @@ function handleSubmit() {
|
|||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="address-page__address">
|
<text class="address-page__address">
|
||||||
{{ formatAddress(item) }}
|
{{ formatAddressDisplay(item) }}
|
||||||
</text>
|
</text>
|
||||||
<view class="address-page__card-footer">
|
<view class="address-page__card-footer">
|
||||||
<view
|
<view
|
||||||
@@ -241,18 +328,41 @@ function handleSubmit() {
|
|||||||
v-model="formPhone"
|
v-model="formPhone"
|
||||||
class="address-page__form-input"
|
class="address-page__form-input"
|
||||||
type="number"
|
type="number"
|
||||||
|
maxlength="11"
|
||||||
placeholder="请输入联系电话"
|
placeholder="请输入联系电话"
|
||||||
placeholder-class="address-page__form-placeholder"
|
placeholder-class="address-page__form-placeholder"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
<view class="address-page__form-row">
|
<view class="address-page__form-row">
|
||||||
<text class="address-page__form-label">
|
<text class="address-page__form-label">
|
||||||
地区
|
省份
|
||||||
</text>
|
</text>
|
||||||
<input
|
<input
|
||||||
v-model="formRegion"
|
v-model="formProvince"
|
||||||
class="address-page__form-input"
|
class="address-page__form-input"
|
||||||
placeholder="请输入所在地区"
|
placeholder="请输入省份"
|
||||||
|
placeholder-class="address-page__form-placeholder"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
<view class="address-page__form-row">
|
||||||
|
<text class="address-page__form-label">
|
||||||
|
城市
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="formCity"
|
||||||
|
class="address-page__form-input"
|
||||||
|
placeholder="请输入城市"
|
||||||
|
placeholder-class="address-page__form-placeholder"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
<view class="address-page__form-row">
|
||||||
|
<text class="address-page__form-label">
|
||||||
|
区/县
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="formDistrict"
|
||||||
|
class="address-page__form-input"
|
||||||
|
placeholder="请输入区/县"
|
||||||
placeholder-class="address-page__form-placeholder"
|
placeholder-class="address-page__form-placeholder"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -50,6 +50,40 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bind-email-change__code {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 96rpx;
|
||||||
|
padding: 0 24rpx 0 32rpx;
|
||||||
|
background: $color-bg-input;
|
||||||
|
border-radius: 48rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bind-email-change__code-input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: 100%;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bind-email-change__placeholder {
|
||||||
|
color: $color-text-placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bind-email-change__code-btn {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-left: 16rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: $color-primary;
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.bind-email-change__submit {
|
.bind-email-change__submit {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -1,12 +1,47 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { onUnmounted, ref } from 'vue'
|
||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
|
import { bindAccountEmail, sendAccountEmailCode } from '@/api/account'
|
||||||
|
import type { EmailCodeScene } from '@/types/account-api'
|
||||||
import ForgotInput from '@/pages/Login/user-forgot-password/components/ForgotInput.vue'
|
import ForgotInput from '@/pages/Login/user-forgot-password/components/ForgotInput.vue'
|
||||||
import CodeInput from '@/pages/Login/user-register/components/CodeInput.vue'
|
import { clearAccountSecurityCache, loadAccountSecurityCache } from '@/utils/account-security-cache'
|
||||||
|
import { fetchAndCacheAccountSecurity } from '@/utils/fetch-account-security'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
|
||||||
const email = ref('')
|
const email = ref('')
|
||||||
const code = ref('')
|
const code = ref('')
|
||||||
|
const submitting = ref(false)
|
||||||
|
const sending = ref(false)
|
||||||
|
const countdown = ref(0)
|
||||||
|
const emailScene = ref<EmailCodeScene>('bindEmail')
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
|
function resolveScene(raw?: string): EmailCodeScene {
|
||||||
|
if (raw === 'changeEmail' || raw === 'bindEmail')
|
||||||
|
return raw
|
||||||
|
return loadAccountSecurityCache()?.emailBound ? 'changeEmail' : 'bindEmail'
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad(async (options) => {
|
||||||
|
emailScene.value = resolveScene(options?.scene ? String(options.scene) : undefined)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const vo = await fetchAndCacheAccountSecurity({ showErrorToast: false })
|
||||||
|
if (!options?.scene)
|
||||||
|
emailScene.value = vo?.emailBound ? 'changeEmail' : 'bindEmail'
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 使用进入页时的 scene / 缓存即可
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/bind-email/index')
|
navigateBackWithFallback('/pages/personal-center/bind-email/index')
|
||||||
@@ -16,21 +51,90 @@ function isValidEmail(value: string) {
|
|||||||
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
function onCodeInput(e: { detail: { value: string } }) {
|
||||||
if (!email.value.trim()) {
|
code.value = e.detail.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function startCountdown() {
|
||||||
|
countdown.value = 60
|
||||||
|
timer = setInterval(() => {
|
||||||
|
countdown.value -= 1
|
||||||
|
if (countdown.value <= 0 && timer) {
|
||||||
|
clearInterval(timer)
|
||||||
|
timer = null
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSendCode() {
|
||||||
|
if (countdown.value > 0 || sending.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const emailValue = email.value.trim()
|
||||||
|
if (!emailValue) {
|
||||||
uni.showToast({ title: '请输入邮箱', icon: 'none' })
|
uni.showToast({ title: '请输入邮箱', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!isValidEmail(email.value.trim())) {
|
if (!isValidEmail(emailValue)) {
|
||||||
uni.showToast({ title: '请输入正确的邮箱', icon: 'none' })
|
uni.showToast({ title: '请输入正确的邮箱', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!code.value.trim()) {
|
|
||||||
|
sending.value = true
|
||||||
|
try {
|
||||||
|
await sendAccountEmailCode({
|
||||||
|
email: emailValue,
|
||||||
|
scene: emailScene.value,
|
||||||
|
})
|
||||||
|
uni.showToast({ title: '验证码已发送', icon: 'none' })
|
||||||
|
startCountdown()
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
sending.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
if (submitting.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const emailValue = email.value.trim()
|
||||||
|
const emailCode = code.value.trim()
|
||||||
|
|
||||||
|
if (!emailValue) {
|
||||||
|
uni.showToast({ title: '请输入邮箱', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!isValidEmail(emailValue)) {
|
||||||
|
uni.showToast({ title: '请输入正确的邮箱', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!emailCode) {
|
||||||
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToResultPage('modifySuccess')
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await bindAccountEmail({
|
||||||
|
email: emailValue,
|
||||||
|
emailCode,
|
||||||
|
})
|
||||||
|
clearAccountSecurityCache()
|
||||||
|
navigateToResultPage('modifySuccess')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -48,7 +152,7 @@ function handleSubmit() {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<text class="bind-email-change__navbar-title">
|
<text class="bind-email-change__navbar-title">
|
||||||
绑定邮箱
|
{{ emailScene === 'changeEmail' ? '换绑邮箱' : '绑定邮箱' }}
|
||||||
</text>
|
</text>
|
||||||
<view class="bind-email-change__navbar-placeholder" />
|
<view class="bind-email-change__navbar-placeholder" />
|
||||||
</view>
|
</view>
|
||||||
@@ -62,7 +166,23 @@ function handleSubmit() {
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="bind-email-change__field">
|
<view class="bind-email-change__field">
|
||||||
<CodeInput v-model="code" />
|
<view class="bind-email-change__code">
|
||||||
|
<input
|
||||||
|
class="bind-email-change__code-input"
|
||||||
|
type="number"
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
placeholder-class="bind-email-change__placeholder"
|
||||||
|
:value="code"
|
||||||
|
@input="onCodeInput"
|
||||||
|
>
|
||||||
|
<text
|
||||||
|
class="bind-email-change__code-btn"
|
||||||
|
:class="{ 'bind-email-change__code-btn--disabled': countdown > 0 || sending }"
|
||||||
|
@tap="handleSendCode"
|
||||||
|
>
|
||||||
|
{{ countdown > 0 ? `${countdown}s` : (sending ? '发送中' : '获取验证码') }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
|
|||||||
@@ -1,28 +1,71 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { unbindAccountEmail } from '@/api/account'
|
||||||
import { BOUND_EMAIL_MASKED } from '@/constants/bind-email'
|
import { BOUND_EMAIL_MASKED } from '@/constants/bind-email'
|
||||||
|
import { clearAccountSecurityCache, loadAccountSecurityCache } from '@/utils/account-security-cache'
|
||||||
|
import { getBoundEmailMaskedFromAccount } from '@/utils/map-account-security'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const boundEmail = BOUND_EMAIL_MASKED
|
const boundEmail = ref(BOUND_EMAIL_MASKED)
|
||||||
|
const emailBound = ref(true)
|
||||||
|
const submitting = ref(false)
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
const cached = loadAccountSecurityCache()
|
||||||
|
emailBound.value = cached?.emailBound === true
|
||||||
|
const masked = getBoundEmailMaskedFromAccount(cached)
|
||||||
|
if (masked)
|
||||||
|
boundEmail.value = masked
|
||||||
|
else if (!emailBound.value)
|
||||||
|
boundEmail.value = '未绑定邮箱'
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/account-security/index')
|
navigateBackWithFallback('/pages/personal-center/account-security/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDeleteEmail() {
|
function handleDeleteEmail() {
|
||||||
|
if (!emailBound.value) {
|
||||||
|
uni.showToast({ title: '当前未绑定邮箱', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '删除邮箱',
|
title: '删除邮箱',
|
||||||
content: '删除后将无法通过邮箱接收通知,确认删除吗?',
|
content: '删除后将无法通过邮箱接收通知,确认删除吗?',
|
||||||
confirmText: '确认删除',
|
confirmText: '确认删除',
|
||||||
confirmColor: '#2563EB',
|
confirmColor: '#2563EB',
|
||||||
success: (res) => {
|
success: async (res) => {
|
||||||
if (res.confirm)
|
if (!res.confirm || submitting.value)
|
||||||
uni.showToast({ title: '邮箱已删除', icon: 'none' })
|
return
|
||||||
|
|
||||||
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '处理中...', mask: true })
|
||||||
|
try {
|
||||||
|
await unbindAccountEmail()
|
||||||
|
clearAccountSecurityCache()
|
||||||
|
emailBound.value = false
|
||||||
|
boundEmail.value = '未绑定邮箱'
|
||||||
|
uni.showToast({ title: '邮箱已解绑', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChangeEmail() {
|
function handleChangeEmail() {
|
||||||
uni.navigateTo({ url: '/pages/personal-center/bind-email-change/index' })
|
uni.navigateTo({
|
||||||
|
url: emailBound.value
|
||||||
|
? '/pages/personal-center/bind-email-change/index?scene=changeEmail'
|
||||||
|
: '/pages/personal-center/bind-email-change/index?scene=bindEmail',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -59,6 +102,7 @@ function handleChangeEmail() {
|
|||||||
|
|
||||||
<view class="bind-email__actions">
|
<view class="bind-email__actions">
|
||||||
<view
|
<view
|
||||||
|
v-if="emailBound"
|
||||||
class="bind-email__btn bind-email__btn--primary"
|
class="bind-email__btn bind-email__btn--primary"
|
||||||
@tap="handleDeleteEmail"
|
@tap="handleDeleteEmail"
|
||||||
>
|
>
|
||||||
@@ -68,7 +112,7 @@ function handleChangeEmail() {
|
|||||||
class="bind-email__btn bind-email__btn--primary"
|
class="bind-email__btn bind-email__btn--primary"
|
||||||
@tap="handleChangeEmail"
|
@tap="handleChangeEmail"
|
||||||
>
|
>
|
||||||
更换绑定邮箱
|
{{ emailBound ? '更换绑定邮箱' : '绑定邮箱' }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -1,34 +1,62 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { changeAccountPhone } from '@/api/account'
|
||||||
import { BIND_PHONE_NEW_HINT } from '@/constants/bind-phone'
|
import { BIND_PHONE_NEW_HINT } from '@/constants/bind-phone'
|
||||||
import CodeInput from '@/pages/Login/user-register/components/CodeInput.vue'
|
import CodeInput from '@/pages/Login/user-register/components/CodeInput.vue'
|
||||||
import RegisterInput from '@/pages/Login/user-register/components/RegisterInput.vue'
|
import RegisterInput from '@/pages/Login/user-register/components/RegisterInput.vue'
|
||||||
|
import { setLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
|
import { clearAccountSecurityCache } from '@/utils/account-security-cache'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
|
||||||
const hint = BIND_PHONE_NEW_HINT
|
const hint = BIND_PHONE_NEW_HINT
|
||||||
const newPhone = ref('')
|
const newPhone = ref('')
|
||||||
const code = ref('')
|
const code = ref('')
|
||||||
|
const submitting = ref(false)
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/bind-phone/index')
|
navigateBackWithFallback('/pages/personal-center/bind-phone/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
async function handleSubmit() {
|
||||||
if (!newPhone.value.trim()) {
|
if (submitting.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const phone = newPhone.value.trim()
|
||||||
|
const smsCode = code.value.trim()
|
||||||
|
|
||||||
|
if (!phone) {
|
||||||
uni.showToast({ title: '请输入新手机号', icon: 'none' })
|
uni.showToast({ title: '请输入新手机号', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!/^1\d{10}$/.test(newPhone.value.trim())) {
|
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
||||||
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
uni.showToast({ title: '请输入正确的手机号', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!code.value.trim()) {
|
if (!smsCode) {
|
||||||
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToResultPage('modifySuccess')
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await changeAccountPhone({
|
||||||
|
phoneNumber: phone,
|
||||||
|
smsCode,
|
||||||
|
})
|
||||||
|
setLoginPhoneNumber(phone)
|
||||||
|
clearAccountSecurityCache()
|
||||||
|
navigateToResultPage('modifySuccess')
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -68,7 +96,11 @@ function handleSubmit() {
|
|||||||
<text class="bind-phone-new__label">
|
<text class="bind-phone-new__label">
|
||||||
验证码
|
验证码
|
||||||
</text>
|
</text>
|
||||||
<CodeInput v-model="code" />
|
<CodeInput
|
||||||
|
v-model="code"
|
||||||
|
:phone="newPhone"
|
||||||
|
scene="changePhone"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<text class="bind-phone-new__hint">
|
<text class="bind-phone-new__hint">
|
||||||
|
|||||||
@@ -1,17 +1,35 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
import { BOUND_PHONE_MASKED } from '@/constants/bind-phone'
|
import { BOUND_PHONE_MASKED } from '@/constants/bind-phone'
|
||||||
import CodeInput from '@/pages/Login/user-register/components/CodeInput.vue'
|
import CodeInput from '@/pages/Login/user-register/components/CodeInput.vue'
|
||||||
|
import { loadAccountSecurityCache } from '@/utils/account-security-cache'
|
||||||
|
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
|
import { getBoundPhoneMaskedFromAccount } from '@/utils/map-account-security'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const boundPhone = BOUND_PHONE_MASKED
|
const boundPhone = ref(BOUND_PHONE_MASKED)
|
||||||
|
const verifyPhone = computed(() => getLoginPhoneNumber()?.trim() || '')
|
||||||
const code = ref('')
|
const code = ref('')
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
const cached = loadAccountSecurityCache()
|
||||||
|
const masked = getBoundPhoneMaskedFromAccount(cached)
|
||||||
|
if (masked)
|
||||||
|
boundPhone.value = masked
|
||||||
|
else if (verifyPhone.value)
|
||||||
|
boundPhone.value = verifyPhone.value.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/account-security/index')
|
navigateBackWithFallback('/pages/personal-center/account-security/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
|
if (!verifyPhone.value) {
|
||||||
|
uni.showToast({ title: '未找到当前手机号,请重新登录', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!code.value.trim()) {
|
if (!code.value.trim()) {
|
||||||
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
uni.showToast({ title: '请输入验证码', icon: 'none' })
|
||||||
return
|
return
|
||||||
@@ -56,7 +74,11 @@ function handleSubmit() {
|
|||||||
<text class="bind-phone__label">
|
<text class="bind-phone__label">
|
||||||
验证码
|
验证码
|
||||||
</text>
|
</text>
|
||||||
<CodeInput v-model="code" />
|
<CodeInput
|
||||||
|
v-model="code"
|
||||||
|
:phone="verifyPhone"
|
||||||
|
scene="changePhone"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
|
|||||||
@@ -1,34 +1,83 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { changeLoginPassword } from '@/api/account'
|
||||||
|
import { logout as logoutApi } from '@/api/auth'
|
||||||
|
import {
|
||||||
|
CHANGE_LOGIN_PASSWORD_MAX_LENGTH,
|
||||||
|
CHANGE_LOGIN_PASSWORD_MIN_LENGTH,
|
||||||
|
} from '@/types/account-api'
|
||||||
import PasswordField from '@/pages/Login/user-register/components/PasswordField.vue'
|
import PasswordField from '@/pages/Login/user-register/components/PasswordField.vue'
|
||||||
import PasswordStrength from '@/pages/Login/user-register/components/PasswordStrength.vue'
|
import PasswordStrength from '@/pages/Login/user-register/components/PasswordStrength.vue'
|
||||||
import { getPasswordStrength } from '@/utils/password-strength'
|
import { clearAccountSecurityCache } from '@/utils/account-security-cache'
|
||||||
|
import { LOGIN_PAGE } from '@/utils/auth-guard'
|
||||||
|
import { clearAuthSession } from '@/utils/auth-storage'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
|
||||||
|
|
||||||
const oldPassword = ref('')
|
const oldPassword = ref('')
|
||||||
const newPassword = ref('')
|
const newPassword = ref('')
|
||||||
const confirmPassword = ref('')
|
const confirmPassword = ref('')
|
||||||
|
const submitting = ref(false)
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/account-security/index')
|
navigateBackWithFallback('/pages/personal-center/account-security/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
function forceRelogin() {
|
||||||
if (!oldPassword.value || !newPassword.value || !confirmPassword.value) {
|
clearAccountSecurityCache()
|
||||||
|
clearAuthSession()
|
||||||
|
// 退出接口不阻塞跳转,避免卡住或 401 抢跳转
|
||||||
|
logoutApi().catch(() => {})
|
||||||
|
uni.hideLoading()
|
||||||
|
uni.showToast({ title: '修改成功,请重新登录', icon: 'none', duration: 1500 })
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.reLaunch({ url: LOGIN_PAGE })
|
||||||
|
}, 300)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
if (submitting.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const oldPwd = oldPassword.value.trim()
|
||||||
|
const newPwd = newPassword.value.trim()
|
||||||
|
const confirmPwd = confirmPassword.value.trim()
|
||||||
|
|
||||||
|
if (!oldPwd || !newPwd || !confirmPwd) {
|
||||||
uni.showToast({ title: '请填写完整信息', icon: 'none' })
|
uni.showToast({ title: '请填写完整信息', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (newPassword.value !== confirmPassword.value) {
|
if (oldPwd === newPwd) {
|
||||||
|
uni.showToast({ title: '新密码不能与旧密码相同', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (newPwd.length < CHANGE_LOGIN_PASSWORD_MIN_LENGTH || newPwd.length > CHANGE_LOGIN_PASSWORD_MAX_LENGTH) {
|
||||||
|
uni.showToast({
|
||||||
|
title: `新密码长度为${CHANGE_LOGIN_PASSWORD_MIN_LENGTH}-${CHANGE_LOGIN_PASSWORD_MAX_LENGTH}位`,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (newPwd !== confirmPwd) {
|
||||||
uni.showToast({ title: '两次密码输入不一致', icon: 'none' })
|
uni.showToast({ title: '两次密码输入不一致', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (getPasswordStrength(newPassword.value).isTooWeak) {
|
|
||||||
uni.showToast({ title: '密码等级过低,请重新输入', icon: 'none' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
navigateToResultPage('modifySuccess')
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await changeLoginPassword({
|
||||||
|
oldPassword: oldPwd,
|
||||||
|
newPassword: newPwd,
|
||||||
|
confirmPassword: confirmPwd,
|
||||||
|
})
|
||||||
|
forceRelogin()
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,56 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { FEEDBACK_DESCRIPTION_MAX_LENGTH } from '@/constants/feedback'
|
import { submitFeedback } from '@/api/feedback'
|
||||||
|
import { uploadRequirementAttachment } from '@/api/requirement'
|
||||||
|
import { getOssListByIds } from '@/api/oss'
|
||||||
|
import {
|
||||||
|
FEEDBACK_ATTACHMENT_MAX_COUNT,
|
||||||
|
FEEDBACK_DESCRIPTION_MAX_LENGTH,
|
||||||
|
} from '@/constants/feedback'
|
||||||
import deleteIcon from '@/static/icons/X.png'
|
import deleteIcon from '@/static/icons/X.png'
|
||||||
import pdfIcon from '@/static/icons/PDF.png'
|
import pdfIcon from '@/static/icons/PDF.png'
|
||||||
import pngIcon from '@/static/icons/PNG.png'
|
import pngIcon from '@/static/icons/PNG.png'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { chooseLocalFiles } from '@/utils/choose-local-files'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
|
interface FeedbackAttachmentItem {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
icon: string
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
const description = ref('')
|
const description = ref('')
|
||||||
|
const attachments = ref<FeedbackAttachmentItem[]>([])
|
||||||
const attachments = ref([
|
const uploadingAttachment = ref(false)
|
||||||
{ id: '1', name: '需求文档.pdf', icon: pdfIcon },
|
const submitting = ref(false)
|
||||||
{ id: '2', name: '系统....pdf', icon: pdfIcon },
|
|
||||||
{ id: '3', name: '参考图.png', icon: pngIcon },
|
|
||||||
])
|
|
||||||
|
|
||||||
const descLength = computed(() => description.value.length)
|
const descLength = computed(() => description.value.length)
|
||||||
|
|
||||||
|
function resolveAttachmentIcon(name: string) {
|
||||||
|
const ext = name.split('.').pop()?.toLowerCase() || ''
|
||||||
|
if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(ext))
|
||||||
|
return pngIcon
|
||||||
|
return pdfIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resolveUploadUrl(
|
||||||
|
uploaded: { url?: string, ossId?: string | number, id?: string | number },
|
||||||
|
) {
|
||||||
|
const direct = uploaded.url?.trim()
|
||||||
|
if (direct)
|
||||||
|
return direct
|
||||||
|
|
||||||
|
const ossId = uploaded.ossId ?? uploaded.id
|
||||||
|
if (ossId === undefined || ossId === null || ossId === '')
|
||||||
|
return ''
|
||||||
|
|
||||||
|
const files = await getOssListByIds([ossId])
|
||||||
|
return files[0]?.url?.trim() || ''
|
||||||
|
}
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/index')
|
navigateBackWithFallback('/pages/personal-center/index')
|
||||||
}
|
}
|
||||||
@@ -25,21 +59,68 @@ function handleRemoveAttachment(id: string) {
|
|||||||
attachments.value = attachments.value.filter(item => item.id !== id)
|
attachments.value = attachments.value.filter(item => item.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAddAttachment() {
|
async function handleAddAttachment() {
|
||||||
uni.showToast({ title: '附件上传开发中', icon: 'none' })
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (uploadingAttachment.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const remain = FEEDBACK_ATTACHMENT_MAX_COUNT - attachments.value.length
|
||||||
|
if (remain <= 0) {
|
||||||
|
uni.showToast({ title: `最多上传${FEEDBACK_ATTACHMENT_MAX_COUNT}个附件`, icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const files = await chooseLocalFiles(remain)
|
||||||
|
if (!files.length)
|
||||||
|
return
|
||||||
|
|
||||||
|
uploadingAttachment.value = true
|
||||||
|
uni.showLoading({ title: '上传中...', mask: true })
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
const uploaded = await uploadRequirementAttachment(file.path)
|
||||||
|
const url = await resolveUploadUrl(uploaded)
|
||||||
|
if (!url) {
|
||||||
|
uni.showToast({ title: '上传失败,未返回附件地址', icon: 'none' })
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = uploaded.fileName || file.name
|
||||||
|
attachments.value.push({
|
||||||
|
id: String(uploaded.ossId ?? uploaded.id ?? `${Date.now()}-${attachments.value.length}`),
|
||||||
|
name,
|
||||||
|
icon: resolveAttachmentIcon(name),
|
||||||
|
url,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : '上传失败'
|
||||||
|
if (!/cancel/i.test(message))
|
||||||
|
uni.showToast({ title: message, icon: 'none' })
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uploadingAttachment.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleReset() {
|
function handleReset() {
|
||||||
title.value = ''
|
title.value = ''
|
||||||
description.value = ''
|
description.value = ''
|
||||||
attachments.value = [
|
attachments.value = []
|
||||||
{ id: '1', name: '需求文档.pdf', icon: pdfIcon },
|
|
||||||
{ id: '2', name: '系统....pdf', icon: pdfIcon },
|
|
||||||
{ id: '3', name: '参考图.png', icon: pngIcon },
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
if (submitting.value || uploadingAttachment.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
if (!title.value.trim()) {
|
if (!title.value.trim()) {
|
||||||
uni.showToast({ title: '请输入反馈标题', icon: 'none' })
|
uni.showToast({ title: '请输入反馈标题', icon: 'none' })
|
||||||
return
|
return
|
||||||
@@ -49,10 +130,29 @@ function handleSubmit() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.showToast({ title: '提交成功', icon: 'none' })
|
submitting.value = true
|
||||||
setTimeout(() => {
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
uni.navigateBack()
|
|
||||||
}, 1500)
|
try {
|
||||||
|
const urls = attachments.value.map(item => item.url).filter(Boolean)
|
||||||
|
await submitFeedback({
|
||||||
|
title: title.value.trim(),
|
||||||
|
content: description.value.trim(),
|
||||||
|
// OpenAPI 定义为 string,不能直接传数组,否则会 400「请求参数格式错误」
|
||||||
|
attachments: urls.length ? JSON.stringify(urls) : undefined,
|
||||||
|
})
|
||||||
|
uni.showToast({ title: '提交成功', icon: 'success' })
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack()
|
||||||
|
}, 1200)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -107,7 +207,7 @@ function handleSubmit() {
|
|||||||
附件上传
|
附件上传
|
||||||
</text>
|
</text>
|
||||||
<text class="feedback__hint">
|
<text class="feedback__hint">
|
||||||
支持图片/文档/压缩包
|
支持图片/文档/压缩包,最多{{ FEEDBACK_ATTACHMENT_MAX_COUNT }}个
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="feedback__attachment-row">
|
<view class="feedback__attachment-row">
|
||||||
@@ -136,6 +236,7 @@ function handleSubmit() {
|
|||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
|
v-if="attachments.length < FEEDBACK_ATTACHMENT_MAX_COUNT"
|
||||||
class="feedback__attachment-add"
|
class="feedback__attachment-add"
|
||||||
@tap="handleAddAttachment"
|
@tap="handleAddAttachment"
|
||||||
>
|
>
|
||||||
|
|||||||
268
src/pages/personal-center/finance/components/FinanceMixChart.vue
Normal file
268
src/pages/personal-center/finance/components/FinanceMixChart.vue
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
|
||||||
|
import type { FinanceChartView } from '@/utils/map-finance'
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
chart: FinanceChartView
|
||||||
|
/** 画布高度,单位 px */
|
||||||
|
height?: number
|
||||||
|
}>(), {
|
||||||
|
height: 220,
|
||||||
|
})
|
||||||
|
|
||||||
|
const instance = getCurrentInstance()
|
||||||
|
const canvasId = 'finance-mix-chart'
|
||||||
|
const canvasWidth = ref(320)
|
||||||
|
const ready = ref(false)
|
||||||
|
|
||||||
|
let ctx: UniApp.CanvasContext | null = null
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [props.chart, props.height] as const,
|
||||||
|
() => {
|
||||||
|
nextTick(() => drawChart())
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
nextTick(() => {
|
||||||
|
measureAndDraw()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function measureAndDraw() {
|
||||||
|
const query = uni.createSelectorQuery().in(instance)
|
||||||
|
query.select('.finance-mix-chart__canvas-wrap').boundingClientRect((rect) => {
|
||||||
|
if (rect && !Array.isArray(rect) && rect.width)
|
||||||
|
canvasWidth.value = Math.floor(rect.width)
|
||||||
|
ready.value = true
|
||||||
|
nextTick(() => drawChart())
|
||||||
|
}).exec()
|
||||||
|
}
|
||||||
|
|
||||||
|
function niceMax(rawMax: number) {
|
||||||
|
if (rawMax <= 0)
|
||||||
|
return 100
|
||||||
|
const padded = rawMax * 1.1
|
||||||
|
const magnitude = 10 ** Math.floor(Math.log10(padded))
|
||||||
|
const normalized = padded / magnitude
|
||||||
|
let nice = 1
|
||||||
|
if (normalized <= 1)
|
||||||
|
nice = 1
|
||||||
|
else if (normalized <= 2)
|
||||||
|
nice = 2
|
||||||
|
else if (normalized <= 5)
|
||||||
|
nice = 5
|
||||||
|
else
|
||||||
|
nice = 10
|
||||||
|
return nice * magnitude
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTick(value: number) {
|
||||||
|
if (value >= 10000)
|
||||||
|
return `${(value / 10000).toFixed(value % 10000 === 0 ? 0 : 1)}万`
|
||||||
|
if (Number.isInteger(value))
|
||||||
|
return String(value)
|
||||||
|
return value.toFixed(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawChart() {
|
||||||
|
if (!ready.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
ctx = uni.createCanvasContext(canvasId, instance)
|
||||||
|
const width = canvasWidth.value
|
||||||
|
const height = props.height
|
||||||
|
const chart = props.chart
|
||||||
|
const categories = chart.categories || []
|
||||||
|
const series = chart.series || []
|
||||||
|
|
||||||
|
ctx.clearRect(0, 0, width, height)
|
||||||
|
ctx.setFillStyle('#ffffff')
|
||||||
|
ctx.fillRect(0, 0, width, height)
|
||||||
|
|
||||||
|
if (!categories.length || !series.length) {
|
||||||
|
ctx.setFillStyle('#999999')
|
||||||
|
ctx.setFontSize(12)
|
||||||
|
ctx.setTextAlign('center')
|
||||||
|
ctx.fillText('暂无分布数据', width / 2, height / 2)
|
||||||
|
ctx.draw()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const allValues = series.flatMap(item => item.data)
|
||||||
|
const dataMax = Math.max(0, ...allValues)
|
||||||
|
const yMax = niceMax(dataMax)
|
||||||
|
const tickCount = 5
|
||||||
|
const ticks = Array.from({ length: tickCount + 1 }, (_, i) => (yMax / tickCount) * i)
|
||||||
|
|
||||||
|
const padLeft = 36
|
||||||
|
const padRight = 36
|
||||||
|
const padTop = 16
|
||||||
|
const padBottom = 28
|
||||||
|
const plotW = width - padLeft - padRight
|
||||||
|
const plotH = height - padTop - padBottom
|
||||||
|
const slotW = plotW / categories.length
|
||||||
|
const barW = Math.min(28, Math.max(10, slotW * 0.38))
|
||||||
|
|
||||||
|
// grid + y labels (both sides)
|
||||||
|
ctx.setStrokeStyle('#E8EAED')
|
||||||
|
ctx.setLineWidth(1)
|
||||||
|
ticks.forEach((tick) => {
|
||||||
|
const ratio = tick / yMax
|
||||||
|
const y = padTop + plotH * (1 - ratio)
|
||||||
|
ctx.beginPath()
|
||||||
|
ctx.moveTo(padLeft, y)
|
||||||
|
ctx.lineTo(width - padRight, y)
|
||||||
|
ctx.stroke()
|
||||||
|
|
||||||
|
ctx.setFillStyle('#9CA3AF')
|
||||||
|
ctx.setFontSize(10)
|
||||||
|
ctx.setTextAlign('right')
|
||||||
|
ctx.fillText(formatTick(tick), padLeft - 6, y + 3)
|
||||||
|
ctx.setTextAlign('left')
|
||||||
|
ctx.fillText(formatTick(tick), width - padRight + 6, y + 3)
|
||||||
|
})
|
||||||
|
|
||||||
|
function valueY(value: number) {
|
||||||
|
return padTop + plotH * (1 - Math.max(0, value) / yMax)
|
||||||
|
}
|
||||||
|
|
||||||
|
function centerX(index: number) {
|
||||||
|
return padLeft + slotW * index + slotW / 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// columns first
|
||||||
|
series.filter(item => item.type === 'column').forEach((item) => {
|
||||||
|
item.data.forEach((value, index) => {
|
||||||
|
const x = centerX(index) - barW / 2
|
||||||
|
const y = valueY(value)
|
||||||
|
const h = padTop + plotH - y
|
||||||
|
ctx!.setFillStyle(item.color)
|
||||||
|
ctx!.fillRect(x, y, barW, Math.max(0, h))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// lines
|
||||||
|
series.filter(item => item.type === 'line').forEach((item) => {
|
||||||
|
ctx!.setStrokeStyle(item.color)
|
||||||
|
ctx!.setLineWidth(2)
|
||||||
|
ctx!.setLineCap('round')
|
||||||
|
ctx!.setLineJoin('round')
|
||||||
|
ctx!.beginPath()
|
||||||
|
item.data.forEach((value, index) => {
|
||||||
|
const x = centerX(index)
|
||||||
|
const y = valueY(value)
|
||||||
|
if (index === 0)
|
||||||
|
ctx!.moveTo(x, y)
|
||||||
|
else
|
||||||
|
ctx!.lineTo(x, y)
|
||||||
|
})
|
||||||
|
ctx!.stroke()
|
||||||
|
|
||||||
|
item.data.forEach((value, index) => {
|
||||||
|
const x = centerX(index)
|
||||||
|
const y = valueY(value)
|
||||||
|
ctx!.beginPath()
|
||||||
|
ctx!.setFillStyle('#ffffff')
|
||||||
|
ctx!.arc(x, y, 4, 0, Math.PI * 2)
|
||||||
|
ctx!.fill()
|
||||||
|
ctx!.beginPath()
|
||||||
|
ctx!.setFillStyle(item.color)
|
||||||
|
ctx!.arc(x, y, 3, 0, Math.PI * 2)
|
||||||
|
ctx!.fill()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// x labels
|
||||||
|
ctx.setFillStyle('#6B7280')
|
||||||
|
ctx.setFontSize(11)
|
||||||
|
ctx.setTextAlign('center')
|
||||||
|
categories.forEach((label, index) => {
|
||||||
|
ctx!.fillText(label, centerX(index), height - 8)
|
||||||
|
})
|
||||||
|
|
||||||
|
ctx.draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ redraw: measureAndDraw })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="finance-mix-chart">
|
||||||
|
<view class="finance-mix-chart__canvas-wrap">
|
||||||
|
<canvas
|
||||||
|
:canvas-id="canvasId"
|
||||||
|
class="finance-mix-chart__canvas"
|
||||||
|
:style="{ width: `${canvasWidth}px`, height: `${height}px` }"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-if="chart.series.length"
|
||||||
|
class="finance-mix-chart__legend"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
v-for="item in chart.series"
|
||||||
|
:key="item.name"
|
||||||
|
class="finance-mix-chart__legend-item"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
class="finance-mix-chart__legend-dot"
|
||||||
|
:style="{ background: item.color }"
|
||||||
|
/>
|
||||||
|
<text class="finance-mix-chart__legend-text">
|
||||||
|
{{ item.name }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.finance-mix-chart {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finance-mix-chart__canvas-wrap {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finance-mix-chart__canvas {
|
||||||
|
width: 100%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finance-mix-chart__legend {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
row-gap: 16rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
padding: 0 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finance-mix-chart__legend-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 50%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0 12rpx;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finance-mix-chart__legend-dot {
|
||||||
|
width: 16rpx;
|
||||||
|
height: 16rpx;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finance-mix-chart__legend-text {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #4b5563;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -102,14 +102,16 @@
|
|||||||
|
|
||||||
.finance-center__quick-grid {
|
.finance-center__quick-grid {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
flex-wrap: wrap;
|
||||||
|
row-gap: 28rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.finance-center__quick-item {
|
.finance-center__quick-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
width: 33.33%;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.finance-center__quick-icon-wrap {
|
.finance-center__quick-icon-wrap {
|
||||||
@@ -146,9 +148,21 @@
|
|||||||
color: $color-text-primary;
|
color: $color-text-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.finance-center__chart-placeholder {
|
.finance-center__chart-empty {
|
||||||
min-height: 360rpx;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 280rpx;
|
||||||
margin-top: 24rpx;
|
margin-top: 24rpx;
|
||||||
background: $color-bg-section;
|
background: $color-bg-section;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.finance-center__chart-empty-text {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.finance-center__mix-chart {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,35 +1,95 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { getFinanceSummary } from '@/api/finance'
|
||||||
import {
|
import {
|
||||||
FINANCE_CENTER_TOTAL,
|
FINANCE_DIMENSION_OPTIONS,
|
||||||
FINANCE_MONTH_OPTIONS,
|
|
||||||
FINANCE_QUICK_ACTIONS,
|
FINANCE_QUICK_ACTIONS,
|
||||||
} from '@/constants/finance-center'
|
} from '@/constants/finance-center'
|
||||||
import type { FinanceQuickAction } from '@/types/finance-center'
|
import type { FinanceQuickAction } from '@/types/finance-center'
|
||||||
|
import type { FinanceSummaryDimension, FinanceSummaryQuery } from '@/types/finance-api'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { chooseAndExportBills } from '@/utils/bill-export'
|
||||||
|
import { mapFinanceSummary, type FinanceSummaryView } from '@/utils/map-finance'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
import FinanceMixChart from './components/FinanceMixChart.vue'
|
||||||
|
|
||||||
const monthOptions = FINANCE_MONTH_OPTIONS
|
|
||||||
const quickActions = FINANCE_QUICK_ACTIONS
|
const quickActions = FINANCE_QUICK_ACTIONS
|
||||||
const selectedMonthIndex = ref(0)
|
const dimensionOptions = FINANCE_DIMENSION_OPTIONS
|
||||||
|
|
||||||
const selectedMonth = computed(() => monthOptions[selectedMonthIndex.value])
|
const loading = ref(false)
|
||||||
|
const dimension = ref<FinanceSummaryDimension>('YEAR')
|
||||||
|
const summary = ref<FinanceSummaryView>(mapFinanceSummary(null))
|
||||||
|
|
||||||
const totalAmountText = computed(() => `¥ ${FINANCE_CENTER_TOTAL}`)
|
const periodLabel = computed(() => summary.value.periodLabel)
|
||||||
|
const totalAmountText = computed(() => summary.value.totalAmountText)
|
||||||
|
const chart = computed(() => summary.value.chart)
|
||||||
|
const hasChartData = computed(() => chart.value.series.length > 0 && chart.value.categories.length > 0)
|
||||||
|
|
||||||
|
function buildQuery(): FinanceSummaryQuery {
|
||||||
|
const now = new Date()
|
||||||
|
const year = now.getFullYear()
|
||||||
|
const month = now.getMonth() + 1
|
||||||
|
const quarter = Math.ceil(month / 3)
|
||||||
|
const dim = dimension.value
|
||||||
|
|
||||||
|
if (dim === 'MONTH')
|
||||||
|
return { dimension: 'MONTH', year, month }
|
||||||
|
|
||||||
|
if (dim === 'QUARTER')
|
||||||
|
return { dimension: 'QUARTER', year, quarter }
|
||||||
|
|
||||||
|
return { dimension: 'YEAR', year }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadSummary() {
|
||||||
|
if (loading.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const vo = await getFinanceSummary(buildQuery())
|
||||||
|
summary.value = mapFinanceSummary(vo)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
summary.value = mapFinanceSummary(null)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
loadSummary()
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/index')
|
navigateBackWithFallback('/pages/personal-center/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelectMonth() {
|
function handleSelectDimension() {
|
||||||
uni.showActionSheet({
|
uni.showActionSheet({
|
||||||
itemList: monthOptions,
|
itemList: dimensionOptions.map(item => item.label),
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
selectedMonthIndex.value = res.tapIndex
|
const next = dimensionOptions[res.tapIndex]
|
||||||
|
if (!next || next.dimension === dimension.value)
|
||||||
|
return
|
||||||
|
dimension.value = next.dimension
|
||||||
|
loadSummary()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleQuickAction(item: FinanceQuickAction) {
|
function handleQuickAction(item: FinanceQuickAction) {
|
||||||
|
if (item.key === 'export') {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
chooseAndExportBills()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (item.path) {
|
if (item.path) {
|
||||||
uni.navigateTo({ url: item.path })
|
uni.navigateTo({ url: item.path })
|
||||||
return
|
return
|
||||||
@@ -70,10 +130,10 @@ function handleQuickAction(item: FinanceQuickAction) {
|
|||||||
</text>
|
</text>
|
||||||
<view
|
<view
|
||||||
class="finance-center__month"
|
class="finance-center__month"
|
||||||
@tap="handleSelectMonth"
|
@tap="handleSelectDimension"
|
||||||
>
|
>
|
||||||
<text class="finance-center__month-text">
|
<text class="finance-center__month-text">
|
||||||
{{ selectedMonth }}
|
{{ periodLabel }}
|
||||||
</text>
|
</text>
|
||||||
<text class="finance-center__month-arrow">
|
<text class="finance-center__month-arrow">
|
||||||
▾
|
▾
|
||||||
@@ -81,7 +141,7 @@ function handleQuickAction(item: FinanceQuickAction) {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="finance-center__amount">
|
<text class="finance-center__amount">
|
||||||
{{ totalAmountText }}
|
{{ loading ? '加载中...' : totalAmountText }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -111,7 +171,31 @@ function handleQuickAction(item: FinanceQuickAction) {
|
|||||||
<text class="finance-center__chart-title">
|
<text class="finance-center__chart-title">
|
||||||
业务类型分布
|
业务类型分布
|
||||||
</text>
|
</text>
|
||||||
<view class="finance-center__chart-placeholder" />
|
|
||||||
|
<view
|
||||||
|
v-if="loading && !hasChartData"
|
||||||
|
class="finance-center__chart-empty"
|
||||||
|
>
|
||||||
|
<text class="finance-center__chart-empty-text">
|
||||||
|
加载中...
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else-if="!hasChartData"
|
||||||
|
class="finance-center__chart-empty"
|
||||||
|
>
|
||||||
|
<text class="finance-center__chart-empty-text">
|
||||||
|
暂无分布数据
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else
|
||||||
|
class="finance-center__mix-chart"
|
||||||
|
>
|
||||||
|
<FinanceMixChart :chart="chart" />
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -91,3 +91,39 @@
|
|||||||
line-height: 1;
|
line-height: 1;
|
||||||
color: $color-text-placeholder;
|
color: $color-text-placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.personal-center__sheet-title {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 32rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: $color-text-primary;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.personal-center__sheet-input {
|
||||||
|
width: 100%;
|
||||||
|
height: 88rpx;
|
||||||
|
padding: 0 28rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-primary;
|
||||||
|
background: $color-bg-input;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.personal-center__sheet-placeholder {
|
||||||
|
color: $color-text-placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
.personal-center__sheet-submit {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 88rpx;
|
||||||
|
margin-top: 32rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
background: $color-primary;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,38 +1,183 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onShow } from '@dcloudio/uni-app'
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { getAccountProfile, updateAccountProfile } from '@/api/account'
|
||||||
|
import { uploadRequirementAttachment } from '@/api/requirement'
|
||||||
import AppTabBar from '@/components/AppTabBar.vue'
|
import AppTabBar from '@/components/AppTabBar.vue'
|
||||||
|
import BottomSheet from '@/components/BottomSheet.vue'
|
||||||
import {
|
import {
|
||||||
PERSONAL_CENTER_MENU,
|
PERSONAL_CENTER_MENU,
|
||||||
PERSONAL_CENTER_PROFILE,
|
PERSONAL_CENTER_PROFILE,
|
||||||
} from '@/constants/personal-center'
|
} from '@/constants/personal-center'
|
||||||
import type { PersonalCenterMenuItem } from '@/types/personal-center'
|
import type { PersonalCenterMenuItem } from '@/types/personal-center'
|
||||||
import editIcon from '@/static/icon/edit.svg'
|
import editIcon from '@/static/icon/edit.svg'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
|
import { fetchAndCacheAccountSecurity } from '@/utils/fetch-account-security'
|
||||||
|
import { getProfilePhoneFromAccount } from '@/utils/map-account-security'
|
||||||
|
|
||||||
const profile = PERSONAL_CENTER_PROFILE
|
const profile = PERSONAL_CENTER_PROFILE
|
||||||
const menuList = PERSONAL_CENTER_MENU
|
const menuList = PERSONAL_CENTER_MENU
|
||||||
|
const displayNickname = ref(profile.nickname)
|
||||||
const displayPhone = ref('')
|
const displayPhone = ref('')
|
||||||
|
const displayAvatar = ref(profile.avatar)
|
||||||
|
const avatarOssId = ref<string | undefined>()
|
||||||
|
const nicknameSheetVisible = ref(false)
|
||||||
|
const nicknameDraft = ref('')
|
||||||
|
const savingProfile = ref(false)
|
||||||
|
|
||||||
function refreshProfilePhone() {
|
function refreshProfileFromLocal() {
|
||||||
displayPhone.value = getLoginPhoneNumber() || '未登录'
|
const loginPhone = getLoginPhoneNumber()
|
||||||
|
if (!displayPhone.value && loginPhone)
|
||||||
|
displayPhone.value = loginPhone
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshProfile() {
|
||||||
|
refreshProfileFromLocal()
|
||||||
|
|
||||||
|
try {
|
||||||
|
const info = await getAccountProfile({ showErrorToast: false })
|
||||||
|
if (info?.nickName?.trim())
|
||||||
|
displayNickname.value = info.nickName.trim()
|
||||||
|
if (info?.avatar?.trim())
|
||||||
|
displayAvatar.value = info.avatar.trim()
|
||||||
|
if (info?.avatarOssId !== undefined && info.avatarOssId !== null && info.avatarOssId !== '')
|
||||||
|
avatarOssId.value = String(info.avatarOssId)
|
||||||
|
if (info?.phoneNumber?.trim())
|
||||||
|
displayPhone.value = info.phoneNumber.trim()
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 个人资料失败时回退账号安全接口的手机号
|
||||||
|
}
|
||||||
|
|
||||||
|
const vo = await fetchAndCacheAccountSecurity()
|
||||||
|
if (!vo)
|
||||||
|
return
|
||||||
|
|
||||||
|
const phoneFromApi = getProfilePhoneFromAccount(vo)
|
||||||
|
if (phoneFromApi)
|
||||||
|
displayPhone.value = phoneFromApi
|
||||||
|
else if (!displayPhone.value)
|
||||||
|
displayPhone.value = getLoginPhoneNumber() || '未登录'
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
refreshProfilePhone()
|
refreshProfile()
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleEditNickname() {
|
function handleEditNickname() {
|
||||||
uni.showToast({ title: '编辑昵称开发中', icon: 'none' })
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
nicknameDraft.value = displayNickname.value === '这里是昵称' || displayNickname.value === '未设置昵称'
|
||||||
|
? ''
|
||||||
|
: displayNickname.value
|
||||||
|
nicknameSheetVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMenuTap(item: PersonalCenterMenuItem) {
|
function closeNicknameSheet() {
|
||||||
if (item.path) {
|
nicknameSheetVisible.value = false
|
||||||
uni.navigateTo({ url: item.path })
|
}
|
||||||
|
|
||||||
|
async function handleSaveNickname() {
|
||||||
|
if (savingProfile.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const nickName = nicknameDraft.value.trim()
|
||||||
|
if (!nickName) {
|
||||||
|
uni.showToast({ title: '请输入昵称', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (nickName.length > 30) {
|
||||||
|
uni.showToast({ title: '昵称最多30个字', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.showToast({ title: '功能开发中', icon: 'none' })
|
savingProfile.value = true
|
||||||
|
uni.showLoading({ title: '保存中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateAccountProfile({
|
||||||
|
nickName,
|
||||||
|
...(avatarOssId.value ? { avatar: avatarOssId.value } : {}),
|
||||||
|
})
|
||||||
|
displayNickname.value = nickName
|
||||||
|
closeNicknameSheet()
|
||||||
|
uni.showToast({ title: '保存成功', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
savingProfile.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleChangeAvatar() {
|
||||||
|
if (!ensureLoggedIn() || savingProfile.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sizeType: ['compressed'],
|
||||||
|
sourceType: ['album', 'camera'],
|
||||||
|
success: async (res) => {
|
||||||
|
const filePath = res.tempFilePaths?.[0]
|
||||||
|
if (!filePath)
|
||||||
|
return
|
||||||
|
|
||||||
|
savingProfile.value = true
|
||||||
|
uni.showLoading({ title: '上传中...', mask: true })
|
||||||
|
try {
|
||||||
|
// APP 无 system:oss:upload 权限,不能走 /resource/oss/upload(会 403)
|
||||||
|
// 使用 APP 可访问的需求 OSS 上传;ossId 保持字符串,避免雪花精度丢失
|
||||||
|
const uploaded = await uploadRequirementAttachment(filePath)
|
||||||
|
const ossId = String(uploaded.ossId ?? uploaded.id ?? '').trim()
|
||||||
|
if (!ossId) {
|
||||||
|
uni.showToast({ title: '上传失败,未返回头像 ID', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const nickName = (
|
||||||
|
displayNickname.value === '这里是昵称' || displayNickname.value === '未设置昵称'
|
||||||
|
? '用户'
|
||||||
|
: displayNickname.value
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
await updateAccountProfile({
|
||||||
|
nickName,
|
||||||
|
avatar: ossId,
|
||||||
|
})
|
||||||
|
|
||||||
|
avatarOssId.value = ossId
|
||||||
|
displayAvatar.value = uploaded.url?.trim() || filePath
|
||||||
|
uni.showToast({ title: '头像已更新', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 错误提示由 request 统一处理
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
savingProfile.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMenuTap(item: PersonalCenterMenuItem) {
|
||||||
|
if (!item.path) {
|
||||||
|
uni.showToast({ title: '功能开发中', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 消息中心为底部 Tab 页,用 redirect 切换,避免堆栈叠加
|
||||||
|
if (item.key === 'message-push') {
|
||||||
|
uni.redirectTo({ url: item.path })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.navigateTo({ url: item.path })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -41,8 +186,9 @@ function handleMenuTap(item: PersonalCenterMenuItem) {
|
|||||||
<view class="personal-center__header">
|
<view class="personal-center__header">
|
||||||
<image
|
<image
|
||||||
class="personal-center__avatar"
|
class="personal-center__avatar"
|
||||||
:src="profile.avatar"
|
:src="displayAvatar"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
|
@tap="handleChangeAvatar"
|
||||||
/>
|
/>
|
||||||
<view class="personal-center__profile">
|
<view class="personal-center__profile">
|
||||||
<view
|
<view
|
||||||
@@ -50,7 +196,7 @@ function handleMenuTap(item: PersonalCenterMenuItem) {
|
|||||||
@tap="handleEditNickname"
|
@tap="handleEditNickname"
|
||||||
>
|
>
|
||||||
<text class="personal-center__nickname">
|
<text class="personal-center__nickname">
|
||||||
{{ profile.nickname }}
|
{{ displayNickname }}
|
||||||
</text>
|
</text>
|
||||||
<image
|
<image
|
||||||
class="personal-center__edit-icon"
|
class="personal-center__edit-icon"
|
||||||
@@ -92,6 +238,28 @@ function handleMenuTap(item: PersonalCenterMenuItem) {
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<AppTabBar active="personal" />
|
<AppTabBar active="personal" />
|
||||||
|
|
||||||
|
<BottomSheet
|
||||||
|
:visible="nicknameSheetVisible"
|
||||||
|
@close="closeNicknameSheet"
|
||||||
|
>
|
||||||
|
<text class="personal-center__sheet-title">
|
||||||
|
编辑昵称
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="nicknameDraft"
|
||||||
|
class="personal-center__sheet-input"
|
||||||
|
maxlength="30"
|
||||||
|
placeholder="请输入昵称"
|
||||||
|
placeholder-class="personal-center__sheet-placeholder"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
class="personal-center__sheet-submit"
|
||||||
|
@tap="handleSaveNickname"
|
||||||
|
>
|
||||||
|
保存
|
||||||
|
</view>
|
||||||
|
</BottomSheet>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,18 @@
|
|||||||
padding: 20rpx 24rpx calc(140rpx + env(safe-area-inset-bottom));
|
padding: 20rpx 24rpx calc(140rpx + env(safe-area-inset-bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.qualification-list__empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 120rpx 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qualification-list__empty-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.qualification-list__card {
|
.qualification-list__card {
|
||||||
padding: 28rpx 24rpx;
|
padding: 28rpx 24rpx;
|
||||||
margin-bottom: 20rpx;
|
margin-bottom: 20rpx;
|
||||||
@@ -66,12 +78,30 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.qualification-list__type-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12rpx;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.qualification-list__type {
|
.qualification-list__type {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: $color-text-secondary;
|
color: $color-text-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.qualification-list__default-tag {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 2rpx 10rpx;
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: $color-primary;
|
||||||
|
background: rgba(37, 99, 235, 0.1);
|
||||||
|
border-radius: 6rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.qualification-list__status {
|
.qualification-list__status {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-left: 16rpx;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: $color-stat-orange;
|
color: $color-stat-orange;
|
||||||
}
|
}
|
||||||
@@ -102,6 +132,10 @@
|
|||||||
.qualification-list__action {
|
.qualification-list__action {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
|
|
||||||
|
&--default {
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
&--edit {
|
&--edit {
|
||||||
color: $color-primary;
|
color: $color-primary;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,21 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { deleteQualification, setDefaultQualification } from '@/api/qualification'
|
||||||
import { QUALIFICATION_STATUS_LABEL } from '@/constants/qualification'
|
import { QUALIFICATION_STATUS_LABEL } from '@/constants/qualification'
|
||||||
import { useQualifications } from '@/hooks/use-qualifications'
|
import { useQualifications } from '@/hooks/use-qualifications'
|
||||||
import type { QualificationItem } from '@/types/qualification'
|
import type { QualificationItem } from '@/types/qualification'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const { qualifications } = useQualifications()
|
const { qualifications, allQualifications, listLoading, loadQualificationList } = useQualifications()
|
||||||
|
const acting = ref(false)
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
loadQualificationList()
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/index')
|
navigateBackWithFallback('/pages/personal-center/index')
|
||||||
@@ -14,8 +25,12 @@ function formatValidity(item: QualificationItem) {
|
|||||||
return `${item.validFrom}至${item.validTo}`
|
return `${item.validFrom}至${item.validTo}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusLabel(status: QualificationItem['status']) {
|
function statusLabel(item: QualificationItem) {
|
||||||
return QUALIFICATION_STATUS_LABEL[status]
|
return item.statusLabel || QUALIFICATION_STATUS_LABEL[item.status]
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDefault(item: QualificationItem) {
|
||||||
|
return Number(item.defaultFlag) === 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
@@ -30,18 +45,56 @@ function handleEdit(item: QualificationItem) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleSetDefault(item: QualificationItem) {
|
||||||
|
if (acting.value || isDefault(item) || !item.id)
|
||||||
|
return
|
||||||
|
|
||||||
|
acting.value = true
|
||||||
|
uni.showLoading({ title: '设置中...', mask: true })
|
||||||
|
try {
|
||||||
|
await setDefaultQualification(item.id)
|
||||||
|
allQualifications.value = allQualifications.value.map(row => ({
|
||||||
|
...row,
|
||||||
|
defaultFlag: row.id === item.id ? 1 : 0,
|
||||||
|
}))
|
||||||
|
uni.showToast({ title: '已设为默认', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
acting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleDelete(item: QualificationItem) {
|
function handleDelete(item: QualificationItem) {
|
||||||
|
if (acting.value || !item.id)
|
||||||
|
return
|
||||||
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '删除资质',
|
title: '删除资质',
|
||||||
content: `确认删除「${item.certificateName}」吗?`,
|
content: `确认删除「${item.certificateName}」吗?`,
|
||||||
confirmText: '删除',
|
confirmText: '删除',
|
||||||
confirmColor: '#2563EB',
|
confirmColor: '#2563EB',
|
||||||
success: (res) => {
|
success: async (res) => {
|
||||||
if (!res.confirm)
|
if (!res.confirm)
|
||||||
return
|
return
|
||||||
|
|
||||||
qualifications.value = qualifications.value.filter(row => row.id !== item.id)
|
acting.value = true
|
||||||
uni.showToast({ title: '已删除', icon: 'none' })
|
uni.showLoading({ title: '删除中...', mask: true })
|
||||||
|
try {
|
||||||
|
await deleteQualification(item.id)
|
||||||
|
allQualifications.value = allQualifications.value.filter(row => row.id !== item.id)
|
||||||
|
uni.showToast({ title: '已删除', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
acting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -72,17 +125,43 @@ function handleDelete(item: QualificationItem) {
|
|||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
>
|
>
|
||||||
<view class="qualification-list__content">
|
<view class="qualification-list__content">
|
||||||
|
<view
|
||||||
|
v-if="listLoading && !qualifications.length"
|
||||||
|
class="qualification-list__empty"
|
||||||
|
>
|
||||||
|
<text class="qualification-list__empty-text">
|
||||||
|
加载中...
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else-if="!qualifications.length"
|
||||||
|
class="qualification-list__empty"
|
||||||
|
>
|
||||||
|
<text class="qualification-list__empty-text">
|
||||||
|
暂无资质,点击下方新增
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-for="item in qualifications"
|
v-for="item in qualifications"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="qualification-list__card"
|
class="qualification-list__card"
|
||||||
>
|
>
|
||||||
<view class="qualification-list__card-header">
|
<view class="qualification-list__card-header">
|
||||||
<text class="qualification-list__type">
|
<view class="qualification-list__type-row">
|
||||||
{{ item.type }}
|
<text class="qualification-list__type">
|
||||||
</text>
|
{{ item.type }}
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
v-if="isDefault(item)"
|
||||||
|
class="qualification-list__default-tag"
|
||||||
|
>
|
||||||
|
默认
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
<text class="qualification-list__status">
|
<text class="qualification-list__status">
|
||||||
{{ statusLabel(item.status) }}
|
{{ statusLabel(item) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="qualification-list__name">
|
<text class="qualification-list__name">
|
||||||
@@ -98,6 +177,13 @@ function handleDelete(item: QualificationItem) {
|
|||||||
{{ formatValidity(item) }}
|
{{ formatValidity(item) }}
|
||||||
</text>
|
</text>
|
||||||
<view class="qualification-list__actions">
|
<view class="qualification-list__actions">
|
||||||
|
<text
|
||||||
|
v-if="!isDefault(item)"
|
||||||
|
class="qualification-list__action qualification-list__action--default"
|
||||||
|
@tap="handleSetDefault(item)"
|
||||||
|
>
|
||||||
|
设为默认
|
||||||
|
</text>
|
||||||
<text
|
<text
|
||||||
class="qualification-list__action qualification-list__action--edit"
|
class="qualification-list__action qualification-list__action--edit"
|
||||||
@tap="handleEdit(item)"
|
@tap="handleEdit(item)"
|
||||||
|
|||||||
@@ -245,4 +245,9 @@
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
background: $color-primary;
|
background: $color-primary;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
opacity: 0.55;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,122 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { QUALIFICATION_TYPE_OPTIONS } from '@/constants/qualification'
|
import {
|
||||||
|
clearQualificationDrafts,
|
||||||
|
getQualificationDetail,
|
||||||
|
saveQualificationDraft,
|
||||||
|
submitQualification,
|
||||||
|
} from '@/api/qualification'
|
||||||
|
import { uploadRequirementAttachment } from '@/api/requirement'
|
||||||
import { useQualifications } from '@/hooks/use-qualifications'
|
import { useQualifications } from '@/hooks/use-qualifications'
|
||||||
import type { QualificationItem, QualificationStatus } from '@/types/qualification'
|
import type { UserQualificationBo } from '@/types/qualification-api'
|
||||||
|
import type { QualificationItem } from '@/types/qualification'
|
||||||
import deleteIcon from '@/static/icons/X.png'
|
import deleteIcon from '@/static/icons/X.png'
|
||||||
import pdfIcon from '@/static/icons/PDF.png'
|
import pdfIcon from '@/static/icons/PDF.png'
|
||||||
import pngIcon from '@/static/icons/PNG.png'
|
import pngIcon from '@/static/icons/PNG.png'
|
||||||
|
import { mapUserQualificationToItem } from '@/utils/map-qualification'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const { qualifications, getQualificationById } = useQualifications()
|
interface AttachmentItem {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
icon: string
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const { typeOptions, loadQualificationTypes, loadLatestDraft } = useQualifications()
|
||||||
|
|
||||||
const editingId = ref<string | null>(null)
|
const editingId = ref<string | null>(null)
|
||||||
const typeOptions = QUALIFICATION_TYPE_OPTIONS
|
const loadingDetail = ref(false)
|
||||||
|
const submitting = ref(false)
|
||||||
const typeIndex = ref(-1)
|
const typeIndex = ref(-1)
|
||||||
|
const companyName = ref('')
|
||||||
const certificateName = ref('')
|
const certificateName = ref('')
|
||||||
const certificateNo = ref('')
|
const certificateNo = ref('')
|
||||||
const issuer = ref('')
|
const issuer = ref('')
|
||||||
const validFrom = ref('')
|
const validFrom = ref('')
|
||||||
const validTo = ref('')
|
const validTo = ref('')
|
||||||
|
const attachments = ref<AttachmentItem[]>([])
|
||||||
|
|
||||||
const attachments = ref([
|
const typeLabels = computed(() => typeOptions.value.map(item => item.label))
|
||||||
{ id: '1', name: '需求文档.pdf', icon: pdfIcon },
|
|
||||||
{ id: '2', name: '系统....pdf', icon: pdfIcon },
|
|
||||||
{ id: '3', name: '参考图.png', icon: pngIcon },
|
|
||||||
])
|
|
||||||
|
|
||||||
const selectedType = computed(() => {
|
const selectedType = computed(() => {
|
||||||
if (typeIndex.value < 0)
|
if (typeIndex.value < 0)
|
||||||
return ''
|
return ''
|
||||||
return typeOptions[typeIndex.value]
|
return typeOptions.value[typeIndex.value]?.label || ''
|
||||||
})
|
})
|
||||||
|
|
||||||
onLoad((options) => {
|
function fileIconByName(name: string) {
|
||||||
|
return /\.(png|jpe?g|gif|webp)$/i.test(name) ? pngIcon : pdfIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileNameFromUrl(url: string) {
|
||||||
|
const clean = url.split('?')[0] || ''
|
||||||
|
return clean.split('/').pop() || '附件'
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveTypeIndex(item: Pick<QualificationItem, 'type' | 'qualType'>) {
|
||||||
|
const byValue = typeOptions.value.findIndex(opt => opt.value === item.qualType)
|
||||||
|
if (byValue >= 0)
|
||||||
|
return byValue
|
||||||
|
const byLabel = typeOptions.value.findIndex(opt => opt.label === item.type)
|
||||||
|
return byLabel >= 0 ? byLabel : -1
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillForm(item: QualificationItem) {
|
||||||
|
editingId.value = item.id || null
|
||||||
|
typeIndex.value = resolveTypeIndex(item)
|
||||||
|
companyName.value = item.companyName || ''
|
||||||
|
certificateName.value = item.certificateName === '-' ? '' : item.certificateName
|
||||||
|
certificateNo.value = item.certificateNo === '-' ? '' : item.certificateNo
|
||||||
|
issuer.value = item.issuer === '-' ? '' : item.issuer
|
||||||
|
validFrom.value = item.validFrom === '-' ? '' : item.validFrom
|
||||||
|
validTo.value = item.validTo === '-' ? '' : item.validTo
|
||||||
|
attachments.value = (item.files || []).map((url, index) => {
|
||||||
|
const name = fileNameFromUrl(url)
|
||||||
|
return {
|
||||||
|
id: `${index}-${name}`,
|
||||||
|
name,
|
||||||
|
icon: fileIconByName(name),
|
||||||
|
url,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadDetail(id: string) {
|
||||||
|
loadingDetail.value = true
|
||||||
|
uni.showLoading({ title: '加载中...', mask: true })
|
||||||
|
try {
|
||||||
|
const vo = await getQualificationDetail(id)
|
||||||
|
fillForm(mapUserQualificationToItem(vo))
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
setTimeout(() => uni.navigateBack(), 1200)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loadingDetail.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad(async (options) => {
|
||||||
|
await loadQualificationTypes()
|
||||||
|
|
||||||
const rawId = options?.id
|
const rawId = options?.id
|
||||||
if (!rawId)
|
if (rawId) {
|
||||||
|
await loadDetail(decodeURIComponent(String(rawId)))
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const id = decodeURIComponent(String(rawId))
|
// 新增:回填最近一份保存的草稿(草稿不在列表展示)
|
||||||
const item = getQualificationById(id)
|
try {
|
||||||
if (!item)
|
const draft = await loadLatestDraft()
|
||||||
return
|
if (draft?.id)
|
||||||
|
await loadDetail(draft.id)
|
||||||
editingId.value = id
|
}
|
||||||
const index = typeOptions.indexOf(item.type)
|
catch {
|
||||||
typeIndex.value = index >= 0 ? index : 0
|
// 无草稿则空白表单
|
||||||
certificateName.value = item.certificateName
|
}
|
||||||
certificateNo.value = item.certificateNo
|
|
||||||
issuer.value = item.issuer
|
|
||||||
validFrom.value = item.validFrom
|
|
||||||
validTo.value = item.validTo
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
@@ -72,44 +139,106 @@ function handleRemoveAttachment(id: string) {
|
|||||||
attachments.value = attachments.value.filter(item => item.id !== id)
|
attachments.value = attachments.value.filter(item => item.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isChooseCanceled(errMsg?: string) {
|
||||||
|
return Boolean(errMsg?.includes('cancel') || errMsg?.includes('取消'))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadPaths(files: Array<{ name: string, path: string }>) {
|
||||||
|
for (const file of files) {
|
||||||
|
try {
|
||||||
|
uni.showLoading({ title: '上传中...', mask: true })
|
||||||
|
const uploaded = await uploadRequirementAttachment(file.path)
|
||||||
|
const url = uploaded.url?.trim()
|
||||||
|
if (!url) {
|
||||||
|
uni.showToast({ title: '上传失败', icon: 'none' })
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const name = uploaded.fileName?.trim() || file.name || fileNameFromUrl(url)
|
||||||
|
attachments.value.push({
|
||||||
|
id: `${Date.now()}-${attachments.value.length}`,
|
||||||
|
name,
|
||||||
|
icon: fileIconByName(name),
|
||||||
|
url,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request/upload 已提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleAddAttachment() {
|
function handleAddAttachment() {
|
||||||
uni.showToast({ title: '附件上传开发中', icon: 'none' })
|
uni.chooseImage({
|
||||||
|
count: 6,
|
||||||
|
success: (res) => {
|
||||||
|
uploadPaths(res.tempFilePaths.map((path, index) => ({
|
||||||
|
name: `图片${index + 1}.jpg`,
|
||||||
|
path,
|
||||||
|
})))
|
||||||
|
},
|
||||||
|
fail: (error) => {
|
||||||
|
if (isChooseCanceled(error.errMsg))
|
||||||
|
return
|
||||||
|
|
||||||
|
uni.chooseFile({
|
||||||
|
count: 6,
|
||||||
|
extension: ['.pdf', '.png', '.jpg', '.jpeg'],
|
||||||
|
success: (res) => {
|
||||||
|
uploadPaths(res.tempFiles.map(file => ({
|
||||||
|
name: file.name,
|
||||||
|
path: file.path,
|
||||||
|
})))
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
if (isChooseCanceled(err.errMsg))
|
||||||
|
return
|
||||||
|
uni.showToast({ title: '选择附件失败', icon: 'none' })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
if (!editingId.value) {
|
if (editingId.value) {
|
||||||
typeIndex.value = -1
|
loadDetail(editingId.value)
|
||||||
certificateName.value = ''
|
return
|
||||||
certificateNo.value = ''
|
|
||||||
issuer.value = ''
|
|
||||||
validFrom.value = ''
|
|
||||||
validTo.value = ''
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const item = getQualificationById(editingId.value)
|
|
||||||
if (item) {
|
|
||||||
const index = typeOptions.indexOf(item.type)
|
|
||||||
typeIndex.value = index >= 0 ? index : 0
|
|
||||||
certificateName.value = item.certificateName
|
|
||||||
certificateNo.value = item.certificateNo
|
|
||||||
issuer.value = item.issuer
|
|
||||||
validFrom.value = item.validFrom
|
|
||||||
validTo.value = item.validTo
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attachments.value = [
|
typeIndex.value = -1
|
||||||
{ id: '1', name: '需求文档.pdf', icon: pdfIcon },
|
companyName.value = ''
|
||||||
{ id: '2', name: '系统....pdf', icon: pdfIcon },
|
certificateName.value = ''
|
||||||
{ id: '3', name: '参考图.png', icon: pngIcon },
|
certificateNo.value = ''
|
||||||
]
|
issuer.value = ''
|
||||||
|
validFrom.value = ''
|
||||||
|
validTo.value = ''
|
||||||
|
attachments.value = []
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateForm() {
|
/** 草稿仅基本校验(与后端「保存草稿时仅基本校验」一致) */
|
||||||
if (!selectedType.value) {
|
function validateDraft() {
|
||||||
|
if (!selectedType.value || typeIndex.value < 0) {
|
||||||
uni.showToast({ title: '请选择资质类型', icon: 'none' })
|
uni.showToast({ title: '请选择资质类型', icon: 'none' })
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if (validFrom.value && validTo.value && validFrom.value > validTo.value) {
|
||||||
|
uni.showToast({ title: '有效期起始不能晚于截止', icon: 'none' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交认证全量校验 */
|
||||||
|
function validateSubmit() {
|
||||||
|
if (!validateDraft())
|
||||||
|
return false
|
||||||
|
if (!companyName.value.trim()) {
|
||||||
|
uni.showToast({ title: '请输入公司名称', icon: 'none' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (!certificateName.value.trim()) {
|
if (!certificateName.value.trim()) {
|
||||||
uni.showToast({ title: '请输入证书名称', icon: 'none' })
|
uni.showToast({ title: '请输入证书名称', icon: 'none' })
|
||||||
return false
|
return false
|
||||||
@@ -129,56 +258,83 @@ function validateForm() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildPayload(status: QualificationStatus): Omit<QualificationItem, 'id'> {
|
function buildBo(): UserQualificationBo | null {
|
||||||
return {
|
const option = typeOptions.value[typeIndex.value]
|
||||||
type: selectedType.value,
|
if (!option)
|
||||||
certificateName: certificateName.value.trim(),
|
return null
|
||||||
certificateNo: certificateNo.value.trim(),
|
|
||||||
issuer: issuer.value.trim(),
|
const payload: UserQualificationBo = {
|
||||||
validFrom: validFrom.value,
|
qualType: option.value,
|
||||||
validTo: validTo.value,
|
companyName: companyName.value.trim(),
|
||||||
status,
|
qualName: certificateName.value.trim(),
|
||||||
|
qualNo: certificateNo.value.trim(),
|
||||||
|
issueOrg: issuer.value.trim(),
|
||||||
|
validStart: validFrom.value,
|
||||||
|
validEnd: validTo.value,
|
||||||
|
files: attachments.value.map(item => item.url).filter(Boolean),
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑/更新草稿必须带主键,且保持字符串避免精度丢失
|
||||||
|
if (editingId.value)
|
||||||
|
payload.id = editingId.value
|
||||||
|
|
||||||
|
return payload
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSaveDraft() {
|
||||||
|
if (submitting.value || !validateDraft())
|
||||||
|
return
|
||||||
|
|
||||||
|
const data = buildBo()
|
||||||
|
if (!data)
|
||||||
|
return
|
||||||
|
|
||||||
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '保存中...', mask: true })
|
||||||
|
try {
|
||||||
|
const vo = await saveQualificationDraft(data)
|
||||||
|
if (vo?.id)
|
||||||
|
editingId.value = String(vo.id)
|
||||||
|
uni.showToast({ title: '草稿已保存', icon: 'none' })
|
||||||
|
setTimeout(() => uni.navigateBack(), 800)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function upsertItem(status: QualificationStatus) {
|
async function handleSubmit() {
|
||||||
const payload = buildPayload(status)
|
if (submitting.value || !validateSubmit())
|
||||||
|
|
||||||
if (editingId.value) {
|
|
||||||
qualifications.value = qualifications.value.map(row => (
|
|
||||||
row.id === editingId.value
|
|
||||||
? { ...row, ...payload }
|
|
||||||
: row
|
|
||||||
))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
const data = buildBo()
|
||||||
|
if (!data)
|
||||||
|
return
|
||||||
|
|
||||||
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
try {
|
||||||
|
const vo = await submitQualification(data)
|
||||||
|
// 提交成功后清空草稿,避免下次「新增」再次回填
|
||||||
|
await clearQualificationDrafts({
|
||||||
|
keepId: vo?.id ?? editingId.value,
|
||||||
|
showErrorToast: false,
|
||||||
|
})
|
||||||
|
editingId.value = null
|
||||||
|
uni.showToast({ title: '提交成功', icon: 'none' })
|
||||||
|
setTimeout(() => uni.navigateBack(), 800)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
|
|
||||||
qualifications.value.push({
|
|
||||||
id: `${Date.now()}`,
|
|
||||||
...payload,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSaveDraft() {
|
|
||||||
if (!validateForm())
|
|
||||||
return
|
|
||||||
|
|
||||||
upsertItem('draft')
|
|
||||||
uni.showToast({ title: '草稿已保存', icon: 'none' })
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 1200)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSubmit() {
|
|
||||||
if (!validateForm())
|
|
||||||
return
|
|
||||||
|
|
||||||
upsertItem('reviewing')
|
|
||||||
uni.showToast({ title: '提交成功', icon: 'none' })
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 1200)
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -213,7 +369,7 @@ function handleSubmit() {
|
|||||||
</text>
|
</text>
|
||||||
<picker
|
<picker
|
||||||
mode="selector"
|
mode="selector"
|
||||||
:range="typeOptions"
|
:range="typeLabels"
|
||||||
:value="typeIndex < 0 ? 0 : typeIndex"
|
:value="typeIndex < 0 ? 0 : typeIndex"
|
||||||
@change="handleTypeChange"
|
@change="handleTypeChange"
|
||||||
>
|
>
|
||||||
@@ -231,6 +387,18 @@ function handleSubmit() {
|
|||||||
</picker>
|
</picker>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="qualification-upload__field">
|
||||||
|
<text class="qualification-upload__label">
|
||||||
|
公司名称<text class="qualification-upload__required">*</text>
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="companyName"
|
||||||
|
class="qualification-upload__input"
|
||||||
|
placeholder="请输入公司名称"
|
||||||
|
placeholder-class="qualification-upload__placeholder"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="qualification-upload__field">
|
<view class="qualification-upload__field">
|
||||||
<text class="qualification-upload__label">
|
<text class="qualification-upload__label">
|
||||||
证书名称<text class="qualification-upload__required">*</text>
|
证书名称<text class="qualification-upload__required">*</text>
|
||||||
@@ -312,7 +480,7 @@ function handleSubmit() {
|
|||||||
附件上传
|
附件上传
|
||||||
</text>
|
</text>
|
||||||
<text class="qualification-upload__hint">
|
<text class="qualification-upload__hint">
|
||||||
支持图片/文档/压缩包
|
支持图片/PDF
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="qualification-upload__attachment-row">
|
<view class="qualification-upload__attachment-row">
|
||||||
@@ -359,18 +527,21 @@ function handleSubmit() {
|
|||||||
<view class="qualification-upload__footer">
|
<view class="qualification-upload__footer">
|
||||||
<view
|
<view
|
||||||
class="qualification-upload__footer-btn"
|
class="qualification-upload__footer-btn"
|
||||||
|
:class="{ 'qualification-upload__footer-btn--disabled': submitting || loadingDetail }"
|
||||||
@tap="handleSaveDraft"
|
@tap="handleSaveDraft"
|
||||||
>
|
>
|
||||||
保存草稿
|
保存草稿
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="qualification-upload__footer-btn"
|
class="qualification-upload__footer-btn"
|
||||||
|
:class="{ 'qualification-upload__footer-btn--disabled': submitting || loadingDetail }"
|
||||||
@tap="resetForm"
|
@tap="resetForm"
|
||||||
>
|
>
|
||||||
重置
|
重置
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="qualification-upload__footer-btn"
|
class="qualification-upload__footer-btn"
|
||||||
|
:class="{ 'qualification-upload__footer-btn--disabled': submitting || loadingDetail }"
|
||||||
@tap="handleSubmit"
|
@tap="handleSubmit"
|
||||||
>
|
>
|
||||||
提交认证
|
提交认证
|
||||||
|
|||||||
@@ -1,24 +1,107 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { getChatHotlineConfig, saveChatCallRecord } from '@/api/chat'
|
||||||
import {
|
import {
|
||||||
PERSONAL_CENTER_SERVICE_HOTLINE,
|
PERSONAL_CENTER_SERVICE_HOTLINE,
|
||||||
PERSONAL_CENTER_SERVICE_HOTLINE_HOURS,
|
PERSONAL_CENTER_SERVICE_HOTLINE_HOURS,
|
||||||
} from '@/constants/personal-center'
|
} from '@/constants/personal-center'
|
||||||
|
import type { CsHotlineConfig } from '@/types/chat-api'
|
||||||
import serviceHotlineIcon from '@/static/icon/service-hotline.svg'
|
import serviceHotlineIcon from '@/static/icon/service-hotline.svg'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
const hotlineDisplay = `专属客服热线-${PERSONAL_CENTER_SERVICE_HOTLINE}`
|
const config = ref<CsHotlineConfig | null>(null)
|
||||||
const workHours = PERSONAL_CENTER_SERVICE_HOTLINE_HOURS
|
const loading = ref(false)
|
||||||
const dialNumber = PERSONAL_CENTER_SERVICE_HOTLINE.replace(/-/g, '')
|
const dialing = ref(false)
|
||||||
|
|
||||||
|
const titleText = computed(() => {
|
||||||
|
const title = config.value?.title?.trim() || '专属客服'
|
||||||
|
const number = config.value?.number?.trim() || PERSONAL_CENTER_SERVICE_HOTLINE
|
||||||
|
return `${title}-${number}`
|
||||||
|
})
|
||||||
|
|
||||||
|
const workHours = computed(() =>
|
||||||
|
config.value?.workTime?.trim() || PERSONAL_CENTER_SERVICE_HOTLINE_HOURS,
|
||||||
|
)
|
||||||
|
|
||||||
|
const iconUrl = computed(() => config.value?.icon?.trim() || serviceHotlineIcon)
|
||||||
|
|
||||||
|
const dialNumber = computed(() => {
|
||||||
|
const raw = config.value?.number?.trim() || PERSONAL_CENTER_SERVICE_HOTLINE
|
||||||
|
return raw.replace(/[^\d+]/g, '')
|
||||||
|
})
|
||||||
|
|
||||||
|
async function loadConfig() {
|
||||||
|
if (loading.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
config.value = await getChatHotlineConfig({ showErrorToast: false })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
config.value = null
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
loadConfig()
|
||||||
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/personal-center/index')
|
navigateBackWithFallback('/pages/personal-center/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function reportCallRecord(status: string) {
|
||||||
|
const number = dialNumber.value
|
||||||
|
if (!number)
|
||||||
|
return
|
||||||
|
|
||||||
|
try {
|
||||||
|
await saveChatCallRecord({
|
||||||
|
dialedNumber: number,
|
||||||
|
userPhone: getLoginPhoneNumber()?.trim() || undefined,
|
||||||
|
status,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 上报失败不影响拨号体验
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleDial() {
|
function handleDial() {
|
||||||
|
if (dialing.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
const number = dialNumber.value
|
||||||
|
if (!number) {
|
||||||
|
uni.showToast({ title: '暂无热线号码', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dialing.value = true
|
||||||
uni.makePhoneCall({
|
uni.makePhoneCall({
|
||||||
phoneNumber: dialNumber,
|
phoneNumber: number,
|
||||||
|
success: () => {
|
||||||
|
reportCallRecord('DIALED')
|
||||||
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
uni.showToast({ title: PERSONAL_CENTER_SERVICE_HOTLINE, icon: 'none' })
|
reportCallRecord('CANCELLED')
|
||||||
|
uni.showToast({
|
||||||
|
title: config.value?.number?.trim() || PERSONAL_CENTER_SERVICE_HOTLINE,
|
||||||
|
icon: 'none',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
dialing.value = false
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -47,12 +130,12 @@ function handleDial() {
|
|||||||
<view class="service-hotline__card">
|
<view class="service-hotline__card">
|
||||||
<image
|
<image
|
||||||
class="service-hotline__icon"
|
class="service-hotline__icon"
|
||||||
:src="serviceHotlineIcon"
|
:src="iconUrl"
|
||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
<view class="service-hotline__info">
|
<view class="service-hotline__info">
|
||||||
<text class="service-hotline__title">
|
<text class="service-hotline__title">
|
||||||
{{ hotlineDisplay }}
|
{{ titleText }}
|
||||||
</text>
|
</text>
|
||||||
<text class="service-hotline__hours">
|
<text class="service-hotline__hours">
|
||||||
{{ workHours }}
|
{{ workHours }}
|
||||||
|
|||||||
@@ -1,44 +1,88 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
import { BUSINESS_TYPE_OPTIONS } from '@/constants/business-types'
|
import { getRequirementDetail, submitRequirementAfterSale, uploadRequirementAttachment } from '@/api/requirement'
|
||||||
import { getProjectDetail } from '@/constants/project-detail'
|
import { useRequirementBusinessTypes } from '@/hooks/use-requirement-business-types'
|
||||||
import deleteIcon from '@/static/icons/X.png'
|
import deleteIcon from '@/static/icons/X.png'
|
||||||
import pdfIcon from '@/static/icons/PDF.png'
|
import pdfIcon from '@/static/icons/PDF.png'
|
||||||
import pngIcon from '@/static/icons/PNG.png'
|
import pngIcon from '@/static/icons/PNG.png'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { getLoginPhoneNumber } from '@/utils/auth-storage'
|
||||||
|
import { buildAfterSaleActionBody } from '@/utils/build-after-sale-action'
|
||||||
|
import {
|
||||||
|
chooseLocalFiles,
|
||||||
|
REQUIREMENT_ATTACHMENT_MAX_COUNT,
|
||||||
|
} from '@/utils/choose-local-files'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
import { navigateToResultPage } from '@/utils/navigate-result'
|
import { navigateToResultPage } from '@/utils/navigate-result'
|
||||||
|
|
||||||
const projectId = ref('1')
|
const { businessTypes, loadRequirementBusinessTypes } = useRequirementBusinessTypes()
|
||||||
|
|
||||||
|
const projectId = ref('')
|
||||||
const fallbackUrl = ref('/pages/project-center/index')
|
const fallbackUrl = ref('/pages/project-center/index')
|
||||||
const businessType = ref('')
|
const businessType = ref('')
|
||||||
const businessTypeDropdownVisible = ref(false)
|
const businessTypeDropdownVisible = ref(false)
|
||||||
const businessTypeOptions = BUSINESS_TYPE_OPTIONS
|
|
||||||
const projectName = ref('')
|
const projectName = ref('')
|
||||||
const description = ref('')
|
const description = ref('')
|
||||||
const userName = ref('王永志')
|
const userName = ref('')
|
||||||
const userPhone = ref('186****9618')
|
const userPhone = ref('')
|
||||||
const remark = ref('')
|
const remark = ref('')
|
||||||
|
const submitting = ref(false)
|
||||||
|
const uploadingAttachment = ref(false)
|
||||||
|
|
||||||
const attachments = ref([
|
interface AfterSaleAttachmentItem {
|
||||||
{ id: '1', name: '需求文档.pdf', icon: pdfIcon },
|
id: string
|
||||||
{ id: '2', name: '系统....pdf', icon: pdfIcon },
|
name: string
|
||||||
{ id: '3', name: '参考图.png', icon: pngIcon },
|
icon: string
|
||||||
])
|
ossId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const attachments = ref<AfterSaleAttachmentItem[]>([])
|
||||||
|
|
||||||
const descLength = computed(() => description.value.length)
|
const descLength = computed(() => description.value.length)
|
||||||
|
|
||||||
onLoad((options) => {
|
function resolveAttachmentIcon(name: string) {
|
||||||
const id = options?.id ? decodeURIComponent(String(options.id)) : '1'
|
const ext = name.split('.').pop()?.toLowerCase()
|
||||||
projectId.value = id
|
if (ext === 'png' || ext === 'jpg' || ext === 'jpeg')
|
||||||
fallbackUrl.value = `/pages/project-center/detail/index?id=${encodeURIComponent(id)}`
|
return pngIcon
|
||||||
|
|
||||||
const detail = getProjectDetail(id)
|
return pdfIcon
|
||||||
if (detail) {
|
}
|
||||||
projectName.value = detail.title
|
|
||||||
if (BUSINESS_TYPE_OPTIONS.includes(detail.category))
|
async function loadRequirement(id: string) {
|
||||||
businessType.value = detail.category
|
try {
|
||||||
|
const detail = await getRequirementDetail(id)
|
||||||
|
projectName.value = detail.projectName || ''
|
||||||
|
if (detail.businessType)
|
||||||
|
businessType.value = detail.businessType
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
// 详情失败仍允许填写售后说明
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
const id = options?.id ? decodeURIComponent(String(options.id)) : ''
|
||||||
|
if (!id) {
|
||||||
|
uni.showToast({ title: '参数错误', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
projectId.value = id
|
||||||
|
fallbackUrl.value = `/pages/project-center/detail/index?id=${encodeURIComponent(id)}&tab=aftersales`
|
||||||
|
loadRequirement(id)
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
loadRequirementBusinessTypes()
|
||||||
|
const phone = getLoginPhoneNumber()
|
||||||
|
if (phone && !userPhone.value)
|
||||||
|
userPhone.value = phone
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
@@ -63,23 +107,71 @@ function handleRemoveAttachment(id: string) {
|
|||||||
attachments.value = attachments.value.filter(item => item.id !== id)
|
attachments.value = attachments.value.filter(item => item.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAddAttachment() {
|
async function handleAddAttachment() {
|
||||||
uni.showToast({ title: '附件上传开发中', icon: 'none' })
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (uploadingAttachment.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
const remain = REQUIREMENT_ATTACHMENT_MAX_COUNT - attachments.value.length
|
||||||
|
if (remain <= 0) {
|
||||||
|
uni.showToast({ title: `最多上传${REQUIREMENT_ATTACHMENT_MAX_COUNT}个附件`, icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const files = await chooseLocalFiles(remain)
|
||||||
|
if (!files.length)
|
||||||
|
return
|
||||||
|
|
||||||
|
uploadingAttachment.value = true
|
||||||
|
uni.showLoading({ title: '上传中...', mask: true })
|
||||||
|
|
||||||
|
for (const file of files) {
|
||||||
|
const uploaded = await uploadRequirementAttachment(file.path)
|
||||||
|
const ossId = uploaded.ossId ?? uploaded.id
|
||||||
|
if (ossId === undefined || ossId === null || ossId === '') {
|
||||||
|
uni.showToast({ title: '上传失败,未返回附件 ID', icon: 'none' })
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const ossIdText = String(ossId)
|
||||||
|
const name = uploaded.fileName || file.name
|
||||||
|
attachments.value.push({
|
||||||
|
id: ossIdText,
|
||||||
|
ossId: ossIdText,
|
||||||
|
name,
|
||||||
|
icon: resolveAttachmentIcon(name),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : '上传失败'
|
||||||
|
if (!/cancel/i.test(message))
|
||||||
|
uni.showToast({ title: message, icon: 'none' })
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uploadingAttachment.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleReset() {
|
function handleReset() {
|
||||||
description.value = ''
|
description.value = ''
|
||||||
remark.value = ''
|
remark.value = ''
|
||||||
businessType.value = ''
|
attachments.value = []
|
||||||
const detail = getProjectDetail(projectId.value)
|
if (projectId.value)
|
||||||
if (detail) {
|
loadRequirement(projectId.value)
|
||||||
projectName.value = detail.title
|
|
||||||
if (BUSINESS_TYPE_OPTIONS.includes(detail.category))
|
|
||||||
businessType.value = detail.category
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
if (submitting.value || !projectId.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
if (!businessType.value) {
|
if (!businessType.value) {
|
||||||
uni.showToast({ title: '请选择业务类型', icon: 'none' })
|
uni.showToast({ title: '请选择业务类型', icon: 'none' })
|
||||||
return
|
return
|
||||||
@@ -89,11 +181,39 @@ function handleSubmit() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!description.value.trim()) {
|
if (!description.value.trim()) {
|
||||||
uni.showToast({ title: '请填写核心需求描述', icon: 'none' })
|
uni.showToast({ title: '请填写问题描述', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToResultPage('afterSalesSuccess', { id: projectId.value })
|
if (description.value.trim().length > 500) {
|
||||||
|
uni.showToast({ title: '问题描述不超过500字', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
const body = buildAfterSaleActionBody({
|
||||||
|
requirementId: projectId.value,
|
||||||
|
reason: description.value,
|
||||||
|
remark: remark.value,
|
||||||
|
businessType: businessType.value,
|
||||||
|
contactName: userName.value,
|
||||||
|
contactPhone: userPhone.value,
|
||||||
|
attachmentOssIds: attachments.value.map(item => item.ossId || item.id),
|
||||||
|
})
|
||||||
|
|
||||||
|
await submitRequirementAfterSale(projectId.value, body)
|
||||||
|
navigateToResultPage('afterSalesSuccess', { id: projectId.value })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 层已 toast
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -152,7 +272,7 @@ function handleSubmit() {
|
|||||||
@tap.stop
|
@tap.stop
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
v-for="option in businessTypeOptions"
|
v-for="option in businessTypes"
|
||||||
:key="option"
|
:key="option"
|
||||||
class="after-sales-apply__dropdown-item"
|
class="after-sales-apply__dropdown-item"
|
||||||
:class="{ 'after-sales-apply__dropdown-item--active': businessType === option }"
|
:class="{ 'after-sales-apply__dropdown-item--active': businessType === option }"
|
||||||
@@ -182,7 +302,7 @@ function handleSubmit() {
|
|||||||
|
|
||||||
<view class="after-sales-apply__field">
|
<view class="after-sales-apply__field">
|
||||||
<text class="after-sales-apply__label">
|
<text class="after-sales-apply__label">
|
||||||
核心需求描述<text class="after-sales-apply__required">
|
问题描述<text class="after-sales-apply__required">
|
||||||
*
|
*
|
||||||
</text>
|
</text>
|
||||||
</text>
|
</text>
|
||||||
|
|||||||
@@ -182,4 +182,10 @@
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
background: $color-primary;
|
background: $color-primary;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
&--ghost {
|
||||||
|
color: $color-primary;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 2rpx solid $color-primary;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { getBill } from '@/constants/bill-list'
|
import { getBillDetail } from '@/api/bill'
|
||||||
import { PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
|
import { BILL_STATUS_LABEL } from '@/constants/bill-list'
|
||||||
import billPendingIcon from '@/static/icon/bill-pending.png'
|
import billPendingIcon from '@/static/icon/bill-pending.png'
|
||||||
import notDueIcon from '@/static/icon/not-due.png'
|
import notDueIcon from '@/static/icon/not-due.png'
|
||||||
import successIcon from '@/static/icons/icon-register-success.png'
|
import successIcon from '@/static/icons/icon-register-success.png'
|
||||||
import type { BillItem } from '@/types/bill'
|
import type { BillItem } from '@/types/bill'
|
||||||
|
import { mapFinanceBillToItem } from '@/utils/map-bill'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
type PaymentMethod = 'wechat' | 'alipay'
|
type PaymentMethod = 'wechat' | 'alipay'
|
||||||
@@ -17,7 +18,7 @@ const paymentMethod = ref<PaymentMethod>('wechat')
|
|||||||
const statusLabel = computed(() => {
|
const statusLabel = computed(() => {
|
||||||
if (!bill.value)
|
if (!bill.value)
|
||||||
return ''
|
return ''
|
||||||
return PAYMENT_PLAN_STATUS_LABEL[bill.value.status] || ''
|
return BILL_STATUS_LABEL[bill.value.status] || ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const heroIcon = computed(() => {
|
const heroIcon = computed(() => {
|
||||||
@@ -33,8 +34,13 @@ const heroIcon = computed(() => {
|
|||||||
const paymentMethodLabel = computed(() => {
|
const paymentMethodLabel = computed(() => {
|
||||||
if (!bill.value)
|
if (!bill.value)
|
||||||
return ''
|
return ''
|
||||||
if (bill.value.status === 'paid')
|
if (bill.value.status === 'paid') {
|
||||||
return paymentMethod.value === 'wechat' ? '微信支付' : '支付宝'
|
if (bill.value.paidMethod === 'alipay' || paymentMethod.value === 'alipay')
|
||||||
|
return '支付宝'
|
||||||
|
if (bill.value.paidMethod === 'wechat' || paymentMethod.value === 'wechat')
|
||||||
|
return '微信支付'
|
||||||
|
return bill.value.payChannel || '--'
|
||||||
|
}
|
||||||
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
|
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
|
||||||
return '微信支付'
|
return '微信支付'
|
||||||
return '--'
|
return '--'
|
||||||
@@ -46,13 +52,15 @@ const paymentTime = computed(() => {
|
|||||||
if (bill.value.paidAt)
|
if (bill.value.paidAt)
|
||||||
return bill.value.paidAt
|
return bill.value.paidAt
|
||||||
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
|
if (bill.value.status === 'pending' || bill.value.status === 'not_due')
|
||||||
return '2026-01-21 15:00:00'
|
return bill.value.dueDate || '--'
|
||||||
return '--'
|
return '--'
|
||||||
})
|
})
|
||||||
|
|
||||||
const orderCardTitle = computed(() => {
|
const orderCardTitle = computed(() => {
|
||||||
if (bill.value?.status === 'paid' || bill.value?.status === 'pending')
|
if (bill.value?.status === 'paid')
|
||||||
return '已支付订单'
|
return '已支付订单'
|
||||||
|
if (bill.value?.status === 'pending')
|
||||||
|
return '待支付订单'
|
||||||
if (bill.value?.status === 'not_due')
|
if (bill.value?.status === 'not_due')
|
||||||
return '账单订单'
|
return '账单订单'
|
||||||
return '账单订单'
|
return '账单订单'
|
||||||
@@ -65,17 +73,33 @@ const showPaymentInfo = computed(() =>
|
|||||||
)
|
)
|
||||||
|
|
||||||
const showPayFooter = computed(() => bill.value?.status === 'pending')
|
const showPayFooter = computed(() => bill.value?.status === 'pending')
|
||||||
|
const showRefundFooter = computed(() => bill.value?.status === 'paid')
|
||||||
|
const showFooter = computed(() => showPayFooter.value || showRefundFooter.value)
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad(async (options) => {
|
||||||
const projectId = options?.projectId ? decodeURIComponent(String(options.projectId)) : '1'
|
const id = options?.id
|
||||||
const planId = options?.planId ? decodeURIComponent(String(options.planId)) : '1'
|
? decodeURIComponent(String(options.id))
|
||||||
|
: (options?.planId ? decodeURIComponent(String(options.planId)) : '')
|
||||||
const method = options?.method ? decodeURIComponent(String(options.method)) : 'wechat'
|
const method = options?.method ? decodeURIComponent(String(options.method)) : 'wechat'
|
||||||
paymentMethod.value = method === 'alipay' ? 'alipay' : 'wechat'
|
paymentMethod.value = method === 'alipay' ? 'alipay' : 'wechat'
|
||||||
bill.value = getBill(projectId, planId)
|
|
||||||
|
|
||||||
if (!bill.value) {
|
if (!id) {
|
||||||
uni.showToast({ title: '账单不存在', icon: 'none' })
|
uni.showToast({ title: '账单不存在', icon: 'none' })
|
||||||
setTimeout(() => uni.navigateBack(), 1500)
|
setTimeout(() => uni.navigateBack(), 1500)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showLoading({ title: '加载中...', mask: true })
|
||||||
|
try {
|
||||||
|
const vo = await getBillDetail(id)
|
||||||
|
bill.value = mapFinanceBillToItem(vo)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
bill.value = null
|
||||||
|
setTimeout(() => uni.navigateBack(), 1200)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -84,7 +108,7 @@ function handleBack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatAmount(amount: number) {
|
function formatAmount(amount: number) {
|
||||||
return `¥ ${amount}`
|
return `¥ ${Number(amount || 0).toFixed(2)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePayNow() {
|
function handlePayNow() {
|
||||||
@@ -92,7 +116,16 @@ function handlePayNow() {
|
|||||||
return
|
return
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(bill.value.projectId)}&planId=${encodeURIComponent(bill.value.id)}`,
|
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(bill.value.projectId)}&planId=${encodeURIComponent(bill.value.id)}&billId=${encodeURIComponent(bill.value.id)}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleApplyRefund() {
|
||||||
|
if (!bill.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/project-center/refund-apply/index?billId=${encodeURIComponent(bill.value.id)}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -101,7 +134,7 @@ function handlePayNow() {
|
|||||||
<view
|
<view
|
||||||
v-if="bill"
|
v-if="bill"
|
||||||
class="bill-detail"
|
class="bill-detail"
|
||||||
:class="{ 'bill-detail--with-footer': showPayFooter }"
|
:class="{ 'bill-detail--with-footer': showFooter }"
|
||||||
>
|
>
|
||||||
<view class="bill-detail__navbar">
|
<view class="bill-detail__navbar">
|
||||||
<view
|
<view
|
||||||
@@ -203,15 +236,23 @@ function handlePayNow() {
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-if="showPayFooter"
|
v-if="showFooter"
|
||||||
class="bill-detail__footer"
|
class="bill-detail__footer"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
|
v-if="showPayFooter"
|
||||||
class="bill-detail__pay-btn"
|
class="bill-detail__pay-btn"
|
||||||
@tap="handlePayNow"
|
@tap="handlePayNow"
|
||||||
>
|
>
|
||||||
立即支付
|
立即支付
|
||||||
</view>
|
</view>
|
||||||
|
<view
|
||||||
|
v-if="showRefundFooter"
|
||||||
|
class="bill-detail__pay-btn bill-detail__pay-btn--ghost"
|
||||||
|
@tap="handleApplyRefund"
|
||||||
|
>
|
||||||
|
申请退款
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
166
src/pages/project-center/bill-generate/index.scss
Normal file
166
src/pages/project-center/bill-generate/index.scss
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
@import '@/styles/variables.scss';
|
||||||
|
|
||||||
|
.bill-generate {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 100vh;
|
||||||
|
background: $color-bg-section;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__navbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: calc(var(--status-bar-height, 44px) + 12rpx) 24rpx 20rpx;
|
||||||
|
background: $color-bg-page;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__back {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 64rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__back-icon {
|
||||||
|
width: 40rpx;
|
||||||
|
height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__navbar-title {
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__navbar-placeholder {
|
||||||
|
width: 64rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__scroll {
|
||||||
|
flex: 1;
|
||||||
|
height: 0;
|
||||||
|
padding: 20rpx 24rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__card {
|
||||||
|
padding: 28rpx 24rpx;
|
||||||
|
background: $color-bg-page;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__field {
|
||||||
|
margin-bottom: 28rpx;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__required {
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__label-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
|
||||||
|
.bill-generate__label {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__hint {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__input,
|
||||||
|
.bill-generate__picker {
|
||||||
|
height: 80rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
background: $color-bg-page;
|
||||||
|
border: 1rpx solid #e8eaef;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__input {
|
||||||
|
width: 100%;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__picker {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__picker-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-primary;
|
||||||
|
|
||||||
|
&--placeholder {
|
||||||
|
color: $color-text-placeholder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__picker-arrow {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__placeholder {
|
||||||
|
color: $color-text-placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 160rpx;
|
||||||
|
padding: 20rpx 24rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-primary;
|
||||||
|
background: $color-bg-page;
|
||||||
|
border: 1rpx solid #e8eaef;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
|
||||||
|
background: $color-bg-page;
|
||||||
|
border-top: 1rpx solid #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-generate__submit {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 88rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #ffffff;
|
||||||
|
background: $color-primary;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
opacity: 0.55;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
318
src/pages/project-center/bill-generate/index.vue
Normal file
318
src/pages/project-center/bill-generate/index.vue
Normal file
@@ -0,0 +1,318 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import { generateBill } from '@/api/bill'
|
||||||
|
import {
|
||||||
|
BILL_BIZ_TYPE_OPTIONS,
|
||||||
|
BILL_TYPE_OPTIONS,
|
||||||
|
} from '@/constants/bill-list'
|
||||||
|
import type { BillGenerateBo } from '@/types/bill-api'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
|
const submitting = ref(false)
|
||||||
|
const bizTypeIndex = ref(-1)
|
||||||
|
const billTypeIndex = ref(-1)
|
||||||
|
const periodName = ref('')
|
||||||
|
const periodRatio = ref('')
|
||||||
|
const amount = ref('')
|
||||||
|
const dueDate = ref('')
|
||||||
|
const contractId = ref('')
|
||||||
|
const remark = ref('')
|
||||||
|
|
||||||
|
const bizTypeLabels = computed(() => BILL_BIZ_TYPE_OPTIONS.map(item => item.label))
|
||||||
|
const billTypeLabels = computed(() => BILL_TYPE_OPTIONS.map(item => item.label))
|
||||||
|
|
||||||
|
const selectedBizType = computed(() => {
|
||||||
|
if (bizTypeIndex.value < 0)
|
||||||
|
return ''
|
||||||
|
return BILL_BIZ_TYPE_OPTIONS[bizTypeIndex.value]?.label || ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const selectedBillType = computed(() => {
|
||||||
|
if (billTypeIndex.value < 0)
|
||||||
|
return ''
|
||||||
|
return BILL_TYPE_OPTIONS[billTypeIndex.value]?.label || ''
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleBack() {
|
||||||
|
navigateBackWithFallback('/pages/project-center/bill-list/index')
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleBizTypeChange(event: { detail: { value: string } }) {
|
||||||
|
bizTypeIndex.value = Number(event.detail.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleBillTypeChange(event: { detail: { value: string } }) {
|
||||||
|
billTypeIndex.value = Number(event.detail.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDueDateChange(event: { detail: { value: string } }) {
|
||||||
|
dueDate.value = event.detail.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateForm() {
|
||||||
|
if (billTypeIndex.value < 0) {
|
||||||
|
uni.showToast({ title: '请选择账单类型', icon: 'none' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (!periodName.value.trim()) {
|
||||||
|
uni.showToast({ title: '请输入期次名称', icon: 'none' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const amountNum = Number(amount.value)
|
||||||
|
if (!amount.value.trim() || !Number.isFinite(amountNum) || amountNum <= 0) {
|
||||||
|
uni.showToast({ title: '请输入正确金额', icon: 'none' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (periodRatio.value.trim()) {
|
||||||
|
const ratio = Number(periodRatio.value)
|
||||||
|
if (!Number.isFinite(ratio) || ratio < 0 || ratio > 100) {
|
||||||
|
uni.showToast({ title: '比例需在 0-100 之间', icon: 'none' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (contractId.value.trim() && !/^\d+$/.test(contractId.value.trim())) {
|
||||||
|
uni.showToast({ title: '合同 ID 需为数字', icon: 'none' })
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPayload(): BillGenerateBo {
|
||||||
|
const payload: BillGenerateBo = {
|
||||||
|
sourceType: 'MANUAL',
|
||||||
|
billType: BILL_TYPE_OPTIONS[billTypeIndex.value]?.value,
|
||||||
|
periodName: periodName.value.trim(),
|
||||||
|
amount: Number(amount.value),
|
||||||
|
}
|
||||||
|
|
||||||
|
const biz = BILL_BIZ_TYPE_OPTIONS[bizTypeIndex.value]
|
||||||
|
if (biz)
|
||||||
|
payload.bizType = biz.value
|
||||||
|
|
||||||
|
if (periodRatio.value.trim())
|
||||||
|
payload.periodRatio = Number(periodRatio.value)
|
||||||
|
|
||||||
|
if (dueDate.value)
|
||||||
|
payload.dueDate = dueDate.value
|
||||||
|
|
||||||
|
if (contractId.value.trim())
|
||||||
|
payload.contractId = contractId.value.trim()
|
||||||
|
|
||||||
|
if (remark.value.trim())
|
||||||
|
payload.supplementaryRemark = remark.value.trim()
|
||||||
|
|
||||||
|
return payload
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
if (!ensureLoggedIn() || submitting.value || !validateForm())
|
||||||
|
return
|
||||||
|
|
||||||
|
submitting.value = true
|
||||||
|
uni.showLoading({ title: '生成中...', mask: true })
|
||||||
|
try {
|
||||||
|
const id = await generateBill(buildPayload())
|
||||||
|
uni.showToast({ title: '账单已生成', icon: 'none' })
|
||||||
|
setTimeout(() => {
|
||||||
|
if (id != null && String(id)) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: `/pages/project-center/bill-detail/index?id=${encodeURIComponent(String(id))}`,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.navigateBack()
|
||||||
|
}, 600)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示(无权限等)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
submitting.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<view class="bill-generate">
|
||||||
|
<view class="bill-generate__navbar">
|
||||||
|
<view
|
||||||
|
class="bill-generate__back"
|
||||||
|
@tap="handleBack"
|
||||||
|
>
|
||||||
|
<image
|
||||||
|
class="bill-generate__back-icon"
|
||||||
|
src="/static/icons/icon-back.svg"
|
||||||
|
mode="aspectFit"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text class="bill-generate__navbar-title">
|
||||||
|
手动建账
|
||||||
|
</text>
|
||||||
|
<view class="bill-generate__navbar-placeholder" />
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<scroll-view
|
||||||
|
class="bill-generate__scroll"
|
||||||
|
scroll-y
|
||||||
|
:show-scrollbar="false"
|
||||||
|
>
|
||||||
|
<view class="bill-generate__card">
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
账单类型<text class="bill-generate__required">*</text>
|
||||||
|
</text>
|
||||||
|
<picker
|
||||||
|
mode="selector"
|
||||||
|
:range="billTypeLabels"
|
||||||
|
:value="billTypeIndex < 0 ? 0 : billTypeIndex"
|
||||||
|
@change="handleBillTypeChange"
|
||||||
|
>
|
||||||
|
<view class="bill-generate__picker">
|
||||||
|
<text
|
||||||
|
class="bill-generate__picker-text"
|
||||||
|
:class="{ 'bill-generate__picker-text--placeholder': !selectedBillType }"
|
||||||
|
>
|
||||||
|
{{ selectedBillType || '请选择账单类型' }}
|
||||||
|
</text>
|
||||||
|
<text class="bill-generate__picker-arrow">
|
||||||
|
▾
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
期次名称<text class="bill-generate__required">*</text>
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="periodName"
|
||||||
|
class="bill-generate__input"
|
||||||
|
placeholder="如:第1期·预付款"
|
||||||
|
placeholder-class="bill-generate__placeholder"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
账单金额(元)<text class="bill-generate__required">*</text>
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="amount"
|
||||||
|
class="bill-generate__input"
|
||||||
|
type="digit"
|
||||||
|
placeholder="请输入金额"
|
||||||
|
placeholder-class="bill-generate__placeholder"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
业务类型
|
||||||
|
</text>
|
||||||
|
<picker
|
||||||
|
mode="selector"
|
||||||
|
:range="bizTypeLabels"
|
||||||
|
:value="bizTypeIndex < 0 ? 0 : bizTypeIndex"
|
||||||
|
@change="handleBizTypeChange"
|
||||||
|
>
|
||||||
|
<view class="bill-generate__picker">
|
||||||
|
<text
|
||||||
|
class="bill-generate__picker-text"
|
||||||
|
:class="{ 'bill-generate__picker-text--placeholder': !selectedBizType }"
|
||||||
|
>
|
||||||
|
{{ selectedBizType || '请选择业务类型' }}
|
||||||
|
</text>
|
||||||
|
<text class="bill-generate__picker-arrow">
|
||||||
|
▾
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
占比(%)
|
||||||
|
</text>
|
||||||
|
<input
|
||||||
|
v-model="periodRatio"
|
||||||
|
class="bill-generate__input"
|
||||||
|
type="digit"
|
||||||
|
placeholder="可选,如 30"
|
||||||
|
placeholder-class="bill-generate__placeholder"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
到期日
|
||||||
|
</text>
|
||||||
|
<picker
|
||||||
|
mode="date"
|
||||||
|
:value="dueDate"
|
||||||
|
@change="handleDueDateChange"
|
||||||
|
>
|
||||||
|
<view class="bill-generate__picker">
|
||||||
|
<text
|
||||||
|
class="bill-generate__picker-text"
|
||||||
|
:class="{ 'bill-generate__picker-text--placeholder': !dueDate }"
|
||||||
|
>
|
||||||
|
{{ dueDate || '请选择到期日' }}
|
||||||
|
</text>
|
||||||
|
<text class="bill-generate__picker-arrow">
|
||||||
|
▾
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<view class="bill-generate__label-row">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
关联合同 ID
|
||||||
|
</text>
|
||||||
|
<text class="bill-generate__hint">
|
||||||
|
与期次名一起可防重
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<input
|
||||||
|
v-model="contractId"
|
||||||
|
class="bill-generate__input"
|
||||||
|
type="number"
|
||||||
|
placeholder="可选"
|
||||||
|
placeholder-class="bill-generate__placeholder"
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-generate__field">
|
||||||
|
<text class="bill-generate__label">
|
||||||
|
补充备注
|
||||||
|
</text>
|
||||||
|
<textarea
|
||||||
|
v-model="remark"
|
||||||
|
class="bill-generate__textarea"
|
||||||
|
maxlength="200"
|
||||||
|
placeholder="可选"
|
||||||
|
placeholder-class="bill-generate__placeholder"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
|
||||||
|
<view class="bill-generate__footer">
|
||||||
|
<view
|
||||||
|
class="bill-generate__submit"
|
||||||
|
:class="{ 'bill-generate__submit--disabled': submitting }"
|
||||||
|
@tap="handleSubmit"
|
||||||
|
>
|
||||||
|
生成账单
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
@import './index.scss';
|
||||||
|
</style>
|
||||||
@@ -3,11 +3,14 @@
|
|||||||
.bill-list {
|
.bill-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-height: 100vh;
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
background: $color-bg-section;
|
background: $color-bg-section;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bill-list__navbar {
|
.bill-list__navbar {
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -17,6 +20,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.bill-list__back {
|
.bill-list__back {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -30,9 +35,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.bill-list__navbar-title {
|
.bill-list__navbar-title {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
z-index: 0;
|
||||||
font-size: 34rpx;
|
font-size: 34rpx;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: $color-text-primary;
|
color: $color-text-primary;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
pointer-events: none;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bill-list__navbar-placeholder {
|
.bill-list__navbar-placeholder {
|
||||||
@@ -40,11 +51,32 @@
|
|||||||
height: 64rpx;
|
height: 64rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bill-list__navbar-actions {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 24rpx;
|
||||||
|
min-width: 64rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
padding: 0 4rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__navbar-action-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-primary;
|
||||||
|
}
|
||||||
|
|
||||||
.bill-list__scroll {
|
.bill-list__scroll {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: 0;
|
height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bill-list--selecting .bill-list__content {
|
||||||
|
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
|
||||||
|
}
|
||||||
|
|
||||||
.bill-list__content {
|
.bill-list__content {
|
||||||
padding: 24rpx 24rpx calc(32rpx + env(safe-area-inset-bottom));
|
padding: 24rpx 24rpx calc(32rpx + env(safe-area-inset-bottom));
|
||||||
}
|
}
|
||||||
@@ -102,11 +134,92 @@
|
|||||||
color: $color-text-placeholder;
|
color: $color-text-placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bill-list__toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
padding: 18rpx 24rpx;
|
||||||
|
background: $color-bg-page;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__toolbar-hint {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__toolbar-action {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: $color-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 80rpx 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__empty-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.bill-list__card {
|
.bill-list__card {
|
||||||
padding: 28rpx 24rpx;
|
padding: 28rpx 24rpx;
|
||||||
margin-top: 24rpx;
|
margin-top: 24rpx;
|
||||||
background: $color-bg-page;
|
background: $color-bg-page;
|
||||||
|
border: 2rpx solid transparent;
|
||||||
border-radius: 20rpx;
|
border-radius: 20rpx;
|
||||||
|
|
||||||
|
&--selected {
|
||||||
|
border-color: $color-primary;
|
||||||
|
background: rgba(37, 99, 235, 0.04);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__card-main {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__check {
|
||||||
|
display: flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 36rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
margin-top: 6rpx;
|
||||||
|
border: 2rpx solid #d8dde6;
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&--active {
|
||||||
|
background: $color-primary;
|
||||||
|
border-color: $color-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__check-mark {
|
||||||
|
font-size: 20rpx;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__card-body-wrap {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bill-list__card-header {
|
.bill-list__card-header {
|
||||||
@@ -146,6 +259,12 @@
|
|||||||
background: #25eb9f;
|
background: #25eb9f;
|
||||||
border-radius: 40rpx;
|
border-radius: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--cancelled {
|
||||||
|
color: #ffffff;
|
||||||
|
background: #9ca3af;
|
||||||
|
border-radius: 40rpx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bill-list__card-body {
|
.bill-list__card-body {
|
||||||
@@ -186,3 +305,58 @@
|
|||||||
background: $color-primary;
|
background: $color-primary;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bill-list__batch-footer {
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 30;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 20rpx;
|
||||||
|
padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom));
|
||||||
|
background: $color-bg-page;
|
||||||
|
border-top: 1rpx solid #f0f0f0;
|
||||||
|
box-shadow: 0 -8rpx 24rpx rgba(15, 23, 42, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__batch-info {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__batch-count {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__batch-amount {
|
||||||
|
margin-top: 6rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: $color-text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bill-list__batch-btn {
|
||||||
|
display: flex;
|
||||||
|
flex-shrink: 0;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-width: 200rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
padding: 0 28rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #ffffff;
|
||||||
|
background: $color-primary;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
opacity: 0.45;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,59 +1,244 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import { BILL_LIST, BILL_LIST_SUMMARY } from '@/constants/bill-list'
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
import { PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
|
import { getBillPage, getBillStatistics } from '@/api/bill'
|
||||||
import type { BillItem } from '@/types/bill'
|
import { BILL_PAGE_SIZE, BILL_STATUS_LABEL, EMPTY_BILL_SUMMARY } from '@/constants/bill-list'
|
||||||
import type { PaymentPlanStatus } from '@/types/project-detail'
|
import type { BillItem, BillListSummary } from '@/types/bill'
|
||||||
|
import type { FinanceBillStatus } from '@/types/bill-api'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { chooseAndExportBills } from '@/utils/bill-export'
|
||||||
|
import { mapBillStatistics, mapFinanceBillsToItems } from '@/utils/map-bill'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
import LoadMoreFooter from '@/pages/case-library/components/LoadMoreFooter.vue'
|
||||||
|
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const billList = ref(BILL_LIST.map(item => ({ ...item })))
|
const statusFilter = ref<FinanceBillStatus | ''>('')
|
||||||
|
const billList = ref<BillItem[]>([])
|
||||||
|
const summary = ref<BillListSummary>({ ...EMPTY_BILL_SUMMARY })
|
||||||
|
const totalCount = ref(0)
|
||||||
|
const pageNum = ref(1)
|
||||||
|
const loadingList = ref(false)
|
||||||
|
const loadingMore = ref(false)
|
||||||
|
const selectMode = ref(false)
|
||||||
|
const selectedIds = ref<string[]>([])
|
||||||
|
|
||||||
const filteredBills = computed(() => {
|
let keywordTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
const text = keyword.value.trim()
|
|
||||||
if (!text)
|
|
||||||
return billList.value
|
|
||||||
|
|
||||||
return billList.value.filter(item =>
|
const hasMore = computed(() => billList.value.length < totalCount.value)
|
||||||
item.title.includes(text)
|
const loadFinished = computed(() => !hasMore.value && billList.value.length > 0)
|
||||||
|| item.billNo.includes(text)
|
|
||||||
|| item.relatedProject.includes(text)
|
const pendingBills = computed(() => billList.value.filter(item => item.status === 'pending'))
|
||||||
|| item.transactionNo.includes(text),
|
|
||||||
)
|
const selectedBills = computed(() =>
|
||||||
|
billList.value.filter(item => selectedIds.value.includes(item.id) && item.status === 'pending'),
|
||||||
|
)
|
||||||
|
|
||||||
|
const selectedCount = computed(() => selectedBills.value.length)
|
||||||
|
|
||||||
|
const selectedAmount = computed(() =>
|
||||||
|
selectedBills.value.reduce((sum, item) => sum + Number(item.amount || 0), 0),
|
||||||
|
)
|
||||||
|
|
||||||
|
function buildFilterParams() {
|
||||||
|
return {
|
||||||
|
keyword: keyword.value.trim() || undefined,
|
||||||
|
status: statusFilter.value || undefined,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchStatistics() {
|
||||||
|
try {
|
||||||
|
const vo = await getBillStatistics(buildFilterParams())
|
||||||
|
summary.value = mapBillStatistics(vo)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
summary.value = { ...EMPTY_BILL_SUMMARY }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchBillList(reset = false) {
|
||||||
|
if (reset) {
|
||||||
|
pageNum.value = 1
|
||||||
|
billList.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadingList.value || loadingMore.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (reset)
|
||||||
|
loadingList.value = true
|
||||||
|
else
|
||||||
|
loadingMore.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await getBillPage({
|
||||||
|
...buildFilterParams(),
|
||||||
|
pageNum: pageNum.value,
|
||||||
|
pageSize: BILL_PAGE_SIZE,
|
||||||
|
})
|
||||||
|
const mapped = mapFinanceBillsToItems(result?.rows ?? [])
|
||||||
|
totalCount.value = Number(result?.total ?? 0)
|
||||||
|
billList.value = reset ? mapped : [...billList.value, ...mapped]
|
||||||
|
|
||||||
|
// 刷新后清理已不存在/不可支付的勾选
|
||||||
|
const pendingIdSet = new Set(
|
||||||
|
billList.value.filter(item => item.status === 'pending').map(item => item.id),
|
||||||
|
)
|
||||||
|
selectedIds.value = selectedIds.value.filter(id => pendingIdSet.has(id))
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
if (reset) {
|
||||||
|
billList.value = []
|
||||||
|
totalCount.value = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loadingList.value = false
|
||||||
|
loadingMore.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshAll() {
|
||||||
|
await Promise.all([fetchStatistics(), fetchBillList(true)])
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(keyword, () => {
|
||||||
|
if (keywordTimer)
|
||||||
|
clearTimeout(keywordTimer)
|
||||||
|
keywordTimer = setTimeout(() => {
|
||||||
|
refreshAll()
|
||||||
|
}, 400)
|
||||||
|
})
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
const rawStatus = options?.status ? decodeURIComponent(String(options.status)) : ''
|
||||||
|
if (rawStatus)
|
||||||
|
statusFilter.value = rawStatus.toUpperCase()
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
refreshAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
navigateBackWithFallback('/pages/project-center/index')
|
if (selectMode.value) {
|
||||||
|
exitSelectMode()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
navigateBackWithFallback('/pages/personal-center/finance/index')
|
||||||
}
|
}
|
||||||
|
|
||||||
function paymentStatusClass(status: PaymentPlanStatus) {
|
function handleExport() {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
chooseAndExportBills(buildFilterParams())
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleGenerate() {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/project-center/bill-generate/index',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function enterSelectMode() {
|
||||||
|
if (!pendingBills.value.length) {
|
||||||
|
uni.showToast({ title: '暂无待支付账单', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
selectMode.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function exitSelectMode() {
|
||||||
|
selectMode.value = false
|
||||||
|
selectedIds.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSelectMode() {
|
||||||
|
if (selectMode.value)
|
||||||
|
exitSelectMode()
|
||||||
|
else
|
||||||
|
enterSelectMode()
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSelected(id: string) {
|
||||||
|
return selectedIds.value.includes(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSelect(item: BillItem) {
|
||||||
|
if (item.status !== 'pending') {
|
||||||
|
uni.showToast({ title: '仅可选择待支付账单', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSelected(item.id))
|
||||||
|
selectedIds.value = selectedIds.value.filter(id => id !== item.id)
|
||||||
|
else
|
||||||
|
selectedIds.value = [...selectedIds.value, item.id]
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusClass(status: BillItem['status']) {
|
||||||
return `bill-list__tag--${status}`
|
return `bill-list__tag--${status}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatAmount(amount: number) {
|
function formatAmount(amount: number) {
|
||||||
return `¥ ${amount}`
|
return `¥ ${Number(amount || 0).toFixed(2)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleLoadMore() {
|
||||||
|
if (!hasMore.value || loadingList.value || loadingMore.value)
|
||||||
|
return
|
||||||
|
pageNum.value += 1
|
||||||
|
fetchBillList(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBillTap(item: BillItem) {
|
function handleBillTap(item: BillItem) {
|
||||||
if (item.status === 'pending' || item.status === 'paid' || item.status === 'not_due') {
|
if (selectMode.value) {
|
||||||
const methodQuery = item.status === 'paid'
|
toggleSelect(item)
|
||||||
? `&method=${encodeURIComponent(item.paidMethod || 'wechat')}`
|
return
|
||||||
: ''
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/project-center/bill-detail/index?projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}${methodQuery}`,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.status === 'cancelled')
|
||||||
|
return
|
||||||
|
|
||||||
|
const methodQuery = item.status === 'paid' && item.paidMethod
|
||||||
|
? `&method=${encodeURIComponent(item.paidMethod)}`
|
||||||
|
: ''
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/project-center/bill-detail/index?id=${encodeURIComponent(item.id)}&projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}${methodQuery}`,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePayNow(item: BillItem) {
|
function handlePayNow(item: BillItem) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}`,
|
url: `/pages/project-center/payment/index?projectId=${encodeURIComponent(item.projectId)}&planId=${encodeURIComponent(item.id)}&billId=${encodeURIComponent(item.id)}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleBatchPay() {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (selectedCount.value < 2) {
|
||||||
|
uni.showToast({ title: '请至少选择2笔待支付账单', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const ids = selectedBills.value.map(item => item.id).join(',')
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/project-center/payment/index?ids=${encodeURIComponent(ids)}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="bill-list">
|
<view
|
||||||
|
class="bill-list"
|
||||||
|
:class="{ 'bill-list--selecting': selectMode }"
|
||||||
|
>
|
||||||
<view class="bill-list__navbar">
|
<view class="bill-list__navbar">
|
||||||
<view
|
<view
|
||||||
class="bill-list__back"
|
class="bill-list__back"
|
||||||
@@ -66,21 +251,41 @@ function handlePayNow(item: BillItem) {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<text class="bill-list__navbar-title">
|
<text class="bill-list__navbar-title">
|
||||||
账单明细
|
{{ selectMode ? '选择账单' : '账单明细' }}
|
||||||
</text>
|
</text>
|
||||||
<view class="bill-list__navbar-placeholder" />
|
<view class="bill-list__navbar-actions">
|
||||||
|
<template v-if="!selectMode">
|
||||||
|
<text
|
||||||
|
class="bill-list__navbar-action-text"
|
||||||
|
@tap="handleGenerate"
|
||||||
|
>
|
||||||
|
建账
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
class="bill-list__navbar-action-text"
|
||||||
|
@tap="handleExport"
|
||||||
|
>
|
||||||
|
导出
|
||||||
|
</text>
|
||||||
|
</template>
|
||||||
|
<view
|
||||||
|
v-else
|
||||||
|
class="bill-list__navbar-placeholder"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<scroll-view
|
<scroll-view
|
||||||
class="bill-list__scroll"
|
class="bill-list__scroll"
|
||||||
scroll-y
|
scroll-y
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
|
@scrolltolower="handleLoadMore"
|
||||||
>
|
>
|
||||||
<view class="bill-list__content">
|
<view class="bill-list__content">
|
||||||
<view class="bill-list__summary">
|
<view class="bill-list__summary">
|
||||||
<view class="bill-list__summary-item">
|
<view class="bill-list__summary-item">
|
||||||
<text class="bill-list__summary-value">
|
<text class="bill-list__summary-value">
|
||||||
{{ BILL_LIST_SUMMARY.totalCount }}
|
{{ summary.totalCount }}
|
||||||
</text>
|
</text>
|
||||||
<text class="bill-list__summary-label">
|
<text class="bill-list__summary-label">
|
||||||
总笔数
|
总笔数
|
||||||
@@ -88,7 +293,7 @@ function handlePayNow(item: BillItem) {
|
|||||||
</view>
|
</view>
|
||||||
<view class="bill-list__summary-item">
|
<view class="bill-list__summary-item">
|
||||||
<text class="bill-list__summary-value">
|
<text class="bill-list__summary-value">
|
||||||
¥ {{ BILL_LIST_SUMMARY.totalAmount }}
|
¥ {{ summary.totalAmount }}
|
||||||
</text>
|
</text>
|
||||||
<text class="bill-list__summary-label">
|
<text class="bill-list__summary-label">
|
||||||
总金额
|
总金额
|
||||||
@@ -96,7 +301,7 @@ function handlePayNow(item: BillItem) {
|
|||||||
</view>
|
</view>
|
||||||
<view class="bill-list__summary-item">
|
<view class="bill-list__summary-item">
|
||||||
<text class="bill-list__summary-value">
|
<text class="bill-list__summary-value">
|
||||||
{{ BILL_LIST_SUMMARY.pendingCount }}
|
{{ summary.pendingCount }}
|
||||||
</text>
|
</text>
|
||||||
<text class="bill-list__summary-label">
|
<text class="bill-list__summary-label">
|
||||||
待支付
|
待支付
|
||||||
@@ -104,6 +309,18 @@ function handlePayNow(item: BillItem) {
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="bill-list__toolbar">
|
||||||
|
<text class="bill-list__toolbar-hint">
|
||||||
|
{{ selectMode ? '请勾选至少 2 笔待支付账单' : '可勾选多笔待支付账单合并付款' }}
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
class="bill-list__toolbar-action"
|
||||||
|
@tap="toggleSelectMode"
|
||||||
|
>
|
||||||
|
{{ selectMode ? '取消' : '合并支付' }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="bill-list__search">
|
<view class="bill-list__search">
|
||||||
<image
|
<image
|
||||||
class="bill-list__search-icon"
|
class="bill-list__search-icon"
|
||||||
@@ -113,57 +330,126 @@ function handlePayNow(item: BillItem) {
|
|||||||
<input
|
<input
|
||||||
v-model="keyword"
|
v-model="keyword"
|
||||||
class="bill-list__search-input"
|
class="bill-list__search-input"
|
||||||
placeholder="搜索案例标题、描述、标签..."
|
placeholder="搜索账单号、项目名、交易名称"
|
||||||
placeholder-class="bill-list__search-placeholder"
|
placeholder-class="bill-list__search-placeholder"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-for="item in filteredBills"
|
v-if="loadingList && !billList.length"
|
||||||
:key="`${item.projectId}-${item.id}`"
|
class="bill-list__empty"
|
||||||
|
>
|
||||||
|
<text class="bill-list__empty-text">
|
||||||
|
加载中...
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else-if="!billList.length"
|
||||||
|
class="bill-list__empty"
|
||||||
|
>
|
||||||
|
<text class="bill-list__empty-text">
|
||||||
|
暂无账单
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-for="item in billList"
|
||||||
|
:key="item.id"
|
||||||
class="bill-list__card"
|
class="bill-list__card"
|
||||||
|
:class="{ 'bill-list__card--selected': selectMode && isSelected(item.id) }"
|
||||||
@tap="handleBillTap(item)"
|
@tap="handleBillTap(item)"
|
||||||
>
|
>
|
||||||
<view class="bill-list__card-header">
|
<view class="bill-list__card-main">
|
||||||
<text class="bill-list__card-title">
|
<view
|
||||||
{{ item.title }} {{ item.ratio }}
|
v-if="selectMode"
|
||||||
</text>
|
class="bill-list__check"
|
||||||
<text
|
:class="{
|
||||||
class="bill-list__tag"
|
'bill-list__check--active': isSelected(item.id),
|
||||||
:class="paymentStatusClass(item.status)"
|
'bill-list__check--disabled': item.status !== 'pending',
|
||||||
|
}"
|
||||||
|
@tap.stop="toggleSelect(item)"
|
||||||
>
|
>
|
||||||
{{ PAYMENT_PLAN_STATUS_LABEL[item.status] }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="bill-list__card-body">
|
|
||||||
<view class="bill-list__card-meta">
|
|
||||||
<text
|
<text
|
||||||
v-if="item.status === 'paid'"
|
v-if="isSelected(item.id)"
|
||||||
class="bill-list__card-row"
|
class="bill-list__check-mark"
|
||||||
>
|
>
|
||||||
交易流水号:{{ item.transactionNo }}
|
✓
|
||||||
</text>
|
|
||||||
<text class="bill-list__card-row">
|
|
||||||
账单号:{{ item.billNo }}
|
|
||||||
</text>
|
|
||||||
<text class="bill-list__card-row">
|
|
||||||
关联项目:{{ item.relatedProject }}
|
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="bill-list__card-amount">
|
|
||||||
{{ formatAmount(item.amount) }}
|
<view class="bill-list__card-body-wrap">
|
||||||
</text>
|
<view class="bill-list__card-header">
|
||||||
|
<text class="bill-list__card-title">
|
||||||
|
{{ item.title }} {{ item.ratio }}
|
||||||
|
</text>
|
||||||
|
<text
|
||||||
|
class="bill-list__tag"
|
||||||
|
:class="statusClass(item.status)"
|
||||||
|
>
|
||||||
|
{{ BILL_STATUS_LABEL[item.status] }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view class="bill-list__card-body">
|
||||||
|
<view class="bill-list__card-meta">
|
||||||
|
<text
|
||||||
|
v-if="item.status === 'paid' && item.transactionNo !== '-'"
|
||||||
|
class="bill-list__card-row"
|
||||||
|
>
|
||||||
|
交易流水号:{{ item.transactionNo }}
|
||||||
|
</text>
|
||||||
|
<text class="bill-list__card-row">
|
||||||
|
账单号:{{ item.billNo }}
|
||||||
|
</text>
|
||||||
|
<text class="bill-list__card-row">
|
||||||
|
关联项目:{{ item.relatedProject }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<text class="bill-list__card-amount">
|
||||||
|
{{ formatAmount(item.amount) }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-if="item.status === 'pending'"
|
v-if="!selectMode && item.status === 'pending'"
|
||||||
class="bill-list__pay-btn"
|
class="bill-list__pay-btn"
|
||||||
@tap.stop="handlePayNow(item)"
|
@tap.stop="handlePayNow(item)"
|
||||||
>
|
>
|
||||||
立即支付
|
立即支付
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<LoadMoreFooter
|
||||||
|
:loading="loadingMore"
|
||||||
|
:has-more="hasMore"
|
||||||
|
:finished="loadFinished"
|
||||||
|
@load-more="handleLoadMore"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-if="selectMode"
|
||||||
|
class="bill-list__batch-footer"
|
||||||
|
>
|
||||||
|
<view class="bill-list__batch-info">
|
||||||
|
<text class="bill-list__batch-count">
|
||||||
|
已选 {{ selectedCount }} 笔
|
||||||
|
</text>
|
||||||
|
<text class="bill-list__batch-amount">
|
||||||
|
合计 {{ formatAmount(selectedAmount) }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="bill-list__batch-btn"
|
||||||
|
:class="{ 'bill-list__batch-btn--disabled': selectedCount < 2 }"
|
||||||
|
@tap="handleBatchPay"
|
||||||
|
>
|
||||||
|
去支付
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,13 @@
|
|||||||
.project-center-card__status {
|
.project-center-card__status {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: $color-text-secondary;
|
color: #666666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-center-card__meta {
|
.project-center-card__meta {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 12rpx;
|
||||||
margin-top: 16rpx;
|
margin-top: 16rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,15 +39,14 @@
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
padding: 4rpx 12rpx;
|
padding: 4rpx 12rpx;
|
||||||
font-size: 20rpx;
|
font-size: 20rpx;
|
||||||
color: $color-primary;
|
color: white;
|
||||||
background: $color-primary-light;
|
background: #2563EB;
|
||||||
border-radius: 6rpx;
|
border-radius: 188.93rpx 188.93rpx 188.93rpx 188.93rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-center-card__no {
|
.project-center-card__no {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
margin-left: 12rpx;
|
|
||||||
font-size: 22rpx;
|
font-size: 22rpx;
|
||||||
color: #666666;
|
color: #666666;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@@ -82,15 +82,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.project-center-card__footer {
|
.project-center-card__footer {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-top: 20rpx;
|
margin-top: 20rpx;
|
||||||
|
|
||||||
&--simple {
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 24rpx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-center-card__time {
|
.project-center-card__time {
|
||||||
@@ -99,6 +91,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.project-center-card__detail {
|
.project-center-card__detail {
|
||||||
|
flex-shrink: 0;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
color: #666666;
|
color: #666666;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
import type { ProjectCenterItem } from '@/types/project-center'
|
import type { ProjectCenterItem } from '@/types/project-center'
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
item: ProjectCenterItem
|
item: ProjectCenterItem
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
detail: [id: string]
|
detail: [id: string]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const showProgress = computed(() => {
|
||||||
|
const progress = props.item.progress
|
||||||
|
return progress !== undefined && progress > 0
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -28,10 +34,16 @@ const emit = defineEmits<{
|
|||||||
<text class="project-center-card__no">
|
<text class="project-center-card__no">
|
||||||
项目编号:{{ item.projectNo }}
|
项目编号:{{ item.projectNo }}
|
||||||
</text>
|
</text>
|
||||||
|
<text
|
||||||
|
class="project-center-card__detail"
|
||||||
|
@tap.stop="emit('detail', item.id)"
|
||||||
|
>
|
||||||
|
查看详情 >
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-if="item.status === '进行中' && item.progress !== undefined"
|
v-if="showProgress"
|
||||||
class="project-center-card__progress"
|
class="project-center-card__progress"
|
||||||
>
|
>
|
||||||
<view class="project-center-card__progress-bar">
|
<view class="project-center-card__progress-bar">
|
||||||
@@ -46,21 +58,12 @@ const emit = defineEmits<{
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
|
v-if="showProgress && item.updateTime"
|
||||||
class="project-center-card__footer"
|
class="project-center-card__footer"
|
||||||
:class="{ 'project-center-card__footer--simple': item.status !== '进行中' }"
|
|
||||||
>
|
>
|
||||||
<text
|
<text class="project-center-card__time">
|
||||||
v-if="item.updateTime"
|
|
||||||
class="project-center-card__time"
|
|
||||||
>
|
|
||||||
更新时间:{{ item.updateTime }}
|
更新时间:{{ item.updateTime }}
|
||||||
</text>
|
</text>
|
||||||
<text
|
|
||||||
class="project-center-card__detail"
|
|
||||||
@tap.stop="emit('detail', item.id)"
|
|
||||||
>
|
|
||||||
查看详情 >
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,15 +1,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
import { getProjectDetail, PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
|
import { getContractsByProjectNo } from '@/api/contract'
|
||||||
import type { PaymentPlanStatus } from '@/types/project-detail'
|
import { getRequirementDetail, withdrawRequirementAfterSale } from '@/api/requirement'
|
||||||
|
import { PAYMENT_PLAN_STATUS_LABEL } from '@/constants/project-detail'
|
||||||
|
import type { PaymentPlanStatus, ProjectFileItem } from '@/types/project-detail'
|
||||||
import afterSalesIcon from '@/static/icons/售后.png'
|
import afterSalesIcon from '@/static/icons/售后.png'
|
||||||
import cardBg from '@/static/icons/new-card.png'
|
import cardBg from '@/static/icons/new-card.png'
|
||||||
import deleteIcon from '@/static/icons/X.png'
|
import deleteIcon from '@/static/icons/X.png'
|
||||||
import type { ProjectDetail, ProjectDetailTab } from '@/types/project-detail'
|
import type { ProjectDetail, ProjectDetailTab } from '@/types/project-detail'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { openContractPreview } from '@/utils/contract-preview'
|
||||||
|
import { mapContractVosToProjectFiles } from '@/utils/map-contract'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
import { mapProjectRequirementToDetail } from '@/utils/map-requirement-detail'
|
||||||
|
|
||||||
const detail = ref<ProjectDetail | null>(null)
|
const detail = ref<ProjectDetail | null>(null)
|
||||||
|
const requirementId = ref('')
|
||||||
|
const loading = ref(true)
|
||||||
|
const withdrawingAfterSale = ref(false)
|
||||||
const activeTab = ref<ProjectDetailTab>('progress')
|
const activeTab = ref<ProjectDetailTab>('progress')
|
||||||
|
|
||||||
const tabs: Array<{ key: ProjectDetailTab, label: string }> = [
|
const tabs: Array<{ key: ProjectDetailTab, label: string }> = [
|
||||||
@@ -19,19 +28,61 @@ const tabs: Array<{ key: ProjectDetailTab, label: string }> = [
|
|||||||
{ key: 'aftersales', label: '售后信息' },
|
{ key: 'aftersales', label: '售后信息' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
async function loadProjectContracts(projectNo?: string) {
|
||||||
|
if (!detail.value || !projectNo)
|
||||||
|
return
|
||||||
|
|
||||||
|
try {
|
||||||
|
const rows = await getContractsByProjectNo(projectNo)
|
||||||
|
detail.value.contractFiles = mapContractVosToProjectFiles(rows ?? [])
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
detail.value.contractFiles = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadDetail(id: string) {
|
||||||
|
loading.value = true
|
||||||
|
uni.showLoading({ title: '加载中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await getRequirementDetail(id)
|
||||||
|
detail.value = mapProjectRequirementToDetail(data)
|
||||||
|
await loadProjectContracts(detail.value.projectNo)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
detail.value = null
|
||||||
|
uni.showToast({ title: '加载失败', icon: 'none' })
|
||||||
|
setTimeout(() => {
|
||||||
|
navigateBackWithFallback('/pages/project-center/index')
|
||||||
|
}, 1500)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
const rawId = options?.id
|
const rawId = options?.id
|
||||||
const id = rawId ? decodeURIComponent(String(rawId)) : '1'
|
const id = rawId ? decodeURIComponent(String(rawId)) : ''
|
||||||
const tab = options?.tab ? decodeURIComponent(String(options.tab)) : ''
|
const tab = options?.tab ? decodeURIComponent(String(options.tab)) : ''
|
||||||
detail.value = getProjectDetail(id)
|
|
||||||
|
|
||||||
if (tab === 'aftersales' || tab === 'progress' || tab === 'files' || tab === 'finance')
|
if (tab === 'aftersales' || tab === 'progress' || tab === 'files' || tab === 'finance')
|
||||||
activeTab.value = tab
|
activeTab.value = tab
|
||||||
|
|
||||||
if (!detail.value) {
|
if (!id) {
|
||||||
uni.showToast({ title: '项目不存在', icon: 'none' })
|
loading.value = false
|
||||||
setTimeout(() => uni.navigateBack(), 1500)
|
uni.showToast({ title: '参数错误', icon: 'none' })
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requirementId.value = id
|
||||||
|
loadDetail(id)
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
ensureLoggedIn()
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleBack() {
|
function handleBack() {
|
||||||
@@ -68,8 +119,72 @@ function handleApplyAfterSales() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleOpenContractFile(file: ProjectFileItem) {
|
||||||
|
if (file.contractId) {
|
||||||
|
openContractPreview(file.contractId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (file.url) {
|
||||||
|
uni.downloadFile({
|
||||||
|
url: file.url,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
uni.showToast({ title: '打开失败', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.openDocument({
|
||||||
|
filePath: res.tempFilePath,
|
||||||
|
showMenu: true,
|
||||||
|
fail: () => uni.showToast({ title: '无法打开文件', icon: 'none' }),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail: () => uni.showToast({ title: '打开失败', icon: 'none' }),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.showToast({ title: '暂无合同文件', icon: 'none' })
|
||||||
|
}
|
||||||
|
|
||||||
function handleCancelAfterSales() {
|
function handleCancelAfterSales() {
|
||||||
uni.showToast({ title: '取消售后功能开发中', icon: 'none' })
|
if (!detail.value || !requirementId.value || withdrawingAfterSale.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!detail.value.afterSales.processing) {
|
||||||
|
uni.showToast({ title: '当前没有进行中的售后申请', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '撤回售后',
|
||||||
|
content: '确定要撤回当前售后申请吗?',
|
||||||
|
confirmText: '撤回',
|
||||||
|
cancelText: '取消',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm)
|
||||||
|
return
|
||||||
|
|
||||||
|
withdrawingAfterSale.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
|
||||||
|
try {
|
||||||
|
await withdrawRequirementAfterSale(requirementId.value, {
|
||||||
|
reason: '用户撤回售后申请',
|
||||||
|
})
|
||||||
|
uni.showToast({ title: '已撤回售后申请', icon: 'success' })
|
||||||
|
await loadDetail(requirementId.value)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 层已 toast
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
withdrawingAfterSale.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAddAfterSalesAttachment() {
|
function handleAddAfterSalesAttachment() {
|
||||||
@@ -378,19 +493,16 @@ function handleAddAfterSalesAttachment() {
|
|||||||
<text class="project-detail__panel-title">
|
<text class="project-detail__panel-title">
|
||||||
合同文件
|
合同文件
|
||||||
</text>
|
</text>
|
||||||
<view class="project-detail__files">
|
<view
|
||||||
|
v-if="detail.contractFiles.length"
|
||||||
|
class="project-detail__files"
|
||||||
|
>
|
||||||
<view
|
<view
|
||||||
v-for="file in detail.contractFiles"
|
v-for="file in detail.contractFiles"
|
||||||
:key="file.id"
|
:key="file.id"
|
||||||
class="project-detail__file"
|
class="project-detail__file"
|
||||||
|
@tap="handleOpenContractFile(file)"
|
||||||
>
|
>
|
||||||
<view class="project-detail__file-remove">
|
|
||||||
<image
|
|
||||||
class="project-detail__file-remove-icon"
|
|
||||||
:src="deleteIcon"
|
|
||||||
mode="aspectFit"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
<image
|
<image
|
||||||
class="project-detail__file-icon"
|
class="project-detail__file-icon"
|
||||||
:src="file.icon"
|
:src="file.icon"
|
||||||
@@ -401,6 +513,12 @@ function handleAddAfterSalesAttachment() {
|
|||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<text
|
||||||
|
v-else
|
||||||
|
class="project-detail__empty-text"
|
||||||
|
>
|
||||||
|
暂无合同
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -509,8 +627,29 @@ function handleAddAfterSalesAttachment() {
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else-if="!loading"
|
||||||
|
class="project-detail project-detail--empty"
|
||||||
|
>
|
||||||
|
<text class="project-detail__empty-text">
|
||||||
|
暂无详情
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import './index.scss';
|
@import './index.scss';
|
||||||
|
|
||||||
|
.project-detail--empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-detail__empty-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #999999;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,38 +1,128 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { onShow } from '@dcloudio/uni-app'
|
||||||
|
import { getRequirementList } from '@/api/requirement'
|
||||||
import AppTabBar from '@/components/AppTabBar.vue'
|
import AppTabBar from '@/components/AppTabBar.vue'
|
||||||
import { DEFAULT_CASE_FILTER } from '@/constants/case-library'
|
import { DEFAULT_CASE_FILTER } from '@/constants/case-library'
|
||||||
import {
|
import {
|
||||||
PROJECT_CATEGORIES,
|
PROJECT_CATEGORIES,
|
||||||
PROJECT_CENTER_LIST,
|
PROJECT_PAGE_SIZE,
|
||||||
} from '@/constants/project-center'
|
} from '@/constants/project-center'
|
||||||
|
import { useRequirementBusinessTypes } from '@/hooks/use-requirement-business-types'
|
||||||
import filterIcon from '@/static/icons/icon-filter.svg'
|
import filterIcon from '@/static/icons/icon-filter.svg'
|
||||||
import type { CaseFilterValues } from '@/types/case-library'
|
import type { CaseFilterValues } from '@/types/case-library'
|
||||||
import type { ProjectCategory } from '@/types/project-center'
|
import type { ProjectCategory, ProjectCenterItem } from '@/types/project-center'
|
||||||
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { buildRequirementListQuery } from '@/utils/build-requirement-list-query'
|
||||||
|
import type { CaseFilterTarget } from '@/utils/case-filter'
|
||||||
import { cloneCaseFilter, matchCaseFilter } from '@/utils/case-filter'
|
import { cloneCaseFilter, matchCaseFilter } from '@/utils/case-filter'
|
||||||
|
import { ensureCaseBusinessTypeMap } from '@/utils/ensure-case-business-type-map'
|
||||||
|
import { fetchRequirementListByBusinessTypes } from '@/utils/fetch-requirement-by-types'
|
||||||
|
import { mapProjectRequirementsToCenterItems } from '@/utils/map-requirement'
|
||||||
import CaseFilterPanel from '../case-library/components/CaseFilterPanel.vue'
|
import CaseFilterPanel from '../case-library/components/CaseFilterPanel.vue'
|
||||||
|
import LoadMoreFooter from '../case-library/components/LoadMoreFooter.vue'
|
||||||
import ProjectCenterCard from './components/ProjectCenterCard.vue'
|
import ProjectCenterCard from './components/ProjectCenterCard.vue'
|
||||||
|
|
||||||
|
const { businessTypes, loadRequirementBusinessTypes } = useRequirementBusinessTypes()
|
||||||
|
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const activeCategory = ref<ProjectCategory>('全部')
|
const activeCategory = ref<ProjectCategory>('全部')
|
||||||
const projectList = ref(PROJECT_CENTER_LIST.map(item => ({ ...item })))
|
const projectList = ref<ProjectCenterItem[]>([])
|
||||||
|
const totalCount = ref(0)
|
||||||
|
const pageNum = ref(1)
|
||||||
|
const loadingList = ref(false)
|
||||||
|
const loadingMore = ref(false)
|
||||||
const filterVisible = ref(false)
|
const filterVisible = ref(false)
|
||||||
const appliedFilter = ref<CaseFilterValues>(cloneCaseFilter(DEFAULT_CASE_FILTER))
|
const appliedFilter = ref<CaseFilterValues>(cloneCaseFilter(DEFAULT_CASE_FILTER))
|
||||||
|
|
||||||
const filteredProjects = computed(() => {
|
let keywordTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
const text = keyword.value.trim()
|
|
||||||
|
|
||||||
return projectList.value.filter((item) => {
|
function toFilterTarget(item: ProjectCenterItem): CaseFilterTarget {
|
||||||
const matchCategory = activeCategory.value === '全部' || item.category === activeCategory.value
|
return {
|
||||||
const matchKeyword = !text
|
industry: item.category,
|
||||||
|| item.title.includes(text)
|
scale: item.scale,
|
||||||
|| item.category.includes(text)
|
completedAt: item.completedAt,
|
||||||
|| item.projectNo.includes(text)
|
}
|
||||||
|| item.status.includes(text)
|
}
|
||||||
|| item.industry.includes(text)
|
|
||||||
const matchFilter = matchCaseFilter(item, appliedFilter.value)
|
const filterTargets = computed(() => projectList.value.map(toFilterTarget))
|
||||||
return matchCategory && matchKeyword && matchFilter
|
|
||||||
})
|
const filteredProjects = computed(() => {
|
||||||
|
return projectList.value.filter(item => matchCaseFilter(toFilterTarget(item), appliedFilter.value))
|
||||||
|
})
|
||||||
|
|
||||||
|
const hasMore = computed(() => projectList.value.length < totalCount.value)
|
||||||
|
const loadFinished = computed(() => !hasMore.value && projectList.value.length > 0)
|
||||||
|
|
||||||
|
async function fetchProjectList(reset = false) {
|
||||||
|
if (reset) {
|
||||||
|
pageNum.value = 1
|
||||||
|
projectList.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadingList.value || loadingMore.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (reset)
|
||||||
|
loadingList.value = true
|
||||||
|
else
|
||||||
|
loadingMore.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ensureCaseBusinessTypeMap()
|
||||||
|
|
||||||
|
const { query, businessTypeValues } = buildRequirementListQuery({
|
||||||
|
keyword: keyword.value,
|
||||||
|
activeCategory: activeCategory.value,
|
||||||
|
filter: appliedFilter.value,
|
||||||
|
pageNum: pageNum.value,
|
||||||
|
pageSize: PROJECT_PAGE_SIZE,
|
||||||
|
})
|
||||||
|
|
||||||
|
const result = businessTypeValues.length
|
||||||
|
? await fetchRequirementListByBusinessTypes(query, businessTypeValues)
|
||||||
|
: await getRequirementList(query)
|
||||||
|
const rows = result?.rows ?? []
|
||||||
|
const mapped = mapProjectRequirementsToCenterItems(rows)
|
||||||
|
|
||||||
|
totalCount.value = Number(result?.total ?? 0)
|
||||||
|
projectList.value = reset
|
||||||
|
? mapped
|
||||||
|
: [...projectList.value, ...mapped]
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
if (reset) {
|
||||||
|
projectList.value = []
|
||||||
|
totalCount.value = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loadingList.value = false
|
||||||
|
loadingMore.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(keyword, () => {
|
||||||
|
if (keywordTimer)
|
||||||
|
clearTimeout(keywordTimer)
|
||||||
|
keywordTimer = setTimeout(() => {
|
||||||
|
fetchProjectList(true)
|
||||||
|
}, 400)
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(activeCategory, () => {
|
||||||
|
fetchProjectList(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(async () => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
loadRequirementBusinessTypes(),
|
||||||
|
ensureCaseBusinessTypeMap(),
|
||||||
|
])
|
||||||
|
fetchProjectList(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleSelectCategory(category: ProjectCategory) {
|
function handleSelectCategory(category: ProjectCategory) {
|
||||||
@@ -49,6 +139,15 @@ function handleCloseFilter() {
|
|||||||
|
|
||||||
function handleConfirmFilter(value: CaseFilterValues) {
|
function handleConfirmFilter(value: CaseFilterValues) {
|
||||||
appliedFilter.value = cloneCaseFilter(value)
|
appliedFilter.value = cloneCaseFilter(value)
|
||||||
|
fetchProjectList(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleLoadMore() {
|
||||||
|
if (loadingMore.value || !hasMore.value)
|
||||||
|
return
|
||||||
|
|
||||||
|
pageNum.value += 1
|
||||||
|
fetchProjectList(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleViewDetail(id: string) {
|
function handleViewDetail(id: string) {
|
||||||
@@ -74,7 +173,7 @@ function handleViewDetail(id: string) {
|
|||||||
<input
|
<input
|
||||||
v-model="keyword"
|
v-model="keyword"
|
||||||
class="project-center__search-input"
|
class="project-center__search-input"
|
||||||
placeholder="搜索案例标题、描述、标签..."
|
placeholder="搜索项目名称、编号、状态..."
|
||||||
placeholder-class="project-center__search-placeholder"
|
placeholder-class="project-center__search-placeholder"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
@@ -99,7 +198,7 @@ function handleViewDetail(id: string) {
|
|||||||
|
|
||||||
<view class="project-center__toolbar">
|
<view class="project-center__toolbar">
|
||||||
<text class="project-center__count">
|
<text class="project-center__count">
|
||||||
共 {{ filteredProjects.length }}
|
共 {{ totalCount }}
|
||||||
</text>
|
</text>
|
||||||
<view
|
<view
|
||||||
class="project-center__filter"
|
class="project-center__filter"
|
||||||
@@ -121,6 +220,8 @@ function handleViewDetail(id: string) {
|
|||||||
class="project-center__scroll"
|
class="project-center__scroll"
|
||||||
scroll-y
|
scroll-y
|
||||||
:show-scrollbar="false"
|
:show-scrollbar="false"
|
||||||
|
:lower-threshold="120"
|
||||||
|
@scrolltolower="handleLoadMore"
|
||||||
>
|
>
|
||||||
<view class="project-center__list">
|
<view class="project-center__list">
|
||||||
<ProjectCenterCard
|
<ProjectCenterCard
|
||||||
@@ -129,6 +230,13 @@ function handleViewDetail(id: string) {
|
|||||||
:item="item"
|
:item="item"
|
||||||
@detail="handleViewDetail"
|
@detail="handleViewDetail"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<LoadMoreFooter
|
||||||
|
:loading="loadingList || loadingMore"
|
||||||
|
:has-more="hasMore"
|
||||||
|
:finished="loadFinished"
|
||||||
|
@load-more="handleLoadMore"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
@@ -136,7 +244,9 @@ function handleViewDetail(id: string) {
|
|||||||
|
|
||||||
<CaseFilterPanel
|
<CaseFilterPanel
|
||||||
:visible="filterVisible"
|
:visible="filterVisible"
|
||||||
:cases="projectList"
|
:cases="filterTargets"
|
||||||
|
:industries="businessTypes"
|
||||||
|
industry-label="业务类型"
|
||||||
:value="appliedFilter"
|
:value="appliedFilter"
|
||||||
@close="handleCloseFilter"
|
@close="handleCloseFilter"
|
||||||
@confirm="handleConfirmFilter"
|
@confirm="handleConfirmFilter"
|
||||||
|
|||||||
@@ -60,6 +60,14 @@
|
|||||||
color: $color-text-primary;
|
color: $color-text-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.payment-success__order-block {
|
||||||
|
& + & {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
padding-top: 20rpx;
|
||||||
|
border-top: 1rpx dashed #f0f0f0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.payment-success__info-row {
|
.payment-success__info-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|||||||
@@ -1,40 +1,119 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { getPaymentPlan } from '@/constants/project-detail'
|
import { getBillDetail } from '@/api/bill'
|
||||||
|
import { queryPayResult } from '@/api/pay'
|
||||||
import successIcon from '@/static/icons/icon-register-success.png'
|
import successIcon from '@/static/icons/icon-register-success.png'
|
||||||
import type { PaymentPlanItem } from '@/types/project-detail'
|
import type { BillItem } from '@/types/bill'
|
||||||
|
import { mapFinanceBillToItem } from '@/utils/map-bill'
|
||||||
|
|
||||||
type PaymentMethod = 'wechat' | 'alipay'
|
const bills = ref<BillItem[]>([])
|
||||||
|
const billId = ref('')
|
||||||
|
const billIds = ref<string[]>([])
|
||||||
|
const projectId = ref('')
|
||||||
|
const channel = ref('WECHAT')
|
||||||
|
const paymentTime = ref('--')
|
||||||
|
const transactionNo = ref('--')
|
||||||
|
const displayAmount = ref(0)
|
||||||
|
const orderCount = ref(1)
|
||||||
|
|
||||||
const plan = ref<PaymentPlanItem | null>(null)
|
const paymentMethodLabel = computed(() => {
|
||||||
const projectId = ref('1')
|
const key = channel.value.toUpperCase()
|
||||||
const planId = ref('2')
|
if (key === 'ALIPAY')
|
||||||
const paymentMethod = ref<PaymentMethod>('wechat')
|
return '支付宝'
|
||||||
const paymentTime = ref('2026-01-21 15:00:00')
|
if (key === 'BANK')
|
||||||
const transactionNo = ref('T20260819153035678K2M001')
|
return '银行转账'
|
||||||
|
if (key === 'WORKWX')
|
||||||
|
return '企业微信'
|
||||||
|
return '微信支付'
|
||||||
|
})
|
||||||
|
|
||||||
const paymentMethodLabel = computed(() =>
|
const isBatch = computed(() => orderCount.value > 1)
|
||||||
paymentMethod.value === 'wechat' ? '微信支付' : '支付宝',
|
|
||||||
)
|
|
||||||
|
|
||||||
onLoad((options) => {
|
onLoad(async (options) => {
|
||||||
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : '1'
|
const rawIds = options?.ids ? decodeURIComponent(String(options.ids)) : ''
|
||||||
planId.value = options?.planId ? decodeURIComponent(String(options.planId)) : '2'
|
const ids = rawIds
|
||||||
const method = options?.method ? decodeURIComponent(String(options.method)) : 'wechat'
|
? rawIds.split(',').map(item => item.trim()).filter(Boolean)
|
||||||
paymentMethod.value = method === 'alipay' ? 'alipay' : 'wechat'
|
: []
|
||||||
plan.value = getPaymentPlan(projectId.value, planId.value)
|
|
||||||
|
|
||||||
if (!plan.value) {
|
const id = options?.id
|
||||||
|
? decodeURIComponent(String(options.id))
|
||||||
|
: (options?.billId
|
||||||
|
? decodeURIComponent(String(options.billId))
|
||||||
|
: (options?.planId ? decodeURIComponent(String(options.planId)) : (ids[0] || '')))
|
||||||
|
|
||||||
|
if (id && !ids.includes(id))
|
||||||
|
ids.unshift(id)
|
||||||
|
|
||||||
|
billId.value = id
|
||||||
|
billIds.value = ids
|
||||||
|
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : ''
|
||||||
|
channel.value = options?.channel
|
||||||
|
? decodeURIComponent(String(options.channel)).toUpperCase()
|
||||||
|
: (options?.method === 'alipay' ? 'ALIPAY' : 'WECHAT')
|
||||||
|
orderCount.value = Number(options?.count) || ids.length || 1
|
||||||
|
|
||||||
|
const amountFromQuery = Number(options?.amount)
|
||||||
|
if (Number.isFinite(amountFromQuery) && amountFromQuery > 0)
|
||||||
|
displayAmount.value = amountFromQuery
|
||||||
|
|
||||||
|
const outTradeNo = options?.outTradeNo
|
||||||
|
? decodeURIComponent(String(options.outTradeNo))
|
||||||
|
: ''
|
||||||
|
|
||||||
|
if (!ids.length) {
|
||||||
uni.showToast({ title: '订单不存在', icon: 'none' })
|
uni.showToast({ title: '订单不存在', icon: 'none' })
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.redirectTo({ url: '/pages/project-center/index' })
|
uni.redirectTo({ url: '/pages/project-center/bill-list/index' })
|
||||||
}, 1500)
|
}, 1200)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showLoading({ title: '加载中...', mask: true })
|
||||||
|
try {
|
||||||
|
const vos = await Promise.all(ids.map(itemId => getBillDetail(itemId)))
|
||||||
|
bills.value = vos.map(mapFinanceBillToItem)
|
||||||
|
|
||||||
|
if (!displayAmount.value)
|
||||||
|
displayAmount.value = bills.value.reduce((sum, item) => sum + Number(item.amount || 0), 0)
|
||||||
|
|
||||||
|
if (!projectId.value)
|
||||||
|
projectId.value = bills.value.find(item => item.projectId)?.projectId || ''
|
||||||
|
|
||||||
|
const firstPaid = bills.value.find(item => item.paidAt)
|
||||||
|
if (firstPaid?.paidAt)
|
||||||
|
paymentTime.value = firstPaid.paidAt
|
||||||
|
|
||||||
|
const firstTxn = bills.value.find(item => item.transactionNo && item.transactionNo !== '-')
|
||||||
|
if (firstTxn?.transactionNo)
|
||||||
|
transactionNo.value = firstTxn.transactionNo
|
||||||
|
|
||||||
|
if (outTradeNo) {
|
||||||
|
try {
|
||||||
|
const payResult = await queryPayResult(outTradeNo)
|
||||||
|
if (payResult.payTime)
|
||||||
|
paymentTime.value = payResult.payTime
|
||||||
|
if (payResult.transactionNo)
|
||||||
|
transactionNo.value = payResult.transactionNo
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// 查询失败仍展示账单信息
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
bills.value = []
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.redirectTo({ url: '/pages/project-center/bill-list/index' })
|
||||||
|
}, 1200)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function formatAmount(amount: number) {
|
function formatAmount(amount: number) {
|
||||||
return `¥ ${amount}`
|
return `¥ ${Number(amount || 0).toFixed(2)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBackToList() {
|
function handleBackToList() {
|
||||||
@@ -43,14 +122,14 @@ function handleBackToList() {
|
|||||||
|
|
||||||
function handleViewDetail() {
|
function handleViewDetail() {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/project-center/bill-detail/index?projectId=${encodeURIComponent(projectId.value)}&planId=${encodeURIComponent(planId.value)}&method=${encodeURIComponent(paymentMethod.value)}`,
|
url: `/pages/project-center/bill-detail/index?id=${encodeURIComponent(billId.value || billIds.value[0] || '')}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view
|
<view
|
||||||
v-if="plan"
|
v-if="bills.length"
|
||||||
class="payment-success"
|
class="payment-success"
|
||||||
>
|
>
|
||||||
<scroll-view
|
<scroll-view
|
||||||
@@ -69,7 +148,7 @@ function handleViewDetail() {
|
|||||||
支付成功
|
支付成功
|
||||||
</text>
|
</text>
|
||||||
<text class="payment-success__subtitle">
|
<text class="payment-success__subtitle">
|
||||||
共1个订单,付款金额:{{ formatAmount(plan.amount) }}
|
共{{ orderCount }}个订单,付款金额:{{ formatAmount(displayAmount) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -105,22 +184,28 @@ function handleViewDetail() {
|
|||||||
|
|
||||||
<view class="payment-success__card">
|
<view class="payment-success__card">
|
||||||
<text class="payment-success__card-title">
|
<text class="payment-success__card-title">
|
||||||
已支付订单
|
{{ isBatch ? '已支付订单' : '已支付订单' }}
|
||||||
</text>
|
</text>
|
||||||
<view class="payment-success__order-row">
|
<view
|
||||||
<text class="payment-success__order-title">
|
v-for="item in bills"
|
||||||
{{ plan.title }} {{ plan.ratio }}
|
:key="item.id"
|
||||||
|
class="payment-success__order-block"
|
||||||
|
>
|
||||||
|
<view class="payment-success__order-row">
|
||||||
|
<text class="payment-success__order-title">
|
||||||
|
{{ item.title }} {{ item.ratio }}
|
||||||
|
</text>
|
||||||
|
<text class="payment-success__order-amount">
|
||||||
|
{{ formatAmount(item.amount) }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<text class="payment-success__order-meta">
|
||||||
|
账单号:{{ item.billNo }}
|
||||||
</text>
|
</text>
|
||||||
<text class="payment-success__order-amount">
|
<text class="payment-success__order-meta">
|
||||||
{{ formatAmount(plan.amount) }}
|
关联项目:{{ item.relatedProject }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="payment-success__order-meta">
|
|
||||||
账单号:{{ plan.billNo }}
|
|
||||||
</text>
|
|
||||||
<text class="payment-success__order-meta">
|
|
||||||
关联项目:{{ plan.relatedProject }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|||||||
@@ -77,6 +77,15 @@
|
|||||||
margin-top: 24rpx;
|
margin-top: 24rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.project-payment__order-block {
|
||||||
|
padding-top: 20rpx;
|
||||||
|
|
||||||
|
& + & {
|
||||||
|
margin-top: 16rpx;
|
||||||
|
border-top: 1rpx dashed #f0f0f0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.project-payment__order-title {
|
.project-payment__order-title {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding-right: 16rpx;
|
padding-right: 16rpx;
|
||||||
@@ -179,6 +188,29 @@
|
|||||||
border-top: 1rpx solid #f0f0f0;
|
border-top: 1rpx solid #f0f0f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.project-payment__order-block {
|
||||||
|
padding-bottom: 20rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
border-bottom: 1rpx solid #f0f0f0;
|
||||||
|
|
||||||
|
&:last-of-type {
|
||||||
|
margin-bottom: 0;
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-payment__empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 32rpx 0 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-payment__empty-text {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: $color-text-secondary;
|
||||||
|
}
|
||||||
|
|
||||||
.project-payment__confirm-btn {
|
.project-payment__confirm-btn {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -188,4 +220,9 @@
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
background: $color-primary;
|
background: $color-primary;
|
||||||
border-radius: 12rpx;
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
&--disabled {
|
||||||
|
opacity: 0.55;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,95 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { getPaymentPlan } from '@/constants/project-detail'
|
import { getBillDetail } from '@/api/bill'
|
||||||
import alipayIcon from '@/static/icons/支付宝.png'
|
import { getPayChannels, payBill, payBillBatch } from '@/api/pay'
|
||||||
import wechatIcon from '@/static/icons/微信.png'
|
import type { BillItem } from '@/types/bill'
|
||||||
import type { PaymentPlanItem } from '@/types/project-detail'
|
import { ensureLoggedIn } from '@/utils/auth-guard'
|
||||||
|
import { invokePayFromResult } from '@/utils/invoke-pay'
|
||||||
|
import { mapFinanceBillToItem } from '@/utils/map-bill'
|
||||||
|
import { mapPayChannelsToOptions, type PayChannelOption } from '@/utils/map-pay'
|
||||||
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
import { navigateBackWithFallback } from '@/utils/navigate-back'
|
||||||
|
|
||||||
type PaymentMethod = 'wechat' | 'alipay'
|
const bills = ref<BillItem[]>([])
|
||||||
|
const billIds = ref<string[]>([])
|
||||||
|
const projectId = ref('')
|
||||||
|
const channels = ref<PayChannelOption[]>([])
|
||||||
|
const selectedChannel = ref('')
|
||||||
|
const loading = ref(false)
|
||||||
|
const paying = ref(false)
|
||||||
|
const fallbackUrl = ref('/pages/project-center/bill-list/index')
|
||||||
|
|
||||||
const plan = ref<PaymentPlanItem | null>(null)
|
const isBatch = computed(() => billIds.value.length > 1)
|
||||||
const projectId = ref('1')
|
const totalAmount = computed(() =>
|
||||||
const planId = ref('2')
|
bills.value.reduce((sum, item) => sum + Number(item.amount || 0), 0),
|
||||||
const paymentMethod = ref<PaymentMethod>('wechat')
|
)
|
||||||
const fallbackUrl = ref('/pages/project-center/index')
|
const allPayable = computed(() =>
|
||||||
|
bills.value.length > 0 && bills.value.every(item => item.status === 'pending'),
|
||||||
|
)
|
||||||
|
const selectedChannelName = computed(() => {
|
||||||
|
return channels.value.find(item => item.code === selectedChannel.value)?.name || ''
|
||||||
|
})
|
||||||
|
|
||||||
const paymentMethods: Array<{ key: PaymentMethod, label: string, icon: string }> = [
|
function parseIds(options?: Record<string, unknown>) {
|
||||||
{ key: 'wechat', label: '微信支付', icon: wechatIcon },
|
const rawIds = options?.ids ? decodeURIComponent(String(options.ids)) : ''
|
||||||
{ key: 'alipay', label: '支付宝', icon: alipayIcon },
|
if (rawIds) {
|
||||||
]
|
return rawIds
|
||||||
|
.split(',')
|
||||||
|
.map(item => item.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
onLoad((options) => {
|
const single = options?.billId
|
||||||
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : '1'
|
? decodeURIComponent(String(options.billId))
|
||||||
planId.value = options?.planId ? decodeURIComponent(String(options.planId)) : '2'
|
: (options?.id
|
||||||
fallbackUrl.value = `/pages/project-center/detail/index?id=${encodeURIComponent(projectId.value)}`
|
? decodeURIComponent(String(options.id))
|
||||||
plan.value = getPaymentPlan(projectId.value, planId.value)
|
: (options?.planId ? decodeURIComponent(String(options.planId)) : ''))
|
||||||
|
|
||||||
if (!plan.value) {
|
return single ? [single] : []
|
||||||
uni.showToast({ title: '订单不存在', icon: 'none' })
|
}
|
||||||
setTimeout(() => uni.navigateBack(), 1500)
|
|
||||||
|
onLoad(async (options) => {
|
||||||
|
if (!ensureLoggedIn())
|
||||||
|
return
|
||||||
|
|
||||||
|
const ids = parseIds(options)
|
||||||
|
projectId.value = options?.projectId ? decodeURIComponent(String(options.projectId)) : ''
|
||||||
|
billIds.value = ids
|
||||||
|
fallbackUrl.value = ids.length === 1
|
||||||
|
? `/pages/project-center/bill-detail/index?id=${encodeURIComponent(ids[0])}`
|
||||||
|
: '/pages/project-center/bill-list/index'
|
||||||
|
|
||||||
|
if (!ids.length) {
|
||||||
|
uni.showToast({ title: '账单不存在', icon: 'none' })
|
||||||
|
setTimeout(() => uni.navigateBack(), 1200)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
uni.showLoading({ title: '加载中...', mask: true })
|
||||||
|
try {
|
||||||
|
const [channelRows, ...billVos] = await Promise.all([
|
||||||
|
getPayChannels(),
|
||||||
|
...ids.map(id => getBillDetail(id)),
|
||||||
|
])
|
||||||
|
|
||||||
|
bills.value = billVos.map(mapFinanceBillToItem)
|
||||||
|
if (!projectId.value)
|
||||||
|
projectId.value = bills.value.find(item => item.projectId)?.projectId || ''
|
||||||
|
|
||||||
|
channels.value = mapPayChannelsToOptions(channelRows)
|
||||||
|
selectedChannel.value = channels.value[0]?.code || ''
|
||||||
|
|
||||||
|
if (!allPayable.value)
|
||||||
|
uni.showToast({ title: '存在不可支付账单', icon: 'none' })
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
bills.value = []
|
||||||
|
setTimeout(() => uni.navigateBack(), 1200)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
loading.value = false
|
||||||
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -36,24 +97,91 @@ function handleBack() {
|
|||||||
navigateBackWithFallback(fallbackUrl.value)
|
navigateBackWithFallback(fallbackUrl.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSelectMethod(method: PaymentMethod) {
|
function handleSelectChannel(code: string) {
|
||||||
paymentMethod.value = method
|
selectedChannel.value = code
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatAmount(amount: number) {
|
function formatAmount(amount: number) {
|
||||||
return `¥ ${amount}`
|
return `¥ ${Number(amount || 0).toFixed(2)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleConfirmPay() {
|
function goSuccess(outTradeNo?: string, mergedAmount?: number) {
|
||||||
|
const first = bills.value[0]
|
||||||
|
if (!first)
|
||||||
|
return
|
||||||
|
|
||||||
|
const method = selectedChannel.value === 'ALIPAY' ? 'alipay' : 'wechat'
|
||||||
|
const query = [
|
||||||
|
`id=${encodeURIComponent(first.id)}`,
|
||||||
|
`ids=${encodeURIComponent(billIds.value.join(','))}`,
|
||||||
|
`projectId=${encodeURIComponent(first.projectId || projectId.value)}`,
|
||||||
|
`method=${encodeURIComponent(method)}`,
|
||||||
|
`channel=${encodeURIComponent(selectedChannel.value)}`,
|
||||||
|
`count=${encodeURIComponent(String(billIds.value.length))}`,
|
||||||
|
`amount=${encodeURIComponent(String(mergedAmount ?? totalAmount.value))}`,
|
||||||
|
]
|
||||||
|
if (outTradeNo)
|
||||||
|
query.push(`outTradeNo=${encodeURIComponent(outTradeNo)}`)
|
||||||
|
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: `/pages/project-center/payment-success/index?projectId=${encodeURIComponent(projectId.value)}&planId=${encodeURIComponent(planId.value)}&method=${encodeURIComponent(paymentMethod.value)}`,
|
url: `/pages/project-center/payment-success/index?${query.join('&')}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleConfirmPay() {
|
||||||
|
if (!ensureLoggedIn() || paying.value || !bills.value.length)
|
||||||
|
return
|
||||||
|
|
||||||
|
if (!allPayable.value) {
|
||||||
|
uni.showToast({ title: '存在不可支付账单', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedChannel.value) {
|
||||||
|
uni.showToast({ title: '请选择支付方式', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
paying.value = true
|
||||||
|
uni.showLoading({ title: '提交中...', mask: true })
|
||||||
|
try {
|
||||||
|
const result = isBatch.value
|
||||||
|
? await payBillBatch({
|
||||||
|
ids: billIds.value,
|
||||||
|
payChannel: selectedChannel.value,
|
||||||
|
})
|
||||||
|
: await payBill({
|
||||||
|
id: billIds.value[0],
|
||||||
|
payChannel: selectedChannel.value,
|
||||||
|
})
|
||||||
|
|
||||||
|
uni.hideLoading()
|
||||||
|
try {
|
||||||
|
const invoked = await invokePayFromResult(result, selectedChannel.value)
|
||||||
|
if (invoked.mode === 'none' && !result.outTradeNo) {
|
||||||
|
uni.showToast({ title: '未返回支付调起参数', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
goSuccess(result.outTradeNo, result.mergedAmount)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : '支付失败'
|
||||||
|
uni.showToast({ title: message, icon: 'none' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
// request 统一提示
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
paying.value = false
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view
|
<view
|
||||||
v-if="plan"
|
v-if="bills.length"
|
||||||
class="project-payment"
|
class="project-payment"
|
||||||
>
|
>
|
||||||
<view class="project-payment__navbar">
|
<view class="project-payment__navbar">
|
||||||
@@ -68,7 +196,7 @@ function handleConfirmPay() {
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
<text class="project-payment__navbar-title">
|
<text class="project-payment__navbar-title">
|
||||||
确认支付
|
{{ isBatch ? '合并支付' : '确认支付' }}
|
||||||
</text>
|
</text>
|
||||||
<view class="project-payment__navbar-placeholder" />
|
<view class="project-payment__navbar-placeholder" />
|
||||||
</view>
|
</view>
|
||||||
@@ -84,27 +212,35 @@ function handleConfirmPay() {
|
|||||||
<text class="project-payment__card-title">
|
<text class="project-payment__card-title">
|
||||||
订单明细
|
订单明细
|
||||||
</text>
|
</text>
|
||||||
<view class="project-payment__order-row">
|
|
||||||
<text class="project-payment__order-title">
|
<view
|
||||||
{{ plan.title }} {{ plan.ratio }}
|
v-for="item in bills"
|
||||||
|
:key="item.id"
|
||||||
|
class="project-payment__order-block"
|
||||||
|
>
|
||||||
|
<view class="project-payment__order-row">
|
||||||
|
<text class="project-payment__order-title">
|
||||||
|
{{ item.title }} {{ item.ratio }}
|
||||||
|
</text>
|
||||||
|
<text class="project-payment__order-amount">
|
||||||
|
{{ formatAmount(item.amount) }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<text class="project-payment__order-meta">
|
||||||
|
账单号:{{ item.billNo }}
|
||||||
</text>
|
</text>
|
||||||
<text class="project-payment__order-amount">
|
<text class="project-payment__order-meta">
|
||||||
{{ formatAmount(plan.amount) }}
|
关联项目:{{ item.relatedProject }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="project-payment__order-meta">
|
|
||||||
账单号:{{ plan.billNo }}
|
|
||||||
</text>
|
|
||||||
<text class="project-payment__order-meta">
|
|
||||||
关联项目:{{ plan.relatedProject }}
|
|
||||||
</text>
|
|
||||||
<view class="project-payment__order-divider" />
|
<view class="project-payment__order-divider" />
|
||||||
<view class="project-payment__order-summary">
|
<view class="project-payment__order-summary">
|
||||||
<text class="project-payment__order-summary-label">
|
<text class="project-payment__order-summary-label">
|
||||||
已选 1笔订单,合计
|
已选 {{ bills.length }}笔订单,合计
|
||||||
</text>
|
</text>
|
||||||
<text class="project-payment__order-summary-amount">
|
<text class="project-payment__order-summary-amount">
|
||||||
{{ formatAmount(plan.amount) }}
|
{{ formatAmount(totalAmount) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -115,11 +251,30 @@ function handleConfirmPay() {
|
|||||||
<text class="project-payment__card-title">
|
<text class="project-payment__card-title">
|
||||||
选择支付方式
|
选择支付方式
|
||||||
</text>
|
</text>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
v-for="method in paymentMethods"
|
v-if="loading && !channels.length"
|
||||||
:key="method.key"
|
class="project-payment__empty"
|
||||||
|
>
|
||||||
|
<text class="project-payment__empty-text">
|
||||||
|
加载支付方式...
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-else-if="!channels.length"
|
||||||
|
class="project-payment__empty"
|
||||||
|
>
|
||||||
|
<text class="project-payment__empty-text">
|
||||||
|
暂无可用支付通道
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-for="method in channels"
|
||||||
|
:key="method.code"
|
||||||
class="project-payment__method"
|
class="project-payment__method"
|
||||||
@tap="handleSelectMethod(method.key)"
|
@tap="handleSelectChannel(method.code)"
|
||||||
>
|
>
|
||||||
<view class="project-payment__method-left">
|
<view class="project-payment__method-left">
|
||||||
<image
|
<image
|
||||||
@@ -128,15 +283,15 @@ function handleConfirmPay() {
|
|||||||
mode="aspectFit"
|
mode="aspectFit"
|
||||||
/>
|
/>
|
||||||
<text class="project-payment__method-label">
|
<text class="project-payment__method-label">
|
||||||
{{ method.label }}
|
{{ method.name }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="project-payment__radio"
|
class="project-payment__radio"
|
||||||
:class="{ 'project-payment__radio--active': paymentMethod === method.key }"
|
:class="{ 'project-payment__radio--active': selectedChannel === method.code }"
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
v-if="paymentMethod === method.key"
|
v-if="selectedChannel === method.code"
|
||||||
class="project-payment__radio-check"
|
class="project-payment__radio-check"
|
||||||
>
|
>
|
||||||
✓
|
✓
|
||||||
@@ -151,9 +306,10 @@ function handleConfirmPay() {
|
|||||||
<view class="project-payment__footer">
|
<view class="project-payment__footer">
|
||||||
<view
|
<view
|
||||||
class="project-payment__confirm-btn"
|
class="project-payment__confirm-btn"
|
||||||
|
:class="{ 'project-payment__confirm-btn--disabled': paying || !selectedChannel || !allPayable }"
|
||||||
@tap="handleConfirmPay"
|
@tap="handleConfirmPay"
|
||||||
>
|
>
|
||||||
确认支付
|
{{ paying ? '支付中...' : `确认支付${selectedChannelName ? ` · ${selectedChannelName}` : ''}` }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user