Authored by 郝肖肖

'有赚列表'

... ... @@ -7,15 +7,17 @@ const headerModel = require('../../../doraemon/models/header');
class HaveGain {
// 列表
index(req, res, next) {
return req.ctx(haveGainModel).index({}).then(result => {
let uid = req.user.uid;
return req.ctx(haveGainModel).index({uid}).then(gainList => {
return res.render('have-gain/index', {
module: 'activity',
page: 'have-gain-index',
width750: true,
localCss: true,
title: '有货有赚',
result,
pageHeader: headerModel.setNav({
gainList,
pageHeader: !req.yoho.isApp && headerModel.setNav({
navTitle: '有货有赚',
navBtn: false
}),
... ... @@ -31,7 +33,7 @@ class HaveGain {
width750: true,
localCss: true,
title: '有货有赚',
pageHeader: headerModel.setNav({
pageHeader: !req.yoho.isApp && headerModel.setNav({
navTitle: '有货有赚',
navBtn: false
}),
... ... @@ -40,7 +42,7 @@ class HaveGain {
// 审核中
verify(req, res, next) {
return req.ctx(haveGainModel).index({}).then(result => {
return req.ctx(haveGainModel).invitecode({}).then(result => {
return res.render('have-gain/verify', {
module: 'activity',
page: 'have-gain-verify',
... ... @@ -48,7 +50,7 @@ class HaveGain {
localCss: true,
title: '有货有赚',
result,
pageHeader: headerModel.setNav({
pageHeader: !req.yoho.isApp && headerModel.setNav({
navTitle: '有货有赚',
navBtn: false
}),
... ...
'use strict';
const helpers = global.yoho.helpers;
const _ = require('lodash');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
index(params) {
return Promise.resolve(params);
}
return Promise.all([
this.invitecode(params),
this.checkApply(params)
]).then(res => {
let checkStatus = _.get(res[1], 'data.status', 0);
let checkUrl = helpers.urlFormat('/activity/have-gain/apply', {}); // 未申请
submitApply(params) {
let options = {
data: {
method: 'app.promotion.validateGetBirthCoupon',
uid: params.uid
if (checkStatus === 1) { // 审核中
checkUrl = helpers.urlFormat('/activity/have-gain/verify', {});
} else if (checkStatus === 2) { // 审核成功
checkUrl = 'https://activity.yoho.cn/feature/2213.html?title=说明详情&openby:yohobuy={"action":"go.h5","params":{"title": "说明详情", url":"https://activity.yoho.cn/feature/2213.html"}}'; // eslint-disable-line
}
};
return this.get(options);
let share = (_.get(res[0], 'data.context', '')).match(/(\d+)/g);
let gainList = [
{
url: _.get(res[0], 'data.url', ''),
img: '//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/{mode}/w/{width}/h/{height}', // eslint-disable-line
totalUser: _.get(share, '[0]', 0),
totalCouponNum: _.get(share, '[1]', 0),
isShow: true
}, {
url: checkUrl,
img: '//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/{mode}/w/{width}/h/{height}', // eslint-disable-line
isShow: false
}
];
return gainList;
}).catch(() => {
return [];
});
}
/**
* [查询参与邀请好友数量]
* @param {[type]} params [{uid:''}]
* @return {[type]} [{}]
*/
invitecode(params) {
return this.get({
data: Object.assign({
method: 'app.invitecode.total'
}, params)
});
}
/**
* [检查是否申请]
* @param {[type]} params [{uid: 0}]
* @return {[type]} [{}]
*/
checkApply(params) {
return this.get({
data: Object.assign({
method: 'app.union.shareOrder.checkApply'
}, params)
});
}
/**
* [提交-申请]
* @param {[type]} params [{uid:'',name:'',mobile:'',socialMediaList:[{type:'',account:'',fans:200}]}]
* @return {[type]} [{}]
*/
submitApply(params) {
return this.get({
data: Object.assign({
method: 'app.union.shareOrder.userApply'
}, params)
});
}
};
... ...
... ... @@ -70,6 +70,6 @@
<input type="checkbox" name="check" />
我已阅读并同意<em>《有货有赚推广协议》</em>
</div>
<div class="apply-btn">申请开通</div>
<div class="apply-btn disable">申请开通</div>
</div>
</div>
... ...
<div class="have-gain-index">
<div class="have-gain-item">
<div class="item-img">
<img class="lazy" data-original="//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/2/w/690/h/430/q/60/format/webp" src="//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/2/w/690/h/430/q/60/format/webp">
</div>
<div class="item-footer">
<div class="eps es-left">
<span class="num">7637321</span>
<span class="people">参与人数</span>
</div>
<div class="eps">
<span class="num">7637321</span>
<span class="people">获得优惠券</span>
</div>
<div class="eps">
<div class="accede-btn">立即加入</div>
</div>
</div>
</div>
<div class="have-gain-item">
<div class="item-img">
<img class="lazy" data-original="//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/2/w/690/h/430/q/60/format/webp" src="//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/2/w/690/h/430/q/60/format/webp">
</div>
<div class="item-footer">
<div class="eps">
邀请好友购物返现金
</div>
<div class="eps">
<div class="accede-btn">立即加入</div>
</div>
</div>
</div>
<div class="have-gain-item">
<div class="item-img">
<img class="lazy" data-original="//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/2/w/690/h/430/q/60/format/webp" src="//img10.static.yhbimg.com/article/2017/06/20/12/01a50a1f45b97365e758d6890858998310.jpg?imageView2/2/w/690/h/430/q/60/format/webp">
</div>
<div class="item-footer">
<div class="eps es-left">
<span class="num">7637321</span>
<span class="people">参与人数</span>
</div>
<div class="eps">
<span class="num">7637321</span>
<span class="people">获得优惠券</span>
</div>
<div class="eps">
<div class="accede-btn">立即加入</div>
{{#gainList}}
<div class="have-gain-item">
<div class="item-img">
<img src="{{image img 690 430}}" />
</div>
<div class="item-footer">
{{#if isShow}}
<div class="eps">
<span class="num">{{totalUser}}</span>
<span class="people">参与人数</span>
</div>
<div class="eps">
<span class="num">{{totalCouponNum}}</span>
<span class="people">获得优惠券</span>
</div>
{{else}}
<div class="eps">
邀请好友购物返现金
</div>
{{/if}}
<div class="eps">
<div class="accede-btn"><a href="{{url}}">立即加入</a></div>
</div>
</div>
</div>
</div>
{{/gainList}}
</div>
... ...
import 'activity/have-gain-index.page.css';
import Page from 'yoho-page';
import $ from 'yoho-jquery';
import tip from 'plugin/tip';
class HaveGainIndexPage extends Page {
constructor() {
super();
this.selector = {
$accedeBtn: $('.accede-btn')
};
this.init();
}
init() {
this.bindEvents();
}
bindEvents() {
this.selector.$accedeBtn.on('click', this.tapAccede.bind(this));
}
tapAccede() {
window.location.href = '//m.yohobuy.com/activity/have-gain/apply';
}
apply() {
return this.ajax({
url: '/activity/grade/graph'
}).then(res => {
if (res.code !== 200) {
return tip.show(res.message);
}
});
}
}
$(() => {
new HaveGainIndexPage();
});
... ...
... ... @@ -132,5 +132,9 @@
color: #fff;
text-align: center;
}
.disable {
background-color: #b0b0b0;
}
}
}
... ...
... ... @@ -14,10 +14,7 @@
text-align: center;
height: 120px;
margin-bottom: -30px;
.es-left {
padding-left: 20px;
}
padding-left: 20px;
.eps {
font-family: PingFangSC-Regular, sans-serif;
... ...