Authored by 李靖

接口联调

'use strict';
const headerModel = require('../../../doraemon/models/header'); // 头部model
// const family = require('../models/family');
const family = require('../models/family');
exports.familyIndex = (req, res) => {
// let uid = req.user.uid;
... ... @@ -14,17 +14,33 @@ exports.familyIndex = (req, res) => {
});
};
exports.scoreDetail = (req, res) => {
exports.coinDetail = (req, res) => {
let responseData = {
module: 'home',
page: 'family-score',
page: 'family-coin',
pageHeader: headerModel.setNav({
navTitle: '会员等级'
navTitle: '积分明细'
}),
title: 'YOHO!FAMILY',
title: 'YOHO!积分明细',
width750: true,
localCss: true
};
res.render('family/score-detail', Object.assign(responseData, ''));
res.render('family/coin-detail', Object.assign(responseData, ''));
};
exports.getCoinData = (req, res, next) => {
let params = {
uid: req.user.uid,
source: req.query.source,
queryType: req.query.queryType,
beginTime: req.query.beginTime,
endTime: req.query.endTime,
page: req.query.page,
limit: req.query.limit
};
req.ctx(family).getCoinData(params).then(result => {
res.json(result);
}).catch(next);
};
... ...
'use strict';
const _ = require('lodash');
class familyModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getCoinData(params) {
let options = {
data: {
method: 'app.yohocoin.lists',
uid: params.uid,
source: params.source || '',
queryType: params.queryType || 0,
beginTime: params.beginTime || '',
endTime: params.endTime || '',
page: params.page || 1,
limit: params.limit || 10
},
param: {
code: 200
}
};
return this.get(options).then(result => {
let resu = {
coinList: []
};
let _this = this;
if (_.get(result, 'data.coinlist')) {
_.forEach(result.data.coinlist, function(val) {
Object.assign(val, {
typeName: _this.checkType(val.iconType),
minus: parseInt(val.num, 10) < 0
});
});
resu.coinList = result.data.coinlist;
}
return resu;
});
}
checkType(params) {
switch (params) {
case 1:
return 'yohobuy';
case 2:
return 'mars';
case 3:
return 'yohonow';
case 4:
return 'store';
case 5:
return 'green';
case 6:
return 'coffee';
case 7:
return 'little';
default:
return 'yohobuy';
}
}
}
module.exports = familyModel;
... ...
... ... @@ -178,5 +178,6 @@ router.post('/return/exchange/cancel-apply', auth, exchange.cancelApply); // AJA
router.get('/tide-command', auth, tideCommand.tideCommand); // 设置潮流口令
router.get('/family', auth, family.familyIndex); // family首页
router.get('/family/scoreDetail', auth, family.scoreDetail); // family首页
router.get('/family/coinDetail', auth, family.coinDetail); // 积分详情页
router.get('/family/coinDetail/getCoinData', auth, family.getCoinData); // 筛选积分详情
module.exports = router;
... ...
<div class="yoho-family-page yoho-page">
<div class="score-detail-c">
<div class="tab">
<div id="source" class="tab-item">版块
<span class="iconfont down">&#xe613;</span>
<span class="iconfont up">&#xe612;</span>
<ul class="list">
<li>
全部
<span class="tick"></span>
</li>
<li>
Yoho!Buy
<span class="tick"></span>
</li>
<li>
Yoho!Now
<span class="tick"></span>
</li>
<li>
Mars
<span class="tick"></span>
</li>
<li>
Yo!Coffee
<span class="tick"></span>
</li>
<li>
Yo!Green
<span class="tick"></span>
</li>
<li>
Yo!Little
<span class="tick"></span>
</li>
</ul>
</div>
<div id="queryType" class="tab-item">积分明细
<span class="iconfont down">&#xe613;</span>
<span class="iconfont up">&#xe612;</span>
<ul class="list">
<li data-queryType="0">
全部
<span class="tick"></span>
</li>
<li data-queryType="1">
收入
<span class="tick"></span>
</li>
<li data-queryType="2">
支出
<span class="tick"></span>
</li>
</ul>
</div>
<div id="time" class="tab-item">最近三月
<span class="iconfont down">&#xe613;</span>
<span class="iconfont up">&#xe612;</span>
<ul class="list">
<li>
全部
<span class="tick"></span></li>
<li>
最近三月
<span class="tick"></span>
</li>
<li>
最近六月
<span class="tick"></span>
</li>
<li>
最近一年
<span class="tick"></span>
</li>
</ul>
</div>
</div>
<div class="cover-bg"></div>
<div class="result"></div>
</div>
</div>
\ No newline at end of file
... ...
<div class="yoho-family-page yoho-page">
<div class="score-detail-c">
<div class="tab">
<div class="tab-item">版块
<ul class="list">
<li>全部</li>
<li>Yoho!Buy</li>
<li>Yoho!Now</li>
<li>Mars</li>
<li>Yo!Coffee</li>
<li>Yo!Green</li>
<li>Yo!Little</li>
</ul>
</div>
<div class="tab-item">积分明细
<ul class="list">
<li>全部</li>
<li>收入</li>
<li>支出</li>
</ul>
</div>
<div class="tab-item">最近三月
<ul class="list">
<li>全部</li>
<li>最近三月</li>
<li>最近六月</li>
<li>最近一年</li>
</ul>
</div>
</div>
<div class="cover-bg"></div>
<div class="result">
<div class="result-item">1111</div>
<div class="result-item">1111</div>
<div class="result-item">1111</div>
<div class="result-item">1111</div>
<div class="result-item">1111</div>
<div class="result-item">1111</div>
</div>
</div>
</div>
\ No newline at end of file
{{# coinList}}
<div class="result-item">
<div class="top">
<div class="pic {{typeName}}"></div>
<span class="title eps">{{message}}</span>
<span class="num{{#if minus}} minus{{/if}}">{{num}}</span>
</div>
<div class="bottom">{{date}}</div>
</div>
{{/ coinList}}
\ No newline at end of file
... ...
import 'home/family-coin.page.css';
import $ from 'yoho-jquery';
import Page from 'yoho-page';
import resultRender from 'home/coin-list.hbs';
class ScoreDetail extends Page {
constructor() {
super();
this.selector = {
$coverBg: $('.cover-bg'),
$tabItem: $('.tab-item'),
$scoreDetailC: $('.score-detail-c'),
$chosen: $('.tab-item .list').find('li'),
$defaultChosen: $('.tab-item .list').find('li:first'),
$result: $('.result')
};
this.view = {
resultRender
};
this.source = 0;
this.queryType = 0;
this.beginTime = '';
this.endTime = '';
this.page = 1;
this.loading = false;
this.end = false;
this.init();
}
init() {
this.selector.$defaultChosen.addClass('chosen');
this.setHeight();
this.bindEvents();
this.chosenData();
$(window).scroll(() => {
window.requestAnimationFrame(this.scrollHandler.bind(this));
});
}
scrollHandler() {
if (($(window).scrollTop() + $(window).height() >= $(document).height() * 0.8)) {
this.doMore();
}
}
doMore() {
if (!this.end && !this.loading) {
this.page++;
this.chosenData();
}
}
bindEvents() {
this.selector.$tabItem.on('click', this.tab.bind(this));
this.selector.$coverBg.on('click', this.coverBg.bind(this));
this.selector.$chosen.on('click', this.chosen.bind(this));
}
chosen(e) {
let $this = $(e.currentTarget);
let $parensId = $this.parents('.tab-item').attr('id');
this.selector.$result.empty();
switch ($parensId) {
case 'source':
alert('source');
break;
case 'queryType':
this.queryType = $this.attr('data-queryType');
break;
case 'time':
alert('time');
break;
default:
alert('default');
}
this.end = false;
this.page = 0;
this.chosenData();
$this.addClass('chosen').siblings('li').removeClass('chosen');
return false;
}
setHeight() {
let wHeight = $(window).height();
this.selector.$coverBg.css('min-height', `${wHeight}px`);
}
tab(e) {
let $this = $(e.currentTarget);
// $this.find('li:first').addClass('chosen');
// $this.find('li:first').siblings('li').removeClass('chosen');
if ($this.hasClass('active')) {
$this.removeClass('active');
this.selector.$scoreDetailC.removeClass('active');
} else {
$this.addClass('active');
$this.siblings('.tab-item').removeClass('active');
this.selector.$scoreDetailC.addClass('active');
}
}
coverBg() {
this.selector.$scoreDetailC.removeClass('active');
this.selector.$tabItem.removeClass('active');
}
chosenData() {
this.loading = true;
this.ajax({
url: '/home/family/coinDetail/getCoinData',
data: {
source: this.source,
queryType: this.queryType,
beginTime: this.beginTime,
endTime: this.endTime,
page: this.page
}
}).then(result => {
if (result && result.coinList.length > 0) {
this.selector.$result.append(this.view.resultRender(result));
this.loading = false;
this.selector.$tabItem.removeClass('active');
this.selector.$scoreDetailC.removeClass('active');
} else {
this.end = true;
}
}).catch(error => {
console.error(error);
});
}
}
$(() => {
new ScoreDetail();
});
... ...
require('home/family-score.page.css');
... ... @@ -4,7 +4,14 @@ html {
}
.score-detail-c {
.eps {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.cover-bg {
display: none;
width: 100%;
height: 100%;
position: absolute;
... ... @@ -16,6 +23,12 @@ html {
opacity: 0.4;
}
&.active {
.cover-bg {
display: block;
}
}
.tab {
height: 86px;
border-bottom: solid 1px #e0e0e0;
... ... @@ -34,6 +47,18 @@ html {
color: #1a1a1a;
border-right: solid 1px #e0e0e0;
.down {
display: inline-block;
}
.up {
display: none;
}
.iconfont {
font-size: 12px;
}
&:last-child {
border-right: 0;
}
... ... @@ -42,29 +67,134 @@ html {
display: none;
width: 750px;
text-align: left;
padding-top: 18px;
position: absolute;
padding: 0 30px;
background-color: #fff;
top: 86px;
left: 0;
li {
line-height: 90px;
border-bottom: solid 1px #e0e0e0;
padding: 0 30px;
background-color: #fff;
color: #b0b0b0;
position: relative;
}
li.chosen {
color: #000;
}
.tick {
width: 30px;
height: 22px;
background: url("/home/family/chosen.png");
position: absolute;
top: 34px;
right: 30px;
display: none;
}
li:last-child {
border-bottom: 0;
}
}
li.chosen {
.tick {
display: block;
}
}
&.active {
.list {
display: block;
}
.down {
display: none;
}
.up {
display: inline-block;
}
}
}
}
.result {
padding: 0 34px;
background-color: #fff;
.result-item {
height: 125px;
line-height: 125px;
padding: 0 34px;
background-color: #fff;
border-bottom: solid 1px #e0e0e0;
padding: 20px 0 10px;
.top {
font-size: 28px;
float: left;
line-height: 45px;
width: 100%;
.pic {
width: 40px;
height: 40px;
border-radius: 5px;
overflow: hidden;
float: left;
margin-right: 10px;
}
.pic.coffee {
background: url("/home/family/ico-coffee.png");
}
.pic.green {
background: url("/home/family/ico-green.png");
}
.pic.little {
background: url("/home/family/ico-little.png");
}
.pic.mars {
background: url("/home/family/ico-mars.png");
}
.pic.yohobuy {
background: url("/home/family/ico-yohobuy.png");
}
.pic.store {
background: url("/home/family/ico-yohobuy.png");
}
.pic.yohonow {
background: url("/home/family/ico-yohonow.png");
}
.title {
float: left;
width: 500px;
}
.num {
float: right;
color: #b0b0b0;
}
.num.minus {
color: #43b98a;
}
}
.bottom {
width: 100%;
line-height: 50px;
float: left;
color: #b0b0b0;
font-size: 24px;
}
&:last-child {
border-bottom: 0;
... ...