Authored by wenjiekong

个人编辑资料,会员信息显示

... ... @@ -5,8 +5,6 @@
*/
'use strict';
const Promise = require('bluebird');
const _ = require('lodash');
const api = global.yoho.API;
const userApi = require('./user-api');
const headerModel = require('../../../doraemon/models/header');
... ... @@ -69,6 +67,61 @@ const configData = {
}]
};
const getDays = (year, month) => {
let m = (month - 1) % 7 % 2 ? 30 : 31,
y400 = year % 400 ? 28 : 29,
y100 = year % 100 ? 29 : y400,
y4 = year % 4 ? 28 : y100;
return month === 2 ? y4 : m;
};
const getBirthday = (birthday) => {
let year = parseInt(birthday.split('-')[0], 0),
month = parseInt(birthday.split('-')[1], 0),
day = parseInt(birthday.split('-')[2], 0),
nowYear = new Date().getFullYear(),
yearArr = [{value: 0, text: '年'}],
monthArr = [{value: 0, text: '月'}],
dayArr = [{value: 0, text: '日'}],
days = getDays(year, month);
for (let i = 1950; i <= nowYear; i++) {
let yearJson = {value: i, text: i};
if (i === year) {
yearJson.isChecked = true;
console.info(yearJson);
}
yearArr.push(yearJson);
}
for (let j = 1; j <= 12; j++) {
let monthJson = {value: j, text: j};
if (j === month) {
monthJson.isChecked = true;
}
monthArr.push(monthJson);
}
for (let k = 1; k <= days; k++) {
let dayJson = {value: k, text: k};
if (k === day) {
dayJson.isChecked = true;
}
dayArr.push(dayJson);
}
return {
yearArr: yearArr,
monthArr: monthArr,
dayArr: dayArr
};
};
const getUserInfo = (channel, uid) => {
return api.all([
... ... @@ -100,31 +153,31 @@ const getUserInfo = (channel, uid) => {
incomeArr;
userInfo = result[1].data;
email = userInfo['email'] !== undefined ? userInfo['email'] : '';
nickname = userInfo['nickname'] !== undefined ? userInfo['nickname'] : '';
username = userInfo['username'] !== undefined ? userInfo['username'] : '';
gender = userInfo['gender'] !== undefined ? userInfo['gender'] : 3;
birthday = userInfo['birthday'] !== undefined ? userInfo['birthday'] : '';
profession = userInfo['profession'] !== undefined ? userInfo['profession'] : 0;
income = userInfo['income'] !== undefined ? userInfo['income'] : 0;
email = userInfo.email !== undefined ? userInfo.email : '';
nickname = userInfo.nickname !== undefined ? userInfo.nickname : '';
username = userInfo.username !== undefined ? userInfo.username : '';
gender = userInfo.gender !== undefined ? userInfo.gender : 3;
birthday = userInfo.birthday !== undefined ? userInfo.birthday : '';
profession = userInfo.profession !== undefined ? userInfo.profession : 0;
income = userInfo.income !== undefined ? userInfo.income : 0;
genderArr = configData.gender;
for (var value of genderArr) {
if (value.value == gender) {
for (let value of genderArr) {
if (value.value === parseInt(gender, 0)) {
value.isChecked = true;
}
}
professionArr = configData.profession;
for (var value of professionArr) {
if (value.value == profession) {
for (let value of professionArr) {
if (value.value === parseInt(profession, 0)) {
value.isChecked = true;
}
}
incomeArr = configData.income;
for (var value of incomeArr) {
if (value.value == income) {
for (let value of incomeArr) {
if (value.value === parseInt(income, 0)) {
value.isChecked = true;
}
}
... ... @@ -138,7 +191,7 @@ const getUserInfo = (channel, uid) => {
subTitle: '会员信息',
firstBox: true,
submitId: 'base-info',
profileSrc: userInfo['head_ico'],
profileSrc: userInfo.head_ico,
email: {
labelText: '登录邮箱:',
value: email
... ... @@ -159,10 +212,10 @@ const getUserInfo = (channel, uid) => {
],
gender: {
labelText: '性别:',
key: 'gender',
data: genderArr
},
birthday: {
key: 'gender',
data: genderArr
},
birthday: {
labelText: '生日:',
key: 'birthday',
tips: '',
... ... @@ -181,7 +234,7 @@ const getUserInfo = (channel, uid) => {
key: 'day',
options: dayArr,
unit: '日'
},
}
]
},
profession: {
... ... @@ -205,58 +258,6 @@ const getUserInfo = (channel, uid) => {
});
};
const getBirthday = (birthday) => {
let year = birthday.split('-')[0],
month = birthday.split('-')[1],
day = birthday.split('-')[2],
nowYear = new Date().getFullYear(),
yearArr = [{value: 0, text: '年'}],
monthArr = [{value: 0, text: '月'}],
dayArr = [{value: 0, text: '日'}],
days = getDays(year,month);
for (let i = 1950; i <= nowYear; i++) {
let yearJson = {value: i, text: i};
if (i == year) {
yearJson.isChecked = true;
console.info(yearJson);
}
yearArr.push(yearJson);
}
for (let j = 1; j <= 12; j++) {
let monthJson = {value: j, text: j};
if (j == month) {
monthJson.isChecked = true;
}
monthArr.push(monthJson);
}
for (let k = 1; k <= days; k++) {
let dayJson = {value: k, text: k};
if (k == day) {
dayJson.isChecked = true;
}
dayArr.push(dayJson);
}
return {
yearArr: yearArr,
monthArr: monthArr,
dayArr: dayArr
}
}
const getDays = (year,month) => {
return month == 2 ?
(year % 4 ? 28 : (year % 100 ? 29 : (year % 400 ? 28 : 29))) :
((month - 1) % 7 % 2 ? 30 : 31);
}
module.exports = {
getUserInfo
};
... ...