Showing
1 changed file
with
74 additions
and
73 deletions
@@ -5,8 +5,6 @@ | @@ -5,8 +5,6 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | -const Promise = require('bluebird'); | ||
9 | -const _ = require('lodash'); | ||
10 | const api = global.yoho.API; | 8 | const api = global.yoho.API; |
11 | const userApi = require('./user-api'); | 9 | const userApi = require('./user-api'); |
12 | const headerModel = require('../../../doraemon/models/header'); | 10 | const headerModel = require('../../../doraemon/models/header'); |
@@ -69,6 +67,61 @@ const configData = { | @@ -69,6 +67,61 @@ const configData = { | ||
69 | }] | 67 | }] |
70 | }; | 68 | }; |
71 | 69 | ||
70 | +const getDays = (year, month) => { | ||
71 | + let m = (month - 1) % 7 % 2 ? 30 : 31, | ||
72 | + y400 = year % 400 ? 28 : 29, | ||
73 | + y100 = year % 100 ? 29 : y400, | ||
74 | + y4 = year % 4 ? 28 : y100; | ||
75 | + | ||
76 | + return month === 2 ? y4 : m; | ||
77 | +}; | ||
78 | + | ||
79 | +const getBirthday = (birthday) => { | ||
80 | + let year = parseInt(birthday.split('-')[0], 0), | ||
81 | + month = parseInt(birthday.split('-')[1], 0), | ||
82 | + day = parseInt(birthday.split('-')[2], 0), | ||
83 | + nowYear = new Date().getFullYear(), | ||
84 | + yearArr = [{value: 0, text: '年'}], | ||
85 | + monthArr = [{value: 0, text: '月'}], | ||
86 | + dayArr = [{value: 0, text: '日'}], | ||
87 | + days = getDays(year, month); | ||
88 | + | ||
89 | + for (let i = 1950; i <= nowYear; i++) { | ||
90 | + let yearJson = {value: i, text: i}; | ||
91 | + | ||
92 | + if (i === year) { | ||
93 | + yearJson.isChecked = true; | ||
94 | + console.info(yearJson); | ||
95 | + } | ||
96 | + yearArr.push(yearJson); | ||
97 | + } | ||
98 | + | ||
99 | + for (let j = 1; j <= 12; j++) { | ||
100 | + let monthJson = {value: j, text: j}; | ||
101 | + | ||
102 | + if (j === month) { | ||
103 | + monthJson.isChecked = true; | ||
104 | + } | ||
105 | + monthArr.push(monthJson); | ||
106 | + } | ||
107 | + | ||
108 | + for (let k = 1; k <= days; k++) { | ||
109 | + let dayJson = {value: k, text: k}; | ||
110 | + | ||
111 | + if (k === day) { | ||
112 | + dayJson.isChecked = true; | ||
113 | + } | ||
114 | + dayArr.push(dayJson); | ||
115 | + } | ||
116 | + | ||
117 | + return { | ||
118 | + yearArr: yearArr, | ||
119 | + monthArr: monthArr, | ||
120 | + dayArr: dayArr | ||
121 | + }; | ||
122 | + | ||
123 | +}; | ||
124 | + | ||
72 | const getUserInfo = (channel, uid) => { | 125 | const getUserInfo = (channel, uid) => { |
73 | 126 | ||
74 | return api.all([ | 127 | return api.all([ |
@@ -100,31 +153,31 @@ const getUserInfo = (channel, uid) => { | @@ -100,31 +153,31 @@ const getUserInfo = (channel, uid) => { | ||
100 | incomeArr; | 153 | incomeArr; |
101 | 154 | ||
102 | userInfo = result[1].data; | 155 | userInfo = result[1].data; |
103 | - email = userInfo['email'] !== undefined ? userInfo['email'] : ''; | ||
104 | - nickname = userInfo['nickname'] !== undefined ? userInfo['nickname'] : ''; | ||
105 | - username = userInfo['username'] !== undefined ? userInfo['username'] : ''; | ||
106 | - gender = userInfo['gender'] !== undefined ? userInfo['gender'] : 3; | ||
107 | - birthday = userInfo['birthday'] !== undefined ? userInfo['birthday'] : ''; | ||
108 | - profession = userInfo['profession'] !== undefined ? userInfo['profession'] : 0; | ||
109 | - income = userInfo['income'] !== undefined ? userInfo['income'] : 0; | 156 | + email = userInfo.email !== undefined ? userInfo.email : ''; |
157 | + nickname = userInfo.nickname !== undefined ? userInfo.nickname : ''; | ||
158 | + username = userInfo.username !== undefined ? userInfo.username : ''; | ||
159 | + gender = userInfo.gender !== undefined ? userInfo.gender : 3; | ||
160 | + birthday = userInfo.birthday !== undefined ? userInfo.birthday : ''; | ||
161 | + profession = userInfo.profession !== undefined ? userInfo.profession : 0; | ||
162 | + income = userInfo.income !== undefined ? userInfo.income : 0; | ||
110 | 163 | ||
111 | genderArr = configData.gender; | 164 | genderArr = configData.gender; |
112 | - for (var value of genderArr) { | ||
113 | - if (value.value == gender) { | 165 | + for (let value of genderArr) { |
166 | + if (value.value === parseInt(gender, 0)) { | ||
114 | value.isChecked = true; | 167 | value.isChecked = true; |
115 | } | 168 | } |
116 | } | 169 | } |
117 | 170 | ||
118 | professionArr = configData.profession; | 171 | professionArr = configData.profession; |
119 | - for (var value of professionArr) { | ||
120 | - if (value.value == profession) { | 172 | + for (let value of professionArr) { |
173 | + if (value.value === parseInt(profession, 0)) { | ||
121 | value.isChecked = true; | 174 | value.isChecked = true; |
122 | } | 175 | } |
123 | } | 176 | } |
124 | 177 | ||
125 | incomeArr = configData.income; | 178 | incomeArr = configData.income; |
126 | - for (var value of incomeArr) { | ||
127 | - if (value.value == income) { | 179 | + for (let value of incomeArr) { |
180 | + if (value.value === parseInt(income, 0)) { | ||
128 | value.isChecked = true; | 181 | value.isChecked = true; |
129 | } | 182 | } |
130 | } | 183 | } |
@@ -138,7 +191,7 @@ const getUserInfo = (channel, uid) => { | @@ -138,7 +191,7 @@ const getUserInfo = (channel, uid) => { | ||
138 | subTitle: '会员信息', | 191 | subTitle: '会员信息', |
139 | firstBox: true, | 192 | firstBox: true, |
140 | submitId: 'base-info', | 193 | submitId: 'base-info', |
141 | - profileSrc: userInfo['head_ico'], | 194 | + profileSrc: userInfo.head_ico, |
142 | email: { | 195 | email: { |
143 | labelText: '登录邮箱:', | 196 | labelText: '登录邮箱:', |
144 | value: email | 197 | value: email |
@@ -159,10 +212,10 @@ const getUserInfo = (channel, uid) => { | @@ -159,10 +212,10 @@ const getUserInfo = (channel, uid) => { | ||
159 | ], | 212 | ], |
160 | gender: { | 213 | gender: { |
161 | labelText: '性别:', | 214 | labelText: '性别:', |
162 | - key: 'gender', | ||
163 | - data: genderArr | ||
164 | - }, | ||
165 | - birthday: { | 215 | + key: 'gender', |
216 | + data: genderArr | ||
217 | + }, | ||
218 | + birthday: { | ||
166 | labelText: '生日:', | 219 | labelText: '生日:', |
167 | key: 'birthday', | 220 | key: 'birthday', |
168 | tips: '', | 221 | tips: '', |
@@ -181,7 +234,7 @@ const getUserInfo = (channel, uid) => { | @@ -181,7 +234,7 @@ const getUserInfo = (channel, uid) => { | ||
181 | key: 'day', | 234 | key: 'day', |
182 | options: dayArr, | 235 | options: dayArr, |
183 | unit: '日' | 236 | unit: '日' |
184 | - }, | 237 | + } |
185 | ] | 238 | ] |
186 | }, | 239 | }, |
187 | profession: { | 240 | profession: { |
@@ -205,58 +258,6 @@ const getUserInfo = (channel, uid) => { | @@ -205,58 +258,6 @@ const getUserInfo = (channel, uid) => { | ||
205 | }); | 258 | }); |
206 | }; | 259 | }; |
207 | 260 | ||
208 | -const getBirthday = (birthday) => { | ||
209 | - let year = birthday.split('-')[0], | ||
210 | - month = birthday.split('-')[1], | ||
211 | - day = birthday.split('-')[2], | ||
212 | - nowYear = new Date().getFullYear(), | ||
213 | - yearArr = [{value: 0, text: '年'}], | ||
214 | - monthArr = [{value: 0, text: '月'}], | ||
215 | - dayArr = [{value: 0, text: '日'}], | ||
216 | - days = getDays(year,month); | ||
217 | - | ||
218 | - for (let i = 1950; i <= nowYear; i++) { | ||
219 | - let yearJson = {value: i, text: i}; | ||
220 | - | ||
221 | - if (i == year) { | ||
222 | - yearJson.isChecked = true; | ||
223 | - console.info(yearJson); | ||
224 | - } | ||
225 | - yearArr.push(yearJson); | ||
226 | - } | ||
227 | - | ||
228 | - for (let j = 1; j <= 12; j++) { | ||
229 | - let monthJson = {value: j, text: j}; | ||
230 | - | ||
231 | - if (j == month) { | ||
232 | - monthJson.isChecked = true; | ||
233 | - } | ||
234 | - monthArr.push(monthJson); | ||
235 | - } | ||
236 | - | ||
237 | - for (let k = 1; k <= days; k++) { | ||
238 | - let dayJson = {value: k, text: k}; | ||
239 | - | ||
240 | - if (k == day) { | ||
241 | - dayJson.isChecked = true; | ||
242 | - } | ||
243 | - dayArr.push(dayJson); | ||
244 | - } | ||
245 | - | ||
246 | - return { | ||
247 | - yearArr: yearArr, | ||
248 | - monthArr: monthArr, | ||
249 | - dayArr: dayArr | ||
250 | - } | ||
251 | - | ||
252 | -} | ||
253 | - | ||
254 | -const getDays = (year,month) => { | ||
255 | - return month == 2 ? | ||
256 | - (year % 4 ? 28 : (year % 100 ? 29 : (year % 400 ? 28 : 29))) : | ||
257 | - ((month - 1) % 7 % 2 ? 30 : 31); | ||
258 | -} | ||
259 | - | ||
260 | module.exports = { | 261 | module.exports = { |
261 | getUserInfo | 262 | getUserInfo |
262 | }; | 263 | }; |
-
Please register or login to post a comment