健康同学微信公众号h5项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <div class="location-monitor-container">
  3. <!-- nav -->
  4. <div class="nav-bar">
  5. <van-nav-bar title="血压监测" left-text="返回" @click-left="onNavBack" left-arrow>
  6. <template #right>
  7. <!-- <div class="setupClock_save" @click="onSubmit">保存</div> -->
  8. <van-button type="primary" @click="onSubmit" size="small">保存</van-button>
  9. </template>
  10. </van-nav-bar>
  11. </div>
  12. <!-- main -->
  13. <div class="main" v-if="isLoading">
  14. <!-- 血压 -->
  15. <div class="list">
  16. <div class="item" v-show="true">
  17. <div class="left">
  18. <span class="title">开启血压监测:</span>
  19. </div>
  20. <div class="right">
  21. <!-- <img :src="rightIcon" alt=""> -->
  22. <van-switch v-model="bloodConfig.bloodPressenabled" :active-color="$green" />
  23. </div>
  24. </div>
  25. <div class="item left-gray" v-show="bloodConfig.bloodPressenabled">
  26. <div class="left">
  27. <span class="title gray">检测周期:</span>
  28. </div>
  29. <div class="right" @click="onClick('bloodPressinteval')">
  30. <span>{{ formatInteval(bloodConfig.bloodPressinteval) }}</span>
  31. <img :src="rightIcon" alt="" />
  32. </div>
  33. </div>
  34. <div class="item left-gray" v-show="bloodConfig.bloodPressenabled">
  35. <div class="left">
  36. <span class="title gray">告警阈值-收缩压:</span>
  37. </div>
  38. <div class="right" @click="onClick('systolicmaxvalue')">
  39. <span>{{ bloodConfig.systolicmaxvalue }}</span>
  40. <img :src="rightIcon" alt="" />
  41. </div>
  42. </div>
  43. <div class="item alarmType left-gray" v-show="bloodConfig.bloodPressenabled">
  44. <div class="left">
  45. <span class="title gray">告警方式:</span>
  46. </div>
  47. <div class="right">
  48. <div class="checkbox-group">
  49. <van-checkbox
  50. name="bloodPressvibrateenabled"
  51. v-model="bloodConfig.bloodPressvibrateenabled"
  52. shape="square"
  53. direction="horizontal"
  54. >震动</van-checkbox
  55. >
  56. <van-checkbox
  57. name="bloodPresslcdenabled"
  58. v-model="bloodConfig.bloodPresslcdenabled"
  59. shape="square"
  60. direction="horizontal"
  61. >亮屏</van-checkbox
  62. >
  63. </div>
  64. </div>
  65. </div>
  66. <div class="item" v-show="false">
  67. <div class="left">
  68. <span class="title">修改登记信息</span>
  69. </div>
  70. <div class="right" @click="onUpdateInfos()">
  71. <span>修改</span>
  72. <img :src="rightIcon" alt="" />
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <!-- 弹窗 -->
  78. <van-dialog v-model="dialog.isDialogshow" show-cancel-button cancel-button-text="返回" :show-confirm-button="false">
  79. <template #title>
  80. <div class="title">
  81. <span>设置</span>
  82. </div>
  83. </template>
  84. <template #default>
  85. <div class="dialog-container">
  86. <div class="selectConfirm">
  87. <div class="con">
  88. <van-cell v-for="(item, index) in dialog.confirmData" :key="`selectVPT${index}`" @click="onSelect(item)">
  89. <div class="text">
  90. <div v-html="item.text"></div>
  91. </div>
  92. <em :class="['circle', { on: selectConfirmActive == index }]"></em>
  93. </van-cell>
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. </van-dialog>
  99. </div>
  100. </template>
  101. <script>
  102. import ToastService from '@/services/toast-service';
  103. import DialogService from '@/services/dialog-service';
  104. import APIHealthy from '@/api/heathly';
  105. import APIDevice from '@/api/device';
  106. import { isNull } from '@/services/utils-service';
  107. export default {
  108. name: '',
  109. data() {
  110. return {
  111. rightIcon: require('../../../assets/img/health/right_more.png'),
  112. checked: false,
  113. sampleinteval: '', //上报频率-定位检测
  114. temperatureAlarmType: ['temperaturevibrateenabled', 'temperaturelcdenabled', 'temperaturereportenabled'], //体温告警方式
  115. heartrateAlarmType: ['heartratevibrateenabled', 'heartratelcdenabled', 'heartratereportenabled'], //心率
  116. spo2AlarmType: ['spo2vibrateenabled', 'spo2lcdenabled', 'spo2reportenabled'], //血氧
  117. dialog: {
  118. isDialogshow: false,
  119. title: '上报频率',
  120. confirmData: []
  121. },
  122. bloodConfig: {
  123. imei: '',
  124. bloodPressenabled: 0, //血压使能 0禁用 1启用
  125. bloodPressinteval: 360, //血压检测周期,单位分钟,最小10分钟,最大1400分钟,默认360分钟。设置时以10分钟为颗粒度
  126. systolicminvalue: 0, //血压收缩压告警的最小值,
  127. systolicmaxvalue: 140, //血压收缩压告警的最大值,
  128. diastolicminvalue: 0, //血压舒张压告警的最小值
  129. diastolicmaxvalue: 0, //血压舒张压告警的最大值
  130. bloodPressvibrateenabled: 0, //血压异常时是否震动 0禁用 1启用
  131. bloodPresslcdenabled: 0, //血压异常时是否亮屏 0禁用 1启用
  132. bloodPressreportenabled: 1 //血压异常时是否上报数据 0禁用 1启用
  133. },
  134. // todo 以下这些弹窗列表可以用函数生成
  135. // 检测周期时间数据
  136. // 15、30、60、120
  137. monitorList: [
  138. {
  139. text: '10分钟',
  140. model: 6,
  141. checked: false,
  142. value: 10
  143. },
  144. {
  145. text: '15分钟',
  146. model: 0,
  147. checked: false,
  148. value: 15
  149. },
  150. {
  151. text: '30分钟',
  152. model: 1,
  153. checked: false,
  154. value: 30
  155. },
  156. {
  157. text: '60分钟',
  158. model: 2,
  159. checked: false,
  160. value: 60
  161. },
  162. /* {
  163. text: "120分钟",
  164. model: 3,
  165. checked: false,
  166. value: 120
  167. }, */
  168. {
  169. text: '6小时',
  170. model: 4,
  171. checked: false,
  172. value: 360
  173. },
  174. {
  175. text: '8小时',
  176. model: 5,
  177. checked: false,
  178. value: 480
  179. }
  180. ],
  181. //血压弹窗收缩压数据
  182. bloodMaxList: [
  183. {
  184. text: '120',
  185. model: 3,
  186. checked: false,
  187. className: 'circle',
  188. value: 120,
  189. name: '血压监测'
  190. },
  191. {
  192. text: '140',
  193. model: 0,
  194. checked: false,
  195. className: 'circle',
  196. value: 140,
  197. name: '血压监测'
  198. },
  199. {
  200. text: '160',
  201. model: 1,
  202. checked: false,
  203. className: 'circle',
  204. value: 160,
  205. name: '血压监测'
  206. },
  207. {
  208. text: '180',
  209. model: 2,
  210. checked: false,
  211. className: 'circle',
  212. value: 180,
  213. name: '血压监测'
  214. }
  215. ],
  216. //血压弹窗舒张值上限数据
  217. bloodMinList: [
  218. {
  219. text: '90',
  220. model: 0,
  221. checked: false,
  222. className: 'circle',
  223. value: 90,
  224. name: '血压监测'
  225. },
  226. {
  227. text: '100',
  228. model: 1,
  229. checked: false,
  230. className: 'circle',
  231. value: 100,
  232. name: '血压监测'
  233. },
  234. {
  235. text: '110',
  236. model: 2,
  237. checked: false,
  238. className: 'circle',
  239. value: 110,
  240. name: '血压监测'
  241. }
  242. ],
  243. selectConfirmActive: 0,
  244. currentDiallogName: '',
  245. isRegisterBlood: null, //是否已经登记个人信息
  246. isSetAgeAgain: null, //是否需要重新设置年龄
  247. isLoading: false
  248. };
  249. },
  250. computed: {
  251. imei() {
  252. return this.$store.getters.serialNo;
  253. },
  254. watchRole() {
  255. return this.$store.getters.watchRole;
  256. }
  257. },
  258. mounted() {
  259. this.getPersonData();
  260. this.getBloodConfig();
  261. },
  262. methods: {
  263. onNavBack() {
  264. let fromRouter = this.$route.query.from;
  265. this.$router.push({
  266. name: fromRouter ? fromRouter : 'watchSetting'
  267. });
  268. },
  269. onSubmit() {
  270. ToastService.loading({ message: '设置中' });
  271. /* if(!this.isRegisterBlood) {
  272. return DialogService.confirm({
  273. title: '信息提示',
  274. message: '使用血压监测功能前需要登记使用者信息,是否前往登记?',
  275. showCancelButton: true
  276. }).then(() => {
  277. this.$router.push({
  278. name: 'registeUserInfos',
  279. query: {
  280. from: 'blood'
  281. }
  282. });
  283. }).catch(() =>{})
  284. } */ /* else if(this.isSetAgeAgain) {
  285. // 2023.06.26 需求取消 小于16岁年龄限制
  286. return DialogService.confirm({
  287. title: '信息提示',
  288. message: '使用血压监测功能年龄最小需要大于16岁,是否需要前往登记?',
  289. showCancelButton: true
  290. }).then(() => {
  291. this.$router.push({
  292. name: 'registeUserInfos',
  293. query: {
  294. from: 'blood'
  295. }
  296. });
  297. }).catch(() =>{})
  298. } */
  299. let reqBody = { ...this.bloodConfig };
  300. Object.values(this.bloodConfig).filter((item, index) => {
  301. if (typeof item === 'boolean') {
  302. item = item === false ? 0 : 1;
  303. reqBody[Object.keys(this.bloodConfig)[index]] = item;
  304. } else {
  305. reqBody[Object.keys(this.bloodConfig)[index]] = item;
  306. }
  307. });
  308. reqBody.imei = this.imei;
  309. console.log('保存的数据', reqBody);
  310. APIHealthy.setBloodPressConfig(reqBody)
  311. .then(res => {
  312. if (res.data.stateCode === 1) {
  313. ToastService.success({ message: '设置成功' });
  314. let fromRouter = this.$route.query.from;
  315. setTimeout(() => {
  316. this.$router.push({
  317. name: fromRouter ? fromRouter : 'watchSetting'
  318. });
  319. }, 1500);
  320. } else {
  321. DialogService.confirm({
  322. title: '设置失败',
  323. message: `${res.data.message}`
  324. });
  325. }
  326. })
  327. .catch(e => {
  328. DialogService.confirm({
  329. title: '设置失败',
  330. message: `${e.message}`
  331. });
  332. })
  333. .finally(() => {
  334. setTimeout(() => {
  335. ToastService.clear();
  336. }, 1500);
  337. });
  338. },
  339. onSelect(data) {
  340. this.bloodConfig[this.currentDiallogName] = data.value;
  341. this.selectConfirmActive = data.model;
  342. this.dialog.isDialogshow = false;
  343. },
  344. onClick(name) {
  345. this.currentDiallogName = name;
  346. this.dialog.confirmData = [];
  347. const intevalList = ['temperatureinteval', 'spo2inteval', 'heartrateinteval', 'bloodPressinteval'];
  348. if (intevalList.includes(name)) {
  349. this.dialog.confirmData = this.monitorList;
  350. } else if (name === 'systolicmaxvalue') {
  351. // 血压-收缩压
  352. this.dialog.confirmData = this.bloodMaxList;
  353. } else if (name === 'bloodminvalue') {
  354. // 血压-舒张压
  355. this.dialog.confirmData = this.bloodMinList;
  356. }
  357. let seclectIndex = this.dialog.confirmData.findIndex(item => {
  358. return item.value === this.bloodConfig[name];
  359. });
  360. this.selectConfirmActive = seclectIndex;
  361. this.dialog.isDialogshow = true;
  362. },
  363. getResult(number1, number2) {
  364. const result = parseInt(number1) / parseInt(number2);
  365. return result.toString().indexOf('.') != -1 ? parseInt(result).toFixed(2).slice(0, 1) : result;
  366. },
  367. getPersonData() {
  368. APIDevice.getPersonInfo({
  369. userId: this.$store.getters.userId,
  370. deviceId: this.$store.getters.deviceId
  371. })
  372. .then(res => {
  373. let data = res.data;
  374. if (isNull(data.gender) || data.height === 0 || data.weight === 0 || isNull(data.bornDate)) {
  375. this.isRegisterBlood = false;
  376. // 未进行信息登记,无法使用血压周期性下发功能
  377. // 2023.08.04 血压个人资料不完整,跳转个人信息等级页面
  378. setTimeout(() => {
  379. this.$router.push({
  380. name: 'registeUserInfos',
  381. query: {
  382. from: 'blood',
  383. backRouter: 'watchSetting'
  384. }
  385. });
  386. }, 1500);
  387. } else {
  388. // 2023.06.26 需求取消 小于16岁年龄限制
  389. /* if(isNotNull(data.age)) {
  390. if(Number(data.age) < 16) {
  391. // 血压限制 大于 >16,需要重新设置年龄
  392. this.isSetAgeAgain = true;
  393. }
  394. } */
  395. this.isRegisterBlood = true;
  396. }
  397. })
  398. .catch(e => {
  399. console.log('e', e);
  400. DialogService.confirm({
  401. message: `${e.message}`
  402. });
  403. })
  404. .finally(() => {
  405. setTimeout(() => {
  406. ToastService.clear();
  407. this.isLoading = true;
  408. }, 1500);
  409. });
  410. },
  411. getBloodConfig() {
  412. ToastService.loading({ message: '数据加载中' });
  413. APIHealthy.getBloodPressConfig(this.imei)
  414. .then(res => {
  415. let data = res.data.data;
  416. if (data) {
  417. let bloodConfig = data;
  418. this.bloodConfig.bloodPressenabled = bloodConfig.bloodPressenabled === 1;
  419. this.bloodConfig.bloodPressinteval = bloodConfig.bloodPressinteval;
  420. this.bloodConfig.systolicminvalue = bloodConfig.systolicminvalue;
  421. this.bloodConfig.systolicmaxvalue = bloodConfig.systolicmaxvalue;
  422. this.bloodConfig.diastolicminvalue = bloodConfig.diastolicminvalue;
  423. this.bloodConfig.diastolicmaxvalue = bloodConfig.diastolicmaxvalue;
  424. this.bloodConfig.bloodPressvibrateenabled = bloodConfig.bloodPressvibrateenabled === 1;
  425. this.bloodConfig.bloodPresslcdenabled = bloodConfig.bloodPresslcdenabled === 1;
  426. this.bloodConfig.bloodPressreportenabled = bloodConfig.bloodPressreportenabled === 1;
  427. } else {
  428. //1 是学生 2是老人
  429. this.bloodConfig.systolicmaxvalue = this.watchRole === 1 ? 120 : 140;
  430. this.bloodConfig.bloodPressinteval = this.watchRole === 1 ? 360 : 60;
  431. }
  432. ToastService.success({ message: '数据加载完成' });
  433. })
  434. .catch(e => {
  435. console.log('e', e);
  436. ToastService.clear();
  437. DialogService.confirm({
  438. message: `${e.message}`
  439. });
  440. });
  441. },
  442. onUpdateInfos() {
  443. this.$router.push({
  444. name: 'registeUserInfos',
  445. query: {
  446. from: 'blood'
  447. }
  448. });
  449. },
  450. // 格式化某些特殊参数值的时间显示方式
  451. formatInteval(value) {
  452. return value >= 360 ? value / 60 + '小时' : value + '分钟';
  453. }
  454. }
  455. };
  456. </script>
  457. <style scoped lang="scss">
  458. .location-monitor-container {
  459. height: 100vh;
  460. overflow: hidden;
  461. /* padding: 0 20px; */
  462. .nav-bar {
  463. height: 100px;
  464. padding: 0 20px;
  465. }
  466. .main {
  467. height: calc(100vh - 160px);
  468. background-color: $background;
  469. padding: 20px;
  470. overflow: scroll;
  471. .list {
  472. height: auto;
  473. background-color: #fff;
  474. border-radius: 8px;
  475. margin-bottom: 20px;
  476. .item {
  477. height: auto;
  478. padding: 20px;
  479. display: flex;
  480. justify-content: space-between;
  481. align-items: center;
  482. border-bottom: 2px solid #e5e5e5;
  483. .left {
  484. @include center();
  485. span {
  486. color: #282828;
  487. font-size: 32px;
  488. }
  489. .title {
  490. font-weight: 450;
  491. &.gray {
  492. color: gray;
  493. }
  494. }
  495. }
  496. .right {
  497. /* width: 60%; */
  498. @include center();
  499. font-size: 32px;
  500. img {
  501. height: 35px;
  502. width: 35px;
  503. }
  504. span {
  505. font-size: 32px;
  506. margin-right: 10px;
  507. color: #aaaaaa;
  508. }
  509. .checkbox-group {
  510. @include center();
  511. .van-checkbox {
  512. padding: 5px;
  513. }
  514. }
  515. }
  516. &.left-gray {
  517. padding-left: 30px;
  518. color: gray;
  519. }
  520. &.alarmType {
  521. height: 180px;
  522. display: flex;
  523. justify-content: flex-start;
  524. align-items: flex-start;
  525. .left {
  526. }
  527. .right {
  528. margin-left: 40px;
  529. width: 60%;
  530. display: flex;
  531. justify-content: space-between;
  532. align-items: flex-start;
  533. }
  534. }
  535. }
  536. }
  537. }
  538. .title {
  539. font-size: 32px;
  540. }
  541. .selectConfirm {
  542. padding: 0;
  543. .con {
  544. .van-cell {
  545. height: 60px;
  546. .van-cell__value {
  547. em {
  548. font-style: normal;
  549. position: absolute;
  550. top: 0;
  551. right: 0;
  552. @include colorAndFont(#999, 24);
  553. &.circle {
  554. width: 20px;
  555. height: 20px;
  556. border: 2px solid #bfbfbf;
  557. border-radius: 50%;
  558. position: absolute;
  559. right: 15px;
  560. &.on {
  561. border-color: $green;
  562. &:before {
  563. content: '';
  564. position: absolute;
  565. left: 50%;
  566. top: 50%;
  567. transform: translate(-50%, -50%);
  568. width: 14px;
  569. height: 14px;
  570. background: $green;
  571. border-radius: 50%;
  572. }
  573. }
  574. }
  575. }
  576. }
  577. }
  578. }
  579. }
  580. }
  581. </style>