report-upload.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <template>
  2. <view class="upload-container">
  3. <!-- 说明提示 -->
  4. <view class="tip-banner">
  5. <text class="tip-icon">📋</text>
  6. <text class="tip-text">上传体检/菌群报告、认知测评、心理测评或情绪打卡记录,为您生成个性化成长方案</text>
  7. </view>
  8. <!-- 表单 -->
  9. <view class="form-section">
  10. <!-- 上传方式:并排卡片 -->
  11. <view class="upload-methods">
  12. <view class="upload-card card-file" @click="pickFile">
  13. <view class="upload-card-icon">📄</view>
  14. <text class="upload-card-title">从聊天选择文件</text>
  15. <text class="upload-card-desc">PDF / Word / 图片<br/>体检报告、测评报告、情绪打卡</text>
  16. </view>
  17. <view class="upload-card card-photo" @click="takePhoto">
  18. <view class="upload-card-icon">📷</view>
  19. <text class="upload-card-title">拍照上传</text>
  20. <text class="upload-card-desc">拍摄舌象照片<br/>或单页纸质报告</text>
  21. </view>
  22. </view>
  23. <!-- 责任声明 -->
  24. <view class="form-item disclaimer-box">
  25. <view class="disclaimer-check" @click="toggleAgree">
  26. <view class="disclaimer-checkbox" :class="{ 'disclaimer-checked': agreedToTerms }">
  27. <text class="disclaimer-checkmark" v-if="agreedToTerms">✓</text>
  28. </view>
  29. <text class="disclaimer-label">我已阅读并同意以下声明</text>
  30. </view>
  31. <view class="disclaimer-content">
  32. <text class="disclaimer-text">我同意平台使用本报告数据进行分析,为我提供个性化健康解决方案;未经我授权,平台不会以任何形式将我的报告内容提供给其他任何个人或机构。</text>
  33. </view>
  34. </view>
  35. <!-- 上传中 -->
  36. <view class="form-item" v-if="uploading">
  37. <text class="form-label">上传中...</text>
  38. <view class="analyzing-status">
  39. <text class="analyzing-text">正在上传文件,即将进入分析页面...</text>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 上传说明 -->
  44. <view class="guide-section">
  45. <view class="guide-header">
  46. <text class="guide-header-icon">📖</text>
  47. <text class="guide-header-title">可上传的报告类型</text>
  48. </view>
  49. <view class="guide-list">
  50. <view class="guide-item">
  51. <view class="guide-icon-box guide-icon-blue"><text class="guide-icon">📄</text></view>
  52. <view class="guide-info">
  53. <text class="guide-name">体检报告</text>
  54. <text class="guide-desc">血常规、尿常规、生化检验等,支持 PDF 或清晰照片</text>
  55. </view>
  56. </view>
  57. <view class="guide-item">
  58. <view class="guide-icon-box guide-icon-green"><text class="guide-icon">🦠</text></view>
  59. <view class="guide-info">
  60. <text class="guide-name">肠道菌群检测报告</text>
  61. <text class="guide-desc">支持 PDF 或清晰照片,AI 自动解读菌群健康</text>
  62. </view>
  63. </view>
  64. <view class="guide-item">
  65. <view class="guide-icon-box guide-icon-orange"><text class="guide-icon">👅</text></view>
  66. <view class="guide-info">
  67. <text class="guide-name">舌象照片</text>
  68. <text class="guide-desc">拍摄舌象照片,AI 辅助舌诊分析</text>
  69. </view>
  70. </view>
  71. <view class="guide-item">
  72. <view class="guide-icon-box guide-icon-purple"><text class="guide-icon">🧠</text></view>
  73. <view class="guide-info">
  74. <text class="guide-name">认知能力测评报告</text>
  75. <text class="guide-desc">韦氏、瑞文等标准化认知测评,以及双培强基工程DAN认知能力测评,AI 解读认知结构与发展建议</text>
  76. </view>
  77. </view>
  78. <view class="guide-item">
  79. <view class="guide-icon-box guide-icon-teal"><text class="guide-icon">💭</text></view>
  80. <view class="guide-info">
  81. <text class="guide-name">心理测评报告</text>
  82. <text class="guide-desc">气质类型、情绪智力、人格特征等心理测评,以及双培强基工程DAN人格、情绪、自我概念和自驱力测评,辅助家庭教育决策</text>
  83. </view>
  84. </view>
  85. <view class="guide-item">
  86. <view class="guide-icon-box guide-icon-pink"><text class="guide-icon">📝</text></view>
  87. <view class="guide-info">
  88. <text class="guide-name">情绪打卡记录</text>
  89. <text class="guide-desc">手机端情绪打卡截图或记录文件,追踪情绪变化趋势</text>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="guide-tips">
  94. <text class="guide-tips-title">温馨提示</text>
  95. <text class="guide-tips-item">· 单次上传 1 个文件,支持 PDF / JPG / PNG 格式</text>
  96. <text class="guide-tips-item">· 拍照时请保持光线充足,确保报告内容完整清晰</text>
  97. <text class="guide-tips-item">· 上传后由 AI 自动解析,解析结果可在线编辑确认</text>
  98. </view>
  99. </view>
  100. </view>
  101. </template>
  102. <script>
  103. import { uploadReportOnly } from '../../utils/api.js'
  104. export default {
  105. data() {
  106. return {
  107. memberId: null,
  108. uploading: false,
  109. selectedFile: null,
  110. photoPath: null,
  111. agreedToTerms: false
  112. }
  113. },
  114. onLoad: function(options) {
  115. this.memberId = options.memberId ? parseInt(options.memberId) : null
  116. },
  117. methods: {
  118. // 切换同意声明
  119. toggleAgree() {
  120. this.agreedToTerms = !this.agreedToTerms
  121. },
  122. // 未勾选声明时弹窗确认
  123. ensureAgreed(isPhoto) {
  124. if (this.agreedToTerms) {
  125. this.startPick(isPhoto)
  126. return
  127. }
  128. uni.showModal({
  129. title: '数据使用声明',
  130. content: '上传报告即代表您同意平台使用本报告数据进行分析,为您提供个性化健康解决方案;未经您授权,平台不会以任何形式将您的报告内容提供给其他任何个人或机构。点击「同意继续」即表示您已阅读并同意。',
  131. confirmText: '同意继续',
  132. cancelText: '暂不',
  133. success: (res) => {
  134. if (res.confirm) {
  135. this.agreedToTerms = true
  136. this.startPick(isPhoto)
  137. }
  138. }
  139. })
  140. },
  141. startPick(isPhoto) {
  142. if (isPhoto) {
  143. uni.chooseImage({
  144. count: 1,
  145. sourceType: ['camera', 'album'],
  146. success: (res) => {
  147. this.photoPath = res.tempFilePaths[0]
  148. this.uploadAndGoConfirm(this.photoPath, 'image')
  149. }
  150. })
  151. } else {
  152. uni.chooseMessageFile({
  153. count: 1,
  154. type: 'file',
  155. extension: ['pdf'],
  156. success: (res) => {
  157. var files = res.tempFiles
  158. if (files && files.length > 0) {
  159. this.selectedFile = files[0]
  160. this.uploadAndGoConfirm(files[0].path, '')
  161. }
  162. },
  163. fail: (e) => {
  164. console.log('选择文件取消或失败', e)
  165. }
  166. })
  167. }
  168. },
  169. // ===== 拍照上传 =====
  170. takePhoto() {
  171. if (this.agreedToTerms) {
  172. this.startPick(true)
  173. return
  174. }
  175. uni.showModal({
  176. title: '数据使用声明',
  177. content: '上传报告即代表您同意平台使用本报告数据进行分析,为您提供个性化健康解决方案;未经您授权,平台不会以任何形式将您的报告内容提供给其他任何个人或机构。点击「同意继续」即表示您已阅读并同意。',
  178. confirmText: '同意继续',
  179. cancelText: '暂不',
  180. success: (res) => {
  181. if (res.confirm) {
  182. this.agreedToTerms = true
  183. this.startPick(true)
  184. }
  185. }
  186. })
  187. },
  188. // ===== 文件上传 =====
  189. pickFile() {
  190. if (this.agreedToTerms) {
  191. this.startPick(false)
  192. return
  193. }
  194. uni.showModal({
  195. title: '数据使用声明',
  196. content: '上传报告即代表您同意平台使用本报告数据进行分析,为您提供个性化健康解决方案;未经您授权,平台不会以任何形式将您的报告内容提供给其他任何个人或机构。点击「同意继续」即表示您已阅读并同意。',
  197. confirmText: '同意继续',
  198. cancelText: '暂不',
  199. success: (res) => {
  200. if (res.confirm) {
  201. this.agreedToTerms = true
  202. this.startPick(false)
  203. }
  204. }
  205. })
  206. },
  207. // 上传文件 → 自动跳转确认页(确认页按 draftId 触发解析并自动刷新显示结果)
  208. uploadAndGoConfirm(filePath, type) {
  209. if (!filePath) return
  210. this.uploading = true
  211. uni.showLoading({ title: '上传中...' })
  212. uploadReportOnly(filePath, type).then((res) => {
  213. uni.hideLoading()
  214. this.uploading = false
  215. var draftId = res.data && res.data.draftId
  216. if (!draftId) {
  217. uni.showToast({ title: (res && res.message) || '上传失败', icon: 'none' })
  218. return
  219. }
  220. uni.redirectTo({ url: '/pages/health/report-detail?draftId=' + draftId })
  221. }).catch((err) => {
  222. uni.hideLoading()
  223. this.uploading = false
  224. var msg = (err && err.message) || '上传失败,请重试'
  225. uni.showToast({ title: msg, icon: 'none' })
  226. })
  227. }
  228. }
  229. }
  230. </script>
  231. <style scoped>
  232. .upload-container {
  233. min-height: 100vh;
  234. background: #F5F7FA;
  235. }
  236. /* ===== 导航栏 ===== */
  237. .nav-bar {
  238. position: sticky;
  239. top: 0;
  240. background: #fff;
  241. display: flex;
  242. flex-direction: row;
  243. align-items: center;
  244. justify-content: space-between;
  245. padding: 20rpx 30rpx;
  246. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  247. z-index: 100;
  248. }
  249. .nav-back {
  250. font-size: 32rpx;
  251. color: #5B9BD5;
  252. }
  253. .nav-title {
  254. font-size: 32rpx;
  255. font-weight: bold;
  256. color: #333;
  257. }
  258. .nav-placeholder {
  259. width: 80rpx;
  260. }
  261. /* ===== 提示条 ===== */
  262. .tip-banner {
  263. display: flex;
  264. flex-direction: row;
  265. align-items: center;
  266. background: #E3F2FD;
  267. margin: 20rpx 30rpx;
  268. padding: 20rpx 24rpx;
  269. border-radius: 16rpx;
  270. }
  271. .tip-icon {
  272. font-size: 32rpx;
  273. margin-right: 16rpx;
  274. flex-shrink: 0;
  275. }
  276. .tip-text {
  277. font-size: 24rpx;
  278. color: #1565C0;
  279. line-height: 1.5;
  280. }
  281. /* ===== 表单 ===== */
  282. .form-section {
  283. margin: 0 30rpx;
  284. }
  285. .form-item {
  286. background: #fff;
  287. border-radius: 16rpx;
  288. padding: 24rpx;
  289. margin-bottom: 20rpx;
  290. }
  291. .form-label {
  292. font-size: 26rpx;
  293. font-weight: bold;
  294. color: #333;
  295. display: block;
  296. margin-bottom: 16rpx;
  297. }
  298. /* 上传中状态 */
  299. .analyzing-status {
  300. display: flex;
  301. flex-direction: row;
  302. align-items: center;
  303. }
  304. .analyzing-text {
  305. font-size: 26rpx;
  306. color: #5B9BD5;
  307. }
  308. /* ===== 底部 ===== */
  309. .bottom-spacer {
  310. height: 60rpx;
  311. }
  312. /* ===== 责任声明 ===== */
  313. .disclaimer-box {
  314. background: #FFF8F0;
  315. border: 2rpx solid #FDE68A;
  316. }
  317. .disclaimer-check {
  318. display: flex;
  319. flex-direction: row;
  320. align-items: center;
  321. margin-bottom: 12rpx;
  322. }
  323. .disclaimer-checkbox {
  324. width: 36rpx;
  325. height: 36rpx;
  326. border-radius: 6rpx;
  327. border: 2rpx solid #CBD5E1;
  328. background: #fff;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. flex-shrink: 0;
  333. margin-right: 12rpx;
  334. }
  335. .disclaimer-checked {
  336. background: #5B9BD5;
  337. border-color: #5B9BD5;
  338. }
  339. .disclaimer-checkmark {
  340. font-size: 24rpx;
  341. color: #fff;
  342. font-weight: bold;
  343. }
  344. .disclaimer-label {
  345. font-size: 24rpx;
  346. color: #333;
  347. font-weight: 500;
  348. }
  349. .disclaimer-content {
  350. background: #FFFDF5;
  351. border-radius: 10rpx;
  352. padding: 16rpx;
  353. margin-left: 48rpx;
  354. }
  355. .disclaimer-text {
  356. font-size: 22rpx;
  357. color: #92400E;
  358. line-height: 1.6;
  359. }
  360. /* ===== 上传方式:并排卡片 ===== */
  361. .upload-methods {
  362. display: flex;
  363. flex-direction: row;
  364. gap: 20rpx;
  365. margin-bottom: 20rpx;
  366. }
  367. .upload-card {
  368. flex: 1;
  369. display: flex;
  370. flex-direction: column;
  371. align-items: center;
  372. justify-content: center;
  373. padding: 40rpx 20rpx;
  374. border-radius: 20rpx;
  375. text-align: center;
  376. min-height: 240rpx;
  377. }
  378. .upload-card:active {
  379. opacity: 0.85;
  380. }
  381. .upload-card-icon {
  382. width: 96rpx;
  383. height: 96rpx;
  384. border-radius: 24rpx;
  385. font-size: 48rpx;
  386. display: flex;
  387. align-items: center;
  388. justify-content: center;
  389. margin-bottom: 20rpx;
  390. }
  391. .upload-card-title {
  392. font-size: 28rpx;
  393. font-weight: 600;
  394. color: #333;
  395. margin-bottom: 10rpx;
  396. }
  397. .upload-card-desc {
  398. font-size: 22rpx;
  399. color: #94A3B8;
  400. line-height: 1.5;
  401. }
  402. .card-file {
  403. background: #F0F7FF;
  404. border: 2rpx dashed #93C5FD;
  405. }
  406. .card-file .upload-card-icon {
  407. background: linear-gradient(135deg, #3B82F6, #1D4ED8);
  408. color: #fff;
  409. box-shadow: 0 4rpx 12rpx rgba(59, 130, 246, 0.3);
  410. }
  411. .card-photo {
  412. background: #FFF7ED;
  413. border: 2rpx solid #FED7AA;
  414. }
  415. .card-photo .upload-card-icon {
  416. background: linear-gradient(135deg, #FB923C, #EA580C);
  417. color: #fff;
  418. box-shadow: 0 4rpx 12rpx rgba(234, 88, 12, 0.25);
  419. }
  420. /* ===== 上传说明 ===== */
  421. .guide-section {
  422. margin: 0 30rpx 30rpx;
  423. background: #fff;
  424. border-radius: 20rpx;
  425. padding: 28rpx 24rpx;
  426. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  427. }
  428. .guide-header {
  429. display: flex;
  430. flex-direction: row;
  431. align-items: center;
  432. margin-bottom: 20rpx;
  433. }
  434. .guide-header-icon {
  435. font-size: 30rpx;
  436. margin-right: 10rpx;
  437. }
  438. .guide-header-title {
  439. font-size: 28rpx;
  440. font-weight: bold;
  441. color: #333;
  442. }
  443. .guide-list {
  444. display: flex;
  445. flex-direction: column;
  446. }
  447. .guide-item {
  448. display: flex;
  449. flex-direction: row;
  450. align-items: center;
  451. padding: 16rpx 0;
  452. border-bottom: 1rpx solid #F0F0F0;
  453. }
  454. .guide-item:last-of-type {
  455. border-bottom: none;
  456. }
  457. .guide-icon-box {
  458. width: 72rpx;
  459. height: 72rpx;
  460. border-radius: 16rpx;
  461. display: flex;
  462. align-items: center;
  463. justify-content: center;
  464. flex-shrink: 0;
  465. margin-right: 20rpx;
  466. }
  467. .guide-icon {
  468. font-size: 36rpx;
  469. }
  470. .guide-icon-blue {
  471. background: #E3F2FD;
  472. }
  473. .guide-icon-green {
  474. background: #E8F5E9;
  475. }
  476. .guide-icon-orange {
  477. background: #FFF3E0;
  478. }
  479. .guide-icon-purple {
  480. background: #F3E5F5;
  481. }
  482. .guide-icon-teal {
  483. background: #E0F2F1;
  484. }
  485. .guide-icon-pink {
  486. background: #FCE4EC;
  487. }
  488. .guide-info {
  489. flex: 1;
  490. min-width: 0;
  491. display: flex;
  492. flex-direction: column;
  493. }
  494. .guide-name {
  495. font-size: 26rpx;
  496. font-weight: 600;
  497. color: #333;
  498. margin-bottom: 4rpx;
  499. }
  500. .guide-desc {
  501. font-size: 22rpx;
  502. color: #94A3B8;
  503. line-height: 1.4;
  504. }
  505. .guide-tips {
  506. background: #F8FAFC;
  507. border-radius: 12rpx;
  508. padding: 16rpx 20rpx;
  509. margin-top: 16rpx;
  510. display: flex;
  511. flex-direction: column;
  512. }
  513. .guide-tips-title {
  514. font-size: 24rpx;
  515. font-weight: 600;
  516. color: #5B9BD5;
  517. margin-bottom: 8rpx;
  518. }
  519. .guide-tips-item {
  520. font-size: 22rpx;
  521. color: #64748B;
  522. line-height: 1.7;
  523. }
  524. </style>