Merge branch 'feature/ctxlj' into 'release/6.0'
Feature/ctxlj 个人中心ctx优化 See merge request !754
Showing
21 changed files
with
564 additions
and
621 deletions
@@ -5,7 +5,7 @@ const headerModel = require('../../../doraemon/models/header'), // 头部model | @@ -5,7 +5,7 @@ const headerModel = require('../../../doraemon/models/header'), // 头部model | ||
5 | 5 | ||
6 | // status为使用状态 | 6 | // status为使用状态 |
7 | const index = (req, res, next) => { | 7 | const index = (req, res, next) => { |
8 | - model.couponData({ | 8 | + req.ctx(model).couponData({ |
9 | method: 'app.coupons.li', | 9 | method: 'app.coupons.li', |
10 | uid: req.user.uid, | 10 | uid: req.user.uid, |
11 | status: req.body.status || 0, | 11 | status: req.body.status || 0, |
@@ -29,7 +29,7 @@ const index = (req, res, next) => { | @@ -29,7 +29,7 @@ const index = (req, res, next) => { | ||
29 | }; | 29 | }; |
30 | 30 | ||
31 | const couponsAjax = (req, res, next) => { | 31 | const couponsAjax = (req, res, next) => { |
32 | - model.couponData({ | 32 | + req.ctx(model).couponData({ |
33 | method: 'app.coupons.li', | 33 | method: 'app.coupons.li', |
34 | uid: req.user.uid, | 34 | uid: req.user.uid, |
35 | status: parseInt(req.body.status || 0, 10), | 35 | status: parseInt(req.body.status || 0, 10), |
@@ -15,7 +15,7 @@ const favorite = (req, res, next) => { | @@ -15,7 +15,7 @@ const favorite = (req, res, next) => { | ||
15 | let page = 1; | 15 | let page = 1; |
16 | let limit = 10; | 16 | let limit = 10; |
17 | 17 | ||
18 | - favoriteModel.index(uid, page, limit, tab === 'brand').then((result)=>{ | 18 | + req.ctx(favoriteModel).index(uid, page, limit, tab === 'brand').then((result)=>{ |
19 | res.render('favorite', { | 19 | res.render('favorite', { |
20 | module: 'home', | 20 | module: 'home', |
21 | page: 'favorite', | 21 | page: 'favorite', |
@@ -39,7 +39,7 @@ let favProduct = (req, res, next) => { | @@ -39,7 +39,7 @@ let favProduct = (req, res, next) => { | ||
39 | let page = req.query.page || 1; | 39 | let page = req.query.page || 1; |
40 | let limit = 10; | 40 | let limit = 10; |
41 | 41 | ||
42 | - favoriteModel.favProduct(uid, page, limit).then((result) => { | 42 | + req.ctx(favoriteModel).favProduct(uid, page, limit).then((result) => { |
43 | if (typeof(result.total) === 'undefined' && typeof(result.more) === 'undefined') { | 43 | if (typeof(result.total) === 'undefined' && typeof(result.more) === 'undefined') { |
44 | res.render('favorite/favorite-product', { | 44 | res.render('favorite/favorite-product', { |
45 | layout: false, | 45 | layout: false, |
@@ -56,7 +56,7 @@ let favfavBrand = (req, res, next) => { | @@ -56,7 +56,7 @@ let favfavBrand = (req, res, next) => { | ||
56 | let page = req.query.page || 1; | 56 | let page = req.query.page || 1; |
57 | let limit = 10; | 57 | let limit = 10; |
58 | 58 | ||
59 | - favoriteModel.favfavBrand(uid, page, limit).then((result) => { | 59 | + req.ctx(favoriteModel).favfavBrand(uid, page, limit).then((result) => { |
60 | 60 | ||
61 | if (typeof(result.total) === 'undefined' && typeof(result.more) === 'undefined') { | 61 | if (typeof(result.total) === 'undefined' && typeof(result.more) === 'undefined') { |
62 | res.render('favorite/favorite-brand', { | 62 | res.render('favorite/favorite-brand', { |
@@ -75,7 +75,7 @@ let favoriteDelete = (req, res, next) => { | @@ -75,7 +75,7 @@ let favoriteDelete = (req, res, next) => { | ||
75 | let type = 'product'; | 75 | let type = 'product'; |
76 | let favId = req.body.id; | 76 | let favId = req.body.id; |
77 | 77 | ||
78 | - favoriteModel.favoriteDelete(uid, type, favId).then((result) => { | 78 | + req.ctx(favoriteModel).favoriteDelete(uid, type, favId).then((result) => { |
79 | res.json(result); | 79 | res.json(result); |
80 | }).catch(next); | 80 | }).catch(next); |
81 | }; | 81 | }; |
apps/home/controllers/help.js
deleted
100644 → 0
1 | -// 帮助 by acgpiano | ||
2 | -'use strict'; | ||
3 | -const headerModel = require('../../../doraemon/models/header'), // 头部model | ||
4 | - model = require('../models/help'); | ||
5 | - | ||
6 | -exports.index = (req, res, next) => { | ||
7 | - model.getHelpList().then(result => { | ||
8 | - res.render('help', { | ||
9 | - module: 'home', | ||
10 | - page: 'help', | ||
11 | - pageHeader: headerModel.setNav({ | ||
12 | - navTitle: '帮助中心', | ||
13 | - navBtn: false | ||
14 | - }), | ||
15 | - title: '帮助中心', | ||
16 | - pageFooter: true, | ||
17 | - iHelp: result | ||
18 | - }); | ||
19 | - }).catch(next); | ||
20 | -}; | ||
21 | - | ||
22 | -exports.helpDetail = (req, res, next) => { | ||
23 | - model.getHelpDetail(req.query.code).then(result => { | ||
24 | - res.render('help-detail', { | ||
25 | - module: 'home', | ||
26 | - page: 'help-detail', | ||
27 | - pageHeader: headerModel.setNav({ | ||
28 | - navTitle: req.query.name, | ||
29 | - navBtn: false | ||
30 | - }), | ||
31 | - title: req.query.name, | ||
32 | - pageFooter: true, | ||
33 | - detail: result | ||
34 | - }); | ||
35 | - }).catch(next); | ||
36 | -}; |
@@ -4,7 +4,7 @@ const headerModel = require('../../../doraemon/models/header'), // 头部model | @@ -4,7 +4,7 @@ const headerModel = require('../../../doraemon/models/header'), // 头部model | ||
4 | model = require('../models/message'); | 4 | model = require('../models/message'); |
5 | 5 | ||
6 | const _getList = (req, res, next) => { | 6 | const _getList = (req, res, next) => { |
7 | - model.getList({ | 7 | + req.ctx(model).getList({ |
8 | page: req.body.page, | 8 | page: req.body.page, |
9 | size: 20, | 9 | size: 20, |
10 | uid: req.user.uid, | 10 | uid: req.user.uid, |
@@ -26,7 +26,7 @@ const _getList = (req, res, next) => { | @@ -26,7 +26,7 @@ const _getList = (req, res, next) => { | ||
26 | }; | 26 | }; |
27 | 27 | ||
28 | const _msgDetail = (req, res, next) => { | 28 | const _msgDetail = (req, res, next) => { |
29 | - model.getList({ | 29 | + req.ctx(model).getList({ |
30 | page: req.body.page, | 30 | page: req.body.page, |
31 | size: 1000, | 31 | size: 1000, |
32 | msgid: req.query.id, | 32 | msgid: req.query.id, |
@@ -61,7 +61,7 @@ exports.index = (req, res, next) => { | @@ -61,7 +61,7 @@ exports.index = (req, res, next) => { | ||
61 | }; | 61 | }; |
62 | 62 | ||
63 | exports.ajaxDelMes = (req, res, next) => { | 63 | exports.ajaxDelMes = (req, res, next) => { |
64 | - model.delMsg({ | 64 | + req.ctx(model).delMsg({ |
65 | uid: req.user.uid, | 65 | uid: req.user.uid, |
66 | msgid: req.body.id, | 66 | msgid: req.body.id, |
67 | }).then(result => { | 67 | }).then(result => { |
@@ -71,7 +71,7 @@ exports.ajaxDelMes = (req, res, next) => { | @@ -71,7 +71,7 @@ exports.ajaxDelMes = (req, res, next) => { | ||
71 | }; | 71 | }; |
72 | 72 | ||
73 | exports.pickCoupon = (req, res, next) => { | 73 | exports.pickCoupon = (req, res, next) => { |
74 | - model.pickCoupon({ | 74 | + req.ctx(model).pickCoupon({ |
75 | uid: req.user.uid, | 75 | uid: req.user.uid, |
76 | couponId: req.body.id, | 76 | couponId: req.body.id, |
77 | }).then(result => { | 77 | }).then(result => { |
@@ -92,7 +92,7 @@ exports.birthCoupon = (req, res, next) => { | @@ -92,7 +92,7 @@ exports.birthCoupon = (req, res, next) => { | ||
92 | pageFooter: true | 92 | pageFooter: true |
93 | }; | 93 | }; |
94 | 94 | ||
95 | - model._getBirthCouponById(req.user.uid).then(result => { | 95 | + req.ctx(model)._getBirthCouponById(req.user.uid).then(result => { |
96 | res.render('birth-coupon', Object.assign(responseData, result)); | 96 | res.render('birth-coupon', Object.assign(responseData, result)); |
97 | }).catch(next); | 97 | }).catch(next); |
98 | }; | 98 | }; |
@@ -14,8 +14,7 @@ const myCurrency = (req, res, next) => { | @@ -14,8 +14,7 @@ const myCurrency = (req, res, next) => { | ||
14 | let uid = req.user.uid; | 14 | let uid = req.user.uid; |
15 | let contentCode = '05afedf76886d732573f10f7451a1703'; | 15 | let contentCode = '05afedf76886d732573f10f7451a1703'; |
16 | 16 | ||
17 | - myCurrencyModel.myCurrency(uid, contentCode).then(result => { | ||
18 | - | 17 | + req.ctx(myCurrencyModel).myCurrency(uid, contentCode).then(result => { |
19 | res.render('currency-new', { | 18 | res.render('currency-new', { |
20 | module: 'home', | 19 | module: 'home', |
21 | page: 'mycurrency', | 20 | page: 'mycurrency', |
@@ -39,7 +38,7 @@ const currencyDetail = (req, res, next) => { | @@ -39,7 +38,7 @@ const currencyDetail = (req, res, next) => { | ||
39 | let page = 1; | 38 | let page = 1; |
40 | let limit = 10; | 39 | let limit = 10; |
41 | 40 | ||
42 | - myCurrencyModel.currencyDetailIndex(uid, page, limit).then(result => { | 41 | + req.ctx(myCurrencyModel).currencyDetailIndex(uid, page, limit).then(result => { |
43 | res.render('currency-detail', { | 42 | res.render('currency-detail', { |
44 | module: 'home', | 43 | module: 'home', |
45 | page: 'currencyDetail', | 44 | page: 'currencyDetail', |
@@ -63,7 +62,7 @@ let ajaxCurrencyDetail = (req, res, next) => { | @@ -63,7 +62,7 @@ let ajaxCurrencyDetail = (req, res, next) => { | ||
63 | let page = req.body.page || 1; | 62 | let page = req.body.page || 1; |
64 | let limit = 10; | 63 | let limit = 10; |
65 | 64 | ||
66 | - myCurrencyModel.currencyDetail(uid, page, limit).then((result) => { | 65 | + req.ctx(myCurrencyModel).currencyDetail(uid, page, limit).then(result => { |
67 | res.json(result); | 66 | res.json(result); |
68 | }).catch(next); | 67 | }).catch(next); |
69 | }; | 68 | }; |
@@ -20,7 +20,7 @@ exports.index = (req, res, next) => { | @@ -20,7 +20,7 @@ exports.index = (req, res, next) => { | ||
20 | } catch (e) { | 20 | } catch (e) { |
21 | uname = params.uname; | 21 | uname = params.uname; |
22 | } | 22 | } |
23 | - model.getQr({ | 23 | + req.ctx(model).getQr({ |
24 | token: params.token, | 24 | token: params.token, |
25 | }).then(result => { | 25 | }).then(result => { |
26 | params.token = result; | 26 | params.token = result; |
@@ -11,7 +11,7 @@ const QRcodeModel = require('../models/qrcode'); | @@ -11,7 +11,7 @@ const QRcodeModel = require('../models/qrcode'); | ||
11 | exports.QRcode = (req, res, next) => { | 11 | exports.QRcode = (req, res, next) => { |
12 | let id = req.params.id || 0; | 12 | let id = req.params.id || 0; |
13 | 13 | ||
14 | - QRcodeModel.getQRcodeData(id, req.user.uid).then((result)=>{ | 14 | + req.ctx(QRcodeModel).getQRcodeData(id, req.user.uid).then((result)=>{ |
15 | if (result) { | 15 | if (result) { |
16 | result.ticks = result.ticks.map(item=>{ | 16 | result.ticks = result.ticks.map(item=>{ |
17 | if (+item.ticket_type === 2) { | 17 | if (+item.ticket_type === 2) { |
@@ -4,37 +4,41 @@ | @@ -4,37 +4,41 @@ | ||
4 | const api = global.yoho.API; | 4 | const api = global.yoho.API; |
5 | const helpers = global.yoho.helpers; | 5 | const helpers = global.yoho.helpers; |
6 | 6 | ||
7 | -const couponData = (params) => { | ||
8 | - return api.get('', params).then(result => { | ||
9 | - | ||
10 | - if (result && result.data && result.data.couponList) { | ||
11 | - let status0 = params.status === 0; | ||
12 | - let status1 = params.status === 1; | ||
13 | - | ||
14 | - return result.data.couponList.map(function(elem) { | ||
15 | - delete elem.id; | ||
16 | - | ||
17 | - if (status0) { | ||
18 | - elem.bestowLink = helpers.urlFormat('/product/index/index', | ||
19 | - { | ||
20 | - coupon_id: elem.couponId, | ||
21 | - coupon_code: elem.couponCode, | ||
22 | - title: '优惠活动商品', | ||
23 | - intro_text: `以下商品可使用【${elem.couponDetailInfomation}】优惠券` | ||
24 | - } | ||
25 | - ); | ||
26 | - } else if (status1) { | ||
27 | - delete elem.overState; | ||
28 | - elem.employbg = true; | ||
29 | - } | ||
30 | - return elem; | ||
31 | - }); | ||
32 | - } | ||
33 | - | ||
34 | - return []; | ||
35 | - }); | ||
36 | -}; | ||
37 | - | ||
38 | -module.exports = { | ||
39 | - couponData | ||
40 | -}; | 7 | +class couponsModel extends global.yoho.BaseModel { |
8 | + constructor(ctx) { | ||
9 | + super(ctx); | ||
10 | + } | ||
11 | + | ||
12 | + couponData(params) { | ||
13 | + return api.get('', params).then(result => { | ||
14 | + | ||
15 | + if (result && result.data && result.data.couponList) { | ||
16 | + let status0 = params.status === 0; | ||
17 | + let status1 = params.status === 1; | ||
18 | + | ||
19 | + return result.data.couponList.map(function(elem) { | ||
20 | + delete elem.id; | ||
21 | + | ||
22 | + if (status0) { | ||
23 | + elem.bestowLink = helpers.urlFormat('/product/index/index', | ||
24 | + { | ||
25 | + coupon_id: elem.couponId, | ||
26 | + coupon_code: elem.couponCode, | ||
27 | + title: '优惠活动商品', | ||
28 | + intro_text: `以下商品可使用【${elem.couponDetailInfomation}】优惠券` | ||
29 | + } | ||
30 | + ); | ||
31 | + } else if (status1) { | ||
32 | + delete elem.overState; | ||
33 | + elem.employbg = true; | ||
34 | + } | ||
35 | + return elem; | ||
36 | + }); | ||
37 | + } | ||
38 | + | ||
39 | + return []; | ||
40 | + }); | ||
41 | + } | ||
42 | +} | ||
43 | + | ||
44 | +module.exports = couponsModel; |
@@ -15,222 +15,223 @@ const _ = require('lodash'); | @@ -15,222 +15,223 @@ const _ = require('lodash'); | ||
15 | const config = global.yoho.config; | 15 | const config = global.yoho.config; |
16 | const helpers = global.yoho.helpers; | 16 | const helpers = global.yoho.helpers; |
17 | 17 | ||
18 | -const favProduct = (uid, page, limit) => { | ||
19 | - | ||
20 | - return api.get('', { | ||
21 | - method: 'app.favorite.product', | ||
22 | - uid: uid, | ||
23 | - page: page, | ||
24 | - limit: limit | ||
25 | - }).then((result) => { | ||
26 | - | ||
27 | - let resu = { | ||
28 | - hasFavProduct: [] | ||
29 | - }; | 18 | +class favoriteIndexModel extends global.yoho.BaseModel { |
19 | + constructor(ctx) { | ||
20 | + super(ctx); | ||
21 | + } | ||
30 | 22 | ||
31 | - if (result && result.code === 200) { | 23 | + favProduct(uid, page, limit) { |
32 | 24 | ||
33 | - let list = camelCase(result); | 25 | + return api.get('', { |
26 | + method: 'app.favorite.product', | ||
27 | + uid: uid, | ||
28 | + page: page, | ||
29 | + limit: limit | ||
30 | + }).then((result) => { | ||
34 | 31 | ||
35 | - if (page > 1 && list === []) { | ||
36 | - resu.end = true; | ||
37 | - } | 32 | + let resu = { |
33 | + hasFavProduct: [] | ||
34 | + }; | ||
38 | 35 | ||
39 | - if (list.data.total === 0) { | ||
40 | - resu.total = 0; | ||
41 | - } | 36 | + if (result && result.code === 200) { |
42 | 37 | ||
43 | - if (page <= list.data.pageTotal) { | ||
44 | - list.data.productList = _.filter(list.data.productList, function(n) { | ||
45 | - return n.productSkn > 0; | ||
46 | - }); | ||
47 | - _.forEach(list.data.productList, function(val) { | ||
48 | - let obj = {}; | 38 | + let list = camelCase(result); |
49 | 39 | ||
50 | - // if (empty(val.productSkn)) { | ||
51 | - // continue; | ||
52 | - // } | 40 | + if (page > 1 && list === []) { |
41 | + resu.end = true; | ||
42 | + } | ||
53 | 43 | ||
54 | - if (val.goodsId && val.cnAlphabet) { | ||
55 | - obj = _.assign(obj, { | ||
56 | - link: config.siteUrl + '/product/' + val.productSkn + '.html' // 商品url改版 | ||
57 | - }); | ||
58 | - } else { | ||
59 | - obj = _.assign(obj, { | ||
60 | - link: '' | ||
61 | - }); | ||
62 | - } | 44 | + if (list.data.total === 0) { |
45 | + resu.total = 0; | ||
46 | + } | ||
63 | 47 | ||
64 | - if (val.image) { | ||
65 | - obj = _.assign(obj, { | ||
66 | - imgUrl: val.image | ||
67 | - }); | ||
68 | - } else { | ||
69 | - obj = _.assign(obj, { | ||
70 | - imgUrl: '' | ||
71 | - }); | ||
72 | - } | ||
73 | - | ||
74 | - if (val.marketPrice - val.salesPrice > 0) { | ||
75 | - obj = _.assign(obj, { | ||
76 | - discountPrice: '¥' + Number(val.salesPrice).toFixed(2) | ||
77 | - }); | ||
78 | - } | ||
79 | - | ||
80 | - if (val.priceDown > 0) { | ||
81 | - obj = _.assign(obj, { | ||
82 | - savePrice: '¥' + Number(val.priceDown).toFixed(2) | ||
83 | - }); | ||
84 | - } else { | ||
85 | - obj = _.assign(obj, { | ||
86 | - savePrice: false | ||
87 | - }); | ||
88 | - } | 48 | + if (page <= list.data.pageTotal) { |
49 | + list.data.productList = _.filter(list.data.productList, function(n) { | ||
50 | + return n.productSkn > 0; | ||
51 | + }); | ||
52 | + _.forEach(list.data.productList, function(val) { | ||
53 | + let obj = {}; | ||
54 | + | ||
55 | + // if (empty(val.productSkn)) { | ||
56 | + // continue; | ||
57 | + // } | ||
58 | + | ||
59 | + if (val.goodsId && val.cnAlphabet) { | ||
60 | + obj = _.assign(obj, { | ||
61 | + link: config.siteUrl + '/product/' + val.productSkn + '.html' // 商品url改版 | ||
62 | + }); | ||
63 | + } else { | ||
64 | + obj = _.assign(obj, { | ||
65 | + link: '' | ||
66 | + }); | ||
67 | + } | ||
68 | + | ||
69 | + if (val.image) { | ||
70 | + obj = _.assign(obj, { | ||
71 | + imgUrl: val.image | ||
72 | + }); | ||
73 | + } else { | ||
74 | + obj = _.assign(obj, { | ||
75 | + imgUrl: '' | ||
76 | + }); | ||
77 | + } | ||
78 | + | ||
79 | + if (val.marketPrice - val.salesPrice > 0) { | ||
80 | + obj = _.assign(obj, { | ||
81 | + discountPrice: '¥' + Number(val.salesPrice).toFixed(2) | ||
82 | + }); | ||
83 | + } | ||
84 | + | ||
85 | + if (val.priceDown > 0) { | ||
86 | + obj = _.assign(obj, { | ||
87 | + savePrice: '¥' + Number(val.priceDown).toFixed(2) | ||
88 | + }); | ||
89 | + } else { | ||
90 | + obj = _.assign(obj, { | ||
91 | + savePrice: false | ||
92 | + }); | ||
93 | + } | ||
94 | + | ||
95 | + if (val.storage <= 0) { | ||
96 | + obj = _.assign(obj, { | ||
97 | + sellOut: true | ||
98 | + }); | ||
99 | + } | ||
89 | 100 | ||
90 | - if (val.storage <= 0) { | ||
91 | obj = _.assign(obj, { | 101 | obj = _.assign(obj, { |
92 | - sellOut: true | 102 | + favId: val.productId, |
103 | + title: val.productName, | ||
104 | + price: '¥' + Number(val.marketPrice).toFixed(2), | ||
105 | + invalidGoods: val.status === 0 | ||
93 | }); | 106 | }); |
94 | - } | ||
95 | 107 | ||
96 | - obj = _.assign(obj, { | ||
97 | - favId: val.productId, | ||
98 | - title: val.productName, | ||
99 | - price: '¥' + Number(val.marketPrice).toFixed(2), | ||
100 | - invalidGoods: val.status === 0 | 108 | + resu.hasFavProduct.push(obj); |
101 | }); | 109 | }); |
102 | 110 | ||
103 | - resu.hasFavProduct.push(obj); | ||
104 | - }); | 111 | + } else { |
112 | + resu.more = true; | ||
113 | + } | ||
105 | 114 | ||
115 | + return resu; | ||
106 | } else { | 116 | } else { |
107 | - resu.more = true; | 117 | + logger.error('fav goods code no 200'); |
118 | + return { | ||
119 | + total: 0 | ||
120 | + }; | ||
108 | } | 121 | } |
122 | + }); | ||
123 | + } | ||
109 | 124 | ||
110 | - return resu; | ||
111 | - } else { | ||
112 | - logger.error('fav goods code no 200'); | ||
113 | - return { | ||
114 | - total: 0 | ||
115 | - }; | ||
116 | - } | ||
117 | - }); | ||
118 | -}; | 125 | + favfavBrand(uid, page, limit) { |
126 | + return api.get('', { | ||
127 | + method: 'app.favorite.brand', | ||
128 | + uid: uid, | ||
129 | + page: page, | ||
130 | + limit: limit | ||
131 | + }).then((result) => { | ||
119 | 132 | ||
120 | -const favfavBrand = (uid, page, limit) => { | 133 | + let resu = { |
134 | + hasFavBrand: [] | ||
135 | + }; | ||
121 | 136 | ||
122 | - return api.get('', { | ||
123 | - method: 'app.favorite.brand', | ||
124 | - uid: uid, | ||
125 | - page: page, | ||
126 | - limit: limit | ||
127 | - }).then((result) => { | 137 | + if (result && result.code === 200) { |
138 | + let list = camelCase(result); | ||
128 | 139 | ||
129 | - let resu = { | ||
130 | - hasFavBrand: [] | ||
131 | - }; | 140 | + if (page > 1 && list === []) { |
141 | + resu.end = true; | ||
142 | + } | ||
132 | 143 | ||
133 | - if (result && result.code === 200) { | ||
134 | - let list = camelCase(result); | 144 | + if (list.data.total === 0) { |
145 | + resu.total = 0; | ||
146 | + } | ||
135 | 147 | ||
136 | - if (page > 1 && list === []) { | ||
137 | - resu.end = true; | ||
138 | - } | 148 | + if (page <= list.data.pageTotal) { |
139 | 149 | ||
140 | - if (list.data.total === 0) { | ||
141 | - resu.total = 0; | ||
142 | - } | 150 | + _.forEach(list.data.brandList, function(val) { |
151 | + let obj = { | ||
152 | + productList: [] | ||
153 | + }; | ||
143 | 154 | ||
144 | - if (page <= list.data.pageTotal) { | 155 | + // if (empty(val.productSkn)) { |
156 | + // continue; | ||
157 | + // } | ||
158 | + if (val.brandOrShopType === 'brandOrShopType') { | ||
159 | + obj = _.assign(obj, { | ||
160 | + link: helpers.urlFormat('/product/index/brand', { | ||
161 | + shop_id: val.shopId | ||
162 | + }) | ||
163 | + }); | ||
164 | + } else { | ||
165 | + obj = _.assign(obj, { | ||
166 | + link: helpers.urlFormat('', {}, val.brandDomain) | ||
145 | 167 | ||
146 | - _.forEach(list.data.brandList, function(val) { | ||
147 | - let obj = { | ||
148 | - productList: [] | ||
149 | - }; | 168 | + }); |
169 | + } | ||
150 | 170 | ||
151 | - // if (empty(val.productSkn)) { | ||
152 | - // continue; | ||
153 | - // } | ||
154 | - if (val.brandOrShopType === 'brandOrShopType') { | ||
155 | obj = _.assign(obj, { | 171 | obj = _.assign(obj, { |
156 | - link: helpers.urlFormat('/product/index/brand', { | ||
157 | - shop_id: val.shopId | ||
158 | - }) | 172 | + id: val.brandId, |
173 | + brandName: val.brandName, | ||
174 | + updata: val.newProductNum, | ||
175 | + discount: val.productDiscountNum, | ||
176 | + brandImg: val.brandIco, | ||
177 | + update: val.newProductNum | ||
159 | }); | 178 | }); |
160 | - } else { | ||
161 | - obj = _.assign(obj, { | ||
162 | - link: helpers.urlFormat('', {}, val.brandDomain) | ||
163 | 179 | ||
180 | + _.forEach(val.newProduct, function(data, key) { | ||
181 | + obj.productList.push({ | ||
182 | + link: '/product/' + data.productSkn + '.html', // 商品url改版 | ||
183 | + imgUrl: data.defaultImages, | ||
184 | + price: '¥' + Number(data.marketPrice).toFixed(2), | ||
185 | + discount: data.marketPrice > data.salesPrice ? '¥' + | ||
186 | + Number(data.salesPrice).toFixed(2) : false, | ||
187 | + top3: key < 3 ? 1 : 0 | ||
188 | + }); | ||
164 | }); | 189 | }); |
165 | - } | ||
166 | - | ||
167 | - obj = _.assign(obj, { | ||
168 | - id: val.brandId, | ||
169 | - brandName: val.brandName, | ||
170 | - updata: val.newProductNum, | ||
171 | - discount: val.productDiscountNum, | ||
172 | - brandImg: val.brandIco, | ||
173 | - update: val.newProductNum | ||
174 | - }); | ||
175 | 190 | ||
176 | - _.forEach(val.newProduct, function(data, key) { | ||
177 | - obj.productList.push({ | ||
178 | - link: '/product/' + data.productSkn + '.html', // 商品url改版 | ||
179 | - imgUrl: data.defaultImages, | ||
180 | - price: '¥' + Number(data.marketPrice).toFixed(2), | ||
181 | - discount: data.marketPrice > data.salesPrice ? '¥' + | ||
182 | - Number(data.salesPrice).toFixed(2) : false, | ||
183 | - top3: key < 3 ? 1 : 0 | ||
184 | - }); | 191 | + resu.hasFavBrand.push(obj); |
185 | }); | 192 | }); |
186 | 193 | ||
187 | - resu.hasFavBrand.push(obj); | ||
188 | - }); | 194 | + } else { |
195 | + resu.more = true; | ||
196 | + } | ||
189 | 197 | ||
198 | + return resu; | ||
190 | } else { | 199 | } else { |
191 | - resu.more = true; | 200 | + logger.error('fav brand code no 200'); |
201 | + return { | ||
202 | + total: 0 | ||
203 | + }; | ||
192 | } | 204 | } |
205 | + }); | ||
206 | + } | ||
207 | + | ||
208 | + favoriteDelete(uid, type, favId) { | ||
209 | + | ||
210 | + return api.get('', { | ||
211 | + method: 'app.favorite.cancel', | ||
212 | + uid: uid, | ||
213 | + type: type, | ||
214 | + fav_id: favId | ||
215 | + }); | ||
216 | + } | ||
193 | 217 | ||
194 | - return resu; | 218 | + index(uid, page, limit, isbrand) { |
219 | + if (isbrand) { | ||
220 | + return this.favfavBrand(uid, page, limit).then(result=> { | ||
221 | + if (result.total === 0) { | ||
222 | + result = {nobrandData: 1}; | ||
223 | + } | ||
224 | + return result; | ||
225 | + }); | ||
195 | } else { | 226 | } else { |
196 | - logger.error('fav brand code no 200'); | ||
197 | - return { | ||
198 | - total: 0 | ||
199 | - }; | 227 | + return this.favProduct(uid, page, limit).then(result=> { |
228 | + if (result.total === 0) { | ||
229 | + result = {noproductData: 1}; | ||
230 | + } | ||
231 | + return result; | ||
232 | + }); | ||
200 | } | 233 | } |
201 | - }); | ||
202 | -}; | ||
203 | - | ||
204 | -const favoriteDelete = (uid, type, favId) => { | ||
205 | - | ||
206 | - return api.get('', { | ||
207 | - method: 'app.favorite.cancel', | ||
208 | - uid: uid, | ||
209 | - type: type, | ||
210 | - fav_id: favId | ||
211 | - }); | ||
212 | -}; | ||
213 | -const index = (uid, page, limit, isbrand) => { | ||
214 | - if (isbrand) { | ||
215 | - return favfavBrand(uid, page, limit).then(result=> { | ||
216 | - if (result.total === 0) { | ||
217 | - result = {nobrandData: 1}; | ||
218 | - } | ||
219 | - return result; | ||
220 | - }); | ||
221 | - } else { | ||
222 | - return favProduct(uid, page, limit).then(result=> { | ||
223 | - if (result.total === 0) { | ||
224 | - result = {noproductData: 1}; | ||
225 | - } | ||
226 | - return result; | ||
227 | - }); | ||
228 | } | 234 | } |
229 | -}; | ||
230 | - | ||
231 | -module.exports = { | ||
232 | - favProduct, | ||
233 | - favfavBrand, | ||
234 | - favoriteDelete, | ||
235 | - index | ||
236 | -}; | 235 | +} |
236 | + | ||
237 | +module.exports = favoriteIndexModel; |
apps/home/models/help.js
deleted
100644 → 0
1 | -// 帮助 by acgpiano | ||
2 | -'use strict'; | ||
3 | - | ||
4 | -const api = global.yoho.API; | ||
5 | - | ||
6 | -// 获取帮助列表 | ||
7 | -exports.getHelpList = () => { | ||
8 | - return api.get('', { | ||
9 | - method: 'app.help.li' | ||
10 | - }).then(result => { | ||
11 | - if (result && result.code === 200 && result.data) { | ||
12 | - let final = []; | ||
13 | - | ||
14 | - for (let name of result.data) { | ||
15 | - final.push({ | ||
16 | - name: name.caption, | ||
17 | - code: name.code, | ||
18 | - }); | ||
19 | - } | ||
20 | - return final; | ||
21 | - } | ||
22 | - }); | ||
23 | -}; | ||
24 | - | ||
25 | -// 获取帮助详情 | ||
26 | -exports.getHelpDetail = (code) => { | ||
27 | - return api.get('', { | ||
28 | - method: 'app.help.detail', | ||
29 | - code: code, | ||
30 | - }).then(result => { | ||
31 | - return result.replace(/^<!DOCTYPE.*<body>/g, ''). | ||
32 | - replace(/<\/body>.*<\/html>/g, ''); | ||
33 | - }); | ||
34 | -}; |
@@ -15,199 +15,200 @@ const _formatDay = (day) => { | @@ -15,199 +15,200 @@ const _formatDay = (day) => { | ||
15 | return moment(day).format('YYYY.MM.DD'); | 15 | return moment(day).format('YYYY.MM.DD'); |
16 | }; | 16 | }; |
17 | 17 | ||
18 | -// 获取列表页 | ||
19 | -const _list = (result) => { | ||
20 | - let final = []; | ||
21 | - | ||
22 | - if (result.data && result.data.list) { | ||
23 | - // PHP排序了,应该不用 | ||
24 | - for (let item of result.data.list) { | ||
25 | - | ||
26 | - let obj = { | ||
27 | - id: item.id, | ||
28 | - isNotReaded: item.is_read === 'Y' ? false : true, | ||
29 | - title: item.title, | ||
30 | - time: `${item.create_date} ${_formatTime(item.create_time * 1000)}`, | ||
31 | - }; | ||
32 | - | ||
33 | - if (item.body && item.type === 'pullCoupon') { | ||
34 | - Object.assign(obj, { | ||
35 | - birthType: true, | ||
36 | - | ||
37 | - // name: item.body.name, | ||
38 | - // collarTime: item.body.collar_time, | ||
39 | - // useTime: item.body.use_time, | ||
40 | - isCollar: item.body.is_collar === 'Y' ? true : false, | ||
41 | - isOverTime: item.body.is_over_time === 'Y' ? true : false | ||
42 | - }); | ||
43 | - } | 18 | +class messageModel extends global.yoho.BaseModel { |
19 | + constructor(ctx) { | ||
20 | + super(ctx); | ||
21 | + } | ||
22 | + | ||
23 | + // 获取列表页 | ||
24 | + _list(result) { | ||
25 | + let final = []; | ||
26 | + | ||
27 | + if (result.data && result.data.list) { | ||
28 | + // PHP排序了,应该不用 | ||
29 | + for (let item of result.data.list) { | ||
30 | + | ||
31 | + let obj = { | ||
32 | + id: item.id, | ||
33 | + isNotReaded: item.is_read === 'Y' ? false : true, | ||
34 | + title: item.title, | ||
35 | + time: `${item.create_date} ${_formatTime(item.create_time * 1000)}`, | ||
36 | + }; | ||
37 | + | ||
38 | + if (item.body && item.type === 'pullCoupon') { | ||
39 | + Object.assign(obj, { | ||
40 | + birthType: true, | ||
44 | 41 | ||
45 | - final.push(obj); | 42 | + // name: item.body.name, |
43 | + // collarTime: item.body.collar_time, | ||
44 | + // useTime: item.body.use_time, | ||
45 | + isCollar: item.body.is_collar === 'Y' ? true : false, | ||
46 | + isOverTime: item.body.is_over_time === 'Y' ? true : false | ||
47 | + }); | ||
48 | + } | ||
49 | + | ||
50 | + final.push(obj); | ||
51 | + } | ||
46 | } | 52 | } |
53 | + return final; | ||
47 | } | 54 | } |
48 | - return final; | ||
49 | -}; | ||
50 | 55 | ||
51 | -// 获取生日信息 | ||
52 | -const _getBirthCouponById = (uid) => { | ||
53 | - return api.get('', { | ||
54 | - method: 'app.promotion.queryBirthCoupon', | ||
55 | - uid: uid, | ||
56 | - couponType: 4, | ||
57 | - }).then(result => { | ||
58 | - if (result && result.data) { | ||
59 | - let final = { | ||
60 | - ticket: [] | ||
61 | - }; | ||
62 | - | ||
63 | - final.birthType = true; | ||
64 | - if (result.data.list && result.data.list[0].body.is_collar === 'Y') { | ||
65 | - final = { | ||
66 | - isCollar: true | 56 | + // 获取生日信息 |
57 | + _getBirthCouponById(uid) { | ||
58 | + return api.get('', { | ||
59 | + method: 'app.promotion.queryBirthCoupon', | ||
60 | + uid: uid, | ||
61 | + couponType: 4, | ||
62 | + }).then(result => { | ||
63 | + if (result && result.data) { | ||
64 | + let final = { | ||
65 | + ticket: [] | ||
67 | }; | 66 | }; |
68 | - } else { | ||
69 | - if (result.data && !result.data[0].err) { | ||
70 | - for (let coupon of result.data) { | ||
71 | - final.ticket.push({ | ||
72 | - id: coupon.id ? coupon.id : '', | ||
73 | - couponAmount: coupon.couponAmount, | ||
74 | - couponName: coupon.couponName.split('-')[0], | ||
75 | - startTime: _formatDay(coupon.startTime), | ||
76 | - endTime: _formatDay(coupon.endTime), | ||
77 | - useLimit: coupon.useLimit | ||
78 | - }); | ||
79 | - } | ||
80 | - } else { | 67 | + |
68 | + final.birthType = true; | ||
69 | + if (result.data.list && result.data.list[0].body.is_collar === 'Y') { | ||
81 | final = { | 70 | final = { |
82 | - err: result.data[0].err | 71 | + isCollar: true |
83 | }; | 72 | }; |
73 | + } else { | ||
74 | + if (result.data && !result.data[0].err) { | ||
75 | + for (let coupon of result.data) { | ||
76 | + final.ticket.push({ | ||
77 | + id: coupon.id ? coupon.id : '', | ||
78 | + couponAmount: coupon.couponAmount, | ||
79 | + couponName: coupon.couponName.split('-')[0], | ||
80 | + startTime: _formatDay(coupon.startTime), | ||
81 | + endTime: _formatDay(coupon.endTime), | ||
82 | + useLimit: coupon.useLimit | ||
83 | + }); | ||
84 | + } | ||
85 | + } else { | ||
86 | + final = { | ||
87 | + err: result.data[0].err | ||
88 | + }; | ||
89 | + } | ||
84 | } | 90 | } |
85 | - } | ||
86 | - return final; | ||
87 | - } else { | ||
88 | - if (result.code === 410) { | ||
89 | - return [{err: result.message}]; | ||
90 | - } else if (result.code === 411) { | ||
91 | - return [{err: result.message}]; | 91 | + return final; |
92 | } else { | 92 | } else { |
93 | - return []; | 93 | + if (result.code === 410) { |
94 | + return [{err: result.message}]; | ||
95 | + } else if (result.code === 411) { | ||
96 | + return [{err: result.message}]; | ||
97 | + } else { | ||
98 | + return []; | ||
99 | + } | ||
94 | } | 100 | } |
95 | - } | ||
96 | - }); | ||
97 | -}; | 101 | + }); |
102 | + } | ||
98 | 103 | ||
99 | -// 获取详情页 | ||
100 | -const _detail = (result, id) => { | ||
101 | - let final = {}; | ||
102 | - | ||
103 | - if (result.data && result.data.list) { | ||
104 | - for (let item of result.data.list) { | ||
105 | - if (item.id === Number(id) && item.type !== 'showGetCoin' && item.type !== 'notice') { | ||
106 | - final.sender = item.from; | ||
107 | - final.title = item.title; | ||
108 | - final.time = `${item.create_date} ${_formatTime(item.create_time * 1000)}`; // 时间 | ||
109 | - | ||
110 | - // 判断消息类型 | ||
111 | - switch (item.type) { | ||
112 | - case 'button': | ||
113 | - // 促销活动 | ||
114 | - if (item.body) { | ||
115 | - final.sale = { | ||
116 | - image: item.body.image ? item.body.image : '', | ||
117 | - content: item.body.text ? item.body.text : '', | ||
118 | - btnLink: item.body.pc_link ? item.body.pc_link : '', | ||
119 | - btnName: item.body.button_text ? item.body.button_text : '', | 104 | + // 获取详情页 |
105 | + _detail(result, id) { | ||
106 | + let final = {}; | ||
107 | + | ||
108 | + if (result.data && result.data.list) { | ||
109 | + for (let item of result.data.list) { | ||
110 | + if (item.id === Number(id) && item.type !== 'showGetCoin' && item.type !== 'notice') { | ||
111 | + final.sender = item.from; | ||
112 | + final.title = item.title; | ||
113 | + final.time = `${item.create_date} ${_formatTime(item.create_time * 1000)}`; // 时间 | ||
114 | + | ||
115 | + // 判断消息类型 | ||
116 | + switch (item.type) { | ||
117 | + case 'button': | ||
118 | + // 促销活动 | ||
119 | + if (item.body) { | ||
120 | + final.sale = { | ||
121 | + image: item.body.image ? item.body.image : '', | ||
122 | + content: item.body.text ? item.body.text : '', | ||
123 | + btnLink: item.body.pc_link ? item.body.pc_link : '', | ||
124 | + btnName: item.body.button_text ? item.body.button_text : '', | ||
125 | + }; | ||
126 | + } | ||
127 | + break; | ||
128 | + case 'pushCoupon': | ||
129 | + // 查看优惠券 | ||
130 | + if (item.body) { | ||
131 | + final.coupons = []; | ||
132 | + final.coupons.push({ | ||
133 | + remark: item.body.coupon_name ? item.body.coupon_name : '', | ||
134 | + useTime: item.body.time ? item.body.time : '', | ||
135 | + id: item.body.inboxId ? item.body.inboxId : '', | ||
136 | + price: item.body.price ? item.body.price : '', | ||
137 | + url: helpers.urlFormat('/home/coupons', { | ||
138 | + t: (new Date().getTime()) / 1000, | ||
139 | + }), | ||
140 | + }); | ||
141 | + } | ||
142 | + break; | ||
143 | + default: | ||
144 | + // 普通文本 | ||
145 | + final.text = { | ||
146 | + content: item.body.content ? item.body.content : '', | ||
120 | }; | 147 | }; |
121 | - } | ||
122 | - break; | ||
123 | - case 'pushCoupon': | ||
124 | - // 查看优惠券 | ||
125 | - if (item.body) { | ||
126 | - final.coupons = []; | ||
127 | - final.coupons.push({ | ||
128 | - remark: item.body.coupon_name ? item.body.coupon_name : '', | ||
129 | - useTime: item.body.time ? item.body.time : '', | ||
130 | - id: item.body.inboxId ? item.body.inboxId : '', | ||
131 | - price: item.body.price ? item.body.price : '', | ||
132 | - url: helpers.urlFormat('/home/coupons', { | ||
133 | - t: (new Date().getTime()) / 1000, | ||
134 | - }), | ||
135 | - }); | ||
136 | - } | ||
137 | - break; | ||
138 | - default: | ||
139 | - // 普通文本 | ||
140 | - final.text = { | ||
141 | - content: item.body.content ? item.body.content : '', | ||
142 | - }; | ||
143 | - break; | 148 | + break; |
149 | + } | ||
144 | } | 150 | } |
145 | } | 151 | } |
146 | } | 152 | } |
153 | + return final; | ||
147 | } | 154 | } |
148 | - return final; | ||
149 | -}; | ||
150 | 155 | ||
151 | -// 获取列表或详情 | ||
152 | -const getList = (params) => { | ||
153 | - return api.get('', { | ||
154 | - method: 'app.inbox.getlist', | ||
155 | - page: params.page || 1, | ||
156 | - size: params.size || 10, | ||
157 | - uid: params.uid, | ||
158 | - }).then(result => { | ||
159 | - if (params.msgid) { | ||
160 | - // 绕的一比 | ||
161 | - return _detail(result, params.msgid); | ||
162 | - } else { | ||
163 | - return _list(result); | ||
164 | - } | ||
165 | - }); | ||
166 | -}; | 156 | + // 获取列表或详情 |
157 | + getList(params) { | ||
158 | + return api.get('', { | ||
159 | + method: 'app.inbox.getlist', | ||
160 | + page: params.page || 1, | ||
161 | + size: params.size || 10, | ||
162 | + uid: params.uid, | ||
163 | + }).then(result => { | ||
164 | + if (params.msgid) { | ||
165 | + // 绕的一比 | ||
166 | + return this._detail(result, params.msgid); | ||
167 | + } else { | ||
168 | + return this._list(result); | ||
169 | + } | ||
170 | + }); | ||
171 | + } | ||
167 | 172 | ||
168 | -// 删除消息 | ||
169 | -const delMsg = (params) => { | ||
170 | - return api.get('', { | ||
171 | - method: 'app.inbox.delmessage', | ||
172 | - uid: params.uid, | ||
173 | - id: params.msgid, | ||
174 | - }).then(result => { | ||
175 | - if (result && result.code === 200) { | ||
176 | - return { | ||
177 | - code: 200 | ||
178 | - }; | ||
179 | - } else { | ||
180 | - return { | ||
181 | - code: 400, | ||
182 | - message: '出错啦~', | ||
183 | - }; | ||
184 | - } | ||
185 | - }); | ||
186 | -}; | 173 | + // 删除消息 |
174 | + delMsg(params) { | ||
175 | + return api.get('', { | ||
176 | + method: 'app.inbox.delmessage', | ||
177 | + uid: params.uid, | ||
178 | + id: params.msgid, | ||
179 | + }).then(result => { | ||
180 | + if (result && result.code === 200) { | ||
181 | + return { | ||
182 | + code: 200 | ||
183 | + }; | ||
184 | + } else { | ||
185 | + return { | ||
186 | + code: 400, | ||
187 | + message: '出错啦~', | ||
188 | + }; | ||
189 | + } | ||
190 | + }); | ||
191 | + } | ||
187 | 192 | ||
188 | -// 领取优惠券 | ||
189 | -const pickCoupon = (params) => { | ||
190 | - return api.get('', { | ||
191 | - method: 'app.promotion.getCoupon', | ||
192 | - uid: params.uid, | ||
193 | - couponId: params.couponId, | ||
194 | - }).then(result => { | ||
195 | - if (result && result.code === 200) { | ||
196 | - return { | ||
197 | - code: 200 | ||
198 | - }; | ||
199 | - } else { | ||
200 | - return { | ||
201 | - code: result.code, | ||
202 | - message: result.message, | ||
203 | - }; | ||
204 | - } | ||
205 | - }); | ||
206 | -}; | 193 | + // 领取优惠券 |
194 | + pickCoupon(params) { | ||
195 | + return api.get('', { | ||
196 | + method: 'app.promotion.getCoupon', | ||
197 | + uid: params.uid, | ||
198 | + couponId: params.couponId, | ||
199 | + }).then(result => { | ||
200 | + if (result && result.code === 200) { | ||
201 | + return { | ||
202 | + code: 200 | ||
203 | + }; | ||
204 | + } else { | ||
205 | + return { | ||
206 | + code: result.code, | ||
207 | + message: result.message, | ||
208 | + }; | ||
209 | + } | ||
210 | + }); | ||
211 | + } | ||
212 | +} | ||
207 | 213 | ||
208 | -module.exports = { | ||
209 | - getList, | ||
210 | - delMsg, | ||
211 | - pickCoupon, | ||
212 | - _getBirthCouponById | ||
213 | -}; | 214 | +module.exports = messageModel; |
@@ -5,90 +5,94 @@ const api = global.yoho.API; | @@ -5,90 +5,94 @@ const api = global.yoho.API; | ||
5 | const _ = require('lodash'); | 5 | const _ = require('lodash'); |
6 | const logger = global.yoho.logger; | 6 | const logger = global.yoho.logger; |
7 | 7 | ||
8 | -const _yohoCoin = (uid) => { | ||
9 | - return api.get('', { | ||
10 | - method: 'app.yoho.yohocoin', | ||
11 | - uid: uid | ||
12 | - }).then((result) => { | ||
13 | - let data = []; | ||
14 | - | ||
15 | - if (result && result.code === 200) { | ||
16 | - data = result.data; | ||
17 | - } else { | ||
18 | - logger.error('youhocoin code no 200'); | ||
19 | - } | ||
20 | - | ||
21 | - return data; | ||
22 | - }); | ||
23 | -}; | ||
24 | - | ||
25 | -const bannerData = (contentCode) => { | ||
26 | - | ||
27 | - return serviceAPI.get('operations/api/v5/resource/get', { | ||
28 | - content_code: contentCode | ||
29 | - }, { | ||
30 | - cache: true | ||
31 | - }).then((result) => { | ||
32 | - | ||
33 | - if (result && result.code === 200) { | ||
34 | - | ||
35 | - return result.data; | ||
36 | - | ||
37 | - } else { | ||
38 | - logger.error('banner is not 200'); | ||
39 | - return {}; | ||
40 | - } | ||
41 | - }); | ||
42 | -}; | ||
43 | - | ||
44 | -const myCurrency = (uid, contentCode) => { | ||
45 | - return Promise.all([_yohoCoin(uid), bannerData(contentCode)]) | ||
46 | - .then((result) => { | 8 | +class myCurrencyModel extends global.yoho.BaseModel { |
9 | + constructor(ctx) { | ||
10 | + super(ctx); | ||
11 | + } | ||
12 | + | ||
13 | + _yohoCoin(uid) { | ||
14 | + return api.get('', { | ||
15 | + method: 'app.yoho.yohocoin', | ||
16 | + uid: uid | ||
17 | + }).then((result) => { | ||
18 | + let data = []; | ||
19 | + | ||
20 | + if (result && result.code === 200) { | ||
21 | + data = result.data; | ||
22 | + } else { | ||
23 | + logger.error('youhocoin code no 200'); | ||
24 | + } | ||
25 | + | ||
26 | + return data; | ||
27 | + }); | ||
28 | + } | ||
29 | + | ||
30 | + bannerData(contentCode) { | ||
31 | + | ||
32 | + return serviceAPI.get('operations/api/v5/resource/get', { | ||
33 | + content_code: contentCode | ||
34 | + }, { | ||
35 | + cache: true | ||
36 | + }).then((result) => { | ||
37 | + | ||
38 | + if (result && result.code === 200) { | ||
39 | + | ||
40 | + return result.data; | ||
41 | + | ||
42 | + } else { | ||
43 | + logger.error('banner is not 200'); | ||
44 | + return {}; | ||
45 | + } | ||
46 | + }); | ||
47 | + } | ||
48 | + | ||
49 | + myCurrency(uid, contentCode) { | ||
50 | + return Promise.all([ | ||
51 | + this._yohoCoin(uid), | ||
52 | + this.bannerData(contentCode) | ||
53 | + ]).then((result) => { | ||
47 | 54 | ||
48 | return { | 55 | return { |
49 | yohoCoin: result[0], | 56 | yohoCoin: result[0], |
50 | banner: result[1] | 57 | banner: result[1] |
51 | }; | 58 | }; |
52 | }); | 59 | }); |
53 | -}; | ||
54 | - | ||
55 | -const currencyDetail = (uid, page, limit) => { | ||
56 | - return api.get('', { | ||
57 | - method: 'app.yohocoin.lists', | ||
58 | - uid: uid, | ||
59 | - page: page, | ||
60 | - limit: limit | ||
61 | - }).then((result) => { | ||
62 | - let data = []; | ||
63 | - | ||
64 | - if (result && result.code === 200) { | ||
65 | - data = _.get(result, 'data.coinlist', []); | ||
66 | - | ||
67 | - _.forEach(data, (perCoin, key) => { | ||
68 | - if (perCoin.num > 0) { | ||
69 | - data[key].num = '+' + perCoin.num; | ||
70 | - } | ||
71 | - }); | ||
72 | - } | ||
73 | - | ||
74 | - return data; | ||
75 | - }); | ||
76 | -}; | ||
77 | - | ||
78 | -const currencyDetailIndex = (uid, page, limit) => { | ||
79 | - return Promise.all( | ||
80 | - [currencyDetail(uid, page, limit), _yohoCoin(uid)] | ||
81 | - ).then(result => { | ||
82 | - return { | ||
83 | - coinlist: result[0], | ||
84 | - yohoCoin: result[1] | ||
85 | - }; | ||
86 | - }); | ||
87 | -}; | ||
88 | - | ||
89 | -module.exports = { | ||
90 | - myCurrency, | ||
91 | - currencyDetailIndex, | ||
92 | - currencyDetail, | ||
93 | - bannerData | ||
94 | -}; | 60 | + } |
61 | + | ||
62 | + currencyDetail(uid, page, limit) { | ||
63 | + return api.get('', { | ||
64 | + method: 'app.yohocoin.lists', | ||
65 | + uid: uid, | ||
66 | + page: page, | ||
67 | + limit: limit | ||
68 | + }).then((result) => { | ||
69 | + let data = []; | ||
70 | + | ||
71 | + if (result && result.code === 200) { | ||
72 | + data = _.get(result, 'data.coinlist', []); | ||
73 | + | ||
74 | + _.forEach(data, (perCoin, key) => { | ||
75 | + if (perCoin.num > 0) { | ||
76 | + data[key].num = '+' + perCoin.num; | ||
77 | + } | ||
78 | + }); | ||
79 | + } | ||
80 | + | ||
81 | + return data; | ||
82 | + }); | ||
83 | + } | ||
84 | + | ||
85 | + currencyDetailIndex(uid, page, limit) { | ||
86 | + return Promise.all([ | ||
87 | + this.currencyDetail(uid, page, limit), | ||
88 | + this._yohoCoin(uid) | ||
89 | + ]).then(result => { | ||
90 | + return { | ||
91 | + coinlist: result[0], | ||
92 | + yohoCoin: result[1] | ||
93 | + }; | ||
94 | + }); | ||
95 | + } | ||
96 | +} | ||
97 | + | ||
98 | +module.exports = myCurrencyModel; |
@@ -4,20 +4,28 @@ const api = global.yoho.API; | @@ -4,20 +4,28 @@ const api = global.yoho.API; | ||
4 | const crypto = global.yoho.crypto; | 4 | const crypto = global.yoho.crypto; |
5 | const PASSWORD = 'yoho9646yoho9646'; | 5 | const PASSWORD = 'yoho9646yoho9646'; |
6 | 6 | ||
7 | -exports.getQr = (params) => { | ||
8 | - let uid = ''; | 7 | +class qrcodeModel extends global.yoho.BaseModel { |
8 | + constructor(ctx) { | ||
9 | + super(ctx); | ||
10 | + } | ||
11 | + | ||
12 | + getQr(params) { | ||
13 | + let uid = ''; | ||
14 | + | ||
15 | + try { | ||
16 | + uid = crypto.decrypt(PASSWORD, decodeURIComponent(params.token)); | ||
17 | + uid = parseInt(uid, 10); | ||
18 | + } catch (e) { | ||
19 | + uid = params.token; | ||
20 | + } | ||
9 | 21 | ||
10 | - try { | ||
11 | - uid = crypto.decrypt(PASSWORD, decodeURIComponent(params.token)); | ||
12 | - uid = parseInt(uid, 10); | ||
13 | - } catch (e) { | ||
14 | - uid = params.token; | 22 | + return api.get('', { |
23 | + method: 'app.twoDimen.getCode', | ||
24 | + uid: uid, | ||
25 | + }).then(result => { | ||
26 | + return (result && result.data && result.data.code) || ''; | ||
27 | + }); | ||
15 | } | 28 | } |
29 | +} | ||
16 | 30 | ||
17 | - return api.get('', { | ||
18 | - method: 'app.twoDimen.getCode', | ||
19 | - uid: uid, | ||
20 | - }).then(result => { | ||
21 | - return (result && result.data && result.data.code) || ''; | ||
22 | - }); | ||
23 | -}; | 31 | +module.exports = qrcodeModel; |
@@ -8,18 +8,25 @@ | @@ -8,18 +8,25 @@ | ||
8 | const logger = global.yoho.logger; | 8 | const logger = global.yoho.logger; |
9 | var api = global.yoho.API; | 9 | var api = global.yoho.API; |
10 | 10 | ||
11 | -exports.getQRcodeData = (id, uid) => { | ||
12 | - return api.get('', { | ||
13 | - method: 'app.SpaceOrders.getQrByOrderCode', | ||
14 | - order_code: id, | ||
15 | - uid: uid | ||
16 | - }).then(result => { | ||
17 | - if (result && result.code === 200) { | ||
18 | - return result.data; | ||
19 | - } else { | ||
20 | - logger.error(`查看二维码ID: ${id} 接口返回数据错误`); | ||
21 | - return false; | ||
22 | - } | ||
23 | - }); | ||
24 | -}; | 11 | +class qrcodeModel extends global.yoho.BaseModel { |
12 | + constructor(ctx) { | ||
13 | + super(ctx); | ||
14 | + } | ||
25 | 15 | ||
16 | + getQRcodeData(id, uid) { | ||
17 | + return api.get('', { | ||
18 | + method: 'app.SpaceOrders.getQrByOrderCode', | ||
19 | + order_code: id, | ||
20 | + uid: uid | ||
21 | + }).then(result => { | ||
22 | + if (result && result.code === 200) { | ||
23 | + return result.data; | ||
24 | + } else { | ||
25 | + logger.error(`查看二维码ID: ${id} 接口返回数据错误`); | ||
26 | + return false; | ||
27 | + } | ||
28 | + }); | ||
29 | + } | ||
30 | +} | ||
31 | + | ||
32 | +module.exports = qrcodeModel; |
@@ -24,7 +24,6 @@ const orderController = require(`${cRoot}/order`); | @@ -24,7 +24,6 @@ const orderController = require(`${cRoot}/order`); | ||
24 | const orderDetailController = require(`${cRoot}/orderDetail`); | 24 | const orderDetailController = require(`${cRoot}/orderDetail`); |
25 | const currencyController = require(`${cRoot}/myCurrency`); | 25 | const currencyController = require(`${cRoot}/myCurrency`); |
26 | const coupons = require(`${cRoot}/coupons`); | 26 | const coupons = require(`${cRoot}/coupons`); |
27 | -const help = require(`${cRoot}/help`); | ||
28 | const suggest = require(`${cRoot}/suggest`); | 27 | const suggest = require(`${cRoot}/suggest`); |
29 | const message = require(`${cRoot}/message`); | 28 | const message = require(`${cRoot}/message`); |
30 | const onlineService = require(`${cRoot}/onlineService`); | 29 | const onlineService = require(`${cRoot}/onlineService`); |
@@ -84,10 +83,6 @@ router.post('/favoriteDel', auth, favorite.favoriteDelete);// 取消收藏 | @@ -84,10 +83,6 @@ router.post('/favoriteDel', auth, favorite.favoriteDelete);// 取消收藏 | ||
84 | router.use('/coupons', auth, coupons.index); | 83 | router.use('/coupons', auth, coupons.index); |
85 | router.use('/couponsAjax', coupons.couponsAjax); | 84 | router.use('/couponsAjax', coupons.couponsAjax); |
86 | 85 | ||
87 | -// 帮助中心 | ||
88 | -router.get('/help', help.index); | ||
89 | -router.get('/helpDetail', help.helpDetail); | ||
90 | - | ||
91 | // 意见反馈 | 86 | // 意见反馈 |
92 | router.get('/suggest', suggest.suggestData); | 87 | router.get('/suggest', suggest.suggestData); |
93 | router.post('/upAndDown', suggest.upAndDown); | 88 | router.post('/upAndDown', suggest.upAndDown); |
1 | -{{{detail}}} |
apps/home/views/action/help.hbs
deleted
100644 → 0
@@ -65,7 +65,7 @@ const about = (req, res, next) => { | @@ -65,7 +65,7 @@ const about = (req, res, next) => { | ||
65 | width750: true | 65 | width750: true |
66 | }; | 66 | }; |
67 | 67 | ||
68 | - aboutModel.about(req.yoho.isApp).then(result => { | 68 | + req.ctx(aboutModel).about(req.yoho.isApp).then(result => { |
69 | res.render('agreement/about', Object.assign(responseData, {wxFooter: result})); | 69 | res.render('agreement/about', Object.assign(responseData, {wxFooter: result})); |
70 | }).catch(next); | 70 | }).catch(next); |
71 | }; | 71 | }; |
@@ -2,25 +2,29 @@ | @@ -2,25 +2,29 @@ | ||
2 | 2 | ||
3 | const api = global.yoho.API; | 3 | const api = global.yoho.API; |
4 | 4 | ||
5 | -const about = (isApp) => { | ||
6 | - return api.get('', { | ||
7 | - method: 'app.document.config' | ||
8 | - }, { | ||
9 | - cache: true, | ||
10 | - code: 200 | ||
11 | - }).then(result => { | ||
12 | - if (result && result.data) { | ||
13 | - result = { | ||
14 | - wxTitle: result.data.wechatAtten, | ||
15 | - wxTip: result.data.wechatAttenSub, | ||
16 | - wxCopy: result.data.wechatCopy, | ||
17 | - isApp: isApp | ||
18 | - }; | ||
19 | - } | ||
20 | - return result; | ||
21 | - }); | ||
22 | -}; | 5 | +class aboutModel extends global.yoho.BaseModel { |
6 | + constructor(ctx) { | ||
7 | + super(ctx); | ||
8 | + } | ||
23 | 9 | ||
24 | -module.exports = { | ||
25 | - about | ||
26 | -}; | 10 | + about(isApp) { |
11 | + return api.get('', { | ||
12 | + method: 'app.document.config' | ||
13 | + }, { | ||
14 | + cache: true, | ||
15 | + code: 200 | ||
16 | + }).then(result => { | ||
17 | + if (result && result.data) { | ||
18 | + result = { | ||
19 | + wxTitle: result.data.wechatAtten, | ||
20 | + wxTip: result.data.wechatAttenSub, | ||
21 | + wxCopy: result.data.wechatCopy, | ||
22 | + isApp: isApp | ||
23 | + }; | ||
24 | + } | ||
25 | + return result; | ||
26 | + }); | ||
27 | + } | ||
28 | +} | ||
29 | + | ||
30 | +module.exports = aboutModel; |
public/js/home/help-detail.page.js
deleted
100644 → 0
1 | -require('common'); |
public/js/home/help.page.js
deleted
100644 → 0
1 | -require('common'); |
-
Please register or login to post a comment