Showing
18 changed files
with
303 additions
and
295 deletions
@@ -17,7 +17,7 @@ let ALL_TYPES = { | @@ -17,7 +17,7 @@ let ALL_TYPES = { | ||
17 | ellipsis: 'p-pe-n' | 17 | ellipsis: 'p-pe-n' |
18 | }; | 18 | }; |
19 | 19 | ||
20 | -exports.pager = function() { | 20 | +exports.gpager = function() { |
21 | 21 | ||
22 | let options = arguments[arguments.length - 1]; | 22 | let options = arguments[arguments.length - 1]; |
23 | 23 |
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | {{/ msgs}} | 20 | {{/ msgs}} |
21 | </div> | 21 | </div> |
22 | <div class="msg-pager pager"> | 22 | <div class="msg-pager pager"> |
23 | - {{pager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} | 23 | + {{gpager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |
26 | <div class="right-side"> | 26 | <div class="right-side"> |
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | {{> msg}} | 30 | {{> msg}} |
31 | {{/ msgs}} | 31 | {{/ msgs}} |
32 | </div> | 32 | </div> |
33 | - {{pager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} | 33 | + {{gpager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} |
34 | </div> | 34 | </div> |
35 | </div> | 35 | </div> |
36 | <div class="right-side"> | 36 | <div class="right-side"> |
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | {{/ msgs}} | 12 | {{/ msgs}} |
13 | </div> | 13 | </div> |
14 | 14 | ||
15 | - {{pager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} | 15 | + {{gpager baseUrl totalRecords=total page=page type="ellipsis" theme="msg-pager"}} |
16 | </div> | 16 | </div> |
17 | <div class="right-side"> | 17 | <div class="right-side"> |
18 | {{> right-side}} | 18 | {{> right-side}} |
@@ -18,6 +18,6 @@ | @@ -18,6 +18,6 @@ | ||
18 | </li> | 18 | </li> |
19 | {{/ list}} | 19 | {{/ list}} |
20 | </ul> | 20 | </ul> |
21 | - <div class="comment-pager pager">{{pager baseUrl totalRecords=commentNum page=page pageSize=pageSize type="ellipsis" theme="msg-pager"}}</div> | 21 | + <div class="comment-pager pager">{{gpager baseUrl totalRecords=commentNum page=page pageSize=pageSize type="ellipsis" theme="msg-pager"}}</div> |
22 | </div> | 22 | </div> |
23 | {{/ comment}} | 23 | {{/ comment}} |
@@ -9,13 +9,12 @@ const message = require('../models/message'); | @@ -9,13 +9,12 @@ const message = require('../models/message'); | ||
9 | 9 | ||
10 | const index = (req, res, next) => { | 10 | const index = (req, res, next) => { |
11 | let uid = req.user.uid; | 11 | let uid = req.user.uid; |
12 | - let page = req.query.page || 1; | ||
13 | 12 | ||
14 | if (!uid) { | 13 | if (!uid) { |
15 | return next(); | 14 | return next(); |
16 | } | 15 | } |
17 | 16 | ||
18 | - message.getMessageList(uid, page).then(result => { | 17 | + message.getMessageList(uid, req.query || {}).then(result => { |
19 | res.render('message', result); | 18 | res.render('message', result); |
20 | }).catch(next); | 19 | }).catch(next); |
21 | }; | 20 | }; |
@@ -23,13 +22,12 @@ const index = (req, res, next) => { | @@ -23,13 +22,12 @@ const index = (req, res, next) => { | ||
23 | const detail = (req, res, next) => { | 22 | const detail = (req, res, next) => { |
24 | let uid = req.user.uid; | 23 | let uid = req.user.uid; |
25 | let id = parseInt(req.query.id, 10); | 24 | let id = parseInt(req.query.id, 10); |
26 | - let page = req.query.page; | ||
27 | 25 | ||
28 | - if (!uid || !id || !page) { | 26 | + if (!uid || !id) { |
29 | return next(); | 27 | return next(); |
30 | } | 28 | } |
31 | 29 | ||
32 | - message.getMessageDetail(uid, id, page).then(result => { | 30 | + message.getMessageDetail(uid, req.query || {}).then(result => { |
33 | res.render('message-detail', result); | 31 | res.render('message-detail', result); |
34 | }).catch(next); | 32 | }).catch(next); |
35 | }; | 33 | }; |
@@ -10,17 +10,31 @@ const api = global.yoho.API; | @@ -10,17 +10,31 @@ const api = global.yoho.API; | ||
10 | const _ = require('lodash'); | 10 | const _ = require('lodash'); |
11 | const Promise = require('bluebird'); | 11 | const Promise = require('bluebird'); |
12 | 12 | ||
13 | +const userApi = require('./user-api'); | ||
13 | const setPager = require(`${global.utils}/pager`).setPager; | 14 | const setPager = require(`${global.utils}/pager`).setPager; |
14 | 15 | ||
15 | const co = Promise.coroutine; | 16 | const co = Promise.coroutine; |
16 | 17 | ||
17 | -const getMessageAsync = (uid, page, size) => { | 18 | +const getMessageTabList = (uid) => { |
18 | return api.get('', { | 19 | return api.get('', { |
19 | - method: 'app.inbox.getlist', | 20 | + method: 'app.inbox.getAllInboxCatInfo', |
21 | + uid: uid | ||
22 | + }, {code: 200}); | ||
23 | +}; | ||
24 | + | ||
25 | +const getMessageAsync = (uid, page, size, type) => { | ||
26 | + let params = { | ||
27 | + method: 'app.inbox.getlistnew', | ||
20 | uid: uid, | 28 | uid: uid, |
21 | page: page || 1, | 29 | page: page || 1, |
22 | size: size || 10 | 30 | size: size || 10 |
23 | - }, {code: 200}); | 31 | + }; |
32 | + | ||
33 | + if (type) { | ||
34 | + params.displayTab = type; | ||
35 | + } | ||
36 | + | ||
37 | + return api.get('', params, {code: 200}); | ||
24 | }; | 38 | }; |
25 | 39 | ||
26 | const delMessageAsync = (uid, id) => { | 40 | const delMessageAsync = (uid, id) => { |
@@ -66,28 +80,69 @@ const getCouponAsync = (uid) => { | @@ -66,28 +80,69 @@ const getCouponAsync = (uid) => { | ||
66 | * 获取消息列表 | 80 | * 获取消息列表 |
67 | * @function getMessageList | 81 | * @function getMessageList |
68 | * @param { Number } uid 用户uid | 82 | * @param { Number } uid 用户uid |
69 | - * @param { Number } page 页码 | 83 | + * @param { Object } params url参数 |
70 | * @param { Number } limit 每页数目 | 84 | * @param { Number } limit 每页数目 |
71 | * @return { Object } 消息列表数据 | 85 | * @return { Object } 消息列表数据 |
72 | */ | 86 | */ |
73 | -const getMessageList = (uid, page, limit) => { | ||
74 | - let process = function*() { | ||
75 | - let resData = {}; | ||
76 | - let result = yield getMessageAsync(uid, page, limit); | 87 | +const getMessageList = (uid, params, limit) => { |
88 | + let resData = {}; | ||
89 | + let page = parseInt(`0${params.page}`, 10) || 1, | ||
90 | + type = parseInt(`0${params.type}`, 10); | ||
91 | + | ||
92 | + return Promise.all([ | ||
93 | + userApi.getUserInfo(uid), | ||
94 | + getMessageTabList(uid), | ||
95 | + getMessageAsync(uid, page, limit, type) | ||
96 | + ]).then(result => { | ||
97 | + const msgBaseUrl = '/home/message'; | ||
98 | + | ||
99 | + resData.userThumb = _.get(result, '[0].data.head_ico', ''); | ||
100 | + | ||
101 | + let tabList = [{ | ||
102 | + name: '全部', | ||
103 | + focus: !type, | ||
104 | + href: msgBaseUrl | ||
105 | + }]; | ||
106 | + | ||
107 | + let focusTabName = ''; | ||
108 | + | ||
109 | + _.forEach(_.get(result, '[1]data.list', []), value => { | ||
110 | + let tab = { | ||
111 | + name: `${value.inboxCatName}`, | ||
112 | + focus: type === value.id * 1, | ||
113 | + href: `${msgBaseUrl}?type=${value.id}` | ||
114 | + }; | ||
115 | + | ||
116 | + if (value.unReadCount * 1) { | ||
117 | + tab.name += ` (${value.unReadCount})`; | ||
118 | + } | ||
119 | + | ||
120 | + if (tab.focus) { | ||
121 | + focusTabName = value.inboxCatName; | ||
122 | + } | ||
77 | 123 | ||
78 | - if (result.data) { | 124 | + tabList.push(tab); |
125 | + }); | ||
126 | + | ||
127 | + resData.tabList = tabList; | ||
128 | + | ||
129 | + if (result[2].data) { | ||
130 | + let data = result[2].data; | ||
79 | let msg = []; | 131 | let msg = []; |
80 | 132 | ||
81 | - _.forEach(_.get(result, 'data.list', []), value => { | 133 | + _.forEach(_.get(data, 'list', []), value => { |
82 | // 信息过滤 | 134 | // 信息过滤 |
83 | if (value.type === '$inboxval' || value.type === 'notice') { | 135 | if (value.type === '$inboxval' || value.type === 'notice') { |
84 | return; | 136 | return; |
85 | } | 137 | } |
86 | 138 | ||
139 | + let href = `/home/message/detail?id=${value.id}&page=${page}`; | ||
140 | + | ||
87 | msg.push({ | 141 | msg.push({ |
88 | id: value.id || 0, | 142 | id: value.id || 0, |
89 | - href: `/home/message/detail?id=${value.id}&page=${page}`, | 143 | + href: type ? href + `&type=${type}` : href, |
90 | title: value.title || '', | 144 | title: value.title || '', |
145 | + content: _.get(value, 'body.content', ''), | ||
91 | sender: value.from || '', | 146 | sender: value.from || '', |
92 | time: value.create_date, | 147 | time: value.create_date, |
93 | isNew: value.is_read === 'Y' ? false : true | 148 | isNew: value.is_read === 'Y' ? false : true |
@@ -96,40 +151,47 @@ const getMessageList = (uid, page, limit) => { | @@ -96,40 +151,47 @@ const getMessageList = (uid, page, limit) => { | ||
96 | 151 | ||
97 | resData.messages = msg; | 152 | resData.messages = msg; |
98 | 153 | ||
154 | + let pagerList = setPager(_.get(result, 'data.page_total', 0), | ||
155 | + Object.assign(params, {page: page})); | ||
156 | + | ||
99 | resData.pager = Object.assign({ | 157 | resData.pager = Object.assign({ |
100 | - count: _.get(result, 'data.total', 0), | 158 | + count: _.get(data, 'total', 0), |
101 | curPage: page, | 159 | curPage: page, |
102 | - totalPages: _.get(result, 'data.page_total', 0) | ||
103 | - }, setPager(_.get(result, 'data.page_total', 0), { | ||
104 | - page: page | ||
105 | - })); | 160 | + totalPages: _.get(data, 'page_total', 0) |
161 | + }, pagerList); | ||
106 | } | 162 | } |
107 | 163 | ||
108 | if (_.isEmpty(resData.messages)) { | 164 | if (_.isEmpty(resData.messages)) { |
109 | - resData.messages = {empty: '您尚未收到任何短消息'}; | 165 | + resData.messages = {empty: `您尚未收到任何${focusTabName}消息`}; |
110 | } | 166 | } |
111 | 167 | ||
112 | return resData; | 168 | return resData; |
113 | - }; | ||
114 | - | ||
115 | - return co(process)(); | 169 | + }); |
116 | }; | 170 | }; |
117 | 171 | ||
118 | /** | 172 | /** |
119 | * 获取消息内容 | 173 | * 获取消息内容 |
120 | * @function getMessageDetail | 174 | * @function getMessageDetail |
121 | * @param { Number } uid 用户uid | 175 | * @param { Number } uid 用户uid |
122 | - * @param { Number } page 页码 | 176 | + * @param { Object } params url参数 |
123 | * @param { Number } limit 每页数目 | 177 | * @param { Number } limit 每页数目 |
124 | * @return { Object } 消息列表数据 | 178 | * @return { Object } 消息列表数据 |
125 | */ | 179 | */ |
126 | -const getMessageDetail = (uid, mid, page, limit) => { | 180 | +const getMessageDetail = (uid, params, limit) => { |
181 | + let mid = parseInt(`0${params.id}`, 10); | ||
182 | + let page = parseInt(`0${params.page}`, 10) || 1; | ||
183 | + let type = parseInt(`0${params.type}`, 10); | ||
184 | + | ||
127 | let process = function*() { | 185 | let process = function*() { |
186 | + let result = yield Promise.all([ | ||
187 | + userApi.getUserInfo(uid), | ||
188 | + getMessageAsync(uid, page, limit, type) | ||
189 | + ]); | ||
128 | let resData = { | 190 | let resData = { |
129 | - backUrl: `/home/message?page=${page}` | 191 | + backUrl: `/home/message?page=${page}`, |
192 | + userThumb: _.get(result, '[0].data.head_ico', '') | ||
130 | }; | 193 | }; |
131 | - let result = yield getMessageAsync(uid, page, limit); | ||
132 | - let msg = _.find(_.get(result, 'data.list', []), {id: mid}); | 194 | + let msg = _.find(_.get(result, '[1]data.list', []), {id: mid}); |
133 | 195 | ||
134 | if (!_.isEmpty(msg)) { | 196 | if (!_.isEmpty(msg)) { |
135 | resData.message = { | 197 | resData.message = { |
@@ -140,6 +202,26 @@ const getMessageDetail = (uid, mid, page, limit) => { | @@ -140,6 +202,26 @@ const getMessageDetail = (uid, mid, page, limit) => { | ||
140 | 202 | ||
141 | switch (msg.type) { | 203 | switch (msg.type) { |
142 | case 'pullCoupon': // eslint-disable-line | 204 | case 'pullCoupon': // eslint-disable-line |
205 | + resData.message.birthCoupon = { | ||
206 | + text: `${_.get(result, '[0].data.nickname', '')} 有货祝您生日快乐!感谢您对有货的支持,特赠您VIP生日专属礼,即刻享受生日福利吧!` | ||
207 | + } | ||
208 | + | ||
209 | + // if (_.get(msg, 'body.is_collar', '') === 'Y') { | ||
210 | + // Object.assign(resData.message.birthCoupon, { | ||
211 | + // over: true, | ||
212 | + // overText: '已领取' | ||
213 | + // }); | ||
214 | + // break; | ||
215 | + // } | ||
216 | + | ||
217 | + // if (_.get(msg, 'body.is_over_time', '') === 'Y') { | ||
218 | + // Object.assign(resData.message.birthCoupon, { | ||
219 | + // over: true, | ||
220 | + // overText: '生日券已过期' | ||
221 | + // }); | ||
222 | + // break; | ||
223 | + // } | ||
224 | + | ||
143 | let couponInfo = yield getCouponAsync(uid); | 225 | let couponInfo = yield getCouponAsync(uid); |
144 | let coupons = []; | 226 | let coupons = []; |
145 | 227 |
@@ -16,7 +16,7 @@ const commentController = require(`${cRoot}/comment`); | @@ -16,7 +16,7 @@ const commentController = require(`${cRoot}/comment`); | ||
16 | 16 | ||
17 | // const consultController = require(`${cRoot}/consult`); | 17 | // const consultController = require(`${cRoot}/consult`); |
18 | // const complaintsController = require(`${cRoot}/complaints`); | 18 | // const complaintsController = require(`${cRoot}/complaints`); |
19 | -// const messageController = require(`${cRoot}/message`); | 19 | +const messageController = require(`${cRoot}/message`); |
20 | // const returnsController = require(`${cRoot}/returns`); | 20 | // const returnsController = require(`${cRoot}/returns`); |
21 | // const IndexController = require(`${cRoot}/Index`); | 21 | // const IndexController = require(`${cRoot}/Index`); |
22 | // const CurrencyController = require(`${cRoot}/Currency`); | 22 | // const CurrencyController = require(`${cRoot}/Currency`); |
@@ -180,11 +180,11 @@ router.get('/comment/order', [getCommonHeader, getHomeNav], commentController.co | @@ -180,11 +180,11 @@ router.get('/comment/order', [getCommonHeader, getHomeNav], commentController.co | ||
180 | // router.post('/complaints/cancel', complaintsController.cancel); | 180 | // router.post('/complaints/cancel', complaintsController.cancel); |
181 | 181 | ||
182 | // 我的消息 | 182 | // 我的消息 |
183 | -// router.get('/message', messageController.index); | ||
184 | -// router.get('/message/detail', messageController.detail); | ||
185 | -// router.get('/message/del', messageController.delMsg); | ||
186 | -// router.get('/message/read', messageController.readMsg); | ||
187 | -// router.get('/message/pickCoupon', messageController.pickCoupon); | 183 | +router.get('/message', [getCommonHeader, getHomeNav], messageController.index); |
184 | +router.get('/message/detail', [getCommonHeader, getHomeNav], messageController.detail); | ||
185 | +router.get('/message/del', messageController.delMsg); | ||
186 | +router.get('/message/read', messageController.readMsg); | ||
187 | +router.get('/message/pickCoupon', messageController.pickCoupon); | ||
188 | 188 | ||
189 | // 我的退/换货 | 189 | // 我的退/换货 |
190 | // router.get('/returns', returnsController.index); | 190 | // router.get('/returns', returnsController.index); |
@@ -13,38 +13,61 @@ | @@ -13,38 +13,61 @@ | ||
13 | {{# message}} | 13 | {{# message}} |
14 | <div class="text-title"> | 14 | <div class="text-title"> |
15 | <h1>{{title}}</h1> | 15 | <h1>{{title}}</h1> |
16 | - <span>{{sender}} 发送于{{time}}</span> | 16 | + <span>{{sender}} 发送于{{time}}</span> |
17 | </div> | 17 | </div> |
18 | <div class="text-content"> | 18 | <div class="text-content"> |
19 | {{# text}} | 19 | {{# text}} |
20 | <!-- 文本消息 --> | 20 | <!-- 文本消息 --> |
21 | <p>{{{content}}}</p> | 21 | <p>{{{content}}}</p> |
22 | {{/ text}} | 22 | {{/ text}} |
23 | - {{# coupons}} | ||
24 | - <!-- 优惠券消息 --> | ||
25 | - <div class="coupon-item"> | ||
26 | - <div class="coupon-img"> | ||
27 | - <img src="//static.yohobuy.com/images/v2/activity/default_coupon.jpg"> | ||
28 | - </div> | ||
29 | - <div class="coupon-info"> | ||
30 | - <p>{{remark}}</p> | ||
31 | - {{#if url}} | ||
32 | - <p>面值:{{price}}</p> | ||
33 | - <p>有效期:{{useTime}}</p> | ||
34 | - {{^}} | ||
35 | - <p>使用时间:{{useTime}}</p> | ||
36 | - <p>领取时间:{{pickTime}}</p> | ||
37 | - {{/if}} | ||
38 | - </div> | ||
39 | - <div class="coupon-action"> | ||
40 | - {{#if url}} | ||
41 | - <a href="{{url}}" class="view-coupon-btn">立即查看</a> | ||
42 | - {{^}} | ||
43 | - <a{{#if canPick}} class="pick-coupon-btn" data-id="{{id}}"{{/if}}>立即领取</a> | ||
44 | - {{/if}} | ||
45 | - </div> | 23 | + {{# birthCoupon}} |
24 | + <p>{{text}}</p> | ||
25 | + <p class="birth-card"> | ||
26 | + {{#if @root.devEnv}} | ||
27 | + <img src="////{{@root.devHost}}:5002/img/home/birth-card.jpg"> | ||
28 | + {{^}} | ||
29 | + <img src="//cdn.yoho.cn/yohobuy-node/assets/img/home/birth-card.jpg"> | ||
30 | + {{/if}} | ||
31 | + </p> | ||
32 | + {{#if over}} | ||
33 | + <div>{{overText}}</div> | ||
34 | + {{^}} | ||
35 | + <div class="show-birth-coupon"{{#if errMsg}} data-msg="{{errMsg}}"{{/if}}>点这里领取</div> | ||
36 | + {{/if}} | ||
37 | + {{/ birthCoupon}} | ||
38 | + | ||
39 | + {{#if coupons}} | ||
40 | + <div class="{{#if birthCoupon}}birth-coupon-wrap{{/if}}"> | ||
41 | + {{#if birthCoupon}} | ||
42 | + <p>您365天内有且仅有一次领劵生日礼券的机会,每次限领1张哦</p> | ||
43 | + {{/if}} | ||
44 | + {{# coupons}} | ||
45 | + <!-- 优惠券消息 --> | ||
46 | + <div class="coupon-item"> | ||
47 | + <div class="coupon-img"> | ||
48 | + <img src="//static.yohobuy.com/images/v2/activity/default_coupon.jpg"> | ||
49 | + </div> | ||
50 | + <div class="coupon-info"> | ||
51 | + <p>{{remark}}</p> | ||
52 | + {{#if url}} | ||
53 | + <p>面值:{{price}}</p> | ||
54 | + <p>有效期:{{useTime}}</p> | ||
55 | + {{^}} | ||
56 | + <p>使用时间:{{useTime}}</p> | ||
57 | + <p>领取时间:{{pickTime}}</p> | ||
58 | + {{/if}} | ||
59 | + </div> | ||
60 | + <div class="coupon-action"> | ||
61 | + {{#if url}} | ||
62 | + <a href="{{url}}" class="view-coupon-btn">立即查看</a> | ||
63 | + {{^}} | ||
64 | + <a{{#if canPick}} class="pick-coupon-btn" data-id="{{id}}"{{/if}}>立即领取</a> | ||
65 | + {{/if}} | ||
66 | + </div> | ||
67 | + </div> | ||
68 | + {{/ coupons}} | ||
46 | </div> | 69 | </div> |
47 | - {{/ coupons}} | 70 | + {{/if}} |
48 | {{# sale}} | 71 | {{# sale}} |
49 | <!-- 促销消息 --> | 72 | <!-- 促销消息 --> |
50 | <div class="sale-img"> | 73 | <div class="sale-img"> |
@@ -60,4 +83,4 @@ | @@ -60,4 +83,4 @@ | ||
60 | 83 | ||
61 | {{> help-us}} | 84 | {{> help-us}} |
62 | </div> | 85 | </div> |
63 | -</div> | ||
86 | +</div> |
@@ -6,19 +6,19 @@ | @@ -6,19 +6,19 @@ | ||
6 | <div class="me-main"> | 6 | <div class="me-main"> |
7 | <div class="message block"> | 7 | <div class="message block"> |
8 | <h2 class="title"></h2> | 8 | <h2 class="title"></h2> |
9 | - | ||
10 | - <p class="message-table-header table-header clearfix"> | ||
11 | - <span class="sender">发件人</span> | ||
12 | - <span class="heading">标题</span> | ||
13 | - <span class="time">发件时间</span> | ||
14 | - <span class="action">操作</span> | ||
15 | - </p> | 9 | + <div class="msg-tabs-wrap"> |
10 | + <ul class="tabs-list clearfix"> | ||
11 | + {{# tabList}} | ||
12 | + <li{{#if focus}} class="active"{{/if}}> | ||
13 | + <a href="{{href}}">{{name}}</a> | ||
14 | + </li> | ||
15 | + {{/ tabList}} | ||
16 | + </ul> | ||
17 | + </div> | ||
16 | <div id="message-main-container"> | 18 | <div id="message-main-container"> |
17 | {{> message/message-list}} | 19 | {{> message/message-list}} |
18 | - {{> pager}} | ||
19 | </div> | 20 | </div> |
21 | + {{> pager}} | ||
20 | </div> | 22 | </div> |
21 | - | ||
22 | - {{> help-us}} | ||
23 | </div> | 23 | </div> |
24 | -</div> | ||
24 | +</div> |
@@ -4,29 +4,17 @@ | @@ -4,29 +4,17 @@ | ||
4 | {{> empty}} | 4 | {{> empty}} |
5 | {{/with}} | 5 | {{/with}} |
6 | {{^}} | 6 | {{^}} |
7 | - <table> | ||
8 | - {{# messages}} | ||
9 | - <tr{{#if isNew}} class="new-msg"{{/if}}> | ||
10 | - <td width="37"> | ||
11 | - <input type="checkbox" class="msg-check" value="{{id}}"> | ||
12 | - </td> | ||
13 | - <td class="td-sender"><a href="{{href}}">{{sender}}</a></td> | ||
14 | - <td class="td-title"><a href="{{href}}">{{title}}</a></td> | ||
15 | - <td width="130">{{time}}</td> | ||
16 | - <td> | ||
17 | - <a class="del-btn" data-id="{{id}}">删除</a> | ||
18 | - </td> | ||
19 | - </tr> | ||
20 | - {{/ messages}} | ||
21 | - <tr class="list-foot"> | ||
22 | - <td> | ||
23 | - <input type="checkbox" class="choose-all"> | ||
24 | - </td> | ||
25 | - <td colspan="4"> | ||
26 | - <button class="del-choose-btn">删除选中的消息</button> | ||
27 | - <button class="read-choose-btn">标记为已读</button> | ||
28 | - </td> | ||
29 | - </tr> | ||
30 | - </table> | 7 | + {{# messages}} |
8 | + <div class="msg-item{{#if isNew}} new-msg{{/if}}"> | ||
9 | + <a href="{{href}}"> | ||
10 | + <p class="it-title">{{title}}</p> | ||
11 | + <p class="it-content">{{content}}</p> | ||
12 | + <p class="it-time">{{time}}</p> | ||
13 | + </a> | ||
14 | + <div class="del-btn" data-id="{{id}}"> | ||
15 | + <i class="iconfont"></i> | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + {{/ messages}} | ||
31 | {{/if}} | 19 | {{/if}} |
32 | </div> | 20 | </div> |
@@ -2,7 +2,9 @@ | @@ -2,7 +2,9 @@ | ||
2 | <p class="title ucenter"></p> | 2 | <p class="title ucenter"></p> |
3 | <div class="user-thumb"> | 3 | <div class="user-thumb"> |
4 | <div class="thumb-bg"> | 4 | <div class="thumb-bg"> |
5 | - <img id="user-thumb" src="{{userThumb}}"> | 5 | + {{#if userThumb}} |
6 | + <img id="user-thumb" src="{{image userThumb 100 100}}"> | ||
7 | + {{/if}} | ||
6 | </div> | 8 | </div> |
7 | </div> | 9 | </div> |
8 | {{# homeNav}} | 10 | {{# homeNav}} |
@@ -23,4 +25,4 @@ | @@ -23,4 +25,4 @@ | ||
23 | </ul> | 25 | </ul> |
24 | </div> | 26 | </div> |
25 | {{/ homeNav}} | 27 | {{/ homeNav}} |
26 | -</div> | ||
28 | +</div> |
@@ -16,11 +16,11 @@ | @@ -16,11 +16,11 @@ | ||
16 | {{# pages}} | 16 | {{# pages}} |
17 | <a{{#if url}} href="{{url}}"{{/if}}{{#if cur}} class="cur"{{/if}}>{{num}}</a> | 17 | <a{{#if url}} href="{{url}}"{{/if}}{{#if cur}} class="cur"{{/if}}>{{num}}</a> |
18 | {{/ pages}} | 18 | {{/ pages}} |
19 | - | 19 | + |
20 | {{# nextPage}} | 20 | {{# nextPage}} |
21 | <a href="{{url}}" title="下一页">下一页<span class="iconfont"></span></a> | 21 | <a href="{{url}}" title="下一页">下一页<span class="iconfont"></span></a> |
22 | {{/ nextPage}} | 22 | {{/ nextPage}} |
23 | </div> | 23 | </div> |
24 | </div> | 24 | </div> |
25 | </div> | 25 | </div> |
26 | -{{/ pager}} | ||
26 | +{{/ pager}} |
public/img/home/birth-card.jpg
0 → 100644
131 KB
@@ -7,125 +7,51 @@ var $ = require('yoho-jquery'); | @@ -7,125 +7,51 @@ var $ = require('yoho-jquery'); | ||
7 | 7 | ||
8 | var Dialog = require('../common/dialog'); | 8 | var Dialog = require('../common/dialog'); |
9 | 9 | ||
10 | -var $container = $('#message-main-container'), | ||
11 | - $msgCheck = $container.find('.msg-check'), | ||
12 | - $readBtn = $container.find('.read-choose-btn'), | ||
13 | - $checked; | ||
14 | - | 10 | +var $container = $('#message-main-container'); |
15 | var $pickBtn = $('.pick-coupon-btn'); | 11 | var $pickBtn = $('.pick-coupon-btn'); |
16 | 12 | ||
17 | -var operationId = []; | ||
18 | - | ||
19 | var pickBusy = false; | 13 | var pickBusy = false; |
20 | 14 | ||
21 | var Alert = Dialog.Alert, | 15 | var Alert = Dialog.Alert, |
22 | - Confirm = Dialog.confirm; | ||
23 | - | ||
24 | -function hasNew() { | ||
25 | - var newMsg = false; | ||
26 | - | ||
27 | - $checked = $container.find('.msg-check:checked'); | ||
28 | - operationId = []; | ||
29 | - | ||
30 | - $checked.each(function() { | ||
31 | - var $par = $(this).parent().parent(); | ||
32 | - | ||
33 | - operationId.push($(this).val()); | ||
34 | - if ($par.hasClass('new-msg')) { | ||
35 | - newMsg = true; | ||
36 | - } | ||
37 | - }); | 16 | + Confirm = Dialog.Confirm; |
38 | 17 | ||
39 | - if (newMsg) { | ||
40 | - $readBtn.addClass('has-new'); | ||
41 | - } else { | ||
42 | - $readBtn.removeClass('has-new'); | ||
43 | - } | ||
44 | -} | ||
45 | - | ||
46 | -function msgOperation(type, data) { | ||
47 | - var url; | ||
48 | - | ||
49 | - switch (type) { | ||
50 | - case 'del': | ||
51 | - url = '/home/message/del'; | ||
52 | - break; | ||
53 | - case 'read': | ||
54 | - url = '/home/message/read'; | ||
55 | - break; | ||
56 | - default: | ||
57 | - break; | ||
58 | - } | ||
59 | - | ||
60 | - if (!url) { | 18 | +function msgOperation(data) { |
19 | + if (!data) { | ||
61 | return; | 20 | return; |
62 | } | 21 | } |
63 | 22 | ||
64 | $.ajax({ | 23 | $.ajax({ |
65 | type: 'GET', | 24 | type: 'GET', |
66 | - url: url, | 25 | + url: '/home/message/del', |
67 | data: data | 26 | data: data |
68 | }).then(function(jsonData) { | 27 | }).then(function(jsonData) { |
69 | if (jsonData.code === 200) { | 28 | if (jsonData.code === 200) { |
70 | - if (type === 'read') { | ||
71 | - $checked.removeAttr('checked'); | ||
72 | - $checked.parent().parent().removeClass('new-msg'); | ||
73 | - hasNew(); | ||
74 | - } else { | ||
75 | - window.location.reload(); | ||
76 | - } | 29 | + window.location.reload(); |
77 | } else { | 30 | } else { |
78 | new Alert(jsonData.message); | 31 | new Alert(jsonData.message); |
79 | } | 32 | } |
80 | }); | 33 | }); |
81 | } | 34 | } |
82 | 35 | ||
83 | -$container.on('change', 'input[type="checkbox"]', function() { | ||
84 | - var checked = $(this).attr('checked'); | ||
85 | - | ||
86 | - if ($(this).hasClass('choose-all')) { | ||
87 | - if (checked === 'checked') { | ||
88 | - $msgCheck.attr('checked', true); | ||
89 | - } else { | ||
90 | - $msgCheck.removeAttr('checked'); | ||
91 | - } | ||
92 | - } | ||
93 | - hasNew(); | ||
94 | -}); | ||
95 | - | ||
96 | $container.on('click', '.del-btn', function() { | 36 | $container.on('click', '.del-btn', function() { |
97 | var data = $(this).data(); | 37 | var data = $(this).data(); |
98 | 38 | ||
99 | - new Confirm({ | ||
100 | - content: '您确定要删除这条短消息?', | ||
101 | - cb: function() { | ||
102 | - msgOperation('del', data); | ||
103 | - } | ||
104 | - }).show(); | ||
105 | -}); | ||
106 | - | ||
107 | -$container.on('click', '.del-choose-btn', function() { | ||
108 | - if (!operationId.length) { | ||
109 | - new Alert('请选中您要删除的消息'); | ||
110 | - return; | 39 | + if (data.id) { |
40 | + new Confirm({ | ||
41 | + content: '您确定要删除这条短消息?', | ||
42 | + cb: function() { | ||
43 | + msgOperation(data); | ||
44 | + } | ||
45 | + }).show(); | ||
111 | } | 46 | } |
112 | - | ||
113 | - new Confirm({ | ||
114 | - content: '确定要删除您选中的消息?', | ||
115 | - cb: function() { | ||
116 | - msgOperation('del', { | ||
117 | - id: operationId.join(',') | ||
118 | - }); | ||
119 | - } | ||
120 | - }).show(); | ||
121 | }); | 47 | }); |
122 | 48 | ||
123 | -$container.on('click', '.read-choose-btn', function() { | ||
124 | - if ($(this).hasClass('has-new')) { | ||
125 | - msgOperation('read', { | ||
126 | - id: operationId.join(',') | ||
127 | - }); | ||
128 | - } | 49 | +$('.show-birth-coupon').click(function() { |
50 | + var $this = $(this); | ||
51 | + | ||
52 | + $this.siblings('.birth-coupon-wrap').show(); | ||
53 | + $this.hide().siblings('p').hide(); | ||
54 | + $(window).scrollTop(0); | ||
129 | }); | 55 | }); |
130 | 56 | ||
131 | $pickBtn.click(function() { | 57 | $pickBtn.click(function() { |
@@ -32,6 +32,19 @@ | @@ -32,6 +32,19 @@ | ||
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | + .birth-card > img { | ||
36 | + width: 100%; | ||
37 | + margin: 6px 0; | ||
38 | + } | ||
39 | + | ||
40 | + .show-birth-coupon { | ||
41 | + cursor: pointer; | ||
42 | + } | ||
43 | + | ||
44 | + .birth-coupon-wrap { | ||
45 | + display: none; | ||
46 | + } | ||
47 | + | ||
35 | .coupon-item { | 48 | .coupon-item { |
36 | display: table-row; | 49 | display: table-row; |
37 | 50 |
1 | .message-me-page { | 1 | .message-me-page { |
2 | - .message .title { | 2 | + .message > .title { |
3 | background-image: resolve('home/message.png'); | 3 | background-image: resolve('home/message.png'); |
4 | } | 4 | } |
5 | 5 | ||
6 | - .message-table-header { | ||
7 | - font-size: 12px; | ||
8 | - | ||
9 | - .sender { | ||
10 | - width: 118px; | ||
11 | - padding-left: 38px; | ||
12 | - text-align: left; | ||
13 | - } | ||
14 | - | ||
15 | - .heading { | ||
16 | - width: 408px; | ||
17 | - text-align: left; | ||
18 | - } | ||
19 | - | ||
20 | - .time { | ||
21 | - width: 130px; | ||
22 | - } | 6 | + .msg-tabs-wrap { |
7 | + padding: 0 10px; | ||
8 | + } | ||
23 | 9 | ||
24 | - .action { | ||
25 | - padding-left: 10px; | ||
26 | - width: 66px; | 10 | + .tabs-list { |
11 | + height: 31px; | ||
12 | + font-size: 14px; | ||
13 | + padding-left: 4px; | ||
14 | + margin-top: 8px; | ||
15 | + border-bottom: 1px solid #e6e6e6; | ||
16 | + | ||
17 | + li { | ||
18 | + display: block; | ||
19 | + float: left; | ||
20 | + min-width: 80px; | ||
21 | + height: 30px; | ||
22 | + line-height: 30px; | ||
23 | + padding: 0 10px; | ||
24 | + text-align: center; | ||
25 | + background-color: #eaeaea; | ||
26 | + border: 1px solid #e6e6e6; | ||
27 | + border-top-left-radius: 4px; | ||
28 | + border-top-right-radius: 4px; | ||
29 | + margin-left: 6px; | ||
30 | + color: #333; | ||
31 | + cursor: pointer; | ||
32 | + | ||
33 | + &.active { | ||
34 | + background-color: #fff; | ||
35 | + border-bottom-color: #fff; | ||
36 | + } | ||
27 | } | 37 | } |
28 | } | 38 | } |
29 | 39 | ||
30 | .message-list { | 40 | .message-list { |
31 | padding: 10px; | 41 | padding: 10px; |
32 | - font-size: 12px; | ||
33 | - | ||
34 | - table { | ||
35 | - width: 100%; | ||
36 | - line-height: 38px; | ||
37 | - | ||
38 | - tr { | ||
39 | - color: #999; | ||
40 | - border: 1px solid #e6e6e6; | ||
41 | - | ||
42 | - td { | ||
43 | - text-align: center; | ||
44 | - } | ||
45 | - | ||
46 | - input { | ||
47 | - vertical-align: middle; | ||
48 | - margin: 0; | ||
49 | - } | 42 | + font-size: 14px; |
43 | + color: #3a3a3a; | ||
44 | + } | ||
50 | 45 | ||
51 | - .del-btn { | ||
52 | - color: #468fa2; | ||
53 | - text-decoration: none; | ||
54 | - cursor: pointer; | ||
55 | - } | ||
56 | - } | 46 | + .msg-item:first-child { |
47 | + border-top: 1px solid #e6e6e6; | ||
48 | + } | ||
57 | 49 | ||
58 | - .list-foot { | ||
59 | - background: #f8f8f8; | 50 | + .msg-item { |
51 | + padding: 10px 150px 10px 30px; | ||
52 | + position: relative; | ||
53 | + border-bottom: 1px solid #e6e6e6; | ||
60 | 54 | ||
61 | - button { | ||
62 | - float: left; | ||
63 | - line-height: 18px; | ||
64 | - padding: 2px 10px; | ||
65 | - border: 1px solid #ccc; | ||
66 | - border-radius: 2px; | ||
67 | - cursor: pointer; | ||
68 | - outline: none; | ||
69 | - } | 55 | + .it-title { |
56 | + line-height: 2; | ||
57 | + padding-bottom: 10px; | ||
58 | + } | ||
70 | 59 | ||
71 | - .del-choose-btn { | ||
72 | - background: #da044a; | ||
73 | - border-color: #cc0345; | ||
74 | - margin-right: 10px; | ||
75 | - color: #fff; | ||
76 | - } | 60 | + &.new-msg .it-title { |
61 | + color: #468fa2; | ||
62 | + } | ||
77 | 63 | ||
78 | - .read-choose-btn { | ||
79 | - background: #ddd; | ||
80 | - color: #b3b3b3; | ||
81 | - } | ||
82 | - .has-new { | ||
83 | - background: #3797af; | ||
84 | - border-color: #147e98; | ||
85 | - color: #fff; | ||
86 | - } | ||
87 | - } | 64 | + .it-content { |
65 | + line-height: 1.5; | ||
66 | + } | ||
88 | 67 | ||
89 | - .td-sender { | ||
90 | - width: 110px; | ||
91 | - color: #666; | ||
92 | - text-align: left; | ||
93 | - white-space: nowrap; | ||
94 | - overflow: hidden; | ||
95 | - } | 68 | + .it-time { |
69 | + color: #b0b0b0; | ||
70 | + line-height: 2; | ||
71 | + } | ||
96 | 72 | ||
97 | - .td-title { | ||
98 | - width: 410px; | ||
99 | - padding-left: 10px; | ||
100 | - color: #666; | ||
101 | - text-align: left; | ||
102 | - white-space: nowrap; | ||
103 | - overflow: hidden; | 73 | + .del-btn { |
74 | + width: 30px; | ||
75 | + height: 30px; | ||
76 | + line-height: 30px; | ||
77 | + text-align: center; | ||
78 | + position: absolute; | ||
79 | + top: 50%; | ||
80 | + right: 20px; | ||
81 | + margin-top: -15px; | ||
82 | + cursor: pointer; | ||
83 | + display: none; | ||
84 | + | ||
85 | + .iconfont { | ||
86 | + font-size: 26px; | ||
104 | } | 87 | } |
88 | + } | ||
105 | 89 | ||
106 | - .new-msg { | ||
107 | - background: #f0f5f8; | ||
108 | - border-bottom: 1px #becfd3 solid; | ||
109 | - | ||
110 | - .td-sender a, | ||
111 | - .td-title a { | ||
112 | - font-weight: bold; | ||
113 | - color: #468fa2; | ||
114 | - } | ||
115 | - } | 90 | + &:hover > .del-btn { |
91 | + display: block; | ||
116 | } | 92 | } |
117 | } | 93 | } |
118 | } | 94 | } |
-
Please register or login to post a comment