selectwaistline.vue 7.5 KB

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