waistLineDetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <view class="container">
  3. <view class="datebox">
  4. <picker mode="date" :value="date" :start="startDate" @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" fields="second" :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>CM</text>
  29. </view>
  30. </view>
  31. <view class="scale">
  32. <simpleScale ref="simpleScale" :minVal="0" :maxVal="200" :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. // 表示有效日期范围的开始,字符串格式为"YYYY-MM-DD"
  53. startDate:this.utils.timeFormat(new Date()) ,
  54. // 表示有效日期范围的结束,字符串格式为"YYYY-MM-DD"
  55. endDate: this.utils.timeFormat(new Date()),
  56. date: this.utils.timeFormat(new Date(),'yyyy-mm-dd'),
  57. time: this.utils.timeFormat(new Date(),'hh:MM:ss'),
  58. active: "0",
  59. loading: false,
  60. style: {
  61. line: '#ccc',
  62. bginner: '#fbfbfb',
  63. bgoutside: '#ffffff',
  64. fontColor: '#333',
  65. fontSize: 16
  66. },
  67. h: uni.upx2px(88),
  68. form:null
  69. }
  70. },
  71. onLoad(options) {
  72. console.log(options)
  73. this.type=options.type;
  74. this.userId=options.userId
  75. if(this.type=='edit'){
  76. this.id=options.id;
  77. this.getDataById();
  78. // this.listByIndicator()
  79. }
  80. this.$nextTick(()=>{
  81. this.$refs.simpleScale.init()
  82. })
  83. },
  84. methods: {
  85. bindDateChange(e) {
  86. this.date = e.detail.value
  87. // this.getList()
  88. },
  89. bindTimeChange(e) {
  90. // console.log(e,'e')
  91. this.time = e.detail.value+':00'
  92. // this.getList()
  93. },
  94. getScroll(e) {
  95. // console.log(e,'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": 0, //测量类型(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('refreshWaistLineList');
  141. uni.navigateBack({
  142. delta: 1
  143. })
  144. }, 500);
  145. }else{
  146. uni.showToast({
  147. icon:'none',
  148. title: res.msg,
  149. });
  150. }
  151. },
  152. rej => {}
  153. );
  154. },
  155. updateData(data){
  156. updateData(data).then(
  157. res => {
  158. if(res.code==200){
  159. uni.showToast({
  160. icon:'success',
  161. title: "更新成功",
  162. });
  163. setTimeout(function() {
  164. uni.$emit('refreshWaistLineList');
  165. uni.navigateBack({
  166. delta: 1
  167. })
  168. }, 500);
  169. }else{
  170. uni.showToast({
  171. icon:'none',
  172. title: res.msg,
  173. });
  174. }
  175. },
  176. rej => {}
  177. );
  178. },
  179. getLatest(){
  180. var data={
  181. userId:this.userId,
  182. measurementType:0
  183. }
  184. getLatest(data).then(
  185. res => {
  186. if(res.code==200){
  187. if(res.data==null){
  188. this.type='add'
  189. }else{
  190. this.type='edit'
  191. this.form = res.data;
  192. }
  193. }else{
  194. uni.showToast({
  195. icon:'none',
  196. title: res.msg,
  197. });
  198. }
  199. },
  200. rej => {}
  201. );
  202. },
  203. // 查询数据
  204. getList() {
  205. this.loading = true
  206. const param = {
  207. startTime: this.date.replace(/-/g, '/') +" " +this.time + ":00",
  208. endTime: this.date.replace(/-/g, '/') +" " + this.time + ":59",
  209. deviceId: uni.getStorageSync("deviceId"),
  210. }
  211. bgInfo(param).then(res => {
  212. this.loading = false
  213. if (res.code == 200) {
  214. if(res.data && res.data.length > 0) {
  215. this.date = res.data[0].createTime && res.data[0].createTime.split(' ')[0]
  216. this.time = res.data[0].createTime && res.data[0].createTime.substring(11, 16)
  217. this.active = String(res.data[0].bloodGlucose || 0)
  218. } else {
  219. this.active = "0"
  220. }
  221. } else {
  222. this.active = "0"
  223. }
  224. this.$nextTick(()=>{
  225. this.$refs.simpleScale.init()
  226. })
  227. }).catch(() => {
  228. this.loading = false
  229. })
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. @mixin u-flex($flexD, $alignI, $justifyC) {
  236. display: flex;
  237. flex-direction: $flexD;
  238. align-items: $alignI;
  239. justify-content: $justifyC;
  240. }
  241. .flex-bt {
  242. @include u-flex(row, center, space-between);
  243. }
  244. .default {
  245. font-weight: 400;
  246. font-size: 28rpx;
  247. color: #999999;
  248. }
  249. .container {
  250. padding: 20rpx 24rpx;
  251. font-family: PingFang SC, PingFang SC;
  252. font-weight: 500;
  253. font-size: 32rpx;
  254. color: #333333;
  255. }
  256. .btn-box {
  257. height: 120upx;
  258. padding: 0 30upx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. .sub-btn {
  263. width: 388rpx;
  264. height: 72rpx;
  265. line-height: 72upx;
  266. text-align: center;
  267. font-size: 32upx;
  268. font-family: PingFang SC;
  269. font-weight: bold;
  270. color: #FFFFFF;
  271. background: #FF5039;
  272. border-radius: 44upx;
  273. margin-bottom: 40upx;
  274. }
  275. }
  276. .datebox {
  277. padding: 0 32rpx;
  278. margin-bottom: 20rpx;
  279. background: #FFFFFF;
  280. border-radius: 16rpx 16rpx 16rpx 16rpx;
  281. &-item {
  282. height: 120rpx;
  283. &-right {
  284. font-weight: 400;
  285. font-size: 32rpx;
  286. @include u-flex(row, center, flex-start);
  287. image {
  288. width: 48rpx;
  289. height: 48rpx;
  290. }
  291. }
  292. }
  293. }
  294. .datebox-detail {
  295. background: #FFFFFF;
  296. border-radius: 16rpx 16rpx 16rpx 16rpx;
  297. padding: 40rpx 32rpx;
  298. &-header-right {
  299. flex-shrink: 0;
  300. font-weight: 400;
  301. font-size: 28rpx;
  302. color: #999999;
  303. .num {
  304. font-size: 48rpx;
  305. color: #333333;
  306. margin-right: 14rpx;
  307. }
  308. }
  309. }
  310. .scale {
  311. height: 176rpx;
  312. margin-top: 36rpx;
  313. overflow: hidden;
  314. background: #FFFFFF;
  315. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(170,170,170,0.1);
  316. border-radius: 0rpx 0rpx 0rpx 0rpx;
  317. border: 2rpx solid #ECECEC;
  318. // width: 200rpx;
  319. // height: 600rpx;
  320. }
  321. </style>