Authored by yyq

Merge branch 'feature/spread' into release/5.9

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