acupointEdit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. <template>
  2. <view class="page">
  3. <!-- 自定义导航栏 -->
  4. <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
  5. <view class="nav-bar">
  6. <view class="nav-back" @click="goBack">
  7. <image src="/static/public/back.png" mode="aspectFill" class="back-icon"></image>
  8. </view>
  9. <text class="nav-title">穴位定位</text>
  10. <view class="nav-right">
  11. <text class="nav-count">{{acupointList.length}}穴位</text>
  12. </view>
  13. </view>
  14. <!-- 人体模型 + 穴位标注 -->
  15. <view class="body-container">
  16. <view class="body-wrapper">
  17. <!-- 中线参考 -->
  18. <view class="midline"></view>
  19. <!-- 人体背部剪影 -->
  20. <image
  21. src="/static/device/body-back-silhouette.svg"
  22. mode="aspectFit"
  23. class="body-img"
  24. @load="onImageLoad"
  25. ></image>
  26. <!-- 穴位点 -->
  27. <view
  28. v-for="(point, index) in positionedAcupoints"
  29. :key="point.id"
  30. class="acupoint-dot"
  31. :class="{
  32. 'acupoint-active': selectedIndex === index
  33. }"
  34. :style="{
  35. left: point.screenX + 'px',
  36. top: point.screenY + 'px'
  37. }"
  38. @click="onAcupointTap(index)"
  39. >
  40. <view class="dot-inner"></view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 穴位列表 -->
  45. <view class="list-section">
  46. <view class="list-header">
  47. <text class="list-title">穴位清单</text>
  48. </view>
  49. <scroll-view class="list-scroll" scroll-y>
  50. <view
  51. v-for="(point, index) in acupointList"
  52. :key="point.id"
  53. class="list-item"
  54. :class="{'list-item-active': selectedIndex === index}"
  55. @click="onListItemTap(index)"
  56. >
  57. <view class="item-left">
  58. <view class="item-index" :class="{'item-index-active': selectedIndex === index}">
  59. <text class="index-text">{{index + 1}}</text>
  60. </view>
  61. <view class="item-info">
  62. <text class="item-name">{{point.acupointName}}</text>
  63. <text class="item-code">{{point.acupointCode}}</text>
  64. </view>
  65. </view>
  66. <view class="item-right">
  67. <text class="item-side" v-if="point.customSide || point.acupointSide !== 'center'">{{ point.customSide || sideLabel(point.acupointSide) }}</text>
  68. <view class="item-params" v-if="point.method">
  69. <text class="param-text">{{point.method}} {{point.temperature}}°C {{point.duration}}min</text>
  70. </view>
  71. <view class="item-coord-box" v-else>
  72. <text class="item-coord">{{point.coordinateX}},{{point.coordinateY}}</text>
  73. <text class="item-unit">mm</text>
  74. </view>
  75. </view>
  76. </view>
  77. </scroll-view>
  78. </view>
  79. <!-- 编辑弹窗 -->
  80. <view class="popup-mask" v-if="showPopup" @click="closePopup">
  81. <view class="popup-content" @click.stop>
  82. <view class="popup-header">
  83. <text class="popup-title">编辑穴位参数</text>
  84. <text class="popup-acupoint-name">{{ currentEditAcupoint?.acupointName }}</text>
  85. </view>
  86. <view class="popup-body">
  87. <!-- 侧别 -->
  88. <view class="form-group">
  89. <text class="form-label">侧别</text>
  90. <view class="tags-row">
  91. <view
  92. class="tag-item"
  93. v-for="item in sideOptions"
  94. :key="item"
  95. :class="{'tag-item-active': editForm.side === item}"
  96. @click="editForm.side = item"
  97. >
  98. {{item}}
  99. </view>
  100. </view>
  101. </view>
  102. <!-- 手法 -->
  103. <view class="form-group">
  104. <text class="form-label">手法选择</text>
  105. <view class="tags-row">
  106. <view
  107. class="tag-item"
  108. v-for="item in methodOptions"
  109. :key="item"
  110. :class="{'tag-item-active': editForm.method === item}"
  111. @click="editForm.method = item"
  112. >
  113. {{item}}
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 温度与时间 -->
  118. <view class="form-row-2">
  119. <view class="form-group half-width">
  120. <text class="form-label">温度 (°C)</text>
  121. <view class="stepper">
  122. <view class="stepper-btn" @click="editForm.temperature > 30 && editForm.temperature--">-</view>
  123. <input class="stepper-input" type="number" v-model="editForm.temperature" />
  124. <view class="stepper-btn" @click="editForm.temperature < 60 && editForm.temperature++">+</view>
  125. </view>
  126. </view>
  127. <view class="form-group half-width">
  128. <text class="form-label">时间 (分钟)</text>
  129. <view class="stepper">
  130. <view class="stepper-btn" @click="editForm.duration > 1 && editForm.duration--">-</view>
  131. <input class="stepper-input" type="number" v-model="editForm.duration" />
  132. <view class="stepper-btn" @click="editForm.duration < 60 && editForm.duration++">+</view>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. <view class="popup-footer">
  138. <view class="btn btn-cancel" @click="closePopup">取消</view>
  139. <view class="btn btn-confirm" @click="saveEdit">确定</view>
  140. </view>
  141. </view>
  142. </view>
  143. <!-- 加载提示 -->
  144. <view class="loading-mask" v-if="loading">
  145. <view class="loading-card">
  146. <view class="loading-spinner"></view>
  147. <text class="loading-text">加载中...</text>
  148. </view>
  149. </view>
  150. </view>
  151. </template>
  152. <script>
  153. import { getBackAcupoints } from '@/utils/api/acupoint.js'
  154. export default {
  155. data() {
  156. return {
  157. statusBarHeight: 44,
  158. loading: false,
  159. acupointList: [],
  160. selectedIndex: -1,
  161. imageReady: false,
  162. // SVG viewBox: 0 0 300 400, 一体式实心剪影
  163. containerWidth: 345,
  164. containerHeight: 460,
  165. // 大椎穴(0,0)在容器中的位置
  166. // 颈根/斜方肌起点(C7)在SVG中 y=78 -> 按比例放大1.15倍
  167. originX: 172.5,
  168. originY: 89.7,
  169. // 毫米到像素缩放比
  170. // 0.5 * 1.15 = 0.575
  171. mmToPixel: 0.575,
  172. // 弹窗表单
  173. showPopup: false,
  174. editForm: {
  175. side: '',
  176. method: '温和灸',
  177. temperature: 45,
  178. duration: 15
  179. },
  180. sideOptions: ['双侧', '中心', '左侧', '右侧'],
  181. methodOptions: ['温和灸', '雀啄灸', '回旋灸']
  182. }
  183. },
  184. computed: {
  185. /** 当前正在编辑的穴位 */
  186. currentEditAcupoint() {
  187. if (this.selectedIndex >= 0 && this.acupointList[this.selectedIndex]) {
  188. return this.acupointList[this.selectedIndex]
  189. }
  190. return null
  191. },
  192. /** 计算屏幕坐标后的穴位列表 */
  193. positionedAcupoints() {
  194. if (!this.imageReady || this.acupointList.length === 0) return []
  195. return this.acupointList.map(point => {
  196. // coordinateX: 向右为正 (mm), coordinateY: 向下为正 (mm)
  197. // 大椎穴为(0,0)原点
  198. const screenX = this.originX + (point.coordinateX * this.mmToPixel)
  199. const screenY = this.originY + (point.coordinateY * this.mmToPixel)
  200. return {
  201. ...point,
  202. screenX: Math.max(8, Math.min(this.containerWidth - 8, screenX)),
  203. screenY: Math.max(8, Math.min(this.containerHeight - 8, screenY))
  204. }
  205. })
  206. }
  207. },
  208. onLoad() {
  209. const sysInfo = uni.getSystemInfoSync()
  210. this.statusBarHeight = sysInfo.statusBarHeight || 44
  211. this.loadAcupoints()
  212. },
  213. methods: {
  214. goBack() {
  215. uni.navigateBack()
  216. },
  217. /** 图片加载完成 */
  218. onImageLoad() {
  219. this.imageReady = true
  220. },
  221. /** 加载穴位数据 */
  222. async loadAcupoints() {
  223. this.loading = true
  224. try {
  225. const data = await getBackAcupoints(4)
  226. if (Array.isArray(data)) {
  227. this.acupointList = data
  228. } else {
  229. this.acupointList = []
  230. }
  231. } catch (e) {
  232. console.error('加载穴位数据失败:', e)
  233. uni.showToast({ title: '穴位数据加载失败', icon: 'none' })
  234. this.acupointList = []
  235. } finally {
  236. this.loading = false
  237. // 确保图片加载后穴位可显示
  238. this.$nextTick(() => {
  239. if (!this.imageReady) {
  240. this.imageReady = true
  241. }
  242. })
  243. }
  244. },
  245. /** 点击穴位点 */
  246. onAcupointTap(index) {
  247. this.openPopup(index)
  248. },
  249. /** 点击列表项 */
  250. onListItemTap(index) {
  251. this.openPopup(index)
  252. },
  253. /** 打开编辑弹窗 */
  254. openPopup(index) {
  255. this.selectedIndex = index
  256. const point = this.acupointList[index]
  257. // 初始化表单数据
  258. this.editForm = {
  259. side: point.customSide || this.sideLabel(point.acupointSide) || '中心',
  260. method: point.method || '温和灸',
  261. temperature: point.temperature || 45,
  262. duration: point.duration || 15
  263. }
  264. this.showPopup = true
  265. },
  266. /** 关闭弹窗 */
  267. closePopup() {
  268. this.showPopup = false
  269. },
  270. /** 保存编辑结果 */
  271. saveEdit() {
  272. if (this.selectedIndex >= 0) {
  273. const point = this.acupointList[this.selectedIndex]
  274. // 更新穴位列表中的对应数据(使用Vue的响应式需要特殊处理,但这里我们直接改属性,若无法触发视图更新可用$set或splice,但简单修改通常有效)
  275. point.customSide = this.editForm.side
  276. point.method = this.editForm.method
  277. point.temperature = this.editForm.temperature
  278. point.duration = this.editForm.duration
  279. }
  280. this.closePopup()
  281. },
  282. /** 侧别标签 */
  283. sideLabel(side) {
  284. const map = { left: '左侧', right: '右侧', center: '中心' }
  285. return map[side] || side
  286. },
  287. /** 置信度标签 */
  288. confidenceLabel(confidence) {
  289. const map = { high: '高', medium: '中', low: '低' }
  290. return map[confidence] || confidence
  291. }
  292. }
  293. }
  294. </script>
  295. <style scoped>
  296. .page {
  297. display: flex;
  298. flex-direction: column;
  299. height: 100vh;
  300. background: linear-gradient(to bottom, #389588, rgba(56,149,136,0.3) 40%, #F8F8F8 60%);
  301. }
  302. .status-bar {
  303. background-color: transparent;
  304. }
  305. /* 导航栏 */
  306. .nav-bar {
  307. display: flex;
  308. flex-direction: row;
  309. justify-content: space-between;
  310. align-items: center;
  311. height: 44px;
  312. padding: 0 15px;
  313. }
  314. .nav-back {
  315. width: 25px;
  316. height: 25px;
  317. display: flex;
  318. justify-content: center;
  319. align-items: center;
  320. }
  321. .back-icon {
  322. width: 25px;
  323. height: 25px;
  324. }
  325. .nav-title {
  326. font-size: 16px;
  327. font-weight: bold;
  328. color: #FFFFFF;
  329. }
  330. .nav-right {
  331. width: 60px;
  332. display: flex;
  333. justify-content: flex-end;
  334. }
  335. .nav-count {
  336. font-size: 12px;
  337. color: rgba(255,255,255,0.8);
  338. }
  339. /* 人体模型容器 */
  340. .body-container {
  341. flex: 1;
  342. display: flex;
  343. justify-content: center;
  344. align-items: flex-start; /* 改为顶部对齐,防止高度不足时头部被居中截断 */
  345. padding: 20px 10px; /* 增加顶部间距,保护头部不贴边 */
  346. overflow-y: auto; /* 允许垂直滚动,适配屏幕高度不足的情况 */
  347. min-height: 0;
  348. }
  349. .body-wrapper {
  350. position: relative;
  351. width: 345px;
  352. height: 460px;
  353. margin: auto 0; /* 空间充足时保持垂直居中,空间不足时贴顶 */
  354. /* Removed bubble-like styling to keep it clean */
  355. }
  356. /* 中线 */
  357. .midline {
  358. position: absolute;
  359. left: 50%;
  360. top: 60px;
  361. bottom: 20px;
  362. width: 1px;
  363. background: transparent;
  364. border-left: 1px dashed rgba(255, 255, 255, 0.4);
  365. z-index: 2;
  366. pointer-events: none;
  367. }
  368. .body-img {
  369. position: relative;
  370. width: 345px;
  371. height: 460px;
  372. z-index: 3;
  373. /* Added a soft drop shadow to make the human shape stand out nicely */
  374. filter: drop-shadow(0px 15px 25px rgba(0, 0, 0, 0.12));
  375. }
  376. /* 穴位点 */
  377. .acupoint-dot {
  378. position: absolute;
  379. width: 30px;
  380. height: 30px;
  381. margin-left: -15px;
  382. margin-top: -15px;
  383. display: flex;
  384. justify-content: center;
  385. align-items: center;
  386. z-index: 10;
  387. }
  388. .dot-inner {
  389. width: 8px;
  390. height: 8px;
  391. border-radius: 50%;
  392. background: #FFFFFF;
  393. border: 1.5px solid #389588;
  394. box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  395. transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  396. z-index: 1;
  397. }
  398. /* 选中态 */
  399. .acupoint-active .dot-inner {
  400. width: 14px;
  401. height: 14px;
  402. background: #F65252;
  403. border: 2px solid #FFFFFF;
  404. box-shadow: 0 4px 12px rgba(246, 82, 82, 0.4);
  405. transform: scale(1.1);
  406. }
  407. /* 穴位列表 */
  408. .list-section {
  409. background: #FFFFFF;
  410. border-radius: 28px 28px 0 0;
  411. padding: 20px 20px 0;
  412. max-height: 40vh;
  413. display: flex;
  414. flex-direction: column;
  415. box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.06);
  416. }
  417. .list-header {
  418. display: flex;
  419. flex-direction: column;
  420. align-items: center;
  421. margin-bottom: 16px;
  422. }
  423. .list-title {
  424. font-size: 15px;
  425. color: #333333;
  426. font-weight: 600;
  427. }
  428. .list-scroll {
  429. flex: 1;
  430. overflow-y: auto;
  431. padding-bottom: 20px;
  432. }
  433. .list-item {
  434. display: flex;
  435. flex-direction: row;
  436. justify-content: space-between;
  437. align-items: center;
  438. padding: 14px 16px;
  439. margin-bottom: 10px;
  440. border-radius: 16px;
  441. background: #F8FAFA;
  442. border: 1px solid rgba(56, 149, 136, 0.05);
  443. transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  444. }
  445. .list-item-active {
  446. background: rgba(56, 149, 136, 0.08);
  447. border-color: rgba(56, 149, 136, 0.3);
  448. box-shadow: 0 4px 12px rgba(56, 149, 136, 0.1);
  449. transform: scale(1.02);
  450. }
  451. .item-left {
  452. display: flex;
  453. flex-direction: row;
  454. align-items: center;
  455. }
  456. .item-index {
  457. width: 28px;
  458. height: 28px;
  459. border-radius: 10px;
  460. background: rgba(56, 149, 136, 0.1);
  461. display: flex;
  462. justify-content: center;
  463. align-items: center;
  464. margin-right: 12px;
  465. transition: all 0.25s;
  466. }
  467. .item-index-active {
  468. background: rgba(246, 82, 82, 0.1);
  469. }
  470. .index-text {
  471. font-size: 11px;
  472. font-weight: 600;
  473. color: #389588;
  474. }
  475. .item-index-active .index-text {
  476. color: #F65252;
  477. }
  478. .item-info {
  479. display: flex;
  480. flex-direction: column;
  481. }
  482. .item-name {
  483. font-size: 13px;
  484. color: #545F71;
  485. font-weight: 500;
  486. line-height: 1.3;
  487. }
  488. .item-code {
  489. font-size: 10px;
  490. color: #9BA5B7;
  491. margin-top: 2px;
  492. font-family: monospace;
  493. }
  494. .item-right {
  495. display: flex;
  496. flex-direction: row;
  497. align-items: center;
  498. gap: 8px;
  499. }
  500. .item-side {
  501. font-size: 10px;
  502. color: #389588;
  503. padding: 2px 6px;
  504. border-radius: 4px;
  505. background: rgba(56, 149, 136, 0.08);
  506. }
  507. .item-coord-box {
  508. display: flex;
  509. flex-direction: row;
  510. align-items: baseline;
  511. }
  512. .item-coord {
  513. font-size: 11px;
  514. color: #9BA5B7;
  515. font-family: monospace;
  516. }
  517. .item-unit {
  518. font-size: 9px;
  519. color: #c0c0c0;
  520. margin-left: 2px;
  521. }
  522. /* 加载遮罩 */
  523. .loading-mask {
  524. position: fixed;
  525. top: 0;
  526. left: 0;
  527. right: 0;
  528. bottom: 0;
  529. background: rgba(0, 0, 0, 0.4);
  530. display: flex;
  531. justify-content: center;
  532. align-items: center;
  533. z-index: 100;
  534. }
  535. .loading-card {
  536. display: flex;
  537. flex-direction: column;
  538. align-items: center;
  539. background: #FFFFFF;
  540. border-radius: 16px;
  541. padding: 28px 36px;
  542. box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  543. }
  544. @keyframes spin {
  545. 0% { transform: rotate(0deg); }
  546. 100% { transform: rotate(360deg); }
  547. }
  548. .loading-spinner {
  549. width: 32px;
  550. height: 32px;
  551. border: 2px solid #EEF1F4;
  552. border-top-color: #389588;
  553. border-radius: 50%;
  554. animation: spin 0.8s linear infinite;
  555. margin-bottom: 14px;
  556. }
  557. .loading-text {
  558. color: #545F71;
  559. font-size: 13px;
  560. font-weight: 500;
  561. }
  562. /* 弹窗样式 */
  563. .popup-mask {
  564. position: fixed;
  565. top: 0;
  566. left: 0;
  567. right: 0;
  568. bottom: 0;
  569. background: rgba(0, 0, 0, 0.5);
  570. z-index: 200;
  571. display: flex;
  572. justify-content: center;
  573. align-items: center;
  574. animation: fadeIn 0.3s ease;
  575. }
  576. @keyframes fadeIn {
  577. from { opacity: 0; }
  578. to { opacity: 1; }
  579. }
  580. .popup-content {
  581. width: 320px;
  582. background: #FFFFFF;
  583. border-radius: 20px;
  584. overflow: hidden;
  585. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  586. animation: slideUp 0.3s ease;
  587. }
  588. @keyframes slideUp {
  589. from { transform: translateY(20px); opacity: 0; }
  590. to { transform: translateY(0); opacity: 1; }
  591. }
  592. .popup-header {
  593. padding: 20px 24px 16px;
  594. border-bottom: 1px solid #F0F2F5;
  595. display: flex;
  596. justify-content: space-between;
  597. align-items: center;
  598. }
  599. .popup-title {
  600. font-size: 16px;
  601. font-weight: 600;
  602. color: #333333;
  603. }
  604. .popup-acupoint-name {
  605. font-size: 15px;
  606. color: #389588;
  607. font-weight: 600;
  608. background: rgba(56, 149, 136, 0.1);
  609. padding: 4px 10px;
  610. border-radius: 6px;
  611. }
  612. .popup-body {
  613. padding: 20px 24px;
  614. }
  615. .form-group {
  616. margin-bottom: 20px;
  617. }
  618. .form-group:last-child {
  619. margin-bottom: 0;
  620. }
  621. .form-row-2 {
  622. display: flex;
  623. justify-content: space-between;
  624. gap: 16px;
  625. }
  626. .half-width {
  627. flex: 1;
  628. }
  629. .form-label {
  630. font-size: 13px;
  631. color: #545F71;
  632. margin-bottom: 10px;
  633. display: block;
  634. font-weight: 500;
  635. }
  636. .tags-row {
  637. display: flex;
  638. flex-wrap: wrap;
  639. gap: 10px;
  640. }
  641. .tag-item {
  642. padding: 8px 14px;
  643. background: #F4F6F8;
  644. border-radius: 8px;
  645. font-size: 13px;
  646. color: #545F71;
  647. border: 1px solid transparent;
  648. transition: all 0.2s;
  649. }
  650. .tag-item-active {
  651. background: rgba(56, 149, 136, 0.1);
  652. color: #389588;
  653. border-color: #389588;
  654. font-weight: 500;
  655. }
  656. .stepper {
  657. display: flex;
  658. align-items: center;
  659. background: #F4F6F8;
  660. border-radius: 8px;
  661. overflow: hidden;
  662. }
  663. .stepper-btn {
  664. width: 36px;
  665. height: 36px;
  666. display: flex;
  667. justify-content: center;
  668. align-items: center;
  669. font-size: 18px;
  670. color: #545F71;
  671. background: #EEF1F4;
  672. }
  673. .stepper-btn:active {
  674. background: #E2E6EA;
  675. }
  676. .stepper-input {
  677. flex: 1;
  678. height: 36px;
  679. text-align: center;
  680. font-size: 14px;
  681. color: #333333;
  682. font-weight: 500;
  683. }
  684. .popup-footer {
  685. display: flex;
  686. border-top: 1px solid #F0F2F5;
  687. }
  688. .btn {
  689. flex: 1;
  690. height: 50px;
  691. display: flex;
  692. justify-content: center;
  693. align-items: center;
  694. font-size: 15px;
  695. font-weight: 500;
  696. }
  697. .btn-cancel {
  698. color: #9BA5B7;
  699. background: #FFFFFF;
  700. }
  701. .btn-confirm {
  702. color: #FFFFFF;
  703. background: #389588;
  704. }
  705. /* 参数展示 */
  706. .item-params {
  707. display: flex;
  708. align-items: center;
  709. }
  710. .param-text {
  711. font-size: 11px;
  712. color: #389588;
  713. background: rgba(56, 149, 136, 0.1);
  714. padding: 2px 6px;
  715. border-radius: 4px;
  716. }
  717. </style>