selectsbp.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <uv-toast ref="toast"></uv-toast>
  3. <view class="">
  4. <navbar :title="$t('blood_pressure')" size="48" :backtext="$t('back')" color="#fff"></navbar>
  5. </view>
  6. <view class="app_content">
  7. <view class='titlearea'>
  8. <text class='title_2'>{{$t('selectsbp_text1')}}</text>
  9. <text class='title_member'>{{$t('report_user')}}:{{selectuser.membername}}</text>
  10. <text class='title_desstr' decode='true'>{{$t('selectsbp_text2')}}</text>
  11. <text class='title_desstr' decode='true'>{{$t('selectsbp_text3')}}</text>
  12. <text class='title_desstr' decode='true'>{{$t('selectsbp_text4')}}</text>
  13. </view>
  14. <view class="agevalue">
  15. <view class="">
  16. {{$t('blood_pressure')}}:
  17. &nbsp;{{label}}&nbsp;
  18. <text class='title2'>{{label_text}}</text>
  19. </view>
  20. <!-- <uv-button type="primary" :plain="true" :text="$t('select')" @click="showselectage" :customStyle="selectbutton1" :customTextStyle="selectbutton3"></uv-button> -->
  21. <view class="showdiv" id="showdiv" :style="{height:style.canvasHeight}">
  22. <scroll-view style="width:100%;height: 100%;"
  23. :scroll-x="true" @scroll="scroll" :scroll-left="scroll_left" :show-scrollbar="false">
  24. <canvas :style="{width:style.canvasWidth,height:style.canvasHeight}"
  25. canvas-id="canvas_ruler" id="canvas_ruler" :width="canvasWidth">
  26. </canvas>
  27. </scroll-view>
  28. <canvas :style="{width:style.screenWidth,height:style.canvasHeight}"
  29. canvas-id="canvas-cursor" id="canvas-cursor">
  30. </canvas>
  31. </view>
  32. </view>
  33. <view class="">
  34. <uv-picker ref="picker" :columns="columns" @change="change" keyName="value" :showToolbar="false" fontSize="25px"></uv-picker>
  35. </view>
  36. <view class="donext_div">
  37. <uv-button type="primary" :text="$t('next_step')" @click="donext" :customStyle="selectbutton2" :customTextStyle="selectbutton3"></uv-button>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {subanswerbyuserid} from "/common/api/scale.js"
  43. import {tohome,tostemlistnext} from "/common/js/common.js"
  44. import {drawruler,getCanvasConfig,getcursorvalue,setcursorvalue,getscrollleft} from "@/common/js/slider_ruler.js"
  45. export default {
  46. data() {
  47. return {
  48. userinfo:{},
  49. selectuser:{},
  50. minhm:60,
  51. maxhm:210,
  52. value:110,
  53. label:"",
  54. label_text:"",
  55. scaleid:0,
  56. srid:0,
  57. sindex:0,
  58. answertype:0,
  59. stemid:6,
  60. columns_limit_list:[
  61. {
  62. uplimit:119,
  63. dowlimit:60,
  64. viewstr:"110",
  65. sbpstr:this.$t('hg_text1')
  66. },
  67. {
  68. uplimit:110,
  69. dowlimit:110,
  70. viewstr:"110",
  71. sbpstr:this.$t('hg_text2')
  72. },
  73. {
  74. uplimit:119,
  75. dowlimit:111,
  76. viewstr:"110~120",
  77. sbpstr:this.$t('hg_text3')
  78. },
  79. {
  80. uplimit:129,
  81. dowlimit:120,
  82. viewstr:"120~130",
  83. sbpstr:this.$t('hg_text3')
  84. },
  85. {
  86. uplimit:139,
  87. dowlimit:130,
  88. viewstr:"130~140",
  89. sbpstr:this.$t('hg_text3')
  90. },
  91. {
  92. uplimit:219,
  93. dowlimit:140,
  94. viewstr:"140",
  95. sbpstr:this.$t('hg_text4')
  96. }
  97. ],
  98. selectbutton1:{
  99. fontSize:'30px',
  100. width:'500rpx',
  101. borderColor:"#3f73b3",
  102. color:"#3f73b3",
  103. },
  104. selectbutton2:{
  105. fontSize:'30px',
  106. width:'500rpx',
  107. background:'#3f73b3',
  108. border:"0px",
  109. },
  110. selectbutton3:{
  111. fontSize:"20px",
  112. fontWeight:"bold",
  113. letterSpacing: "0.5em",
  114. },
  115. canvasHeight:80,
  116. canvasWidth:1000,
  117. scroll_left:0,
  118. }
  119. },
  120. computed:{
  121. columns(){
  122. let list = []
  123. for (var i = this.minhm; i <= this.maxhm; i++) {
  124. let label=i+this.$t("hg_text2")
  125. this.columns_limit_list.map((item,index)=>{
  126. if(i>=item.dowlimit&&i<=item.uplimit){
  127. label=item.viewstr+item.sbpstr
  128. return label
  129. }
  130. })
  131. let item = {
  132. label:label,
  133. value:i
  134. }
  135. list.push(item)
  136. }
  137. return [list]
  138. },
  139. style(){
  140. let value ={
  141. canvasHeight:this.canvasHeight+"px",
  142. canvasWidth:this.canvasWidth+"px",
  143. screenWidth:this.screenWidth+"px"
  144. }
  145. return value
  146. },
  147. },
  148. methods: {
  149. init(){
  150. this.userinfo = uni.getStorageSync("userinfo")
  151. this.selectuser = uni.getStorageSync("selectuser")
  152. //this.getScreenSize()
  153. this.showlabel()
  154. },
  155. change(e){
  156. let value = e.value[0].value
  157. this.value = value
  158. this.label = e.value[0].label
  159. },
  160. showselectage(){
  161. this.$refs.picker.open();
  162. let index = this.value-this.minhm
  163. this.$refs.picker.setIndexs([index],true)
  164. },
  165. // showlabel(){
  166. // let index = this.value-this.minhm
  167. // this.label = this.columns[0][index].label
  168. // },
  169. showlabel(){
  170. if(this.value<110){
  171. this.label=110
  172. this.label_text = this.$t('hg_text1')
  173. }
  174. for(let i=0;i<3;i++){
  175. let min = 110+i*10
  176. let max = 110+(i+1)*10
  177. if(this.value<max&&this.value>=min){
  178. this.label=min+"~"+max
  179. this.label_text = this.$t('hg_text3')
  180. }
  181. }
  182. if(this.value>=140){
  183. this.label=140
  184. this.label_text = this.$t('hg_text4')
  185. }
  186. if(this.value==110){
  187. this.label=110
  188. this.label_text = this.$t('hg_text2')
  189. }
  190. },
  191. donext(){
  192. let answer={
  193. userid:this.userinfo.id,
  194. fmemberid:this.selectuser.fmemberid,
  195. stemid:this.stemid,
  196. answertype:this.answertype,
  197. answervalue:this.value
  198. }
  199. let data={
  200. userid:this.userinfo.id,
  201. fmemberid:this.selectuser.fmemberid,
  202. srid: this.srid,
  203. scaleid: this.scaleid,
  204. }
  205. subanswerbyuserid(answer,data).then(res=>{
  206. res = res.data
  207. if(0==res.code){
  208. this.$refs.toast.show({
  209. type: 'error',
  210. message: res.errmsg
  211. })
  212. return false
  213. }
  214. if(200==res.code){
  215. uni.setStorage({
  216. key: 'srid',
  217. data: res.resultData,
  218. });
  219. tostemlistnext(this.sindex,1)
  220. }
  221. })
  222. //tostemlistnext(this.sindex+1)
  223. },
  224. drawruler(){
  225. let param ={
  226. canvasid:'canvas_ruler',
  227. canvascursorid:'canvas-cursor',
  228. minvalue:this.minhm,
  229. maxvalue:this.maxhm,
  230. interval:1,
  231. defaultvalue:this.value,
  232. precision:0
  233. }
  234. drawruler(param)
  235. this.value=getcursorvalue()
  236. this.canvasHeight=getCanvasConfig().canvasHeight
  237. this.canvasWidth=getCanvasConfig().canvasWidth
  238. this.screenWidth = getCanvasConfig().screenWidth;
  239. this.scroll_left = getscrollleft()
  240. // this.scroll_left = this.canvasWidth/2-this.screenWidth/2
  241. },
  242. scroll(e){
  243. this.value = setcursorvalue(e.detail.scrollLeft);
  244. this.showlabel()
  245. }
  246. },
  247. mounted() {
  248. uni.setNavigationBarTitle({
  249. title: this.$t('blood_pressure')
  250. });
  251. this.init()
  252. },
  253. onLoad: function (option) {
  254. this.scaleid=option.scaleid
  255. this.srid=option.srid
  256. this.sindex = option.sindex
  257. },
  258. onBackPress:function(option){
  259. tohome()
  260. return true
  261. },
  262. onReady(){
  263. this.drawruler()
  264. // this.drowtest()
  265. }
  266. }
  267. </script>
  268. <style scoped>
  269. .titlearea{
  270. display:flex;
  271. flex-direction:column;
  272. justify-content: center;
  273. align-items:center;
  274. }
  275. .title_2{
  276. margin-top:15rpx;
  277. font-size:36rpx;
  278. font-weight:400;
  279. color:#666666;
  280. margin-left: 0.5em;
  281. margin-right: 0.5em;
  282. }
  283. .title_member{
  284. margin-top:15rpx;
  285. font-size:36rpx;
  286. font-weight:400;
  287. color:#648EB8;
  288. }
  289. .title_desstr{
  290. width:700rpx;
  291. margin-left:25rpx;
  292. margin-top:15rpx;
  293. font-size:36rpx;
  294. font-weight:400;
  295. color:#9C9C9C;
  296. }
  297. .agevalue {
  298. color: #0000FF;
  299. font-size: 50rpx;
  300. text-align: center;
  301. line-height: 90rpx;
  302. display: flex;
  303. align-items: center;
  304. flex-direction: column;
  305. }
  306. .canvasview{
  307. position:relative;
  308. }
  309. .showdiv{
  310. position: relative;
  311. width: 100%;
  312. }
  313. .showdiv #canvas_ruler{
  314. position: absolute;
  315. top: 0;
  316. left: 0;
  317. z-index: 0;
  318. }
  319. .showdiv #canvas-cursor{
  320. position: absolute;
  321. top: 0;
  322. left: 0;
  323. z-index: 100;
  324. pointer-events:none;
  325. }
  326. .title2{
  327. color: gray;
  328. font-size: 15px;
  329. }
  330. </style>