selectsbp.vue 7.4 KB

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