index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <view class="mb-5">
  3. <view class="" v-if="userData.id">
  4. <view class="header p-3">
  5. <view class="centerY">
  6. <span class="d-inline-block fs-18 text-white font-bold">个人档案</span>
  7. <span
  8. v-if="ipArr.find(item => item.ip == prodIp) && ipArr.find(item => item.ip == prodIp).name !== '兰溪'"
  9. class="d-inline-block py-1 d-inline-block ml-auto text-white1"
  10. @click="closet"
  11. >
  12. [ 退出 ]
  13. </span>
  14. <span
  15. v-if="ipArr.find(item => item.ip == prodIp) && ipArr.find(item => item.ip == prodIp).name == '兰溪'"
  16. class="d-inline-block py-1 d-inline-block ml-auto text-white1"
  17. @click="operation"
  18. >
  19. [ 切换 ]
  20. </span>
  21. </view>
  22. <view class="centerY mt-2" @click="$mf.clickNavto('/pages/userinfo/userinfo')">
  23. <view class="w-15 userhead">
  24. <view class="picbox">
  25. <image v-if="userData.sex == 1" src="@/static/img/defult/head1.png" mode="widthFix" class="picimg"></image>
  26. <image v-if="userData.sex == 2" src="@/static/img/defult/head2.png" mode="widthFix" class="picimg"></image>
  27. </view>
  28. </view>
  29. <view class="w-85 ml-3">
  30. <view class="text-white fs-16 font-bold">{{ userData.username || '' }}</view>
  31. <view class="centerY" style="margin-top:10rpx;">
  32. <view :class="{ 'iconfont text-white fs-16 font-bold': true, ' nv': userData.sex == 2, nanxing: userData.sex == 1 }"></view>
  33. <view class="py-1 pl-2 text-center centerY text-gry80 bg-white ml-auto" style="border-radius: 6rpx;">
  34. <view class="">基础资料</view>
  35. <view class="iconfont youla2 fs-12 font-bold"></view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="content p-3 bg-white mx-3 my-3 box-border08">
  42. <view class="" style="display:flex;flex-wrap: wrap !important;">
  43. <view class="w-100 border-box">
  44. <view class="" style="background: linear-gradient(180deg, rgb(151,220,249) 0%, rgb(110,197,246) 100%);border-radius: 16rpx;">
  45. <view class="px-3 pt-2 pb-3 ">
  46. <view class="centerY ">
  47. <view class="bule_line"></view>
  48. <text class="fs-18 ml-2 font-bold" style="color: #1C90D7;">个人体征</text>
  49. </view>
  50. <view class="mt-2" style="color: #000;">
  51. <view class="font-bold" style="display:flex;flex-wrap: wrap !important;">
  52. <view class="w-50 border-box pr-1">
  53. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  54. 身高
  55. <span class="ml-auto ml-1">{{ physical.height || '-' }} cm</span>
  56. </view>
  57. </view>
  58. <view class="w-50 border-box pl-1">
  59. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  60. 体重
  61. <span class="ml-auto ml-1">{{ physical.weight || '-' }} kg</span>
  62. </view>
  63. </view>
  64. <view class="w-50 border-box pr-1 mt-2">
  65. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  66. BMI
  67. <span class="ml-auto ml-1">{{ physical.bmi || '-' }} kg/m^2</span>
  68. </view>
  69. </view>
  70. <view class="w-50 border-box pl-1 mt-2">
  71. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  72. 血压
  73. <span class="ml-auto ml-1">{{ physical.diastole || '-' }}/{{ physical.shrink || '-' }} mmHg</span>
  74. </view>
  75. </view>
  76. <view class="w-50 border-box pr-1 mt-2">
  77. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  78. 心率
  79. <span class="ml-auto ml-1">{{ physical.pulse || '-' }} bmp</span>
  80. </view>
  81. </view>
  82. <view class="w-50 border-box pl-1 mt-2">
  83. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  84. 腰围
  85. <span class="ml-auto ml-1">{{ physical.waist || '-' }} cm</span>
  86. </view>
  87. </view>
  88. <view class="w-50 border-box pr-1 mt-2">
  89. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  90. 血糖
  91. <span class="ml-auto ml-1">{{ physical.bloodGlucose || '-' }} mmol/L</span>
  92. </view>
  93. </view>
  94. <view class="w-50 border-box pl-1 mt-2">
  95. <view class=" d-flex px-2 py-1" style="color: #55afdf;border-radius: 10rpx;background-color: rgba(255,255,255)">
  96. 血氧
  97. <span class="ml-auto ml-1">{{ physical.spo2 || '-' }} mmHg</span>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <view class="w-50 pr-2 border-box mt-3">
  106. <image @click="$mf.clickNavto('/pages/medication/medication')" src="@/static/img/index/dqyy.png" mode="widthFix" class="w-100"></image>
  107. </view>
  108. <view class="w-50 pl-2 border-box mt-3">
  109. <image @click="$mf.clickNavto('/pages/health_report/health_report')" src="@/static/img/index/jkbg.png" mode="widthFix" class="w-100"></image>
  110. </view>
  111. </view>
  112. <view class="mt-2"><image @click="$mf.clickNavto('/pages/eye_ground/eye_ground')" src="@/static/img/index/ydjc.png" mode="widthFix" class="w-100"></image></view>
  113. <view class="mt-2"><image @click="$mf.clickNavto('/pages/home_monitoring/home_monitoring')" src="@/static/img/index/jjjc.png" mode="widthFix" class="w-100"></image></view>
  114. </view>
  115. </view>
  116. <view class="">
  117. <uni-popup ref="popup1" type="top" :mask-click="false">
  118. <view class=" w-80 mx-auto" style="margin-top: 30vh;">
  119. <view class="bg-white p-3 w-100 border-box" style="border-radius: 16rpx;">
  120. <view class="text-center mb-3 fs-14 font-bold py-2">查询</view>
  121. <view class=" centerY mb-3 w-100 border-box" style="overflow: hidden; ">
  122. <input
  123. type="text"
  124. v-model="valueId"
  125. class="px-2 m-0 fs-12 w-75 border-box"
  126. style="height: 70rpx;border: 2px solid #007aff;border-top-left-radius: 4rpx;border-bottom-left-radius: 4rpx;"
  127. placeholder="请输入身份证号码"
  128. placeholder-class="fs-12"
  129. />
  130. <uni-button
  131. type="primary"
  132. class="my-button fs-12 ml-auto border-box w-25"
  133. style="height: 70rpx;line-height: 70rpx; padding: 0 ;border-top-right-radius: 12rpx;border-bottom-right-radius: 12rpx;"
  134. @click="search"
  135. >
  136. 搜索
  137. </uni-button>
  138. </view>
  139. </view>
  140. </view>
  141. </uni-popup>
  142. <uni-popup ref="popup2" type="top" :mask-click="false">
  143. <view class=" w-80 mx-auto" style="margin-top: 30vh;">
  144. <view class="bg-white p-3 w-100 text-center border-box" style="border-radius: 16rpx;">
  145. <view class="text-center mb-3 fs-14 font-bold py-2">患者列表</view>
  146. <view class="text-left centerY mb-3" style="border-radius: 14rpx;border: 2px solid #007aff;">
  147. <uni-data-select v-model="userIndex" :localdata="userArr" @change="bindPickerChange" placeholder="请选择身份"></uni-data-select>
  148. </view>
  149. <view class="" v-if="userArr.length == 0"><empty title="还未绑定患者" /></view>
  150. </view>
  151. </view>
  152. </uni-popup>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. const ipArr = [
  158. {
  159. name: '开发',
  160. ip: 'http://192.168.1.103:10066'
  161. },
  162. {
  163. name: '测试',
  164. ip: 'http://testapi.xklr.net:8601'
  165. },
  166. {
  167. name: '正式',
  168. ip: 'http://apiv3.xklr.net'
  169. },
  170. {
  171. name: '兰溪',
  172. ip: 'https://lxh5api.xklr.net'
  173. },
  174. {
  175. name: '附海',
  176. ip: 'http://192.26.1.242:10066'
  177. }
  178. ];
  179. let globalData = getApp().globalData;
  180. import Empty from '@/component/empty/empty.vue';
  181. export default {
  182. components: {
  183. Empty
  184. },
  185. data() {
  186. return {
  187. userData: {},
  188. physical: {},
  189. valueId: '',
  190. prodIp: '',
  191. ipArr,
  192. userArr: [],
  193. userIndex: null
  194. };
  195. },
  196. onLoad() {
  197. this.decrypt();
  198. },
  199. methods: {
  200. //正式
  201. async zhengshi() {
  202. let t = this;
  203. if (!uni.getStorageSync('idCard')) {
  204. t.$refs.popup1.open();
  205. uni.hideLoading();
  206. } else {
  207. t.getuserinfo(uni.getStorageSync('idCard'));
  208. }
  209. },
  210. //兰溪
  211. lanxi() {
  212. let t = this;
  213. uni.getStorage({
  214. key: 'token',
  215. async success(res) {
  216. if (!res.data) return;
  217. let res2 = await t.$api.decrypt({
  218. toKen: res.data
  219. });
  220. if (res2.code !== -1) {
  221. if (!res2.data.uuid) {
  222. uni.showModal({
  223. title: '提示',
  224. content: '您还未登录请先去登录!',
  225. showCancel: false,
  226. success: function(res3) {
  227. if (res3.confirm) {
  228. console.log('用户点击确定');
  229. uni.navigateBack({
  230. delta: 1 //返回层数,2则上上页
  231. });
  232. }
  233. }
  234. });
  235. return;
  236. }
  237. if (res2.data.users && res2.data.users.length > 0) {
  238. t.$refs.popup2.open();
  239. t.userArr = [];
  240. res2.data.users.map((item, index) => {
  241. t.userArr.push({
  242. value: index,
  243. text: item.idcard
  244. });
  245. });
  246. uni.hideLoading();
  247. } else {
  248. t.$refs.popup2.open();
  249. t.userArr = [];
  250. res2.data.users.map((item, index) => {
  251. t.userArr.push({
  252. value: index,
  253. text: item.idcard
  254. });
  255. });
  256. uni.hideLoading();
  257. }
  258. } else {
  259. //返回数据出错
  260. errordata();
  261. }
  262. },
  263. fail(error) {
  264. //未获取到token或者出错
  265. errordata();
  266. }
  267. });
  268. function errordata() {
  269. if (!uni.getStorageSync('idCard')) {
  270. t.$refs.popup1.open();
  271. uni.hideLoading();
  272. } else {
  273. t.getuserinfo(uni.getStorageSync('idCard'));
  274. }
  275. }
  276. },
  277. decrypt() {
  278. //token解码
  279. uni.showLoading({
  280. title: '加载中'
  281. });
  282. let t = this;
  283. let timer = setInterval(() => {
  284. //等待获取ip
  285. if (globalData.configData.prodIp) {
  286. t.prodIp = globalData.configData.prodIp;
  287. clearInterval(timer);
  288. }
  289. ipArr.map(async item => {
  290. if (item.ip == globalData.configData.prodIp && item.name == '兰溪') {
  291. t.lanxi();
  292. return;
  293. }
  294. if (item.ip == globalData.configData.prodIp && item.name == '附海') {
  295. t.zhengshi();
  296. return;
  297. }
  298. if (item.ip == globalData.configData.prodIp && item.name == '正式') {
  299. t.zhengshi();
  300. return;
  301. }
  302. if (item.ip == globalData.configData.prodIp && item.name == '测试') {
  303. t.zhengshi();
  304. return;
  305. }
  306. if (item.ip == globalData.configData.prodIp && item.name == '开发') {
  307. t.zhengshi();
  308. return;
  309. }
  310. });
  311. }, 300);
  312. },
  313. //切换
  314. operation() {
  315. uni.clearStorage('idCard');
  316. uni.clearStorage('userData');
  317. this.valueId = '';
  318. this.userData = {};
  319. this.physical = {};
  320. this.$refs.popup2.open();
  321. },
  322. bindPickerChange(e) {
  323. if (this.userArr[e] && this.userArr[e].text) {
  324. this.getuserinfo(this.userArr[e].text);
  325. }
  326. },
  327. closet() {
  328. uni.clearStorage('idCard');
  329. uni.clearStorage('userData');
  330. this.valueId = '';
  331. this.userData = {};
  332. this.physical = {};
  333. this.$refs.popup1.open();
  334. },
  335. search() {
  336. if (!this.$mf.isCardID(this.valueId)) {
  337. uni.showToast({
  338. title: '请输入正确的身份证号',
  339. icon: 'error',
  340. duration: 2000,
  341. mask: true
  342. });
  343. return;
  344. }
  345. this.userData = {};
  346. this.physical = {};
  347. this.getuserinfo(this.valueId);
  348. },
  349. async find_physical() {
  350. uni.showLoading({
  351. title: '加载中'
  352. });
  353. let idCard = uni.getStorageSync('idCard');
  354. let { data, code } = await this.$api.find_physical({
  355. idCard
  356. });
  357. if (code == 0) {
  358. this.physical = data || {};
  359. uni.hideLoading();
  360. } else {
  361. uni.hideLoading();
  362. }
  363. uni.stopPullDownRefresh();
  364. },
  365. async getuserinfo(idCard) {
  366. //330222194512283184
  367. idCard = idCard || uni.getStorageSync('idCard');
  368. uni.showLoading({
  369. title: '加载中'
  370. });
  371. let { data, code } = await this.$api.getUserInfo({
  372. idCard
  373. });
  374. if (code == 0) {
  375. this.valueId = '';
  376. uni.setStorageSync('userData', data || {});
  377. uni.setStorageSync('idCard', (data && data.idCard) || '');
  378. this.userData = data || {};
  379. if (data && data.id) {
  380. this.find_physical();
  381. this.$refs.popup1.close();
  382. this.$refs.popup2.close();
  383. } else {
  384. uni.showToast({
  385. title: '未查询到患者',
  386. icon: 'error'
  387. });
  388. }
  389. uni.hideLoading();
  390. uni.stopPullDownRefresh();
  391. } else {
  392. this.valueId = '';
  393. uni.hideLoading();
  394. uni.stopPullDownRefresh();
  395. }
  396. }
  397. },
  398. onPullDownRefresh() {
  399. if (this.userData && this.physical) {
  400. if (uni.getStorageSync('idCard')) {
  401. this.find_physical();
  402. } else {
  403. uni.stopPullDownRefresh();
  404. }
  405. } else {
  406. uni.stopPullDownRefresh();
  407. }
  408. }
  409. };
  410. </script>
  411. <style lang="scss">
  412. page {
  413. background: #f5f9ff;
  414. }
  415. .header {
  416. background: linear-gradient(180deg, #096dcb 0%, #6faae1 100%);
  417. }
  418. .userhead {
  419. border-radius: 50%;
  420. box-shadow: 1px 1px 10px 1px #096dcb;
  421. }
  422. .text-gry80 {
  423. color: #808080;
  424. }
  425. .box-border08 {
  426. border-radius: 16rpx;
  427. }
  428. </style>