healthfiles.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="hb column hidden container">
  3. <image class="bg" src="https://user.test.ylrztop.com/images/jkda_top_bg.png" mode="widthFix"></image>
  4. <view :style="{height: statusBarHeight,background: bgColor }"></view>
  5. <u-navbar title="健康档案" titleStyle="font-weight: bold;" @rightClick="rightClick" :autoBack="true"
  6. :bg-color="bgColor">
  7. </u-navbar>
  8. <scroll-view class="content" :scroll-y="true">
  9. <view class="justify-between align-center bg-white radius12 p28">
  10. <view class="justify-start align-center">
  11. <image :src="info.avatar||maleurl" class="w140 h140"></image>
  12. <view class="ml30">
  13. <view class="bold fs32 mb12">{{info.username||'-'}}</view>
  14. <view class="justify-start align-center fs24">
  15. <text class="orangebox">{{info.sex==0?'男':'女'}}</text>
  16. <text class="orangebox ml12">{{info.age||'-'}}岁</text>
  17. </view>
  18. </view>
  19. </view>
  20. <u-icon name="arrow-right" @click="goToUser"></u-icon>
  21. </view>
  22. <view class="fs36 bold mt20">健康数据</view>
  23. <view class="health-monitoring">
  24. <view class="health-monitoring-item" @click="handleMonitoring(0)">
  25. <view class="health-monitoring-title">
  26. <view>
  27. <view class="health-monitoring-maintitle bold">{{BMI?BMI.toFixed(2):'--'}}</view>
  28. <view :class="bmiCategory=='超重'||bmiCategory=='肥胖'?'text-color':''">{{bmiCategory}}</view>
  29. </view>
  30. <image src="/static/images/health/BMI_icon.png" mode="aspectFill"></image>
  31. </view>
  32. <view class="health-bmi mt40">
  33. <view class="justify-between align-center mb12">
  34. <view class="justify-start align-center ">
  35. <text class="color-text2 fs24 mr20">身高</text>
  36. <view class="fs24">{{form.height?form.height+'cm':'--'}}</view>
  37. </view>
  38. <image src="/static/images/health/services_edit_icon.png" class="w32 h32"></image>
  39. </view>
  40. <view class="justify-between align-center">
  41. <view class="justify-start align-center ">
  42. <text class="color-text2 fs24 mr20">体重</text>
  43. <view class="fs24">{{form.weight?form.weight+'kg':'--'}}</view>
  44. </view>
  45. <image src="/static/images/health/services_edit_icon.png" class="w32 h32"></image>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="health-monitoring-item" v-for="(item,index) in infoList" :key="index"
  50. @click="handleMonitoring(item,index+1)">
  51. <view class="health-monitoring-title">
  52. <view>
  53. <view class="health-monitoring-maintitle bold">{{item.title}}</view>
  54. <view v-if='index<2'>{{item.type==0?'正常':item.type==1?'偏小':'偏大'}}</view>
  55. <view v-if='index>1'>{{item.type==0?'正常':item.type==1?'轻微':'严重'}}</view>
  56. </view>
  57. <image :src="item.icon" mode="aspectFill"></image>
  58. </view>
  59. <view>
  60. <view class="health-monitoring-res resnum">{{item.value.value1 || '--'}}</view>
  61. <view class="health-monitoring-time">{{item.value.measurementDate|| '--'}}
  62. {{item.value.measurementTime|| '--'}}</view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="fs36 bold mtb20">健康史</view>
  67. <view class="cardbox">
  68. <view class="health-item" @click="handleEditHealth()">
  69. <image class="health-bgicon" src="https://user.test.ylrztop.com/images/jbs_icon.png"></image>
  70. <view class="health-item-info">
  71. <view class="cardbox-maintitle" style="margin-bottom: 0;">疾病史</view>
  72. <view class="text-overflow" style="margin-top: 20rpx;">{{form.otherMedicalHistory || "尚未记录"}}
  73. </view>
  74. </view>
  75. </view>
  76. <view class="health-item" @click="handleEditHealth()">
  77. <image class="health-bgicon" src="https://user.test.ylrztop.com/images/zzs_icon.png"></image>
  78. <view class="health-item-info">
  79. <view class="cardbox-maintitle" style="margin-bottom: 0;">症状史</view>
  80. <view class="text-overflow" style="margin-top: 20rpx;">{{form.symptomHistory || "尚未记录"}}</view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="h80"></view>
  85. </scroll-view>
  86. </view>
  87. </template>
  88. <script>
  89. import {
  90. getUserInfo
  91. } from '@/api/user.js'
  92. import {
  93. getInfo,
  94. getDoc,
  95. homeInfo
  96. } from '@/api/healthUser.js'
  97. import carKeyboard from '../uni_modules/uview-ui/libs/config/props/carKeyboard';
  98. export default {
  99. data() {
  100. return {
  101. statusBarHeight: '',
  102. top: 0,
  103. null: 0,
  104. famaleurl: "/static/images/health/female_profile.png",
  105. maleurl: "/static/images/health/my_heads.png",
  106. img: [
  107. "/static/images/health/hip_circumference_icon.png",
  108. "/static/images/health/blood_sugar_icon.png",
  109. "/static/images/health/blood_pressure_icon.png",
  110. "/static/images/health/uric_acid_icon.png"
  111. ],
  112. indexInfo: [],
  113. bgColor: 'rgba(11,179,242,0)',
  114. user: null,
  115. bmiCategory: '',
  116. info: {},
  117. infoList: [{
  118. title:'腰围',
  119. icon:"/static/images/health/waist_circumference_icon.png",
  120. type:0,
  121. value:{}
  122. },{
  123. title:'臀围',
  124. icon:"/static/images/health/hip_circumference_icon.png",
  125. type:0,
  126. value:{}
  127. },{
  128. title:'血糖',
  129. icon:"/static/images/health/blood_sugar_icon.png",
  130. type:0,
  131. value:{}
  132. },{
  133. title:'血压',
  134. icon:"/static/images/health/blood_pressure_icon.png",
  135. type:0,
  136. value:{}
  137. },{
  138. title:'尿酸',
  139. icon:"/static/images/health/uric_acid_icon.png",
  140. type:0,
  141. value:{}
  142. }
  143. ],
  144. form: null,
  145. dataMap: {},
  146. BMI: null
  147. }
  148. },
  149. computed: {
  150. // 计算属性的 getter
  151. // bgColor: function() {
  152. // var top=this.top/30;
  153. // return 'rgba(11,179,242, ' + top + ')';
  154. // },
  155. },
  156. onLoad() {
  157. // 获取系统信息
  158. const sys = uni.getSystemInfoSync()
  159. this.statusBarHeight = sys.statusBarHeight + 'px'
  160. // uni.navigateTo({
  161. // url: '/pages_health/doc?type=edit&docId='
  162. // })
  163. this.getUserInfo()
  164. uni.$on('refreshHealthFiles', () => {
  165. this.getDoc()
  166. this.getUserInfo()
  167. // this.homeInfo()
  168. })
  169. // this.getInfo()
  170. },
  171. onUnload() { //普通页面在 onUnload 生命周期中执行
  172. uni.$off('refreshHealthFiles');
  173. uni.$emit('stop')
  174. },
  175. onHide() { //tabBar页面在onHide生命周期中执行
  176. uni.$emit('stop')
  177. },
  178. onPageScroll(e) {
  179. //console.log(e)
  180. // this.top=e.scrollTop;
  181. },
  182. methods: {
  183. getUserInfo() {
  184. getUserInfo().then(
  185. res => {
  186. if (res.code == 200) {
  187. if (res.user != null) {
  188. this.user = res.user;
  189. this.getInfo(this.user.userId)
  190. this.homeInfo(this.user.userId)
  191. } else {
  192. this.utils.loginOut();
  193. }
  194. } else {
  195. uni.showToast({
  196. icon: 'none',
  197. title: "请求失败",
  198. });
  199. }
  200. },
  201. rej => {}
  202. );
  203. },
  204. getInfo(id) {
  205. var that = this
  206. var data = {
  207. userId: id
  208. };
  209. getInfo(data).then(
  210. res => {
  211. if (res.code == 200) {
  212. var data = res.data
  213. if (res.data.birthdate == null) {
  214. uni.showToast({
  215. icon: 'none',
  216. title: "请先完善用户信息",
  217. });
  218. setTimeout(function() {
  219. uni.navigateTo({
  220. url: '/pages_health/addUser?type=edit&userId=' + id
  221. })
  222. }, 500);
  223. } else {
  224. this.getDoc(id, data)
  225. }
  226. } else {
  227. uni.showToast({
  228. title: res.msg,
  229. });
  230. }
  231. },
  232. rej => {}
  233. );
  234. },
  235. getDoc(id, form) {
  236. var data = {
  237. userId: id
  238. };
  239. getDoc(data).then(
  240. res => {
  241. if (res.code == 200) {
  242. this.form = res.data
  243. this.$set(this, 'form', res.data)
  244. if (this.form.weight && this.form.height) {
  245. const heightInMeter = this.form.height / 100; // cm → m
  246. this.BMI = this.form.weight / (heightInMeter * heightInMeter);
  247. // console.log(this.BMI,'bmi')
  248. this.setBmiCategory(); // 同步BMI分类
  249. } else {
  250. this.BMI = null;
  251. this.bmiCategory = '未填写';
  252. }
  253. if (form.birthdate !== null && res.data == null) {
  254. uni.navigateTo({
  255. url: '/pages_health/addDoc?userId=' + id
  256. })
  257. }
  258. } else {
  259. uni.showToast({
  260. title: res.msg,
  261. });
  262. }
  263. },
  264. rej => {}
  265. );
  266. },
  267. setBmiCategory() {
  268. if (!this.BMI) return;
  269. if (this.BMI < 18.5) {
  270. this.bmiCategory = '偏瘦';
  271. } else if (this.BMI < 24) {
  272. this.bmiCategory = '正常';
  273. } else if (this.BMI < 28) {
  274. this.bmiCategory = '超重';
  275. } else {
  276. this.bmiCategory = '肥胖';
  277. }
  278. },
  279. homeInfo(id) {
  280. var data = {
  281. userId: id
  282. };
  283. homeInfo(data).then(
  284. res => {
  285. if (res.code == 200) {
  286. this.info = res.data
  287. const valueList = Object.values(res.data.dataMap);
  288. const list = valueList.filter(item => item !== null);
  289. for (var i = 0; i < this.infoList.length; i++) {
  290. // 假设list与infoList长度相同且对应
  291. this.infoList[i].type = list[i].level;
  292. this.infoList[i].value = list[i];
  293. }
  294. } else {
  295. uni.showToast({
  296. title: res.msg,
  297. });
  298. }
  299. },
  300. rej => {}
  301. );
  302. },
  303. handleMonitoring(item, index) {
  304. console.log(index, 'index')
  305. switch (index) {
  306. case 1:
  307. uni.navigateTo({
  308. url: '/pages_echarts/waistLine?userId=' + this.user.userId
  309. })
  310. break;
  311. case 2:
  312. uni.navigateTo({
  313. url: '/pages_echarts/hips?userId=' + this.user.userId
  314. })
  315. break;
  316. case 3:
  317. uni.navigateTo({
  318. url: '/pages_echarts/bloodSugar?userId=' + this.user.userId
  319. })
  320. break;
  321. case 4:
  322. uni.navigateTo({
  323. url: '/pages_echarts/bloodPressure?userId=' + this.user.userId
  324. })
  325. break;
  326. case 5:
  327. uni.navigateTo({
  328. url: '/pages_echarts/acid?userId=' + this.user.userId
  329. })
  330. break;
  331. default:
  332. uni.navigateTo({
  333. url: '/pages_health/addDoc?type=add&userId=' + this.user.userId
  334. })
  335. break;
  336. }
  337. },
  338. handleEditHealth(item, index) {
  339. uni.navigateTo({
  340. url: '/pages_health/addDoc?type=add&userId=' + this.user.userId
  341. })
  342. },
  343. goToUser() {
  344. console.log(this.info, '---')
  345. if (this.info !== null) {
  346. uni.navigateTo({
  347. url: '/pages_health/addUser?type=edit&userId=' + this.user.userId
  348. })
  349. }
  350. }
  351. }
  352. }
  353. </script>
  354. <style lang="scss" scoped>
  355. .container {
  356. position: relative;
  357. background: #EFF3F7;
  358. .bg {
  359. width: 100%;
  360. height: 380rpx;
  361. position: absolute;
  362. top: 0;
  363. left: 0;
  364. z-index: 0;
  365. }
  366. }
  367. .text-color {
  368. color: #FF4B33;
  369. width: 72rpx;
  370. height: 40rpx;
  371. text-align: center;
  372. line-height: 40rpx;
  373. border-radius: 8rpx 8rpx 8rpx 8rpx;
  374. border: 1rpx solid #FFA599;
  375. }
  376. .content {
  377. padding-top: calc(var(--status-bar-height) + 140rpx) !important;
  378. // height: 100vh;
  379. box-sizing: border-box;
  380. width: 100%;
  381. padding: 20rpx;
  382. }
  383. .orangebox {
  384. border-radius: 24rpx;
  385. border: 1rpx solid #FFA599;
  386. color: #FF4B33;
  387. font-size: 24rpx;
  388. padding: 4rpx 20rpx;
  389. }
  390. .health-monitoring {
  391. // @include u-flex(row, center, flex-start);
  392. display: flex;
  393. justify-content: space-between;
  394. flex-wrap: wrap;
  395. // gap: 16rpx;
  396. margin-top: 20rpx;
  397. margin-bottom: -16rpx;
  398. margin-right: -16rpx;
  399. &-item {
  400. width: 343rpx;
  401. min-height: 264rpx;
  402. margin: 0 16rpx 16rpx 0;
  403. overflow: hidden;
  404. background: #FFFFFF;
  405. border-radius: 16rpx 16rpx 16rpx 16rpx;
  406. padding: 24rpx 34rpx 24rpx 24rpx;
  407. box-sizing: border-box;
  408. }
  409. &-maintitle {
  410. margin-bottom: 4rpx;
  411. font-size: 30rpx;
  412. color: #333333;
  413. }
  414. &-title {
  415. // @include u-flex(row, center, space-between);
  416. display: flex;
  417. justify-content: space-between;
  418. font-weight: 400;
  419. font-size: 24rpx;
  420. color: #999999;
  421. image {
  422. width: 72rpx;
  423. height: 72rpx;
  424. flex-shrink: 0;
  425. }
  426. }
  427. .resnum {
  428. font-family: DIN, DIN;
  429. font-weight: 500;
  430. font-size: 64rpx;
  431. }
  432. &-res {
  433. height: 78rpx;
  434. margin: 20rpx 0 6rpx;
  435. font-family: PingFang SC, PingFang SC;
  436. font-weight: 600;
  437. font-size: 48rpx;
  438. color: #333333;
  439. }
  440. &-time {
  441. font-weight: 400;
  442. font-size: 22rpx;
  443. color: #999999;
  444. }
  445. }
  446. .cardbox {
  447. display: flex;
  448. flex-direction: row;
  449. align-items: center;
  450. justify-content: space-between;
  451. flex-wrap: wrap;
  452. gap: 16rpx 14rpx;
  453. &-maintitle {
  454. margin-bottom: 4rpx;
  455. font-weight: 600;
  456. font-size: 30rpx;
  457. color: #333333;
  458. }
  459. }
  460. .health-item {
  461. width: 343rpx;
  462. height: 224rpx;
  463. padding: 24rpx;
  464. box-sizing: border-box;
  465. background: #FFFFFF;
  466. border-radius: 16rpx 16rpx 16rpx 16rpx;
  467. overflow: hidden;
  468. position: relative;
  469. font-family: PingFang SC, PingFang SC;
  470. font-weight: 400;
  471. font-size: 24rpx;
  472. color: #999999;
  473. }
  474. .health-item-info {
  475. position: relative;
  476. }
  477. .health-bgicon {
  478. position: absolute;
  479. right: 0;
  480. bottom: 0;
  481. width: 168rpx;
  482. height: 168rpx;
  483. }
  484. </style>