更新
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<template>
|
||||
<view class="card-container">
|
||||
<!-- 顶部标题栏 -->
|
||||
<view class="header">
|
||||
<text class="header-title">我的就诊卡</text>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 就诊卡列表 -->
|
||||
<view class="card-list">
|
||||
@@ -61,6 +59,7 @@
|
||||
<view v-if="!loading && cardList.length === 0" class="empty-state">
|
||||
<uni-icons type="wallet" size="60" color="#999"></uni-icons>
|
||||
<text class="empty-text">暂无就诊卡</text>
|
||||
<view class="add-card-btn" @click="createCard">新建就诊卡</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载状态 -->
|
||||
@@ -73,7 +72,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, getCurrentInstance } from 'vue'
|
||||
|
||||
import { onLaunch, onShow, onHide, onError ,onShareAppMessage} from '@dcloudio/uni-app'
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
// 数据
|
||||
@@ -84,7 +83,9 @@ const loading = ref(false)
|
||||
onMounted(() => {
|
||||
loadCardList()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
loadCardList()
|
||||
})
|
||||
// 加载就诊卡列表
|
||||
const loadCardList = async () => {
|
||||
loading.value = true
|
||||
@@ -93,9 +94,9 @@ const loadCardList = async () => {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.showToast({ title: '请先登录', icon: 'none' })
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({ url: '/pages/login/login' })
|
||||
}, 1500)
|
||||
// setTimeout(() => {
|
||||
// uni.redirectTo({ url: '/pages/login/login' })
|
||||
// }, 1500)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -104,7 +105,7 @@ const loadCardList = async () => {
|
||||
const patientId = userData?.diagnosis?.patient_id
|
||||
|
||||
if (!patientId) {
|
||||
uni.showToast({ title: '患者信息不存在', icon: 'none' })
|
||||
//uni.showToast({ title: '患者信息不存在', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -137,6 +138,18 @@ const viewCardDetail = (card) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 新建就诊卡(patient_id 创建后自动生成,仅需登录)
|
||||
const createCard = () => {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.showToast({ title: '请先登录', icon: 'none' })
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/Card/edit_card?add=1'
|
||||
})
|
||||
}
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status) => {
|
||||
return status === 1 ? '启用' : '禁用'
|
||||
@@ -257,8 +270,8 @@ const formatDate = (timestamp) => {
|
||||
|
||||
&.status-confirmed {
|
||||
background: #f6ffed;
|
||||
color: #52c41a;
|
||||
border: 2rpx solid #b7eb8f;
|
||||
color: #204e2b;
|
||||
border: 2rpx solid #204e2b;
|
||||
}
|
||||
|
||||
&.status-pending {
|
||||
@@ -343,9 +356,19 @@ const formatDate = (timestamp) => {
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
color: #999999;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.add-card-btn {
|
||||
padding: 24rpx 64rpx;
|
||||
background: #1890ff;
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
font-weight: 500;
|
||||
border-radius: 48rpx;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
@@ -821,6 +821,7 @@ const agreedToTerms = ref(true) // 默认选中"是"
|
||||
const showDatePicker = ref(false)
|
||||
const diagnosisId = ref(null)
|
||||
const patientId = ref(null)
|
||||
const isAddMode = ref(false) // 新建模式
|
||||
|
||||
// 表单数据
|
||||
const formData = ref({
|
||||
@@ -1063,23 +1064,37 @@ const loadCardDetail = async () => {
|
||||
try {
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
diagnosisId.value = currentPage.options.id
|
||||
|
||||
if (!diagnosisId.value) {
|
||||
uni.showToast({ title: '诊单ID不存在', icon: 'none' })
|
||||
setTimeout(() => uni.navigateBack(), 1500)
|
||||
return
|
||||
}
|
||||
const options = currentPage.options || {}
|
||||
diagnosisId.value = options.id
|
||||
isAddMode.value = options.add === '1' || options.add === 1
|
||||
|
||||
const userData = uni.getStorageSync('userData')
|
||||
patientId.value = userData?.diagnosis?.patient_id
|
||||
|
||||
// 新建模式:patient_id 可选(创建后自动生成),仅需登录
|
||||
if (isAddMode.value) {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.showToast({ title: '请先登录', icon: 'none' })
|
||||
setTimeout(() => uni.redirectTo({ url: '/pages/login/login' }), 1500)
|
||||
return
|
||||
}
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
if (!patientId.value) {
|
||||
uni.showToast({ title: '请先登录', icon: 'none' })
|
||||
setTimeout(() => uni.redirectTo({ url: '/pages/login/login' }), 1500)
|
||||
return
|
||||
}
|
||||
|
||||
if (!diagnosisId.value) {
|
||||
uni.showToast({ title: '诊单ID不存在', icon: 'none' })
|
||||
setTimeout(() => uni.navigateBack(), 1500)
|
||||
return
|
||||
}
|
||||
|
||||
const res = await proxy.apiUrl({
|
||||
url: '/api/tcm/diagnosisDetail',
|
||||
method: 'GET',
|
||||
@@ -1302,18 +1317,26 @@ const submitForm = async () => {
|
||||
submitData.diagnosis_date = submitData.local_hospital_visit_date
|
||||
}
|
||||
|
||||
const apiUrl = isAddMode.value ? '/api/tcm/addCard' : '/api/tcm/updateCard'
|
||||
const apiData = isAddMode.value
|
||||
? { ...submitData, ...(patientId.value ? { patient_id: patientId.value } : {}) }
|
||||
: { id: diagnosisId.value, patient_id: patientId.value, ...submitData }
|
||||
|
||||
const res = await proxy.apiUrl({
|
||||
url: '/api/tcm/updateCard',
|
||||
url: apiUrl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: diagnosisId.value,
|
||||
patient_id: patientId.value,
|
||||
...submitData
|
||||
}
|
||||
data: apiData
|
||||
})
|
||||
|
||||
if (res.code === 1) {
|
||||
uni.showToast({ title: '保存成功', icon: 'success' })
|
||||
// 新建成功:若有返回 patient_id,写入 userData 供后续列表查询
|
||||
if (isAddMode.value && res.data?.patient_id) {
|
||||
const userData = uni.getStorageSync('userData') || {}
|
||||
if (!userData.diagnosis) userData.diagnosis = {}
|
||||
userData.diagnosis.patient_id = res.data.patient_id
|
||||
uni.setStorageSync('userData', userData)
|
||||
}
|
||||
uni.showToast({ title: isAddMode.value ? '创建成功' : '保存成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
|
||||
Reference in New Issue
Block a user