selectwaistline.vue 6.6 KB

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