Showing
9 changed files
with
235 additions
and
2 deletions
apps/home/controllers/myCurrency.js
0 → 100644
1 | +/** | ||
2 | +* 个人中心我的有货币 | ||
3 | +* @author: zxr<xiaoru.zhang@yoho.cn> | ||
4 | +* @date: 2016/08/16 | ||
5 | +*/ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const myCurrencyModel = require('../models/myCurrency'); | ||
10 | +const headerModel = require('../../../doraemon/models/header'); // 头部model | ||
11 | + | ||
12 | +const myCurrency = (req, res, next) => { | ||
13 | + let uid = req.user.uid || 8039759; | ||
14 | + | ||
15 | + myCurrencyModel.myCurrency(uid).then(result => { | ||
16 | + | ||
17 | + res.render('currency-new', { | ||
18 | + module: 'home', | ||
19 | + page: 'currency', | ||
20 | + pageHeader: headerModel.setNav({ | ||
21 | + navTitle: '有货币' | ||
22 | + }), | ||
23 | + title: '有货币', | ||
24 | + pageFooter: true, | ||
25 | + yohoCoin: result | ||
26 | + }); | ||
27 | + }).catch(next); | ||
28 | +}; | ||
29 | + | ||
30 | +const currencyDetail = (req, res, next) => { | ||
31 | + let uid = req.user.uid || 8039759; | ||
32 | + let page = 1; | ||
33 | + let limit = 10; | ||
34 | + | ||
35 | + myCurrencyModel.currencyDetail(uid, page, limit).then(result => { | ||
36 | + | ||
37 | + res.render('currency-detail', { | ||
38 | + module: 'home', | ||
39 | + page: 'currency-detail', | ||
40 | + pageHeader: headerModel.setNav({ | ||
41 | + navTitle: '有货币明细' | ||
42 | + }), | ||
43 | + title: '有货币明细', | ||
44 | + pageFooter: true, | ||
45 | + money: result.money | ||
46 | + }); | ||
47 | + }).catch(next); | ||
48 | +}; | ||
49 | + | ||
50 | +let ajaxCurrencyDetail = (req, res, next) => { | ||
51 | + let uid = req.user.uid || 8039759; | ||
52 | + let page = req.body.page || 1; | ||
53 | + let limit = 10; | ||
54 | + | ||
55 | + myCurrencyModel.currencyDetail(uid, page, limit).then((result) => { | ||
56 | + | ||
57 | + res.render('ajax-currency-detail', { | ||
58 | + layout: false, | ||
59 | + coinlist: result.coinlist | ||
60 | + }); | ||
61 | + }).catch(next); | ||
62 | +}; | ||
63 | + | ||
64 | +module.exports = { | ||
65 | + myCurrency, | ||
66 | + currencyDetail, | ||
67 | + ajaxCurrencyDetail | ||
68 | +}; | ||
69 | + |
apps/home/models/myCurrency.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | + | ||
4 | +const api = global.yoho.API; | ||
5 | +const _ = require('lodash'); | ||
6 | +const camelCase = global.yoho.camelCase; | ||
7 | +const logger = global.yoho.logger; | ||
8 | + | ||
9 | +const myCurrency = (uid) => { | ||
10 | + return api.get('', { | ||
11 | + method: 'app.yoho.yohocoin', | ||
12 | + uid: uid | ||
13 | + }).then((result) => { | ||
14 | + | ||
15 | + if (result && result.code === 200) { | ||
16 | + return camelCase(result.data); | ||
17 | + } else { | ||
18 | + logger.error('youho币总数 cood 不是 200'); | ||
19 | + } | ||
20 | + }); | ||
21 | +}; | ||
22 | + | ||
23 | +// const banner = (CODE_YOHOCOIN_BANNER) => { | ||
24 | +// return api.get('', { | ||
25 | +// content_code: 'CODE_YOHOCOIN_BANNER', | ||
26 | +// }).then((result) => { | ||
27 | +// console.log(content_code) | ||
28 | +// if(result && result.code === 200) { | ||
29 | +// return camelCase(result.data); | ||
30 | +// } else { | ||
31 | +// logger.error('youho币总数 cood 不是 200'); | ||
32 | +// } | ||
33 | +// }) | ||
34 | +// }; | ||
35 | + | ||
36 | +const currencyDetail = (uid, page, limit) => { | ||
37 | + return api.get('', { | ||
38 | + method: 'app.yohocoin.lists', | ||
39 | + uid: uid, | ||
40 | + page: page, | ||
41 | + limit: limit | ||
42 | + }).then((result) => { | ||
43 | + // console.log(result) | ||
44 | + if (result && result.code === 200) { | ||
45 | + let total = parseInt(result.data.page_total, 10) + 1; | ||
46 | + | ||
47 | + if (page && page < total) { | ||
48 | + return myCurrency(uid).then(list => { | ||
49 | + | ||
50 | + if (list.yohocoinNum && list.yohocoinNum === 0) { | ||
51 | + result.data = _.assign(result.data, { | ||
52 | + money: false | ||
53 | + }); | ||
54 | + } else { | ||
55 | + result.data = _.assign(result.data, { | ||
56 | + money: true | ||
57 | + }); | ||
58 | + } | ||
59 | + | ||
60 | + return result.data; | ||
61 | + }); | ||
62 | + } else { | ||
63 | + return; | ||
64 | + } | ||
65 | + | ||
66 | + } else { | ||
67 | + logger.error('youho币列表 cood 不是 200'); | ||
68 | + } | ||
69 | + | ||
70 | + }); | ||
71 | +}; | ||
72 | + | ||
73 | +module.exports = { | ||
74 | + myCurrency, | ||
75 | + currencyDetail | ||
76 | +}; |
@@ -16,6 +16,7 @@ const addressController = require(`${cRoot}/address`); | @@ -16,6 +16,7 @@ const addressController = require(`${cRoot}/address`); | ||
16 | const favorite = require(`${cRoot}/favorite`); | 16 | const favorite = require(`${cRoot}/favorite`); |
17 | const orderController = require(`${cRoot}/order`); | 17 | const orderController = require(`${cRoot}/order`); |
18 | const orderDetailController = require(`${cRoot}/orderDetail`); | 18 | const orderDetailController = require(`${cRoot}/orderDetail`); |
19 | +const currencyController = require(`${cRoot}/myCurrency`); | ||
19 | 20 | ||
20 | // const myDetail = require(`${cRoot}/myDetail); | 21 | // const myDetail = require(`${cRoot}/myDetail); |
21 | 22 | ||
@@ -41,7 +42,10 @@ router.get('/cancelOrder', orderDetailController.cancelOrder); // 取消订单 | @@ -41,7 +42,10 @@ router.get('/cancelOrder', orderDetailController.cancelOrder); // 取消订单 | ||
41 | 42 | ||
42 | router.get('/', homeController.index); // 个人中心首页 | 43 | router.get('/', homeController.index); // 个人中心首页 |
43 | router.get('/mydetails', homeController.myDetails); // 个人基本资料页面 | 44 | router.get('/mydetails', homeController.myDetails); // 个人基本资料页面 |
44 | -router.get('/record', homeController.record); // 浏览记录 | 45 | + |
46 | +router.get('/mycurrency', currencyController.myCurrency); // yoho币总数 | ||
47 | +router.get('/currencyDetail', currencyController.currencyDetail); // yoho币列表 | ||
48 | +router.post('/ajaxCurrencyDetail', currencyController.ajaxCurrencyDetail); // yoho币列表 | ||
45 | 49 | ||
46 | // 我的收藏 | 50 | // 我的收藏 |
47 | router.get('/favorite', favorite.favorite); | 51 | router.get('/favorite', favorite.favorite); |
apps/home/views/action/currency-detail.hbs
0 → 100644
apps/home/views/action/currency-new.hbs
0 → 100644
1 | +<div class="yoho-coin-new-page yoho-page"> | ||
2 | + <div class="coin"> | ||
3 | + {{# yohoCoin}} | ||
4 | + <p class="coin-num"> | ||
5 | + {{yohocoinNum}} | ||
6 | + </p> | ||
7 | + <p class="info"> | ||
8 | + <span class="dollar"></span> | ||
9 | + 个YOHO币 | ||
10 | + </p> | ||
11 | + <a href="/home/currencyDetail" class="more">查看明细</a> | ||
12 | + {{#if notice}} | ||
13 | + <div class="coin-tip"> | ||
14 | + <span class="icon">!</span> | ||
15 | + {{notice}} | ||
16 | + </div> | ||
17 | + {{/if}} | ||
18 | + {{/ yohoCoin}} | ||
19 | + </div> | ||
20 | + <div class="banner"> | ||
21 | + {{#banner}} | ||
22 | + <a href="{{url}}"> | ||
23 | + <img src="{{img}}" alt="img"> | ||
24 | + </a> | ||
25 | + {{/banner}} | ||
26 | + </div> | ||
27 | + | ||
28 | + {{!-- {{> home/maybe_like}} --}} | ||
29 | +</div> |
apps/home/views/action/currency.hbs
0 → 100644
@@ -567,7 +567,7 @@ let _getRefundExchange = (skn) => { | @@ -567,7 +567,7 @@ let _getRefundExchange = (skn) => { | ||
567 | method: 'app.product.refundExchange', | 567 | method: 'app.product.refundExchange', |
568 | product_skn: _.toString(skn) | 568 | product_skn: _.toString(skn) |
569 | }).then((result) => { | 569 | }).then((result) => { |
570 | - console.log(result) | 570 | + // console.log(result) |
571 | if (result.code === 200) { | 571 | if (result.code === 200) { |
572 | let limit; | 572 | let limit; |
573 | let productSkn = _.toString(skn); | 573 | let productSkn = _.toString(skn); |
public/js/home/currency-detail.page.js
0 → 100644
1 | +var $ = require('yoho-jquery'), | ||
2 | + loading = require('../plugin/loading'); | ||
3 | +var page = 1; | ||
4 | +var flag = true; | ||
5 | + | ||
6 | +loading.showLoadingMask(); | ||
7 | + | ||
8 | +function ajaxCurrencyDetail(curPage) { | ||
9 | + flag = false; | ||
10 | + $.ajax({ | ||
11 | + type: 'post', | ||
12 | + url: '/home/ajaxCurrencyDetail', | ||
13 | + dataType: 'html', | ||
14 | + data: { | ||
15 | + page: curPage | ||
16 | + }, | ||
17 | + success: function(data) { | ||
18 | + $('.coin-detail').append(data); | ||
19 | + flag = true; | ||
20 | + } | ||
21 | + }); | ||
22 | +} | ||
23 | + | ||
24 | +function scrollHandler() { | ||
25 | + if ($(window).scrollTop() + $(window).height() > $('body').height() - 100 && flag) { | ||
26 | + page++; | ||
27 | + ajaxCurrencyDetail(page); | ||
28 | + return; | ||
29 | + } | ||
30 | +} | ||
31 | + | ||
32 | +$(window).scroll(function() { | ||
33 | + window.requestAnimationFrame(scrollHandler); | ||
34 | +}); | ||
35 | + | ||
36 | +ajaxCurrencyDetail(page); | ||
37 | + | ||
38 | +$(document).ready(loading.hideLoadingMask); |
-
Please register or login to post a comment