Authored by jinhu.tung

Merge branch 'develop' into release/1.0

... ... @@ -13,7 +13,9 @@ const accountModel = require('../models/account');
* @param res
*/
const changePwd = (req, res) => {
let uid = req.user.uid || '20000190';
let uid = req.user.uid;
// let uid = req.user.uid||"20000190" ;
let pwd = req.body.password;
accountModel.changePwd(uid, pwd).then(result=> {
... ... @@ -29,6 +31,8 @@ const changePwd = (req, res) => {
*/
const checkVerifyMobile = (req, res)=> {
let uid = req.user.uid;
// let uid = req.user.uid||"20000190";
let mobile = req.body.mobile;
let area = req.body.area;
... ... @@ -46,6 +50,8 @@ const checkVerifyMobile = (req, res)=> {
*/
const sendMobileMsg = (req, res)=> {
let uid = req.user.uid;
// let uid = req.user.uid||"20000190";
let mobile = req.body.mobile;
let area = req.body.area || '+86';
... ... @@ -80,6 +86,8 @@ const checkVerifyMsg = (req, res)=> {
*/
const sendVerifyEmail = (req, res)=> {
let uid = req.user.uid;
// let uid = req.user.uid||"20000190";
let email = req.body.email;
accountModel.sendVerifyEmail(uid, email).then(result=> {
... ...
... ... @@ -12,10 +12,10 @@ const orderModel = require('../models/order');
/**
* 我的订单
*/
const index = (req, res, next) => {
const index = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = global.yoho.uid || '13549567';
const uid = req.user.uid || '13549567';
orderModel.getOrderData(uid, type, page).then(result => {
res.display('index', {
... ... @@ -27,12 +27,12 @@ const index = (req, res, next) => {
banner: 'http://placehold.it/{width}x{height}'
}, result)
});
}).catch(next);
});
};
const detail = (req, res, next) => {
const detail = (req, res) => {
const code = req.query.code;
const uid = global.yoho.uid || '7394907';
const uid = req.user.uid || '7394907';
orderModel.getOrderDetail(uid, code).then(result => {
res.display('index', {
... ... @@ -44,13 +44,13 @@ const detail = (req, res, next) => {
banner: 'http://placehold.it/{width}x{height}'
}, result)
});
}).catch(next);
});
};
const getOrderList = (req, res, next) => {
const getOrderList = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = global.yoho.uid || '7394907';
const uid = req.user.uid || '7394907';
orderModel.getOrderData(uid, type, page).then(result => {
res.display('order-table', {
... ... @@ -58,16 +58,14 @@ const getOrderList = (req, res, next) => {
page: 'order',
isMe: true,
orderList: result.order.orderList,
paginationOpts: result.order.paginationOpts,
emptyMsg: result.order.emptyMsg,
showEmptyEn: result.order.showEmptyEn
paginationOpts: result.order.paginationOpts
});
}).catch(next);
});
};
const getOrderTotal = (req, res, next) => {
const getOrderTotal = (req, res) => {
const type = req.query.type;
const uid = global.yoho.uid || '7394907';
const uid = req.user.uid || '7394907';
orderModel.getOrderData(uid, type).then(result => {
... ... @@ -76,44 +74,44 @@ const getOrderTotal = (req, res, next) => {
total: result.order.total,
type: result.order.type
});
}).catch(next);
});
};
const cancelOrder = (req, res, next) => {
const uid = global.yoho.uid || '7394907';
const data = req.query;
const cancelOrder = (req, res) => {
const uid = req.user.uid || '7394907';
const code = req.query.orderCode;
orderModel.cancelOrder(uid, data).then(result => {
orderModel.cancelOrder(uid, code).then(result => {
res.json(result);
}).catch(next);
});
};
const deleteOrder = (req, res, next) => {
const uid = global.yoho.uid || '7394907';
const deleteOrder = (req, res) => {
const uid = req.user.uid || '7394907';
const code = req.query.orderCode;
orderModel.deleteOrder(uid, code).then(result => {
res.json(result);
}).catch(next);
});
};
const getExpressInfo = (req, res, next) => {
const uid = global.yoho.uid || '7394907';
const getExpressInfo = (req, res) => {
const uid = req.user.uid || '7394907';
const code = req.query.orderCode;
orderModel.getExpressInfo(uid, code).then(result => {
res.json(result);
}).catch(next);
});
};
const getCancelOrderReason = (req, res, next) => {
const getCancelOrderReason = (req, res) => {
orderModel.getCancelOrderReason().then(result => {
res.json(result);
}).catch(next);
});
};
const editOrder = (req, res) => {
const uid = global.yoho.uid || '7394907';
const uid = req.user.uid || '7394907';
const query = req.query;
query.uid = uid;
... ... @@ -123,16 +121,6 @@ const editOrder = (req, res) => {
});
};
const reAddCart = (req, res) => {
const uid = global.yoho.uid || '7394907';
const code = req.query.orderCode;
orderModel.reAddCart(uid, code).then(result => {
res.json(result);
});
};
module.exports = {
index: index,
detail: detail,
... ... @@ -142,6 +130,5 @@ module.exports = {
deleteOrder: deleteOrder,
editOrder: editOrder,
getExpressInfo: getExpressInfo,
getCancelOrderReason: getCancelOrderReason,
reAddCart: reAddCart
getCancelOrderReason: getCancelOrderReason
};
... ...
... ... @@ -75,6 +75,8 @@ const _getTitle = (type)=> {
const index = (req, res, next) => {
let uid = req.user.uid;
// let uid = req.user.uid || "20000190";
settingModel.getUserInfo(uid).then(result=> {
result.info.gender ? result.genders[result.info.gender - 1].checked = true :
result.genders[2].checked = true;
... ... @@ -82,7 +84,6 @@ const index = (req, res, next) => {
result.info.mobile = result.info.mobile ?
result.info.mobile.substring(0, 3) + '****' + result.info.mobile.substring(7, 11) : '';
result.stepUrl = '/me/setting/step1';
console.log('详情info:', result.info);
res.display('index', {
module: 'me',
page: 'setting',
... ... @@ -106,10 +107,11 @@ const index = (req, res, next) => {
*/
const editUserInfo = (req, res)=> {
let uid = req.user.uid;
// let uid = req.user.uid || "20000190";
let query = req.body;
settingModel.editUserInfo(uid, query).then(result=> {
// console.log('修改result', result);
res.send(result);
});
};
... ... @@ -120,13 +122,19 @@ const editUserInfo = (req, res)=> {
* */
const bindMobile = (req, res, next) => {
let uid = req.user.uid;
// let uid = req.user.uid || "20000190";
let type = req.params.type;
settingModel.getUserInfo(uid).then(result=> {
if (result.info.verify_mobile !== '') {
let info = result.info;
info.ellipsisMobile = info.mobile.substring(0, 3) + '****' + info.mobile.substring(7, 11);
info.ellipsisMobile = info.verify_mobile.substring(0, 3) + '****' + info.verify_mobile.substring(7, 11);
info.checkCode = settingModel.cipheriv(info.uid + '.completeverify');
// info.checkCode = settingModel.cipheriv("20000190" + ".completeverify");
console.log('info.checkCode:', info.checkCode);
res.display('index', {
module: 'me',
page: 'setting',
... ... @@ -137,7 +145,7 @@ const bindMobile = (req, res, next) => {
nav: mcHandler.getMeCrumb('个人设置'),
navigation: mcHandler.getSideMenu('个人设置'),
banner: 'http://placehold.it/150x120',
step1: true,
validateStep: true,
title: _getTitle(type).typeName,
proTitle: _getTitle(type).proName,
captchaUrl: captchaUrl,
... ... @@ -152,13 +160,18 @@ const bindMobile = (req, res, next) => {
const bindEmail = (req, res, next) => {
let uid = req.user.uid;
// let uid = req.user.uid || "20000190";
let type = req.params.type;
settingModel.getUserInfo(uid).then(result=> {
if (result.info.verify_email !== '') {
let info = result.info;
info.ellipsisEmail = info.email.substring(0, 3) + '****' + info.email.substring(7, 11);
info.ellipsisEmail = info.verify_email.substring(0, 3) + '****' + info.verify_email.substring(7, 11);
info.checkCode = settingModel.cipheriv(info.uid + '.completeverify');
// info.checkCode = settingModel.cipheriv("20000190" + ".completeverify");
res.display('index', {
module: 'me',
page: 'setting',
... ... @@ -167,7 +180,7 @@ const bindEmail = (req, res, next) => {
nav: mcHandler.getMeCrumb('个人设置'),
navigation: mcHandler.getSideMenu('个人设置'),
banner: 'http://placehold.it/150x120',
step1: true,
validateStep: true,
title: _getTitle(type).typeName,
proTitle: _getTitle(type).proName,
captchaUrl: captchaUrl,
... ... @@ -183,6 +196,9 @@ const bindEmail = (req, res, next) => {
const modifyPassword = (req, res) => {
let type = req.params.type;
let checkCode = settingModel.cipheriv(req.user.uid + '.completeverify');
// let checkCode = settingModel.cipheriv("20000190" + ".completeverify");
res.display('index', {
module: 'me',
page: 'setting',
... ... @@ -191,11 +207,12 @@ const modifyPassword = (req, res) => {
nav: mcHandler.getMeCrumb('个人设置'),
navigation: mcHandler.getSideMenu('个人设置'),
banner: 'http://placehold.it/150x120',
step1: true,
validateStep: true,
title: _getTitle(type).typeName,
proTitle: _getTitle(type).proName,
captchaUrl: captchaUrl,
isShowPassword: true
isShowPassword: true,
checkCode: checkCode
}
});
};
... ... @@ -205,30 +222,41 @@ const modifyPassword = (req, res) => {
* */
const edit = (req, res)=> {
let type = req.params.type;
let code = settingModel.decipheriv(req.query.checkCode.split(' ').join('+'));
let codes = code.split('.');
if (codes[0] === req.user.uid && codes[1] === 'completeverify') {
// if (codes[0] === "20000190" && codes[1] === "completeverify") {
let result = {
title: _getTitle(type).typeName,
proTitle: _getTitle(type).proName,
isShowMobile: _getTitle(type).isModifyMobile || _getTitle(type).isBindMobile,
isShowEmail: _getTitle(type).isModifyEmail || _getTitle(type).isBindEmail,
isShowPassword: _getTitle(type).isShowPassword
};
let checkCode = settingModel.cipheriv(req.user.uid + '.completeoperate');
// let checkCode = settingModel.cipheriv("20000190"+ ".completeoperate");
res.display('index', {
module: 'me',
page: 'setting',
isMe: true,
content: Object.assign({
region: passportHelper.getCountry(),
location: '+86',
nav: mcHandler.getMeCrumb('个人设置'),
navigation: mcHandler.getSideMenu('个人设置'),
banner: 'http://placehold.it/150x120',
operateStep: true,
stepUrl: '/me/setting/step3/' + type,
captchaUrl: captchaUrl,
checkCode: checkCode
}, result)
});
}
let result = {
title: _getTitle(type).typeName,
proTitle: _getTitle(type).proName,
isShowMobile: _getTitle(type).isModifyMobile || _getTitle(type).isBindMobile,
isShowEmail: _getTitle(type).isModifyEmail || _getTitle(type).isBindEmail,
isShowPassword: _getTitle(type).isShowPassword
};
res.display('index', {
module: 'me',
page: 'setting',
isMe: true,
content: Object.assign({
region: passportHelper.getCountry(),
location: '+86',
nav: mcHandler.getMeCrumb('个人设置'),
navigation: mcHandler.getSideMenu('个人设置'),
banner: 'http://placehold.it/150x120',
step2: true,
stepUrl: '/me/setting/step3/' + type,
captchaUrl: captchaUrl
}, result)
});
};
/*
... ... @@ -236,31 +264,37 @@ const edit = (req, res)=> {
* */
const success = (req, res)=> {
let type = req.params.type;
let code = settingModel.decipheriv(req.query.checkCode.split(' ').join('+'));
let codes = code.split('.');
let result = {
title: _getTitle(type).typeName,
proTitle: _getTitle(type).proName,
isModifyMobile: _getTitle(type).isModifyMobile,
isBindMobile: _getTitle(type).isBindMobile,
isModifyEmail: _getTitle(type).isModifyEmail,
isBindEmail: _getTitle(type).isBindEmail,
isShowPassword: _getTitle(type).isShowPassword
};
if (codes[0] === req.user.uid && codes[1] === 'completeoperate') {
// if (codes[0] === "20000190" && codes[1] === "completeoperate") {
let result = {
title: _getTitle(type).typeName,
proTitle: _getTitle(type).proName,
isModifyMobile: _getTitle(type).isModifyMobile,
isBindMobile: _getTitle(type).isBindMobile,
isModifyEmail: _getTitle(type).isModifyEmail,
isBindEmail: _getTitle(type).isBindEmail,
isShowPassword: _getTitle(type).isShowPassword
};
res.display('index', {
module: 'me',
page: 'setting',
isMe: true,
content: Object.assign({
region: passportHelper.getCountry(),
location: '+86',
nav: mcHandler.getMeCrumb('个人设置'),
navigation: mcHandler.getSideMenu('个人设置'),
banner: 'http://placehold.it/150x120',
successStep: true,
captchaUrl: captchaUrl
}, result)
});
}
res.display('index', {
module: 'me',
page: 'setting',
isMe: true,
content: Object.assign({
region: passportHelper.getCountry(),
location: '+86',
nav: mcHandler.getMeCrumb('个人设置'),
navigation: mcHandler.getSideMenu('个人设置'),
banner: 'http://placehold.it/150x120',
step3: true,
captchaUrl: captchaUrl
}, result)
});
};
/*
... ... @@ -269,6 +303,8 @@ const success = (req, res)=> {
const validate1 = (req, res)=> {
co(function *() {
let type = req.params.type;
// let uid = req.user.uid || "20000190";
let uid = req.user.uid;
let body = req.body;
... ... @@ -295,6 +331,8 @@ const validate2 = (req, res)=> {
co(function *() {
let type = req.params.type;
let uid = req.user.uid;
// let uid = req.user.uid || "20000190";
let body = req.body;
if (type === 'password') {
... ...
... ... @@ -60,13 +60,13 @@
{{#if setting}}
{{> setting}}
{{/if}}
{{#if step1}}
{{#if validateStep}}
{{> setting/act/step1}}
{{/if}}
{{#if step2}}
{{#if operateStep}}
{{> setting/act/step2}}
{{/if}}
{{#if step3}}
{{#if successStep}}
{{> setting/act/step3}}
{{/if}}
... ...
... ... @@ -12,15 +12,14 @@
<div class="form-group">
<lable class="label-name">已绑定的手机号码:</lable>
<p id="cur-mobile">{{ellipsisMobile}}</p>
<input id="real-mobile" type="hidden" value="{{mobile}}">
<input id="real-mobile" type="hidden" value="{{verify_mobile}}">
<input type="hidden" id="checkCode" value="{{checkCode}}">
</div>
{{/data}}
<div class="form-group">
<lable class="label-name">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;手机验证码:</lable>
<lable class="label-name">手机验证码:</lable>
<input id="msg-code" type="text" class="input small-input">
<span id="send-code" class="btn white">发送验证码</span>
<span class="tips-success blue ok">成功</span>
<span class="tips-error notok">失败</span>
</div>
<div class="form-group">
<span id="mobile-step1" class="btn submit">提交</span>
... ... @@ -33,9 +32,8 @@
<div class="form-group">
<lable class="label-name">已绑定的邮箱:</lable>
<p>{{ellipsisEmail}}</p>
<!--<p>169****691@qq.com</p>-->
<input type="hidden" id="real-email" value="{{email}}">
<!--<input type="hidden" id="real-email" value="1691164691@qq.com">-->
<input type="hidden" id="real-email" value="{{verify_email}}">
<input type="hidden" id="checkCode" value="{{checkCode}}">
</div>
{{/data}}
<div class="form-group">
... ... @@ -61,14 +59,15 @@
<div class="form-group">
<lable class="label-name">请输入登录密码:</lable>
<input id="verifyPwd" type="password" class="input">
<input type="hidden" id="checkCode" value="{{checkCode}}">
</div>
<div class="form-group">
<lable class="label-name">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码:</lable>
<input id="captcha" type="text" class="input small-input">
<img id="captcha-img" class="captcha-img" src="{{captchaUrl}}" alt="">
<a class="change-captcha operation"><span class="iconfont gray operation">&#xe613;</span></a>
<span class="tips-success blue ok">成功</span>
<span class="tips-error notok">失败</span>
<span class="tips-success blue ok">{{> icon/round-hook}}</span>
<span class="tips-error notok">{{> icon/error-round}}</span>
</div>
<div class="form-group">
<span id="pwd-step1" class="btn submit">提交</span>
... ...
... ... @@ -17,11 +17,12 @@
</select>
<span id="country-code" class="country-code">{{location}}</span>
<input id="real-mobile" type="text" class="input">
<span class="tips-success blue ok">成功</span>
<span class="tips-error notok">失败</span>
<span class="tips-success blue ok">{{> icon/round-hook}}</span>
<span class="tips-error notok">{{> icon/error-round}}</span>
<input type="hidden" id="checkCode" value="{{checkCode}}">
</div>
<div class="form-group">
<lable class="label-name">&nbsp;&nbsp;手机验证码:</lable>
<lable class="label-name">手机验证码:</lable>
<input id="msg-code" type="text" class="input small-input">
<span id="send-code2" class="btn white">发送验证码</span>
</div>
... ... @@ -35,9 +36,10 @@
<div class="form-group">
<lable class="label-name">我的邮箱:</lable>
<input type="text" class="input">
<input type="hidden" id="checkCode" value="{{checkCode}}">
</div>
<div class="form-group">
<lable class="label-name">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码:</lable>
<lable class="label-name">验证码:</lable>
<input id="captcha" type="text" class="input small-input">
<img id="captcha-img" class="captcha-img" src="{{captchaUrl}}" alt="">
<a class="change-captcha operation"><span class="iconfont gray operation">&#xe613;</span></a>
... ... @@ -59,20 +61,21 @@
<div class="form-group">
<lable class="label-name">输入新密码:</lable>
<input id="newPwd" type="password" class="input">
<input type="hidden" id="checkCode" value="{{checkCode}}">
</div>
<div class="form-group">
<lable class="label-name">验证新密码:</lable>
<input id="checkPwd" type="password" class="input">
<span class="tips-success blue ok">成功</span>
<span class="tips-error notok">失败</span>
<span class="tips-success blue ok">{{> icon/round-hook}}</span>
<span class="tips-error notok">{{> icon/error-round}}</span>
</div>
<div class="form-group">
<lable class="label-name">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码:</lable>
<lable class="label-name">验证码:</lable>
<input id="captcha" type="text" class="input small-input">
<img id="captcha-img" class="captcha-img" src="{{captchaUrl}}" alt="">
<a class="change-captcha operation"><span class="iconfont gray operation">&#xe613;</span></a>
<span class="tips-success blue ok">成功</span>
<span class="tips-error notok">失败</span>
<span class="tips-success blue ok">{{> icon/round-hook}}</span>
<span class="tips-error notok">{{> icon/error-round}}</span>
</div>
<div class="form-group">
<span id="step2-pwd" class="btn submit">提交</span>
... ...
... ... @@ -8,28 +8,28 @@
</div>
{{#if isModifyMobile}}
<div class="operate2">
<p class="bold">恭喜您,您已经成功更换了绑定手机</p>
<p>今后您可以使用新的手机号码+密码尽情登录</p>
<p class="bold"><span>{{> icon/round-hook}}</span>恭喜您,您已经成功更换了绑定手机</p>
<p>今后您可以使用新的手机号码+密码进行登录</p>
</div>
{{/if}}
{{#if isModifyEmail}}
<div class="operate2">
<p class="bold">恭喜您,您已经成功修改了绑定邮箱</p>
<p class="bold"><span>{{> icon/round-hook}}</span>恭喜您,您已经成功修改了绑定邮箱</p>
</div>
{{/if}}
{{#if isShowPassword}}
<div class="operate2">
<p class="bold">恭喜您,您已经成功修改了登录密码</p>
<p class="bold"><span>{{> icon/round-hook}}</span>恭喜您,您已经成功修改了登录密码</p>
</div>
{{/if}}
{{#if isBindMobile}}
<div class="operate2">
<p class="bold">恭喜您,您已经成功绑定手机!</p>
<p class="bold"><span>{{> icon/round-hook}}</span>恭喜您,您已经成功绑定手机!</p>
</div>
{{/if}}
{{#if isBindEmail}}
<div class="operate2">
<p class="bold">恭喜您,您已经成功绑定了邮箱</p>
<p class="bold"><span>{{> icon/round-hook}}</span>恭喜您,您已经成功绑定了邮箱</p>
</div>
{{/if}}
</div>
... ...
... ... @@ -4,6 +4,7 @@
<input id="gender" type="hidden" value="{{info.gender}}">
<input id="area_code" type="hidden" value="{{concat.area_code}}">
<input id="zip_code" type="hidden" value="{{concat.zip_code}}">
<input id="infoMobile" type="hidden" value="{{info.mobile}}">
<div class="form-group">
<label class="label-name">真实姓名:</label>
<input id="username" class="input" type="text" placeholder="请输入2-12个汉字或英文"
... ... @@ -54,6 +55,7 @@
<div class="form-group">
<label class="label-name">出生日期:</label>
<input id="birthday" class="input" type="text" value="{{info.birthday}}">
<span class="blue error-tips">{{> icon/error-round}}出生日期格式不对</span>
</div>
<div class="form-group-address">
<label class="label-name">居住地址:</label>
... ...
... ... @@ -18,5 +18,5 @@ module.exports = app => {
app.use('/editorial', require('./apps/editorial')); // 资讯
app.use('/product', require('./apps/product'));
app.use('/brand', require('./apps/brand')); // 品牌
app.use('/api', require('./apps/api')); // API
app.use('/api', require('./doraemon/api')); // API
};
... ...
/**
* sub app api
* sub app shopping
* @author: jinhu.dong<jinhu.dong@yoho.cn>
* @date: 2016/07/21
* @date: 2016/07/04
*/
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
var express = require('express');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: ['./views/partial', `${doraemon}/partial`],
helpers: 'helpers'
}));
console.log('api.............');
// router
app.use(require('./router'));
... ...
/**
* router of sub app api
* router of sub app shopping
* @author: jinhu.dong<jinhu.dong@yoho.cn>
* @date: 2016/07/21
* @date: 2016/07/04
*/
'use strict';
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const apiCtrl = require(`${cRoot}/api`);
const uploadApi = require('./upload/upload.js');
router.post('/uploadImg', apiCtrl.uploadImg);
router.post('/uploadImg', uploadApi.uploadImg);
module.exports = router;
... ...
/**
* 公共接口 controller
* 公共接口
* @author: jinhu.dong<jinhu.dong@yoho.cn>
* @date: 2016/07/21
*/
'use strict';
var requestPromise = require('request-promise');
var request = require('request');
var fs = require('fs');
const uploadImg = (req, res) => {
console.log('-----uploadImg:');
const getImgHost = function(url) {
let urlArr = url.split('/'),
domain = 'static.yhbimg.com/goodsimg',
num = urlArr[urlArr.length - 1].substr(1, 1),
url1 = domain + url;
if (num === 1) {
return 'http://img11.' + url1;
} else {
return 'http://img12.' + url1;
}
};
const uploadImg = (req, res) => {
let files, fileIndex;
let ret, imgs, datas;
let imgs, datas;
let flag;
let i = 0;
if (req.user.uid) {
console.log('req.files...', JSON.stringify(req.files));
console.log('req.body.bucket:', req.body.bucket);
files = [req.files.filename];
// 判断是单张传还是多张传
flag = Object.prototype.toString.call(files) === '[object Array]';
console.log('files...', files);
// 如果是单张,则数组化
if (!flag) {
files = [req.files.filename];
}
console.log('upload files....', files);
req.body.files = [];
req.body.fileNames = [];
... ... @@ -41,25 +47,22 @@ const uploadImg = (req, res) => {
req.body.fileNames[fileIndex] = files[fileIndex].name;
}
console.log('upload files path:', JSON.stringify(req.body.files));
console.log('upload files names:', JSON.stringify(req.body.fileNames));
if (req.body.bucket === 'goodsimg') {
requestPromise({
request.post({
url: 'http://upload.static.yohobuy.com',
method: 'POST',
body: {
formData: {
fileData: req.body.files,
project: req.body.bucket
}
}).then((error, httpResponse, rebody) => {
},
json: true
}, function(error, httpResponse, rebody) {
if (!error && httpResponse.statusCode === 200) {
ret = JSON.parse(rebody);
imgs = ret.data.imagesList || [];
imgs = rebody.data.imagesList || [];
datas = [];
// 生成图片绝对地址
for (i = 0; i < imgs.length; i++) {
// datas.push(Utils.joinImg(imgs[i]));
datas.push(getImgHost(imgs[i]));
}
}
... ...
... ... @@ -7,8 +7,11 @@
'use strict';
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
// const cRoot = './controllers';
const apiCtrl = require(`${cRoot}/api`);
router.post('/uploadImg', apiCtrl.uploadImg);
module.exports = router;
... ...
... ... @@ -55,6 +55,7 @@
"passport-sina": "^0.1.0",
"passport-strategy": "1.x.x",
"passport-weixin": "^0.1.0",
"request": "^2.73.0",
"request-promise": "^3.0.0",
"serve-favicon": "^2.3.0",
"uuid": "^2.0.2",
... ...
... ... @@ -30,6 +30,17 @@ var Bll = {
html.push('</form>');
return html.join('');
},
validate: function(info) {
var reg = new RegExp(/^[1-2][0-9][0-9][0-9]-[0-1]{0,1}[0-9]-[0-3]{0,1}[0-9]$/);
var birthdayForm = $('#birthday');
var flag = true;
!reg.test(info.birthday) ? birthdayForm.next().show() : birthdayForm.next().hide();
if (!reg.test(info.birthday)) {
flag = false;
}
return flag;
}
};
... ... @@ -116,33 +127,38 @@ $(function() {
gender: $('#gender').val(),
birthday: $('#birthday').val(),
area_code: area.split(',')[2],
mobile: '15195959898',
// todo 手机号码老接口必填
mobile: $('#infoMobile').val(),
full_address: $('#full_address').val(),
// todo 邮编老接口必填字段
zip_code: $('#zip_code').val() || '210000'
};
$.ajax({
type: 'POST',
url: '/me/setting/editUserInfo',
dataType: 'json',
data: body,
success: function(data) {
var len = 0;
data.forEach(function(x) {
if (x.code === 200) {
len++;
// console.log(body);
if (Bll.validate(body)) {
$.ajax({
type: 'POST',
url: '/me/setting/editUserInfo',
dataType: 'json',
data: body,
success: function(data) {
var len = 0;
data.forEach(function(x) {
if (x.code === 200) {
len++;
}
});
if (len === 2) {
new _alert('修改成功!').show();
} else {
new _alert('修改失败!').show();
}
});
if (len === 2) {
new _alert('修改成功!').show();
} else {
new _alert('修改失败!').show();
}
}
});
});
}
});
});
... ...
... ... @@ -61,7 +61,6 @@ $sms.click(function() {
$('#mobile-step1').click(function() {
var code = $('#msg-code').val().trim();
var mobile = $('#real-mobile').val();
var self = $('#msg-code').parent();
var area = '+86';
$.ajax({
... ... @@ -74,47 +73,16 @@ $('#mobile-step1').click(function() {
},
success: function(data) {
if (data.code === 200) {
self.find('.tips-success').addClass('ok').show();
self.find('.tips-error').removeClass('notok').hide();
location.href = '/me/setting/step2/' + type;
location.href = '/me/setting/step2/' + type + '?checkCode=' + $('#checkCode').val();
} else {
// location.href = '/me/setting/step2/' + type + "?checkCode=" + $("#checkCode").val();
new _alert('验证码不正确!').show();
self.find('.tips-success').removeClass('ok').hide();
self.find('.tips-error').addClass('notok').show();
$('#msg-code').val('');
}
}
});
});
/**
* 邮箱验证
*/
$('#email-step1').click(function() {
var a = $('.notok').length;
if (a === 0) {
$.ajax({
type: 'POST',
url: '/me/setting/step1/email',
data: {
email: $('#real-email').val()
},
success: function(data) {
// todo 发送邮件
if (data.code === 200) {
$('.operate1').hide();
$('.operate2').show();
$('.footer-tips').eq(0).hide();
$('.footer-tips').eq(2).show();
} else {
new _alert(data.message).show();
}
}
});
}
});
/**
* 密码校验
... ... @@ -162,7 +130,7 @@ $('#pwd-step1').click(function() {
},
success: function(data) {
if (data.code === 200) {
location.href = '/me/setting/step2/' + type;
location.href = '/me/setting/step2/' + type + '?checkCode=' + $('#checkCode').val();
} else {
new _alert('登录密码校验错误!').show();
}
... ... @@ -170,3 +138,31 @@ $('#pwd-step1').click(function() {
});
}
});
/**
* 邮箱验证
*/
$('#email-step1').click(function() {
if ($('.notok').length === 0) {
$.ajax({
type: 'POST',
url: '/me/setting/step1/email',
data: {
email: $('#real-email').val()
},
success: function(data) {
// todo 发送邮件
if (data.code === 200) {
$('.operate1').hide();
$('.operate2').show();
$('.footer-tips').eq(0).hide();
$('.footer-tips').eq(2).show();
} else {
new _alert(data.message).show();
}
}
});
}
});
... ...
... ... @@ -124,7 +124,7 @@ $('#mobile-step2').click(function() {
if (data.code === 200) {
self.find('.tips-success').addClass('ok').show();
self.find('.tips-error').removeClass('notok').hide();
location.href = '/me/setting/step3/' + type;
location.href = '/me/setting/step3/' + type + '?checkCode=' + $('#checkCode').val();
} else {
new _alert(data.message).show();
self.find('.tips-success').removeClass('ok').hide();
... ... @@ -187,8 +187,9 @@ $('#step2-pwd').click(function() {
},
success: function(data) {
if (data.code === 200) {
location.href = '/me/setting/step3/modifyPassword';
location.href = '/me/setting/step3/' + type + '?checkCode=' + $('#checkCode').val();
} else {
// location.href = '/me/setting/step3/' + type + "?checkCode=" + $("#checkCode").val();
new _alert(data.message).show();
}
}
... ...
... ... @@ -5,6 +5,7 @@
border-bottom: 1px solid #eee;
padding-left: 300px;
padding-bottom: 5px;
overflow: hidden;
li {
float: left;
... ...
.progress {
margin: 5px 195px 0;
width: 600px;
margin: 5px auto;
height: 300px;
.progress-pic1 {
... ... @@ -32,23 +33,25 @@
}
.operate1,
.operate2 {
margin: 50px 0 0 100px;
margin: 50px 0;
.form-group {
clear: both;
width: 640px;
margin-bottom: 20px;
width: 600px;
margin: 10px auto;
padding-left: 100px;
.label-name {
font-size: 14px;
text-align: left;
float: left;
text-align: right;
line-height: 26px;
margin-right: 30px;
margin-right: 20px;
width: 150px;
display: inline-block;
}
p {
line-height: 26px;
display: inline-block;
}
span {
display: inline-block;
... ... @@ -61,6 +64,10 @@
display: inline-block;
height: 26px;
}
span {
font-size: 14px;
margin-left: 5px;
}
.tips-success {
display: none;
}
... ... @@ -69,27 +76,30 @@
display: none;
}
.white {
width: 100px;
width: 120px;
}
select {
height: 26px;
}
.submit {
margin-left: 150px;
}
}
}
.operate2 {
margin: 50px 0 0 100px;
p {
padding-bottom: 20px;
text-align: center;
font-size: 18px;
span {
color: #369ed6;
}
}
.btn {
width: 90px;
}
}
}
.submit {
margin-left: 150px;
}
... ...