acidDetail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="container">
  3. <view class="datebox">
  4. <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
  5. <view class="datebox-item border-line flex-bt">
  6. <view>日期</view>
  7. <view class="datebox-item-right">
  8. <text :class="date ? '':'default'">{{date ? date : "请选择日期"}}</text>
  9. <image src="@/static/images/health/right_arrow_right_icon24.png"></image>
  10. </view>
  11. </view>
  12. </picker>
  13. <picker mode="time" :value="time" @change="bindTimeChange">
  14. <view class="datebox-item flex-bt">
  15. <view>测量时间</view>
  16. <view class="datebox-item-right">
  17. <text :class="time ? '':'default'">{{time ? time : "请选择测量时间"}}</text>
  18. <image src="@/static/images/health/right_arrow_right_icon24.png"></image>
  19. </view>
  20. </view>
  21. </picker>
  22. </view>
  23. <view class="datebox-detail">
  24. <view class="datebox-detail-header flex-bt">
  25. <view>尿酸</view>
  26. <view class="datebox-detail-header-right">
  27. <text class="num">{{active}}</text>
  28. <text>μmol/L</text>
  29. </view>
  30. </view>
  31. <view class="scale">
  32. <simpleScale ref="simpleScale" :minVal="0" :maxVal="1000" :int="false" :single="10" :h="h" :active="active" :style="style"
  33. @value="getScroll" />
  34. </view>
  35. </view>
  36. <view class="h40"></view>
  37. <view class="btn-box">
  38. <view class="sub-btn" @click="submit()">记录</view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {addData,getDataById,getLatest,updateData} from '@/api/healthUser.js'
  44. import simpleScale from "@/pages_echarts/components/simpleScale/simpleScale.vue"
  45. // import { bgInfo } from "@/api/pages_watch/healthMonitoring.js"
  46. export default {
  47. components: {
  48. simpleScale
  49. },
  50. data() {
  51. return {
  52. startDate:this.utils.timeFormat(new Date()) ,
  53. // 表示有效日期范围的结束,字符串格式为"YYYY-MM-DD"
  54. endDate: this.utils.timeFormat(new Date()),
  55. date: this.utils.timeFormat(new Date(),'yyyy-mm-dd'),
  56. time: this.utils.timeFormat(new Date(),'hh:MM:ss'),
  57. active: "0",
  58. loading: false,
  59. style: {
  60. line: '#ccc',
  61. bginner: '#fbfbfb',
  62. bgoutside: '#ffffff',
  63. fontColor: '#333',
  64. fontSize: 16
  65. },
  66. h: uni.upx2px(88),
  67. }
  68. },
  69. onLoad(options) {
  70. console.log(options)
  71. this.type=options.type;
  72. this.userId=options.userId
  73. if(this.type=='edit'){
  74. this.id=options.id;
  75. this.getDataById();
  76. // this.listByIndicator()
  77. }
  78. // const param = JSON.parse(option.param)
  79. // this.date = param.createTime && param.createTime.split(' ')[0]
  80. // this.time = param.createTime && param.createTime.substring(11, 16)
  81. // this.active = String(param.num || 0)
  82. this.$nextTick(()=>{
  83. this.$refs.simpleScale.init()
  84. })
  85. },
  86. methods: {
  87. bindDateChange(e) {
  88. this.date = e.detail.value
  89. this.getList()
  90. },
  91. bindTimeChange(e) {
  92. this.time = e.detail.value
  93. this.getList()
  94. },
  95. getScroll(e) {
  96. this.active = e
  97. },
  98. getDataById(){
  99. getDataById({id:this.id}).then(
  100. res => {
  101. if(res.code==200){
  102. this.date=res.data.measurementDate
  103. this.time=res.data.measurementTime
  104. this.active= String(res.data.value1)
  105. }else{
  106. uni.showToast({
  107. icon:'none',
  108. title: res.msg,
  109. });
  110. }
  111. },
  112. rej => {}
  113. );
  114. },
  115. submit(){
  116. var data={
  117. userId:this.userId,
  118. "measurementType": 4, //测量类型(0-腰围,1-臀围,2-血糖,3-血压,4-尿酸 5-BMI)
  119. "value1": this.active, //数值1(测量值1 测量值只有一个时默认填写/身高cm/舒张压)
  120. "measurementDate": this.date, //测量日期 yyyy-MM-dd
  121. "measurementTime":this.time//测量时间 HH:mm:ss
  122. }
  123. if(this.type=="add"){
  124. this.addData(data)
  125. }
  126. else if(this.type=="edit"){
  127. data.id=this.id
  128. this.updateData(data)
  129. }
  130. },
  131. addData(data){
  132. addData(data).then(
  133. res => {
  134. if(res.code==200){
  135. uni.showToast({
  136. icon:'success',
  137. title: "操作成功",
  138. });
  139. setTimeout(function() {
  140. uni.$emit('refreshAcidList');
  141. // uni.$emit('refreshAcid');
  142. uni.navigateBack({
  143. delta: 1
  144. })
  145. }, 500);
  146. }else{
  147. uni.showToast({
  148. icon:'none',
  149. title: res.msg,
  150. });
  151. }
  152. },
  153. rej => {}
  154. );
  155. },
  156. updateData(data){
  157. updateData(data).then(
  158. res => {
  159. if(res.code==200){
  160. uni.showToast({
  161. icon:'success',
  162. title: "更新成功",
  163. });
  164. setTimeout(function() {
  165. uni.$emit('refreshAcidList');
  166. // uni.$emit('refreshAcid');
  167. uni.navigateBack({
  168. delta: 1
  169. })
  170. }, 500);
  171. }else{
  172. uni.showToast({
  173. icon:'none',
  174. title: res.msg,
  175. });
  176. }
  177. },
  178. rej => {}
  179. );
  180. },
  181. getLatest(){
  182. var data={
  183. userId:this.userId,
  184. measurementType:2
  185. }
  186. getLatest(data).then(
  187. res => {
  188. if(res.code==200){
  189. if(res.data==null){
  190. this.type='add'
  191. }else{
  192. this.type='edit'
  193. this.form = res.data;
  194. }
  195. }else{
  196. uni.showToast({
  197. icon:'none',
  198. title: res.msg,
  199. });
  200. }
  201. },
  202. rej => {}
  203. );
  204. },
  205. // 查询数据
  206. getList() {
  207. this.loading = true
  208. const param = {
  209. startTime: this.date.replace(/-/g, '/') +" " +this.time + ":00",
  210. endTime: this.date.replace(/-/g, '/') +" " + this.time + ":59",
  211. deviceId: uni.getStorageSync("deviceId"),
  212. }
  213. bgInfo(param).then(res => {
  214. this.loading = false
  215. if (res.code == 200) {
  216. if(res.data && res.data.length > 0) {
  217. this.date = res.data[0].createTime && res.data[0].createTime.split(' ')[0]
  218. this.time = res.data[0].createTime && res.data[0].createTime.substring(11, 16)
  219. this.active = String(res.data[0].bloodGlucose || 0)
  220. } else {
  221. this.active = "0"
  222. }
  223. } else {
  224. this.active = "0"
  225. }
  226. this.$nextTick(()=>{
  227. this.$refs.simpleScale.init()
  228. })
  229. }).catch(() => {
  230. this.loading = false
  231. })
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. @mixin u-flex($flexD, $alignI, $justifyC) {
  238. display: flex;
  239. flex-direction: $flexD;
  240. align-items: $alignI;
  241. justify-content: $justifyC;
  242. }
  243. .flex-bt {
  244. @include u-flex(row, center, space-between);
  245. }
  246. .default {
  247. font-weight: 400;
  248. font-size: 28rpx;
  249. color: #999999;
  250. }
  251. .btn-box {
  252. height: 120upx;
  253. padding: 0 30upx;
  254. display: flex;
  255. align-items: center;
  256. justify-content: center;
  257. .sub-btn {
  258. width: 388rpx;
  259. height: 72rpx;
  260. line-height: 72upx;
  261. text-align: center;
  262. font-size: 32upx;
  263. font-family: PingFang SC;
  264. font-weight: bold;
  265. color: #FFFFFF;
  266. background: #4585F8;
  267. border-radius: 44upx;
  268. margin-bottom: 40upx;
  269. }
  270. }
  271. .container {
  272. padding: 20rpx 24rpx;
  273. font-family: PingFang SC, PingFang SC;
  274. font-weight: 500;
  275. font-size: 32rpx;
  276. color: #333333;
  277. }
  278. .btn-box {
  279. height: 120upx;
  280. padding: 0 30upx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. .sub-btn {
  285. width: 388rpx;
  286. height: 72rpx;
  287. line-height: 72upx;
  288. text-align: center;
  289. font-size: 32upx;
  290. font-family: PingFang SC;
  291. font-weight: bold;
  292. color: #FFFFFF;
  293. background: #2CAE5C;
  294. border-radius: 44upx;
  295. margin-bottom: 40upx;
  296. }
  297. }
  298. .datebox {
  299. padding: 0 32rpx;
  300. margin-bottom: 20rpx;
  301. background: #FFFFFF;
  302. border-radius: 16rpx 16rpx 16rpx 16rpx;
  303. &-item {
  304. height: 120rpx;
  305. &-right {
  306. font-weight: 400;
  307. font-size: 32rpx;
  308. @include u-flex(row, center, flex-start);
  309. image {
  310. width: 48rpx;
  311. height: 48rpx;
  312. }
  313. }
  314. }
  315. }
  316. .datebox-detail {
  317. background: #FFFFFF;
  318. border-radius: 16rpx 16rpx 16rpx 16rpx;
  319. padding: 40rpx 32rpx;
  320. &-header-right {
  321. flex-shrink: 0;
  322. font-weight: 400;
  323. font-size: 28rpx;
  324. color: #999999;
  325. .num {
  326. font-size: 48rpx;
  327. color: #333333;
  328. margin-right: 14rpx;
  329. }
  330. }
  331. }
  332. .scale {
  333. height: 176rpx;
  334. margin-top: 36rpx;
  335. overflow: hidden;
  336. background: #FFFFFF;
  337. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(170,170,170,0.1);
  338. border-radius: 0rpx 0rpx 0rpx 0rpx;
  339. border: 2rpx solid #ECECEC;
  340. // width: 200rpx;
  341. // height: 600rpx;
  342. }
  343. </style>