datum.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="container">
  3. <TopBar></TopBar>
  4. <view class="line-bar flex-between">
  5. <view class="span active"></view>
  6. <view class="span active"></view>
  7. <view class="span active"></view>
  8. <view class="span"></view>
  9. <view class="span"></view>
  10. </view>
  11. <view class="title font44 fw600">
  12. 设置你的社交资料
  13. </view>
  14. <view class="tip font28 fw400">
  15. 10秒填写基本信息,邂逅你喜欢的新朋友
  16. </view>
  17. <view class="select-title font28 fw400">
  18. 你的身高
  19. </view>
  20. <picker mode="selector" :range="heights" :value="userInfo.sex==='Male'?'20':'15'" @change="heightsChange">
  21. <view class="select flex-between">
  22. <view class="select-val font28 fw400" :style="{'color':`${height==='选择身高'?'':'#ffffff'}`}">
  23. {{height}}
  24. </view>
  25. <image :src="`${assetsUrl}info-figure-select.png`" mode="aspectFill" class="select-icon"></image>
  26. </view>
  27. </picker>
  28. <view class="select-title font28 fw400">
  29. 你的体重
  30. </view>
  31. <picker mode="selector" :range="weights" :value="userInfo.sex==='Male'?'30':'15'" @change="weightsChange">
  32. <view class="select flex-between">
  33. <view class="select-val font28 fw400" :style="{'color':`${weight==='选择体重'?'':'#ffffff'}`}">
  34. {{weight}}
  35. </view>
  36. <image :src="`${assetsUrl}info-figure-select.png`" mode="aspectFill" class="select-icon"></image>
  37. </view>
  38. </picker>
  39. <view class="select-title font28 fw400">
  40. 你的年龄
  41. </view>
  42. <picker mode="date" fields="day" start="1963-01-01" end="2004-01-01" value="1993-09-12" @change="agesChange">
  43. <view class="select flex-between">
  44. <view class="select-val font28 fw400" :style="{'color':`${age==='选择年龄'?'':'#ffffff'}`}">
  45. {{age}}
  46. </view>
  47. <image :src="`${assetsUrl}info-figure-select.png`" mode="aspectFill" class="select-icon"></image>
  48. </view>
  49. </picker>
  50. <view class="select-title font28 fw400">
  51. 你的职业
  52. </view>
  53. <picker mode="multiSelector" :range="jobs" @change="jobsChange" @columnchange="jobsColumnChange">
  54. <view class="select flex-between">
  55. <view class="select-val font28 fw400" :style="{'color':`${job==='选择职业'?'':'#ffffff'}`}">
  56. {{job}}
  57. </view>
  58. <image :src="`${assetsUrl}info-figure-select.png`" mode="aspectFill" class="select-icon"></image>
  59. </view>
  60. </picker>
  61. <view style="height: 200rpx;"></view>
  62. <cover-view class="btn font32 fw600" @click="sure">
  63. 下一步
  64. </cover-view>
  65. </view>
  66. </template>
  67. <script>
  68. import TopBar from '@/components/TopBar/TopBar.vue';
  69. export default {
  70. components:{TopBar},
  71. data() {
  72. return {
  73. assetsUrl:this.$util.assetsUrl,
  74. heights:[],
  75. height:'选择身高',
  76. weights:[],
  77. weight:'选择体重',
  78. age:'选择年龄',
  79. jobs:[],
  80. careersData:[],
  81. job:'选择职业',
  82. saveOption:{
  83. birthday:'',
  84. completeUser:null,
  85. },
  86. userInfo:null
  87. };
  88. },
  89. mounted(){
  90. this.userInfo=JSON.parse(uni.getStorageSync('userInfo'))
  91. let arr=[];
  92. for(let i=150;i<210;i++){
  93. arr.push(`${i}cm`);
  94. }
  95. this.heights=arr;
  96. arr=[];
  97. for(let i=30;i<200;i++){
  98. arr.push(`${i}kg`);
  99. }
  100. this.weights=arr;
  101. this.getCareersConfig();
  102. },
  103. methods:{
  104. getCareersConfig(){
  105. this.$api.public.config({tscsj:['Careers']}).then(res=>{
  106. this.careersData=res.data.careers;
  107. let arr=[],arr1=[];
  108. for(let item in res.data.careers){
  109. arr1.push(item)
  110. }
  111. arr.push(arr1);
  112. arr.push(res.data.careers[arr1[0]]);
  113. this.jobs=arr;
  114. }).catch(err=>{
  115. console.log(err)
  116. })
  117. },
  118. sure(){
  119. if(this.height==='选择身高'){uni.showToast({title:'请选择身高',icon:'none'});return;}
  120. if(this.weight==='选择体重'){uni.showToast({title:'请选择体重',icon:'none'});return;}
  121. if(this.age==='选择年龄'){uni.showToast({title:'请选择出生年月',icon:'none'});return;}
  122. if(this.job==='选择职业'){uni.showToast({title:'请选择职业',icon:'none'});return;}
  123. let user=JSON.parse(uni.getStorageSync('user'));
  124. user.career=this.job;
  125. user.height=Number(this.height.split('cm')[0]);
  126. user.weight=Number(this.weight.split('kg')[0]);
  127. this.saveOption.completeUser=user;
  128. this.saveOption.birthday=this.age;
  129. uni.showLoading({
  130. title:'保存中',
  131. mask:true
  132. })
  133. this.$api.login.saveDatum(this.saveOption).then(res=>{
  134. if(res.data.succ){
  135. uni.setStorageSync('regStep','CityStay');
  136. uni.setStorageSync('user',JSON.stringify(user));
  137. uni.hideLoading();
  138. uni.reLaunch({
  139. url:`/pages/info/city`
  140. })
  141. }
  142. }).catch(()=>{})
  143. },
  144. heightsChange(e){
  145. this.height=this.heights[e.detail.value];
  146. },
  147. weightsChange(e){
  148. this.weight=this.weights[e.detail.value];
  149. },
  150. agesChange(e){
  151. this.age=e.detail.value;
  152. },
  153. jobsChange(e){
  154. let str=this.jobs[1][e.detail.value[1]];
  155. this.job=str;
  156. },
  157. jobsColumnChange(e){
  158. let leftValue=this.jobs[e.detail.column][e.detail.value];
  159. if(e.detail.column===0){
  160. this.jobs[1]=this.careersData[leftValue];
  161. this.$forceUpdate()
  162. }
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .container{
  169. width: 100vw;
  170. min-height: 100vh;
  171. background-color: $bgcolor1;
  172. .line-bar{
  173. margin: 0 60rpx;
  174. margin-top: 30rpx;
  175. .span{
  176. width: 120rpx;
  177. height: 8rpx;
  178. border-radius: 4rpx 0rpx 0rpx 4rpx;
  179. background-color: $bgcolor4;
  180. }
  181. .active{
  182. background-color: $primary;
  183. }
  184. }
  185. .title{
  186. color: $fontcolor5;
  187. padding-left: 60rpx;
  188. margin-top: 108rpx;
  189. }
  190. .tip{
  191. color: $fontcolor3;
  192. padding-left: 60rpx;
  193. margin-top: 8rpx;
  194. }
  195. .select-title{
  196. color: $fontcolor3;
  197. margin: 0 60rpx;
  198. margin-top: 56rpx;
  199. }
  200. .select{
  201. background-color: $bgcolor3;
  202. margin: 0 60rpx;
  203. margin-top: 16rpx;
  204. height: 112rpx;
  205. border-radius: 16px;
  206. padding: 0 36rpx;
  207. .select-val{
  208. color: $fontcolor1;
  209. }
  210. .select-icon{
  211. width: 24rpx;
  212. height: 24rpx;
  213. }
  214. }
  215. .img-box{
  216. width: 320rpx;
  217. margin-left: 60rpx;
  218. .img{
  219. width: 320rpx;
  220. height: 320rpx;
  221. }
  222. .img-text{
  223. color: $fontcolor3;
  224. text-align: center;
  225. }
  226. }
  227. .btn{
  228. position: fixed;
  229. z-index: 999;
  230. left: 0;
  231. right: 0;
  232. bottom: 44rpx;
  233. margin: auto;
  234. width: 630rpx;
  235. height: 104rpx;
  236. border-radius: 52rpx;
  237. background-color: $primary;
  238. color: $fontcolor5;
  239. text-align: center;
  240. line-height: 104rpx;
  241. }
  242. }
  243. </style>