Authored by zzzzzzz

fucking php

// 消息 by acgpiano
"use strict";
const headerModel = require('../../../doraemon/models/header'), // 头部model
model = require('../models/message');
const _getList = (req, res, next) => {
model.getList({
page: req.body.page,
size: 20,
}).then(result => {
let options = {
module: 'home',
page: 'message',
pageHeader: headerModel.setNav({
navTitle: '我的消息'
}),
title: '我的消息',
pageFooter: true,
list: result,
};
req.body.page && req.body.page !== '1' && (options.layout = false);
res.render('message', options);
}).catch(next);
}
const _msgDetail = (req, res, next) => {
model.getList({
page: req.body.page,
size: 1000,
msgid: req.query.id,
}).then(result => {
let options = {
pageHeader: headerModel.setNav({
navTitle: '我的消息'
}),
title: '我的消息',
pageFooter: true,
info: result,
};
res.render('message-detail', options);
}).catch(next);
}
exports.index = (req, res, next) => {
if (!req.query.id) {
_getList(req, res, next);
} else {
_msgDetail(req, res, next);
}
}
\ No newline at end of file
... ...
// 消息 by acgpiano
"use strict";
const api = global.yoho.API;
//获取列表页
const _list = (result) => {
let final = [];
if (result.data && result.data.list) {
for (let item of result.data.list) {
final.push({
id: item.id,
isNotReaded: item.is_read === 'Y' ? false : true,
title: item.title,
});
}
}
return final;
}
//获取生日信息
const _getBirthCouponById = (uid) => {
return api.get('', {
method: 'app.promotion.queryBirthCoupon',
uid: uid,
couponType: 4,
});
}
//获取详情页
const _detail = (result, id, uid) => {
let final = {};
if (result.data && result.data.list) {
for (let item of result.data.list) {
if (item.id === Number(id) && item.type !== 'showGetCoin' && item.type !== 'notice') {
final.sender = item.from;
final.title = item.title;
final.time = 11; //时间
//判断消息类型
switch (item['type']) {
case 'pullCoupon':
//领取生日券消息
final['coupons'] = [];
coupondata = _getBirthCouponById(uid); //获取优惠券信息
if (coupondata && coupondata['data']) {
for (let item of coupondata['data']) {
final['coupons'].push({
'id': item['id'] ? item['id'] : '',
'remark': item['couponName'] ? item['couponName'] : '',
'useTime': item['body']['use_time'] ? item['body']['use_time'] : '',
'pickTime': item['body']['collar_time'] ? item['body']['collar_time'] : '',
'canPick': true
});
}
}
break;
case 'button':
//促销活动
final['sale'] = {
'image': item['body']['image'] ? item['body']['image'] : '',
'content': item['body']['text'] ? item['body']['text'] : '',
'btnLink': item['body']['pc_link'] ? item['body']['pc_link'] : '',
'btnName': item['body']['button_text'] ? item['body']['button_text'] : '',
}
break;
case 'pushCoupon':
//查看优惠券
final['coupons'] = [];
final['coupons'].push({
'remark': item['body']['coupon_name'] ? item['body']['coupon_name'] : '',
'useTime': item['body']['time'] ? item['body']['time'] : '',
'id': item['body']['inboxId'] ? item['body']['inboxId'] : '',
'price': item['body']['price'] ? item['body']['price'] : '',
//'url' : Helpers::url('/home/coupons', array('t' => microtime(true)))
});
break;
default:
//普通文本
final['text'] = {
'content': item['body']['content'] ? item['body']['content'] : '',
};
break;
}
}
}
}
return final;
}
const getList = (params) => {
return api.get('', {
method: 'app.inbox.getlist',
page: params.page || 1,
size: params.size || 10,
uid: params.uid || 15184104,
}).then(result => {
if (params.msgid) {
return _detail(result, params.msgid, params.uid);
} else {
return _list(result);
}
});
}
module.exports = {
getList,
}
\ No newline at end of file
... ...
... ... @@ -19,6 +19,7 @@ const orderDetailController = require(`${cRoot}/orderDetail`);
const currencyController = require(`${cRoot}/myCurrency`);
const coupons = require(`${cRoot}/coupons`);
const help = require(`${cRoot}/help`);
const message = require(`${cRoot}/message`);
// const myDetail = require(`${cRoot}/myDetail);
... ... @@ -75,4 +76,6 @@ router.post('/couponData', coupons.couponData);
router.get('/help', help.index);
router.get('/helpDetail', help.helpDetail);
// 消息
router.use('/message', message.index);
module.exports = router;
\ No newline at end of file
... ...
<div class="massage-page yoho-page">
{{#info}}
<div class="massage-main">
<h6>{{title}}</h6>
<span>{{sender}} 发送于{{time}}</span>
</div>
{{#if text}}
<div class="massage-main">
{{#text}}
<!-- 文本消息 -->
<p>{{{content}}}</p>
{{/text}}
</div>
{{/if}}
{{#if coupons}}
{{#coupons}}
<!-- 优惠券消息 -->
<div class="coupon-item">
<div class="coupon-img">
<img src="http://static.yohobuy.com/images/v2/activity/default_coupon.jpg">
</div>
<div class="coupon-info">
<p>{{remark}}</p>
{{#if url}}
<p>面值:<span>{{price}}</span></p>
<p>有效期:{{useTime}}</p>
{{^}}
<p>使用时间:{{useTime}}</p>
<p>领取时间:{{pickTime}}</p>
{{/if}}
</div>
<div class="coupon-action">
{{#if url}}
<a href="{{url}}" class="view-coupon-btn">立即查看</a>
{{^}}
<a{{#if canPick}} class="pick-coupon-btn" data-id="{{id}}"{{/if}}>立即领取</a>
{{/if}}
</div>
</div>
{{/coupons}}
{{/if}}
{{#if sale}}
{{#sale}}
<!-- 促销消息 -->
<div class="sale-img">
<img src="{{image}}">
</div>
<br />
<br />
<p>{{{content}}}</p>
<br />
<br />
<a href="{{btnLink}}" class="sale-btn">{{btnName}}</a>
{{/sale}}
{{/if}}
{{/info}}
</div>
\ No newline at end of file
... ...
<div class="massage-page yoho-page">
{{#list}}
<div class="massage-list">
{{#if isNotReaded}}
<strong></strong>
{{/if}}
<p><a href="//m.yohobuy.com/home/message?id={{id}}">{{title}}</a></p>
<span>{{time}}</span>
<i class="iconfont del">&#xe621;</i>
</div>
{{/list}}
</div>
\ No newline at end of file
... ...
/*
* @Description: dialog
* @Time: 2015/11/18
* @author: chenglong.wang
*/
var $ = require('yoho-jquery'),
Handlebars = require('yoho-handlebars'),
Hammer = require('yoho-hammer');
var $dialogWrapper,
dialogTpl,
dialogTemplate;
function getInstance() {
if (dialogTpl === undefined) {
dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
'<div class="dialog-box">' +
'{{# hasHeader}}' +
'{{/ hasHeader}}' +
'<div class="dialog-content">{{dialogText}}</div>' +
'{{# hasFooter}}' +
'<div class="dialog-footer">' +
'{{# leftBtnText}}' +
'<span class="dialog-left-btn tap-hightlight">{{.}}</span>' +
'{{/ leftBtnText}}' +
'{{# rightBtnText}}' +
'<span class="dialog-right-btn tap-hightlight">{{.}}</span>' +
'{{/ rightBtnText}}' +
'</div>' +
'{{/ hasFooter}}' +
'</div>' +
'</div>';
dialogTemplate = Handlebars.compile(dialogTpl);
}
return dialogTemplate;
}
// fullWithBtn是供详情页获取限购码使用的特殊参数
exports.showDialog = function(data, callback, callbackForLeft, fullWithBtn) {
var dialogTemplate = getInstance(),
dialogStr = dialogTemplate(data),
$dialogBox,
defaultHideDuraton,
dialogWrapperHammer;
$('.dialog-wrapper').remove();
$('body').append($(dialogStr));
$dialogBox = $('.dialog-box');
$dialogWrapper = $('.dialog-wrapper');
dialogWrapperHammer = new Hammer(document.getElementById('dialog-wrapper'));
// 显示
if (data.fast) {
$dialogWrapper.css({
display: 'block'
});
} else {
$dialogWrapper.fadeIn();
}
if (fullWithBtn) {
$('.dialog-wrapper .dialog-footer > span').css('width', '100%');
$('.dialog-wrapper .dialog-content').css({
'padding-left': '1.85rem',
'padding-right': '1.85rem'
});
$dialogWrapper.css('z-index', '10');
}
$dialogBox.css({
top: '50%',
marginTop: -($dialogBox.height() / 2)
});
//隐藏
if (data.autoHide) {
defaultHideDuraton = 1000;
if (data.autoHide > 1) {
defaultHideDuraton = data.autoHide;
}
setTimeout(function() {
$dialogWrapper.fadeOut();
}, defaultHideDuraton);
}
//禁止在dialog上可以上下滚动
$dialogWrapper.on('touchmove', function() {
return false;
});
dialogWrapperHammer.on('tap', function(event) {
if ($(event.target).hasClass('dialog-left-btn')) {
if (typeof callbackForLeft === 'function') {
callbackForLeft();
}
$dialogWrapper.fadeOut();
} else if ($(event.target).hasClass('dialog-right-btn')) {
callback();
}
// 防止出现点透问题
event.preventDefault();
event.srcEvent.stopPropagation();
});
};
exports.hideDialog = function() {
$('.dialog-wrapper').remove();
};
... ...
... ... @@ -4,3 +4,4 @@
@import "favorite";
@import "coupons";
@import "ihelp";
@import "message";
... ...
... ... @@ -15,4 +15,3 @@
@import "pay";
@import "yoho-coin-new";
@import "yoho-coin-detail";
@import "message";
... ...