Authored by yyq

Merge branch 'feature/spread' into release/5.9

/**
* 个人中心---我的推广
* @author yyq <yanqing.yang@yoho.cn>
*/
'use strict';
const spreadModel = require('../models/spread');
exports.index = (req, res, next) => {
req.ctx(spreadModel).getIndexData(req.user.uid).then(result => {
res.render('spread', {
page: 'spread',
spread: result
});
}).catch(next);
};
... ...
... ... @@ -31,6 +31,7 @@ const _homeNav = (switcher) => {
{name: '我的评论', href: '/home/comment'},
// {name: '我的投诉', href: '/home/complaints'},
{name: '我的推广', href: '/home/spread'},
{name: '我的信息', href: '/home/message', count: 0},
{
name: '在线客服',
... ...
/**
* 我的消息model
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/8/29
*/
'use strict';
const _ = require('lodash');
const setPager = require(`${global.utils}/pager`).setPager;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getIndexData(uid, page) {
return Promise.all([
this.get({data: {
method: 'app.invitecode.my',
uid: uid
}}),
this.get({data: {
method: 'app.invitecode.detail',
uid: uid,
page: page || 1
}})
]).then(result => {
let resData = _.get(result, '[0].data', {});
let resList = result[1];
if (resList.code === 200) {
let list = _.get(resList, 'data.data', []);
if (!_.isEmpty(list)) {
resData.list = list;
}
Object.assign(resData, setPager(_.get(resList, 'data.total', 1), {page: page}));
}
return resData;
});
}
};
... ...
... ... @@ -21,6 +21,7 @@ const commentController = require(`${cRoot}/comment`);
const consultController = require(`${cRoot}/consult`);
// const complaintsController = require(`${cRoot}/complaints`);
const spreadController = require(`${cRoot}/spread`);
const messageController = require(`${cRoot}/message`);
const returnsController = require(`${cRoot}/returns`);
... ... @@ -68,6 +69,9 @@ router.get('/consult', tabsMiddleware.getCommonHeader, consultController.index);
// router.post('/complaints/submit', complaintsController.submit);
// router.post('/complaints/cancel', complaintsController.cancel);
// 我的推广
router.get('/spread', tabsMiddleware.getCommonHeader, spreadController.index);
// 我的消息
router.get('/message', tabsMiddleware.getCommonHeader, messageController.index);
... ...
<div class="spread-me-page me-page yoho-page clearfix">
{{> path}}
{{> navigation}}
<div class="me-main">
<div class="spread block">
<h2 class="title"></h2>
{{# spread}}
<div class="spread-wrap clearfix">
<div class="item-card">
<span class="tag">邀请二维码</span>
<div class="card-main">
<div class="spread-code" data-url="{{url}}"></div>
</div>
<p>邀请好友扫一扫,下载有货APP,<br>新人立享199元优惠券</p>
</div>
<div class="item-card">
<span class="tag">邀请码</span>
<div class="card-main">
<p class="spread-id">{{inviteCode}}</p>
</div>
<p>1.复制您的邀请码<br>2.粘贴给您的朋友</p>
</div>
<div class="item-card">
<span class="tag">邀请链接</span>
<div class="card-main">
<div class="spread-url">
<input type="text" value="{{url}}" class
="copy-url" readonly="readonly">
<div class="succ-tip">复制成功</div>
</div>
</div>
<p>1.复制您的邀请链接<br>2.选择您的社交平台<br>3.粘贴给您的朋友</p>
</div>
</div>
<div class="my-spread-list">
<table>
<thead>
<tr>
<th>我邀请的好友</th>
<th>注册时间</th>
<th>首单购物金额</th>
<th>订单状态</th>
<th>我的奖励</th>
<th>奖励状态</th>
<th>发放时间</th>
</tr>
</thead>
<tbody>
{{# list}}
<tr>
<td>{{nickName}}</td>
<td>{{registerTimeDis}}</td>
<td>{{orderAmountDis}}</td>
<td>{{paymentStatusDesc}}</td>
<td>{{couponName}}</td>
<td>{{couponStatusDesc}}</td>
<td>{{couponSendTimeDis}}</td>
</tr>
{{/ list}}
{{#unless list}}
<tr><td colspan="7">暂无数据</td></tr>
{{/unless}}
</tbody>
</table>
</div>
{{> pager}}
{{/ spread}}
</div>
</div>
</div>
... ...
... ... @@ -272,7 +272,7 @@ let mobileRegister = (req, res, next) => {
}
/* 手机注册: 调用注册接口*/
let regResult = yield regService.regMobileAes(area, mobile, password, code, cookie.getShoppingKey(req));
let regResult = yield regService.regMobileAes(area, mobile, password, code, cookie.getShoppingKey(req), req.body); // eslint-disable-line
if (!regResult.code || regResult.code !== 200) {
data.message = '注册失败';
... ...
... ... @@ -6,6 +6,8 @@
* 注册 model
*/
'use strict';
const _ = require('lodash');
const aes = require('./aes-pwd');
const api = global.yoho.API;
... ... @@ -30,7 +32,7 @@ let validMobileCode = (area, mobile, code) => {
return api.post('', params);
};
let regMobileAes = (area, mobile, password, code, shoppingKey)=> {
let regMobileAes = (area, mobile, password, code, shoppingKey, extParam)=> {
let params = {
method: 'app.passport.registerAES',
area: area,
... ... @@ -43,6 +45,12 @@ let regMobileAes = (area, mobile, password, code, shoppingKey)=> {
params.shopping_key = shoppingKey;
}
if (extParam) {
if (extParam.inviteCode) {
params.inviteCode = _.replace(extParam.inviteCode, /[^(0-9a-zA-Z)]/ig, '');
}
}
return api.post('', params);
};
... ...
... ... @@ -37,6 +37,10 @@
</div>
</li>
<li class="clearfix" data-index="3">
<input id="invite-code" class="input invite-code" name="inviteCode" placeholder="邀请码" autocomplete="off" maxlength="20" type="text">
</li>
<li class="items-container clearfix">
<input id="agree-terms" class="agree-terms" type="checkbox" checked="">
<span>
... ...
... ... @@ -25,6 +25,7 @@
"body-parser": "^1.15.0",
"cheerio": "^0.22.0",
"client-sessions": "^0.7.0",
"clipboard": "^1.7.1",
"compression": "^1.6.2",
"connect-memcached": "^0.2.0",
"connect-multiparty": "^2.0.0",
... ...
/**
* 我的推广
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2017/6/22
*/
var $ = require('yoho-jquery');
var Clipboard = require('clipboard');
var $copySuccTip = $('.succ-tip'),
$qrcodeImg = $('.spread-code');
var clipboard;
require('../common');
require('yoho-jquery-qrcode');
// 生成二维码
$qrcodeImg.qrcode({
render: 'div', // 显示方式,canvas,image和div
text: $qrcodeImg.data('url'), // 二维码的内容
size: parseInt($qrcodeImg.width(), 10) // 大小
});
clipboard = new Clipboard('.copy-url', {
text: function(trigger) {
return trigger.value;
}
});
clipboard.on('success', function() {
$copySuccTip.show();
setTimeout(function() {
$copySuccTip.fadeOut();
}, 2000);
});
... ...
... ... @@ -21,6 +21,7 @@ var $sendCaptcha = $('#send-captcha'),
var $pn = $('#phone-num'),
$mc = $('#msg-captcha'),
$pwd = $('#pwd'),
$ic = $('#invite-code'),
getCaptchaImageVal = function() {
return captchaImage.getResults();
},
... ... @@ -621,7 +622,8 @@ exports.init = function(page) {
mobile: $pn.val(),
verifyCode: getCaptchaImageVal(),
code: $mc.val(),
password: $pwd.val()
password: $pwd.val(),
inviteCode: $ic.val()
}
}).then(function(data) {
... ...
... ... @@ -321,6 +321,7 @@
@import "comment";
@import "consult";
@import "complaints";
@import "spread";
@import "message";
@import "message-detail";
@import "returns";
... ...
.spread-me-page {
font-size: 12px;
.spread-wrap {
padding: 10px;
.item-card {
width: 252px;
float: left;
height: 180px;
box-sizing: border-box;
border: 1px solid #dedede;
position: relative;
margin-left: 11px;
> p {
text-align: center;
line-height: 1.4;
}
}
.item-card:first-child {
margin-left: 0;
}
.tag {
width: 76px;
height: 24px;
line-height: 24px;
background-color: #000;
color: #fff;
text-align: center;
position: absolute;
font-weight: 300;
}
.card-main {
height: 80px;
line-height: 80px;
padding-top: 30px;
text-align: center;
> * {
display: inline-block;
}
}
.spread-code {
width: 70px;
height: 70px;
}
.spread-id {
font-size: 38px;
}
.spread-url {
width: 94%;
height: 34px;
line-height: 32px;
border: 1px solid #dedede;
background-color: #f5f5f5;
position: relative;
cursor: pointer;
> input {
width: 100%;
height: 100%;
border: 0;
padding: 0 10px;
box-sizing: border-box;
background: none;
}
.succ-tip {
position: absolute;
width: 100%;
height: 32px;
color: #89c54d;
overflow: hidden;
background-color: #f5f5f5;
top: 1px;
display: none;
}
}
}
.my-spread-list {
padding: 10px;
margin-bottom: 10px;
table {
width: 100%;
}
tr {
border: 1px solid #dedede;
}
th {
background-color: #efefef;
line-height: 30px;
text-align: center;
}
td {
line-height: 20px;
padding: 14px 0;
text-align: center;
}
}
}
... ...