Authored by 姜敏

代码优化以及修复部分界面bug

... ... @@ -11,44 +11,47 @@ const accountModel = require('../models/account');
* 修改密码
* @param req
* @param res
* @param next
*/
const changePwd = (req, res) => {
const changePwd = (req, res, next) => {
let uid = req.user.uid;
let pwd = req.body.password;
accountModel.changePwd(uid, pwd).then(result=> {
res.send(result);
});
}).catch(next);
};
/**
* 验证手机号码
* @param req
* @param res
* @param next
*/
const checkVerifyMobile = (req, res)=> {
const checkVerifyMobile = (req, res, next)=> {
let uid = req.user.uid;
let mobile = req.body.mobile;
let area = req.body.area;
accountModel.checkVerifyMobile(uid, mobile, area).then(result=> {
res.send(result);
});
}).catch(next);
};
/**
* 发送短信
* @param req
* @param res
* @param next
*/
const sendMobileMsg = (req, res)=> {
const sendMobileMsg = (req, res, next)=> {
let uid = req.user.uid;
let mobile = req.body.mobile;
let area = req.body.area || '+86';
accountModel.sendMobileMsg(uid, mobile, area).then(result=> {
res.send(result);
});
}).catch(next);
};
... ... @@ -56,36 +59,38 @@ const sendMobileMsg = (req, res)=> {
* 验证短信
* @param req
* @param res
* @param next
*/
const checkVerifyMsg = (req, res)=> {
const checkVerifyMsg = (req, res, next)=> {
let code = req.body.code;
let mobile = req.body.mobile;
let area = req.body.area || '+86';
accountModel.checkVerifyMsg(code, mobile, area).then(result=> {
res.send(result);
});
}).catch(next);
};
/**
* 发送验证邮件
* @param req
* @param res
* @param next
*/
const sendVerifyEmail = (req, res)=> {
const sendVerifyEmail = (req, res, next)=> {
let uid = req.user.uid;
let email = req.body.email;
accountModel.sendVerifyEmail(uid, email).then(result=> {
res.send(result);
});
}).catch(next);
};
module.exports = {
changePwd: changePwd,
sendMobileMsg: sendMobileMsg,
checkVerifyMsg: checkVerifyMsg,
sendVerifyEmail: sendVerifyEmail,
checkVerifyMobile: checkVerifyMobile
changePwd,
sendMobileMsg,
checkVerifyMsg,
sendVerifyEmail,
checkVerifyMobile
};
... ...
... ... @@ -26,10 +26,10 @@ const index = (req, res, next) => {
addressModel.getAddressDataAsync(uid, 20).then(result => {
let resultData = result.data ? result.data : result;
let length = resultData.length ? resultData.length : 0;
let reg = /(\d{3})\d{4}(\d{4})/;
for (let i = 0; i < length; i++) {
resultData[i].mobile = resultData[i].mobile.substring(0, 3) + '****' +
resultData[i].mobile.substring(7, 11);
resultData[i].mobile = resultData[i].mobile.replace(reg, "$1****$2");
}
resultData.leftLength = 7 - length;
resultData.length = length;
... ... @@ -64,7 +64,7 @@ const getAddressList = (req, res, next) => {
/**
* 添加地址
*/
const addAddressData = (req, res) => {
const addAddressData = (req, res, next) => {
let uid = req.user.uid;
let address = req.body.address;
let areaCode = req.body.area_code;
... ... @@ -76,13 +76,13 @@ const addAddressData = (req, res) => {
addressModel.addAddressData(uid, address, areaCode, consignee, mobile, phone, isInit).then(result => {
res.send(result);
});
}).catch(next);
};
/**
* 修改地址
*/
const updateAddressData = (req, res) => {
const updateAddressData = (req, res, next) => {
let id = req.body.id;
let uid = req.user.uid;
let address = req.body.address;
... ... @@ -93,19 +93,19 @@ const updateAddressData = (req, res) => {
addressModel.updateAddressData(id, uid, address, areaCode, consignee, mobile, phone).then(result => {
res.send(result);
});
}).catch(next);
};
/**
* 删除地址
*/
const delAddressData = (req, res) => {
const delAddressData = (req, res, next) => {
let id = req.body.id;
let uid = req.user.uid;
addressModel.delAddressData(id, uid).then(result => {
res.send(result);
});
}).catch(next);
};
/**
... ...
... ... @@ -17,18 +17,18 @@ const convertUnitTime = (src) => {
/**
* yoho币页面加载
*/
const index = (req, res) => {
var uid = req.user.uid;
var page = parseInt(req.query.page, 10) || 1;
var queryType = parseInt(req.query.queryType, 10) || 0;
var beginTime = req.query.beginTime || convertUnitTime(new Date() / 1000 - 3600 * 24 * 90);
var date1 = new Date().getTime() / 1000;
var date2 = new Date(beginTime).getTime() / 1000;
var selectIndex = parseInt((date1 - date2) / (3600 * 24 * 30 * 6), 10);
const index = (req, res, next) => {
let uid = req.user.uid;
let page = parseInt(req.query.page, 10) || 1;
let queryType = parseInt(req.query.queryType, 10) || 0;
let beginTime = req.query.beginTime || convertUnitTime(new Date() / 1000 - 3600 * 24 * 90);
let date1 = new Date().getTime() / 1000;
let date2 = new Date(beginTime).getTime() / 1000;
let selectIndex = parseInt((date1 - date2) / (3600 * 24 * 30 * 6), 10);
currencyModel.getIndexData(uid, page, queryType, beginTime).then(result=> {
result.list.tabs[queryType].isActive = true;
result.list.coinList.forEach(function(x) {
result.list.coinList.forEach(function (x) {
x.date = x.date.replace(/\-/g, '.');
});
result.list.selects[selectIndex].isSelected = 'selected';
... ... @@ -58,7 +58,7 @@ const index = (req, res) => {
total: result.list.total ? result.list.total : 0
}
});
});
}).catch(next);
};
... ...
... ... @@ -12,6 +12,7 @@ const accountModel = require('../models/account');
const passportHelper = require('../../passport/models/passport-helper');
const Promise = require('bluebird');
const co = Promise.coroutine;
const regMobile = /(\d{3})\d{4}(\d{4})/;//正则匹配替换手机号码中间4位
const captchaUrl = helpers.urlFormat('/passport/images', {t: Date.now()});
... ... @@ -79,8 +80,7 @@ const index = (req, res, next) => {
result.info.gender ? result.genders[result.info.gender - 1].checked = true :
result.genders[2].checked = true;
result.info.head_ico = result.info.head_ico ? helpers.image(result.info.head_ico, 400, 300, 2) : '';
result.info.mobile = result.info.mobile ?
result.info.mobile.substring(0, 3) + '****' + result.info.mobile.substring(7, 11) : '';
result.info.mobile = result.info.mobile ? result.info.mobile.replace(regMobile, "$1****$2") : '';
result.stepUrl = '/me/setting/step1';
res.display('index', {
module: 'me',
... ... @@ -102,19 +102,20 @@ const index = (req, res, next) => {
* 编辑信息
* @param req
* @param res
* @param next
*/
const editUserInfo = (req, res)=> {
const editUserInfo = (req, res, next)=> {
let uid = req.user.uid;
let query = req.body;
settingModel.editUserInfo(uid, query).then(result=> {
res.send(result);
});
}).catch(next);
};
/*
* step1
* step1 绑定的手机号码身份验证
* */
const bindMobile = (req, res, next) => {
let uid = req.user.uid;
... ... @@ -124,7 +125,7 @@ const bindMobile = (req, res, next) => {
if (result.info.verify_mobile !== '') {
let info = result.info;
info.ellipsisMobile = info.verify_mobile.substring(0, 3) + '****' + info.verify_mobile.substring(7, 11);
info.ellipsisMobile = info.verify_mobile.replace(regMobile, "$1****$2");
info.checkCode = settingModel.cipheriv(info.uid + '.completeverify');
res.display('index', {
... ... @@ -150,6 +151,9 @@ const bindMobile = (req, res, next) => {
});
};
/**
* step1 绑定的邮箱进行身份验证
*/
const bindEmail = (req, res, next) => {
let uid = req.user.uid;
let type = req.params.type;
... ... @@ -181,6 +185,9 @@ const bindEmail = (req, res, next) => {
});
};
/**
*step1 登录密码进行身份验证
*/
const modifyPassword = (req, res) => {
let type = req.params.type;
let checkCode = settingModel.cipheriv(req.user.uid + '.completeverify');
... ... @@ -204,7 +211,7 @@ const modifyPassword = (req, res) => {
};
/*
* step2 渲染页面
* step2 操作界面-渲染页面
* */
const edit = (req, res)=> {
let type = req.params.type;
... ... @@ -243,7 +250,7 @@ const edit = (req, res)=> {
};
/*
* step3
* step3 操作成功-渲染界面
* */
const success = (req, res)=> {
let type = req.params.type;
... ... @@ -280,7 +287,7 @@ const success = (req, res)=> {
};
/*
* post1
* post1 第一步的post请求
* */
const validate1 = (req, res)=> {
co(function *() {
... ... @@ -305,7 +312,7 @@ const validate1 = (req, res)=> {
};
/*
* post2
* post2 第二步的post请求
* */
const validate2 = (req, res)=> {
co(function *() {
... ...
... ... @@ -108,11 +108,11 @@ const modifyVerifyMobile = (uid, area, newMobile)=> {
};
module.exports = {
verifyPwd: verifyPwd,
changePwd: changePwd,
sendMobileMsg: sendMobileMsg,
checkVerifyMsg: checkVerifyMsg,
sendVerifyEmail: sendVerifyEmail,
checkVerifyMobile: checkVerifyMobile,
modifyVerifyMobile: modifyVerifyMobile
verifyPwd,
changePwd,
sendMobileMsg,
checkVerifyMsg,
sendVerifyEmail,
checkVerifyMobile,
modifyVerifyMobile
};
... ...
... ... @@ -120,5 +120,5 @@ const getIndexData = (uid, page, queryType, beginTime) => {
};
module.exports = {
getIndexData: getIndexData
getIndexData
};
... ...
... ... @@ -76,11 +76,11 @@ const getUserInfo = (uid) => {
};
/* const getVerifyInfo = (uid)=> {
return api.get('', {
method: 'web.passport.getUserVerifyInfo',
uid: uid
}).then(result => result);
};*/
return api.get('', {
method: 'web.passport.getUserVerifyInfo',
uid: uid
}).then(result => result);
};*/
/**
* 编辑个人详细信息
... ... @@ -180,8 +180,8 @@ const decipheriv = (data) => {
};
module.exports = {
getUserInfo: getUserInfo,
editUserInfo: editUserInfo,
cipheriv: cipheriv,
decipheriv: decipheriv
getUserInfo,
editUserInfo,
cipheriv,
decipheriv
};
... ...
... ... @@ -40,18 +40,16 @@
<a class="blue operation" href="{{stepUrl}}/bindMobile">绑定</a>
{{/if}}
</div>
<!-- <div class="form-group">
<div class="form-group">
<label class="label-name">邮箱:</label>
{{#if info.verify_email}}
<input class="input no-edit" value="{{info.mobile}}">
&lt;!&ndash;<a class="blue operation" href="{{stepUrl}}/modifyEmail">修改</a>&ndash;&gt;
<a class="blue operation">修改</a>
<!--<a class="blue operation" href="{{stepUrl}}/modifyEmail">修改</a>-->
{{else}}
<input class="input" type="text" placeholder="请绑定邮箱" disabled>
&lt;!&ndash;<a class="blue operation" href="{{stepUrl}}/bindEmail">绑定</a>&ndash;&gt;
<a class="blue operation">绑定</a>
<!--<a class="blue operation" href="{{stepUrl}}/bindEmail">绑定</a>-->
{{/if}}
</div>-->
</div>
<div class="form-group">
<label class="label-name">出生日期:</label>
<input id="birthday" class="input" type="text" value="{{info.birthday}}">
... ... @@ -63,7 +61,7 @@
<span class="blue error-tips">{{> icon/error-round}}请选择</span>
</div>
<div class="form-group">
<label class="label-name">详细地址:</label>
<label class="label-name" style="visibility: hidden">详细地址:</label>
<input id="full_address" class="input big-input" type="text" placeholder="请填写详细地址"
maxlength="20" value="{{concat.full_address}}">
</div>
... ...