step1.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view>
  3. <u-navbar :background="background" :border-bottom="false"></u-navbar>
  4. <view class="jpLogin">
  5. <view class="jpLogin-title">
  6. <h2>填写基础信息<span>1</span>/4</h2>
  7. <p>交友第一步,简单介绍下自己吧~</p>
  8. </view>
  9. <view class="jpLogin-main">
  10. <view class="form-tit">
  11. <span>*</span>
  12. <p>为必填项,著名保密箱的为不对外公开信息</p>
  13. </view>
  14. <view class="jpLogin-sex">
  15. <view class="jpLogin-sex-item">
  16. <u-image class="newsList-img" :src="form.sex=='male'?'/static/img/sexMan.png':'/static/img/sexMan2.png'" height="200" width="200" border-radius="10" @click="changeSex('male')"></u-image>
  17. <!-- <u-image class="newsList-img" src="/static/img/sexMan2.png" height="200" width="200" border-radius="10"></u-image> -->
  18. </view>
  19. <view class="jpLogin-sex-item">
  20. <!-- <u-image class="newsList-img" src="/static/img/sexWoman.png" height="200" width="200" border-radius="10"></u-image> -->
  21. <u-image class="newsList-img" :src="form.sex=='female'?'/static/img/sexWoman.png':'/static/img/sexWoman2.png'" height="200" width="200" border-radius="10" @click="changeSex('female')"></u-image>
  22. </view>
  23. </view>
  24. <view class="form-tit">
  25. <p>注册完成,你的性别就不能修改了哦~</p>
  26. </view>
  27. <view class="form-tit" style="margin-top: 36px;">
  28. <p>设置生日、身高和体重</p>
  29. </view>
  30. <u-form :model="form" ref="uForm">
  31. <view class="jpLogin-input">
  32. <u-form-item required="true"><u-input v-model="form.birthday" type="select" placeholder="请选择生日" @click="birthdayChange"/>
  33. </u-form-item>
  34. </view>
  35. <view class="jpLogin-input">
  36. <u-form-item required="true">
  37. <u-input v-model="form.height" type="select" placeholder="请选择身高" @click="show_height = true"/>
  38. <u-select v-model="show_height" mode="single-column" :list="height_ranges_by_names" @confirm="heightConfirm"></u-select>
  39. </u-form-item>
  40. </view>
  41. <view class="jpLogin-input">
  42. <u-form-item>
  43. <u-input v-model="form.weight" type="select" placeholder="请选择填写体重" @click="show_weight = true"/>
  44. <u-select v-model="show_weight" mode="single-column" :list="weight_ranges_by_names" @confirm="weightConfirm"></u-select>
  45. </u-form-item>
  46. </view>
  47. </u-form>
  48. </view>
  49. <view style="margin-top: 60px;">
  50. <u-button type="error" shape="circle" :custom-style="customStyle" @click="next">下一步</u-button>
  51. <view class="step-btn" @click="goHome">跳过</view>
  52. </view>
  53. </view>
  54. <mpvue-date-picker themeColor="#007AFF" ref="mpvueDatePicker" :pickerValueDefault="agePickerValueDefault" @onConfirm="onDateConfirm"></mpvue-date-picker>
  55. </view>
  56. </template>
  57. <script>
  58. let _self;
  59. /**
  60. * 获取任意时间
  61. */
  62. function getDate(date, AddDayCount = 0) {
  63. if (!date) {
  64. date = new Date()
  65. }
  66. if (typeof date !== 'object') {
  67. date = date.replace(/-/g, '/')
  68. }
  69. const dd = new Date(date)
  70. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  71. const y = dd.getFullYear()
  72. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  73. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  74. return {
  75. fullDate: y + '-' + m + '-' + d,
  76. year: y,
  77. month: m,
  78. date: d,
  79. day: dd.getDay()
  80. }
  81. }
  82. import mpvueDatePicker from "../../components/mpvue-datepicker/mpvue-datepicker.vue"
  83. import * as loginApi from '@/apis/login.js'
  84. export default {
  85. components:{
  86. mpvueDatePicker
  87. },
  88. data() {
  89. return {
  90. personal_info:{},
  91. form: {
  92. // name: '',
  93. sex:'male',
  94. birthday:"",
  95. height:'',
  96. weight:'',
  97. },
  98. value:'0',
  99. customStyle: {
  100. background: '#FF5E5E'
  101. },
  102. showCalendar: false,
  103. info: {
  104. lunar: true,
  105. range: true,
  106. insert: false,
  107. selected: []
  108. },
  109. show_height : false,
  110. show_weight : false,
  111. height_ranges:[],
  112. weight_ranges:[],
  113. height_ranges_by_names:[],
  114. weight_ranges_by_names:[],
  115. background:{
  116. background: 'none'
  117. }
  118. }
  119. },
  120. onReady() {
  121. this.$nextTick(() => {
  122. this.showCalendar = true
  123. })
  124. // TODO 模拟请求异步同步数据
  125. setTimeout(() => {
  126. this.info.date = getDate(new Date(),0).fullDate
  127. this.info.startDate = getDate(new Date(),-36500).fullDate
  128. this.info.endDate = getDate(new Date(),0).fullDate
  129. this.info.selected = []
  130. }, 2000)
  131. },
  132. onLoad(){
  133. _self = this;
  134. let subject = {subject:'zfqkList'}
  135. loginApi.getBaseDictionary(subject).then(function(data){
  136. console.log('基础字典'+JSON.stringify(data));
  137. },function(err){
  138. console.log('获取基础字典错误'+JSON.stringify(err))
  139. })
  140. for(let i = 130;i<=220;i++)
  141. {
  142. this.height_ranges.push(i.toString());
  143. }
  144. for(let i = 20;i<=120;i++)
  145. {
  146. this.weight_ranges.push(i.toString());
  147. }
  148. for(let i = 0;i< _self.height_ranges.length;i++)
  149. {
  150. let height_range = {value:i, label: _self.height_ranges[i]+"cm"};
  151. _self.height_ranges_by_names.push(height_range);
  152. }
  153. for(let i = 0;i< _self.weight_ranges.length;i++)
  154. {
  155. let weight_range = {value:i, label:_self.weight_ranges[i]+"kg"};
  156. _self.weight_ranges_by_names.push(weight_range);
  157. }
  158. },
  159. methods: {
  160. changeSex(sex){
  161. this.form.sex = sex;
  162. },
  163. birthdayChange(){
  164. this.$refs.mpvueDatePicker.show()
  165. },
  166. onDateConfirm(e) {
  167. _self.form.birthday = e.label;
  168. console.log('地址选择'+_self.birthday)
  169. },
  170. goHome(){
  171. uni.switchTab({
  172. url:'../index/index'
  173. })
  174. },
  175. open() {
  176. this.$refs.calendar.open()
  177. },
  178. heightConfirm(e){
  179. console.log('e'+JSON.stringify(e))
  180. this.form.height = '';
  181. e.map((val, index) => {
  182. // this.result += this.result == '' ? val.label : '-' + val.label;
  183. let result = val.label
  184. this.form.height += result;
  185. })
  186. },
  187. weightConfirm(e){
  188. console.log('e'+JSON.stringify(e))
  189. this.form.weight = '';
  190. e.map((val, index) => {
  191. // this.result += this.result == '' ? val.label : '-' + val.label;
  192. let result = val.label
  193. this.form.weight += result;
  194. })
  195. },
  196. close(){
  197. this.form.birthday =this.info.date;
  198. console.log('弹窗关闭'+JSON.stringify(this.info.date));
  199. },
  200. change(e) {
  201. console.log('change 返回:', e)
  202. this.info.selected = [];
  203. // 模拟动态打卡
  204. if (this.info.selected.length > 5) return
  205. this.info.selected.push({
  206. date: e.fulldate,
  207. info: '打卡'
  208. })
  209. },
  210. confirm(e) {
  211. this.info.date = e.fulldate;
  212. console.log('confirm 返回:', JSON.stringify(this.info.date))
  213. },
  214. monthSwitch(e) {
  215. console.log('monthSwitchs 返回:', e)
  216. },
  217. next(){
  218. _self.personal_info.step1 = _self.form;
  219. uni.navigateTo({
  220. url:'./step2',
  221. success:function(res){
  222. res.eventChannel.emit('acceptDataFromOpenerPage', _self.personal_info);
  223. console.log('send options'+JSON.stringify(_self.personal_info));
  224. }
  225. })
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. .jpLogin-sex{
  232. display: flex;
  233. margin-bottom: 5px;
  234. .jpLogin-sex-item{
  235. margin-right: 15px;
  236. }
  237. }
  238. .form-tit{
  239. display: flex;
  240. align-items: center;
  241. span{
  242. color:#EE3138 ;
  243. }
  244. p{
  245. color: #999;
  246. margin-bottom: 8px;
  247. }
  248. }
  249. .jpLogin {
  250. background: url(/static/img/loginBg.png) top center no-repeat;
  251. background-size: 100%;
  252. min-height: 100vh;
  253. padding: 50px;
  254. margin-top: -44px;
  255. }
  256. .step-btn{
  257. text-align: center;
  258. margin-top: 20px;
  259. color: #444953 ;
  260. }
  261. .jpLogin-title {
  262. h2 {
  263. font-size: 24px;
  264. font-weight: normal;
  265. }
  266. span{
  267. color: #FF5E5E;
  268. margin-left: 5px;
  269. }
  270. p {
  271. color: #777;
  272. font-size: 14px;
  273. margin-top: 3px;
  274. }
  275. }
  276. .jpLogin-main {
  277. margin-top: 40px;
  278. }
  279. .jpLogin-input {
  280. height: 48px;
  281. background-color: #fff;
  282. border: 1px solid #EEDCDC;
  283. border-radius: 50px;
  284. display: flex;
  285. width: 100%;
  286. padding: 0 20px 0 30px;
  287. margin-bottom: 20px;
  288. .u-form-item{
  289. flex: 1;
  290. }
  291. .jpLogin-icon{
  292. font-size: 20px;
  293. color:#FFC1C1;
  294. margin-right: 20px;
  295. position: relative;
  296. &:after{
  297. content: '';
  298. width: 1px;
  299. height: 16px;
  300. background-color:#E6D6D6;
  301. position: absolute;
  302. right: -10px;
  303. top: 15px;
  304. }
  305. }
  306. }
  307. .jpLogin-link {
  308. display: flex;
  309. justify-content: space-between;
  310. align-items: center;
  311. font-size: 14px;
  312. .jpLogin-link-l {
  313. display: flex;
  314. align-items: center;
  315. p {
  316. color: #4f4646;
  317. }
  318. }
  319. span {
  320. color: #1677FF;
  321. }
  322. }
  323. .jpLogin-radio{
  324. margin-top: 16px;
  325. text-align: center;
  326. p{
  327. font-size: 14px;
  328. color: #a0a4b8;
  329. }
  330. span{
  331. color:#ff5e5e;
  332. font-size: 14px;
  333. }
  334. }
  335. </style>