selectage.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <uv-toast ref="toast"></uv-toast>
  3. <view class="">
  4. <navbar :title="$t('select_age')" 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('selectage_cs1')}}</text>
  9. <text class='title_member'>{{$t('report_user')}}:{{selectuser.membername}}</text>
  10. <text class='title_desstr' decode='true'>{{$t('selectage_cs2')}}</text>
  11. </view>
  12. <view class="agevalue">
  13. <view class="">
  14. {{$t('select_age')}}:
  15. <text class='strage' v-show="viewage<=29">29{{$t("select_age_3")}}</text>
  16. <text class='strage' v-show="viewage>29&&viewage<70">{{viewage}}{{$t("select_age_1")}}</text>
  17. <text class='strage' v-show="viewage>=70">70{{$t("select_age_2")}}</text>
  18. </view>
  19. <!-- <uv-button type="primary" :plain="true" :text="$t('select')" @click="showselectage" :customStyle="selectbutton1" :customTextStyle="selectbutton3"></uv-button> -->
  20. </view>
  21. <!-- <view class="">
  22. <uv-picker ref="picker" :columns="columns" @confirm="confirm" @change="change" keyName="label" :showToolbar="false" fontSize="25px"></uv-picker>
  23. </view> -->
  24. <view class="showdiv" id="showdiv" :style="{height:style.canvasHeight}">
  25. <scroll-view style="width:100%;height: 100%;"
  26. :scroll-x="true" @scroll="scroll" :scroll-left="scroll_left" :show-scrollbar="false">
  27. <canvas :style="{width:style.canvasWidth,height:style.canvasHeight}"
  28. canvas-id="canvas_ruler" id="canvas_ruler" :width="canvasWidth">
  29. </canvas>
  30. </scroll-view>
  31. <canvas :style="{width:style.screenWidth,height:style.canvasHeight}"
  32. canvas-id="canvas-cursor" id="canvas-cursor">
  33. </canvas>
  34. </view>
  35. <view class="donext_div">
  36. <uv-button type="primary" :text="$t('next_step')" @click="donext" :customStyle="selectbutton2" :customTextStyle="selectbutton3"></uv-button>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {subanswerbyuserid} from "/common/api/scale.js"
  42. import {tohome,tostemlistnext} from "/common/js/common.js"
  43. import {drawruler,getCanvasConfig,getcursorvalue,setcursorvalue,getscrollleft} from "@/common/js/slider_ruler.js"
  44. export default {
  45. data() {
  46. return {
  47. minage:18,
  48. maxage:80,
  49. userinfo:{},
  50. selectuser:{},
  51. viewage:35,
  52. selectbutton1:{
  53. fontSize:'30px',
  54. width:'500rpx',
  55. borderColor:"#3f73b3",
  56. color:"#ffffff",
  57. },
  58. selectbutton2:{
  59. fontSize:'30px',
  60. width:'500rpx',
  61. background:'#3f73b3',
  62. border:"0px",
  63. },
  64. selectbutton3:{
  65. fontSize:"20px",
  66. fontWeight:"bold",
  67. letterSpacing: "0.5em",
  68. },
  69. scaleid:0,
  70. srid:0,
  71. sindex:0,
  72. stemid:1,
  73. answertype:0,
  74. canvasHeight:80,
  75. canvasWidth:1000,
  76. scroll_left:0,
  77. }
  78. },
  79. computed:{
  80. columns(){
  81. let list = []
  82. for (var i = this.minage; i <= this.maxage; i++) {
  83. let label=i+this.$t('select_age_1');
  84. if(i<=this.minage){
  85. label=i+this.$t('select_age_3');
  86. }
  87. if(i>=this.maxage){
  88. label=i+this.$t('select_age_2');
  89. }
  90. let item = {
  91. label:label,
  92. value:i
  93. }
  94. list.push(item)
  95. }
  96. return [list]
  97. },
  98. style(){
  99. let value ={
  100. canvasHeight:this.canvasHeight+"px",
  101. canvasWidth:this.canvasWidth+"px",
  102. screenWidth:this.screenWidth+"px"
  103. }
  104. return value
  105. },
  106. },
  107. methods: {
  108. init(){
  109. this.userinfo = uni.getStorageSync("userinfo")
  110. this.selectuser = uni.getStorageSync("selectuser")
  111. //this.getScreenSize()
  112. },
  113. showselectage(){
  114. this.$refs.picker.open();
  115. let index = this.viewage-this.minage
  116. this.$refs.picker.setIndexs([index],true)
  117. },
  118. confirm(e){
  119. let value = e.value[0].value
  120. this.viewage = value
  121. },
  122. change(e){
  123. let value = e.value[0].value
  124. this.viewage = value
  125. },
  126. donext(){
  127. let answer={
  128. userid:this.userinfo.id,
  129. fmemberid:this.selectuser.fmemberid,
  130. stemid:this.stemid,
  131. answertype:this.answertype,
  132. answervalue:this.viewage
  133. }
  134. let data={
  135. userid:this.userinfo.id,
  136. fmemberid:this.selectuser.fmemberid,
  137. srid: this.srid,
  138. scaleid: this.scaleid,
  139. }
  140. subanswerbyuserid(answer,data).then(res=>{
  141. res = res.data
  142. if(0==res.code){
  143. this.$refs.toast.show({
  144. type: 'error',
  145. message: res.errmsg
  146. })
  147. return false
  148. }
  149. if(200==res.code){
  150. uni.setStorage({
  151. key: 'srid',
  152. data: res.resultData,
  153. });
  154. tostemlistnext(this.sindex,1)
  155. }
  156. })
  157. //tostemlistnext(this.sindex+1)
  158. },
  159. drawruler(){
  160. let param ={
  161. canvasid:'canvas_ruler',
  162. canvascursorid:'canvas-cursor',
  163. minvalue:this.minage,
  164. maxvalue:this.maxage,
  165. interval:1,
  166. defaultvalue:this.viewage,
  167. precision:0
  168. }
  169. drawruler(param)
  170. this.viewage=getcursorvalue()
  171. this.canvasHeight=getCanvasConfig().canvasHeight
  172. this.canvasWidth=getCanvasConfig().canvasWidth
  173. this.screenWidth = getCanvasConfig().screenWidth;
  174. this.scroll_left = getscrollleft()
  175. // this.scroll_left = this.canvasWidth/2-this.screenWidth/2
  176. },
  177. scroll(e){
  178. this.viewage = setcursorvalue(e.detail.scrollLeft);
  179. }
  180. },
  181. mounted() {
  182. uni.setNavigationBarTitle({
  183. title: this.$t('select_age')
  184. });
  185. this.init()
  186. },
  187. onLoad: function (option) {
  188. this.scaleid=option.scaleid
  189. this.srid=option.srid
  190. this.sindex = option.sindex
  191. },
  192. onBackPress:function(option){
  193. tohome()
  194. return true
  195. },
  196. onReady(){
  197. this.drawruler()
  198. // this.drowtest()
  199. }
  200. }
  201. </script>
  202. <style scoped>
  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:36rpx;
  227. font-weight:400;
  228. color:#9C9C9C;
  229. }
  230. .agevalue {
  231. color: #0000FF;
  232. font-size: 50rpx;
  233. text-align: center;
  234. line-height: 90rpx;
  235. display: flex;
  236. align-items: center;
  237. flex-direction: column;
  238. }
  239. .canvasview{
  240. position:relative;
  241. }
  242. .showdiv{
  243. position: relative;
  244. width: 100%;
  245. }
  246. .showdiv #canvas_ruler{
  247. position: absolute;
  248. top: 0;
  249. left: 0;
  250. z-index: 0;
  251. }
  252. .showdiv #canvas-cursor{
  253. position: absolute;
  254. top: 0;
  255. left: 0;
  256. z-index: 100;
  257. pointer-events:none;
  258. }
  259. </style>