Showing
11 changed files
with
277 additions
and
0 deletions
apps/home/controllers/QRcode.js
0 → 100644
1 | +/** | ||
2 | + * 个人中心二维码 controller | ||
3 | + * @author: weiqingting<qingting.wei@yoho.cn> | ||
4 | + * @date: 2016/05/16 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const QRcodeModel = require('../models/QRcode'); | ||
10 | + | ||
11 | +exports.QRcode = (req, res) => { | ||
12 | + let id = req.params.id || 0; | ||
13 | + | ||
14 | + QRcodeModel.getQRcodeData(id).then((result)=>{ | ||
15 | + result.ticks = result.ticks.map(item=>{ | ||
16 | + if (+item.ticket_type === 2) { | ||
17 | + item.isgroup = true; | ||
18 | + } | ||
19 | + return item; | ||
20 | + }); | ||
21 | + | ||
22 | + let vm = { | ||
23 | + qrcodeData: result | ||
24 | + }; | ||
25 | + | ||
26 | + res.render('QRcode', vm); | ||
27 | + }).catch((err) => { | ||
28 | + res.send(err); | ||
29 | + }); | ||
30 | +}; |
apps/home/index.js
0 → 100644
1 | +/** | ||
2 | + * sub app coupon | ||
3 | + * @author: lixia.zhang<lixia.zhang@yoho.cn> | ||
4 | + * @date: 2016/05/31 | ||
5 | + */ | ||
6 | + | ||
7 | +var express = require('express'), | ||
8 | + path = require('path'), | ||
9 | + hbs = require('express-handlebars'); | ||
10 | + | ||
11 | +var app = express(); | ||
12 | + | ||
13 | +// set view engin | ||
14 | +var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root | ||
15 | + | ||
16 | +app.on('mount', function(parent) { | ||
17 | + delete parent.locals.settings; // 不继承父 App 的设置 | ||
18 | + Object.assign(app.locals, parent.locals); | ||
19 | +}); | ||
20 | +app.set('views', path.join(__dirname, 'views/action')); | ||
21 | +app.engine('.hbs', hbs({ | ||
22 | + extname: '.hbs', | ||
23 | + defaultLayout: 'layout', | ||
24 | + layoutsDir: doraemon, | ||
25 | + partialsDir: ['./views/partial', `${doraemon}/partial`], | ||
26 | + helpers: global.yoho.helpers | ||
27 | +})); | ||
28 | + | ||
29 | +// router | ||
30 | +app.use(require('./router')); | ||
31 | + | ||
32 | +module.exports = app; |
apps/home/models/QRcode.js
0 → 100644
1 | +/** | ||
2 | + * 个人中心二维码 model | ||
3 | + * @author: weiqingting<qingting.wei@yoho.cn> | ||
4 | + * @date: 2016/05/16 | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | + | ||
8 | +const logger = global.yoho.logger; | ||
9 | +var api = global.yoho.API; | ||
10 | + | ||
11 | +exports.getQRcodeData = (id) => { | ||
12 | + return api.get('', { | ||
13 | + method: 'app.SpaceOrders.getQrByOrderCode' | ||
14 | + }, { | ||
15 | + cache: true | ||
16 | + }).then(result => { | ||
17 | + if (result && result.code === 200) { | ||
18 | + return result.data; | ||
19 | + } else { | ||
20 | + logger.error(`查看二维码ID: ${id} 接口返回数据错误`); | ||
21 | + return {}; | ||
22 | + } | ||
23 | + }); | ||
24 | +}; | ||
25 | + |
apps/home/router.js
0 → 100644
1 | +/** | ||
2 | + * router of sub app product | ||
3 | + * @author: weiqingting<qingting.wei@yoho.cn> | ||
4 | + * @date: 2016/05/06 | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | + | ||
8 | +const express = require('express'); | ||
9 | +const router = express.Router(); // eslint-disable-line | ||
10 | +const cRoot = './controllers'; | ||
11 | + | ||
12 | +const personalController = require(`${cRoot}/QRcode`); | ||
13 | + | ||
14 | +// 查看二维码 | ||
15 | +router.get('/QRcode/:id', personalController.QRcode); | ||
16 | + | ||
17 | +module.exports = router; |
apps/home/views/action/QRcode.hbs
0 → 100644
1 | +<header id="yoho-header" class="yoho-header boys"> | ||
2 | + <a href="javascript:history.go(-1);" class="iconfont nav-back"></a> | ||
3 | + <p class="nav-title">查看二维码</p> | ||
4 | +</header> | ||
5 | +<div class="qrcode yoho-page"> | ||
6 | + <h2 class='qrcode-title'>2016 非常潮流盛世 YO'HOOD门票(限量)1件</h2> | ||
7 | + <p class='qrcode-tip'>提示:凭借二维码入场,每场二维码只可使用一次,请妥善保管。</p> | ||
8 | + <div class='qrcode-wrap'> | ||
9 | + {{#qrcodeData}} | ||
10 | + <p class='qrcode-pages'><a class='pagec'>1</a>/{{ticks.length}}</p> | ||
11 | + <a class='prev chan'></a> | ||
12 | + <a class='next chan'></a> | ||
13 | + <div class="swiper-container"> | ||
14 | + <div class="swiper-wrapper"> | ||
15 | + {{#each ticks}} | ||
16 | + <div class="swiper-slide"> | ||
17 | + <a class='qrcode-img'><img src="{{qr_image}}"></a> | ||
18 | + <p><label class='t'>编号:</label>{{ticket_code}}</p> | ||
19 | + {{#if isgroup}} | ||
20 | + <p><label class='t'>座位号:</label>{{seat_no}}</p> | ||
21 | + {{/if}} | ||
22 | + <p><label class='t'>进场时间:</label>{{entrance_time}}</p> | ||
23 | + </div> | ||
24 | + {{/each}} | ||
25 | + </div> | ||
26 | + </div> | ||
27 | + {{/qrcodeData}} | ||
28 | + </div> | ||
29 | +</div> |
@@ -16,4 +16,5 @@ module.exports = app => { | @@ -16,4 +16,5 @@ module.exports = app => { | ||
16 | app.use('/guang', require('./apps/guang')); | 16 | app.use('/guang', require('./apps/guang')); |
17 | app.use('/passport', require('./apps/passport')); | 17 | app.use('/passport', require('./apps/passport')); |
18 | app.use('/activity', require('./apps/activity')); | 18 | app.use('/activity', require('./apps/activity')); |
19 | + app.use('/home', require('./apps/home')); | ||
19 | }; | 20 | }; |
public/js/home/QRcode.page.js
0 → 100644
1 | +var $ = require('yoho-jquery'); | ||
2 | +var Swiper = require('yoho-swiper'); | ||
3 | +var mySwiper; | ||
4 | + | ||
5 | +mySwiper = new Swiper('.swiper-container', { | ||
6 | + onSlideChangeEnd: function(swiper) { | ||
7 | + $('.pagec').html(swiper.snapIndex + 1); | ||
8 | + } | ||
9 | +}); | ||
10 | +$('.prev').click(function() { | ||
11 | + mySwiper.slidePrev(); | ||
12 | +}); | ||
13 | +$('.next').click(function() { | ||
14 | + mySwiper.slideNext(); | ||
15 | +}); |
public/scss/home/_index.css
0 → 100644
1 | +@import "qrcode"; |
public/scss/home/_qrcode.css
0 → 100644
1 | +.qrcode{ | ||
2 | + padding:0 30px; | ||
3 | + .qrcode-title{ | ||
4 | + margin:30px 0; | ||
5 | + } | ||
6 | + .qrcode-tip{ | ||
7 | + font-size:20px; | ||
8 | + color:#c6c6c6; | ||
9 | + background:url("../img/passport/info.png"); | ||
10 | + } | ||
11 | + .qrcode-say{ | ||
12 | + color:#c6c6c6; | ||
13 | + margin-top:80px; | ||
14 | + } | ||
15 | + .qrcode-wrap{ | ||
16 | + position:relative; | ||
17 | + .chan{ | ||
18 | + background: url("../img/channel/up-icon.png"); | ||
19 | + background-size: 40px 40px; | ||
20 | + position: absolute; | ||
21 | + top: 50%; | ||
22 | + margin-top: -15px; | ||
23 | + width: 40px; | ||
24 | + height: 40px; | ||
25 | + | ||
26 | + } | ||
27 | + .prev{ | ||
28 | + left: 0px; | ||
29 | + transform:rotate(-90deg); | ||
30 | + } | ||
31 | + .next{ | ||
32 | + right:0px; | ||
33 | + transform:rotate(90deg); | ||
34 | + } | ||
35 | + } | ||
36 | + .qrcode-pages{ | ||
37 | + text-align:center; | ||
38 | + padding:30px 0; | ||
39 | + letter-spacing:4px; | ||
40 | + } | ||
41 | + .swiper-container{ | ||
42 | + width:412px; | ||
43 | + .qrcode-img{ | ||
44 | + width:412px; | ||
45 | + height:412px; | ||
46 | + display:block; | ||
47 | + margin-bottom:40px; | ||
48 | + img{ | ||
49 | + width:100%; | ||
50 | + height:100%; | ||
51 | + display:block; | ||
52 | + } | ||
53 | + } | ||
54 | + p{ | ||
55 | + line-height:35px; | ||
56 | + height:35px; | ||
57 | + } | ||
58 | + label{ | ||
59 | + display:inline-block; | ||
60 | + width:148px; | ||
61 | + text-align:right; | ||
62 | + margin-right:40px; | ||
63 | + } | ||
64 | + | ||
65 | + } | ||
66 | + .swiper-container { | ||
67 | + margin:0 auto; | ||
68 | + position:relative; | ||
69 | + overflow:hidden; | ||
70 | + -webkit-backface-visibility:hidden; | ||
71 | + -moz-backface-visibility:hidden; | ||
72 | + -ms-backface-visibility:hidden; | ||
73 | + -o-backface-visibility:hidden; | ||
74 | + backface-visibility:hidden; | ||
75 | + /* Fix of Webkit flickering */ | ||
76 | + z-index:1; | ||
77 | + } | ||
78 | + .swiper-wrapper { | ||
79 | + position:relative; | ||
80 | + width:100%; | ||
81 | + -webkit-transition-property:-webkit-transform, left, top; | ||
82 | + -webkit-transition-duration:0s; | ||
83 | + -webkit-transform:translate3d(0px,0,0); | ||
84 | + -webkit-transition-timing-function:ease; | ||
85 | + | ||
86 | + -moz-transition-property:-moz-transform, left, top; | ||
87 | + -moz-transition-duration:0s; | ||
88 | + -moz-transform:translate3d(0px,0,0); | ||
89 | + -moz-transition-timing-function:ease; | ||
90 | + | ||
91 | + -o-transition-property:-o-transform, left, top; | ||
92 | + -o-transition-duration:0s; | ||
93 | + -o-transform:translate3d(0px,0,0); | ||
94 | + -o-transition-timing-function:ease; | ||
95 | + -o-transform:translate(0px,0px); | ||
96 | + | ||
97 | + -ms-transition-property:-ms-transform, left, top; | ||
98 | + -ms-transition-duration:0s; | ||
99 | + -ms-transform:translate3d(0px,0,0); | ||
100 | + -ms-transition-timing-function:ease; | ||
101 | + | ||
102 | + transition-property:transform, left, top; | ||
103 | + transition-duration:0s; | ||
104 | + transform:translate3d(0px,0,0); | ||
105 | + transition-timing-function:ease; | ||
106 | + | ||
107 | + -webkit-box-sizing: content-box; | ||
108 | + -moz-box-sizing: content-box; | ||
109 | + box-sizing: content-box; | ||
110 | + } | ||
111 | + .swiper-free-mode > .swiper-wrapper { | ||
112 | + -webkit-transition-timing-function: ease-out; | ||
113 | + -moz-transition-timing-function: ease-out; | ||
114 | + -ms-transition-timing-function: ease-out; | ||
115 | + -o-transition-timing-function: ease-out; | ||
116 | + transition-timing-function: ease-out; | ||
117 | + margin: 0 auto; | ||
118 | + } | ||
119 | + .swiper-slide { | ||
120 | + float: left; | ||
121 | + -webkit-box-sizing: content-box; | ||
122 | + -moz-box-sizing: content-box; | ||
123 | + box-sizing: content-box; | ||
124 | + } | ||
125 | +} |
-
mentioned in commit b2cad0cb
-
Please register or login to post a comment