Merge branch 'release/6.8.1' into 'master'
Release/6.8.1 See merge request !1583
Showing
17 changed files
with
574 additions
and
153 deletions
@@ -43,6 +43,19 @@ const redbagPage = async(req, res, next) => { | @@ -43,6 +43,19 @@ const redbagPage = async(req, res, next) => { | ||
43 | if (obj.uid) { | 43 | if (obj.uid) { |
44 | pageData = await req.ctx(redbagModel).renderByUser(obj); | 44 | pageData = await req.ctx(redbagModel).renderByUser(obj); |
45 | } | 45 | } |
46 | + | ||
47 | + pageData.config = await req.ctx(redbagModel).getRewardsUrlList(obj).then(result => { | ||
48 | + for (let i = 0; i < result.data.length; i++) { | ||
49 | + let imageURL = result.data[i].rewardImageUrl; | ||
50 | + | ||
51 | + result.data[i].rewardImageUrl = imageURL.split('?')[0].replace('http:', 'https:') + | ||
52 | + '?imageView2/2/w/186/h/170/q/60'; | ||
53 | + } | ||
54 | + return result; | ||
55 | + }).catch(() => { | ||
56 | + return []; | ||
57 | + }); | ||
58 | + | ||
46 | return res.render('red-envelope/redbag-user', { | 59 | return res.render('red-envelope/redbag-user', { |
47 | pageHeader: headerModel.setNav({ | 60 | pageHeader: headerModel.setNav({ |
48 | navTitle: '领取现金红包' | 61 | navTitle: '领取现金红包' |
@@ -81,7 +94,8 @@ const receiveRedBag = async(req, res, next) => { | @@ -81,7 +94,8 @@ const receiveRedBag = async(req, res, next) => { | ||
81 | if (result.code === 200) { | 94 | if (result.code === 200) { |
82 | return res.json({ | 95 | return res.json({ |
83 | code: 200, | 96 | code: 200, |
84 | - message: '领取成功' | 97 | + message: '领取成功', |
98 | + data: result.data || [] | ||
85 | }); | 99 | }); |
86 | } else { | 100 | } else { |
87 | return res.json({ | 101 | return res.json({ |
@@ -5,6 +5,18 @@ class redEnvelopeModel extends global.yoho.BaseModel { | @@ -5,6 +5,18 @@ class redEnvelopeModel extends global.yoho.BaseModel { | ||
5 | 5 | ||
6 | } | 6 | } |
7 | 7 | ||
8 | + /** | ||
9 | + * 获取奖品展示图片列表,布局用 | ||
10 | + * @returns {Promise.<void>} | ||
11 | + */ | ||
12 | + async getRewardsUrlList() { | ||
13 | + return await this.get({ | ||
14 | + data: { | ||
15 | + method: 'app.passport.getRewardsUrlList' | ||
16 | + } | ||
17 | + }); | ||
18 | + } | ||
19 | + | ||
8 | async isWechatService(obj) { | 20 | async isWechatService(obj) { |
9 | let isWechatService = false; // 是否是微信客服 | 21 | let isWechatService = false; // 是否是微信客服 |
10 | 22 | ||
@@ -76,6 +88,7 @@ class redEnvelopeModel extends global.yoho.BaseModel { | @@ -76,6 +88,7 @@ class redEnvelopeModel extends global.yoho.BaseModel { | ||
76 | rewardType: data.rewardType, | 88 | rewardType: data.rewardType, |
77 | couponAmount: data.couponAmount, | 89 | couponAmount: data.couponAmount, |
78 | rewardUrl: data.rewardUrl, | 90 | rewardUrl: data.rewardUrl, |
91 | + rewardName: data.rewardName | ||
79 | }; | 92 | }; |
80 | case 202: | 93 | case 202: |
81 | return { | 94 | return { |
@@ -342,7 +342,7 @@ router.get('/have-gain/fail', auth, haveGain.fail); // 有货有赚审核不通 | @@ -342,7 +342,7 @@ router.get('/have-gain/fail', auth, haveGain.fail); // 有货有赚审核不通 | ||
342 | router.post('/have-gain/resetApply', auth, haveGain.resetApply); // 有货有赚审核不通过,重新申请API | 342 | router.post('/have-gain/resetApply', auth, haveGain.resetApply); // 有货有赚审核不通过,重新申请API |
343 | router.post('/have-gain/submitApply', auth, haveGain.submitApply); // 有货有赚-申请开通 | 343 | router.post('/have-gain/submitApply', auth, haveGain.submitApply); // 有货有赚-申请开通 |
344 | 344 | ||
345 | -router.get('/red-envelope/index', redPack.redbagPage); | 345 | +router.get('/red-envelope/index', redPack.redbagPage); // 微信客服领红包 |
346 | router.post('/red-envelope/receive', auth, redPack.receiveRedBag); | 346 | router.post('/red-envelope/receive', auth, redPack.receiveRedBag); |
347 | router.post('/red-envelope/submitWxCode', auth, redPack.submitWxCode); | 347 | router.post('/red-envelope/submitWxCode', auth, redPack.submitWxCode); |
348 | 348 |
1 | <div class="redbag-user-container" data-received="{{pageData.received}}" data-sharecode="{{pageData.shareCode}}"> | 1 | <div class="redbag-user-container" data-received="{{pageData.received}}" data-sharecode="{{pageData.shareCode}}"> |
2 | {{# pageData}} | 2 | {{# pageData}} |
3 | - {{#if received}} | ||
4 | - <div class="received-content"> | ||
5 | - {{#isEqualOr rewardType 1}} | ||
6 | - {{#isEqualOr couponAmount 5}} | ||
7 | - <img src="http://img12.static.yhbimg.com/sns/2018/08/02/15/02a4fbd09374acfdc2b97cabd059e32669.png" class="red-bag1 use" /> | ||
8 | - {{/isEqualOr}} | ||
9 | - {{#isEqualOr couponAmount 10}} | ||
10 | - <img src="http://img11.static.yhbimg.com/sns/2018/08/02/15/0188ee9e04c067fa701f33f7be24bb97ca.png" class="red-bag2 use" /> | ||
11 | - {{/isEqualOr}} | ||
12 | - {{#isEqualOr couponAmount 20}} | ||
13 | - <img src="http://img11.static.yhbimg.com/sns/2018/08/02/15/0185441fd89c3bc4a78cd202c9c40eb633.png" class="red-bag3 use" /> | ||
14 | - {{/isEqualOr}} | ||
15 | - {{#isEqualOr couponAmount 50}} | ||
16 | - <img src="http://img11.static.yhbimg.com/sns/2018/08/02/15/01645486f02c4d38679b5058bde79abf02.png" class="red-bag50 use" /> | ||
17 | - {{/isEqualOr}} | ||
18 | - {{#isEqualOr couponAmount 80}} | ||
19 | - <img src="http://img12.static.yhbimg.com/sns/2018/08/02/15/02c329c8192bcdddd7467a8c44501b4525.png" class="red-bag80 use" /> | ||
20 | - {{/isEqualOr}} | ||
21 | - {{#isEqualOr couponAmount 100}} | ||
22 | - <img src="http://img11.static.yhbimg.com/sns/2018/08/02/15/01b6568f91129e886548ab5ff0f5a71ae8.png" class="red-bag100 use" /> | ||
23 | - {{/isEqualOr}} | ||
24 | - {{/isEqualOr}} | ||
25 | - {{#isEqualOr rewardType 2}} | ||
26 | - <img src="{{rewardUrl}}" class="red-bag-other use"/> | ||
27 | - {{/isEqualOr}} | ||
28 | - <button type="button" class="go-use"></button> | ||
29 | - </div> | ||
30 | - {{else}} | 3 | + {{#if received}} |
4 | + <div class="received-wrapper show"> | ||
5 | + <div class="received-content"> | ||
6 | + {{#isEqualOr rewardType 1}} | ||
7 | + {{#isEqualOr couponAmount 5}} | ||
8 | + <img src="//img12.static.yhbimg.com/sns/2018/08/02/15/02a4fbd09374acfdc2b97cabd059e32669.png" class="red-bag1 use"/> | ||
9 | + {{/isEqualOr}} | ||
10 | + {{#isEqualOr couponAmount 10}} | ||
11 | + <img src="//img11.static.yhbimg.com/sns/2018/08/02/15/0188ee9e04c067fa701f33f7be24bb97ca.png" class="red-bag2 use"/> | ||
12 | + {{/isEqualOr}} | ||
13 | + {{#isEqualOr couponAmount 20}} | ||
14 | + <img src="//img11.static.yhbimg.com/sns/2018/08/02/15/0185441fd89c3bc4a78cd202c9c40eb633.png" class="red-bag3 use"/> | ||
15 | + {{/isEqualOr}} | ||
16 | + {{#isEqualOr couponAmount 50}} | ||
17 | + <img src="//img11.static.yhbimg.com/sns/2018/08/02/15/01645486f02c4d38679b5058bde79abf02.png" class="red-bag50 use"/> | ||
18 | + {{/isEqualOr}} | ||
19 | + {{#isEqualOr couponAmount 80}} | ||
20 | + <img src="//img12.static.yhbimg.com/sns/2018/08/02/15/02c329c8192bcdddd7467a8c44501b4525.png" class="red-bag80 use"/> | ||
21 | + {{/isEqualOr}} | ||
22 | + {{#isEqualOr couponAmount 100}} | ||
23 | + <img src="//img11.static.yhbimg.com/sns/2018/08/02/15/01b6568f91129e886548ab5ff0f5a71ae8.png" class="red-bag100 use"/> | ||
24 | + {{/isEqualOr}} | ||
25 | + {{/isEqualOr}} | ||
26 | + {{#isEqualOr rewardType 2}} | ||
27 | + <div class="reward-pic"></div> | ||
28 | + <p>恭喜您获得</p> | ||
29 | + <p class="reward-name">{{rewardName}}</p> | ||
30 | + {{/isEqualOr}} | ||
31 | + | ||
32 | + <button type="button" class="go-use">立即使用</button> | ||
33 | + </div> | ||
34 | + </div> | ||
35 | + {{else}} | ||
36 | + <div class="received-wrapper"> | ||
37 | + <div class="received-content"> | ||
38 | + <div class="reward-pic"></div> | ||
39 | + <p>恭喜您获得</p> | ||
40 | + <p class="reward-name"></p> | ||
41 | + <button type="button" class="go-use">立即使用</button> | ||
42 | + </div> | ||
43 | + </div> | ||
44 | + {{/if}} | ||
45 | + | ||
31 | <div class="rewards-content"> | 46 | <div class="rewards-content"> |
32 | <i class="cuo-icon"></i> | 47 | <i class="cuo-icon"></i> |
33 | - <img src="http://img11.static.yhbimg.com/sns/2018/10/23/14/01bd162a441d22ab50e29244cf66fc4072.png" class="receiveRedBag"/> | 48 | + <div class="reward-container "> |
49 | + <div class="reward-items"> | ||
50 | + {{#each config.data}} | ||
51 | + <div id="item_{{this.rewardId}}" data-id="{{this.rewardId}}" data-index="{{@index}}" | ||
52 | + class="item item-{{@index}}"> | ||
53 | + <img src="{{this.rewardImageUrl}}"> | ||
54 | + <div class="item-mask"></div> | ||
55 | + </div> | ||
56 | + {{/each}} | ||
57 | + <div class="item receive-redbag"> | ||
58 | + <img src="//img11.static.yhbimg.com/article/2018/11/07/16/018b792dffba52e7435771ae5851862cde.png"> | ||
59 | + </div> | ||
60 | + </div> | ||
61 | + <div class="reward-pannel"> | ||
62 | + <div class="reward-light left"></div> | ||
63 | + <div class="reward-light right"></div> | ||
64 | + </div> | ||
65 | + </div> | ||
34 | </div> | 66 | </div> |
35 | - {{/if}} | ||
36 | - <input type="hidden" id="msg" value="{{message}}"> | 67 | + <input type="hidden" id="msg" value="{{message}}"> |
37 | {{/ pageData}} | 68 | {{/ pageData}} |
38 | - <div class="activity-rule"> | ||
39 | - <i class="hand"></i> | ||
40 | - <p class="title">活动规则</p> | ||
41 | - <p class="txt txt-1">领取权益需填写注册有货账户时绑定的手机号,认证后即可参与抽奖;</p> | ||
42 | - <p class="txt txt-2">若忘记或不确定手机号是否绑定账户,请先联系微信客服进行查询;</p> | ||
43 | - <p class="txt txt-3">抽中的优惠券将被放入您的有货账户中,若抽中免单/微信红包/实物奖品,请截图后联系微信客服;</p> | ||
44 | - <p class="txt last">*此活动最终解释权归Yoho!Buy所有</p> | ||
45 | - </div> | 69 | + <div class="activity-rule"> |
70 | + <i class="hand"></i> | ||
71 | + <p class="title">活动规则</p> | ||
72 | + <p class="txt txt-1">领取权益需填写注册有货账户时绑定的手机号,认证后即可参与抽奖;</p> | ||
73 | + <p class="txt txt-2">若忘记或不确定手机号是否绑定账户,请先联系微信客服进行查询;</p> | ||
74 | + <p class="txt txt-3">抽中的优惠券将被放入您的有货账户中,若抽中免单/微信红包/实物奖品,请截图后联系微信客服;</p> | ||
75 | + <p class="txt last">*此活动最终解释权归Yoho!Buy所有</p> | ||
76 | + </div> | ||
46 | </div> | 77 | </div> |
@@ -61,7 +61,7 @@ class cartModel extends global.yoho.BaseModel { | @@ -61,7 +61,7 @@ class cartModel extends global.yoho.BaseModel { | ||
61 | * @return array 接口返回的数据 | 61 | * @return array 接口返回的数据 |
62 | */ | 62 | */ |
63 | removeFromCart(uid, sku, shoppingKey, cartType) { | 63 | removeFromCart(uid, sku, shoppingKey, cartType) { |
64 | - return this.get({data: { | 64 | + return this.post({data: { |
65 | method: 'app.Shopping.removeAndQryCart', | 65 | method: 'app.Shopping.removeAndQryCart', |
66 | product_sku_list: sku, | 66 | product_sku_list: sku, |
67 | uid: uid, | 67 | uid: uid, |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * @date 2016/05/06 | 5 | * @date 2016/05/06 |
6 | */ | 6 | */ |
7 | 7 | ||
8 | -const pkg = require('../package.json'); | 8 | +// const pkg = require('../package.json'); |
9 | const from = require('./from'); | 9 | const from = require('./from'); |
10 | 10 | ||
11 | const isProduction = process.env.NODE_ENV === 'production'; | 11 | const isProduction = process.env.NODE_ENV === 'production'; |
@@ -77,7 +77,8 @@ | @@ -77,7 +77,8 @@ | ||
77 | <link rel="apple-touch-startup-image" href="https://cdn.yoho.cn/h5/forios/startup/startup-orange-5.png" media="screen and (max-device-width: 640px)"> | 77 | <link rel="apple-touch-startup-image" href="https://cdn.yoho.cn/h5/forios/startup/startup-orange-5.png" media="screen and (max-device-width: 640px)"> |
78 | </head> | 78 | </head> |
79 | <body class="{{pageStyle}}{{#if isWechat}} wechat-body{{/if}}{{#if width750}} width750{{/if}}{{#if isPassportPage}} passport-body{{/if}}{{#if isStarIndexPage}} star-index-bg{{/if}}{{#if isStarDetailPage}} star-class-body{{/if}}{{#if isInstallmentPage}}{{#unless notOpen}} installment-body{{/unless}}{{/if}}{{#if @root.isMarsApp}} is-mars-app{{/if}}{{#if @root.isNowApp}} is-now-app{{/if}}"> | 79 | <body class="{{pageStyle}}{{#if isWechat}} wechat-body{{/if}}{{#if width750}} width750{{/if}}{{#if isPassportPage}} passport-body{{/if}}{{#if isStarIndexPage}} star-index-bg{{/if}}{{#if isStarDetailPage}} star-class-body{{/if}}{{#if isInstallmentPage}}{{#unless notOpen}} installment-body{{/unless}}{{/if}}{{#if @root.isMarsApp}} is-mars-app{{/if}}{{#if @root.isNowApp}} is-now-app{{/if}}"> |
80 | - <div class="main-wrap" id="main-wrap" {{#if appPath}}data-apppath='{{{appPath}}}'{{/if}} {{#if miniPath}}data-miniPath='{{{miniPath}}}'{{/if}} {{#if @root.wap.wechat.backDownload}}data-backDownload='{{@root.wap.wechat.backDownload}}'{{/if}}> | 80 | + <div class="main-wrap" id="main-wrap"{{#if appPath}} data-apppath="{{{appPath}}}"{{/if}}{{#if miniPath}} data-miniPath="{{{miniPath}}}"{{/if}}{{#if @root.wap.wechat.miniAutoJump}} data-miniautojump="1"{{/if}}{{#if @root.wap.wechat.backDownload}} data-backDownload="{{@root.wap.wechat.backDownload}}"{{/if}}> |
81 | + | ||
81 | {{#if systemUpdate}} | 82 | {{#if systemUpdate}} |
82 | {{> updata}} | 83 | {{> updata}} |
83 | {{/if}} | 84 | {{/if}} |
@@ -563,6 +563,12 @@ function timedCutProductInit() { | @@ -563,6 +563,12 @@ function timedCutProductInit() { | ||
563 | }); | 563 | }); |
564 | } | 564 | } |
565 | 565 | ||
566 | +function miniProgramHandleInit() { | ||
567 | + if (window.__wxjs_environment === 'miniprogram') { | ||
568 | + require('./miniprogram'); | ||
569 | + } | ||
570 | +} | ||
571 | + | ||
566 | $(function() { | 572 | $(function() { |
567 | if ($('.over').length) { | 573 | if ($('.over').length) { |
568 | // 过期/删除 状态的 活动 | 574 | // 过期/删除 状态的 活动 |
@@ -619,8 +625,10 @@ $(function() { | @@ -619,8 +625,10 @@ $(function() { | ||
619 | timedCutProductInit(); | 625 | timedCutProductInit(); |
620 | 626 | ||
621 | // 小程序相关处理 | 627 | // 小程序相关处理 |
622 | - if (window.__wxjs_environment === 'miniprogram') { | ||
623 | - require('./miniprogram'); | 628 | + if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) { |
629 | + document.addEventListener('WeixinJSBridgeReady', miniProgramHandleInit, false); | ||
630 | + } else { | ||
631 | + miniProgramHandleInit(); | ||
624 | } | 632 | } |
625 | 633 | ||
626 | // 商品曝光事件上报 | 634 | // 商品曝光事件上报 |
1 | /* global wx */ | 1 | /* global wx */ |
2 | import $ from 'yoho-jquery'; | 2 | import $ from 'yoho-jquery'; |
3 | import tip from 'js/plugin/tip'; | 3 | import tip from 'js/plugin/tip'; |
4 | +import {transToMiniappPath} from 'js/common/miniapp-path-rules'; | ||
4 | 5 | ||
5 | class LinkHandle { | 6 | class LinkHandle { |
6 | constructor() { | 7 | constructor() { |
@@ -39,58 +40,13 @@ class LinkHandle { | @@ -39,58 +40,13 @@ class LinkHandle { | ||
39 | * 转换为小程序页面地址 | 40 | * 转换为小程序页面地址 |
40 | */ | 41 | */ |
41 | transToPath(href) { | 42 | transToPath(href) { |
42 | - let path = ''; | ||
43 | - let openbyParamsArr = href.split(/openby:yohobuy(=|=)/); | ||
44 | - let paramsStr = openbyParamsArr[openbyParamsArr.length - 1]; | ||
45 | - let paramsObj = {}; | 43 | + let transData = transToMiniappPath(href); |
46 | 44 | ||
47 | - try { | ||
48 | - paramsObj = JSON.parse(paramsStr); | ||
49 | - } catch (error) { | ||
50 | - console.error('paramsStr is: ', paramsStr); | ||
51 | - } | ||
52 | - | ||
53 | - if (paramsObj.action === 'go.productDetail' && paramsObj.params && paramsObj.params.product_skn) { // 商品详情页 | ||
54 | - path = `/pages/goodsDetail/goodsDetail?productSkn=${paramsObj.params.product_skn}&page_name=home`; | ||
55 | - } else if (paramsObj.action === 'go.list') { // 列表页、专区 | ||
56 | - let queryParams = this.transOpenbyParams(paramsObj.params); | ||
57 | - | ||
58 | - path = `/pages/goodsList/goodsList${queryParams}`; | ||
59 | - } else if (paramsObj.action === 'go.poollist') { // 商品池 | ||
60 | - let queryParams = this.transOpenbyParams(paramsObj.params); | ||
61 | - | ||
62 | - path = `/pages/goodsList/productPool${queryParams}`; | ||
63 | - } else if (paramsObj.action === 'go.h5' && paramsObj.params && paramsObj.params.url) { // 活动模板 | ||
64 | - let queryParams = this.transOpenbyParams(paramsObj.params.param); | ||
65 | - let url = `${paramsObj.params.url}${queryParams}`; | ||
66 | - | ||
67 | - path = `/pages/webview/webview?page_name=home&url=${url}`; | ||
68 | - } else if (paramsObj.action === 'go.shop') { // 店铺 | ||
69 | - path = `/pages/goodsList/brandStore?shopId=${paramsObj.params.shop_id}`; | ||
70 | - } else { | 45 | + if (!transData.path) { |
71 | tip.show('暂不支持,请使用Yoho!buy有货APP选购'); | 46 | tip.show('暂不支持,请使用Yoho!buy有货APP选购'); |
72 | } | 47 | } |
73 | 48 | ||
74 | - return path; | ||
75 | - } | ||
76 | - | ||
77 | - /** | ||
78 | - * 转换 openby 参数 | ||
79 | - */ | ||
80 | - transOpenbyParams(params) { | ||
81 | - let paramsArr = []; | ||
82 | - | ||
83 | - if (params && $.isPlainObject(params)) { | ||
84 | - for (let key in params) { | ||
85 | - if (params.hasOwnProperty(key)) { | ||
86 | - paramsArr.push(`${key}=${params[key]}`); | ||
87 | - } | ||
88 | - } | ||
89 | - } else { | ||
90 | - console.info('params is:', params); | ||
91 | - } | ||
92 | - | ||
93 | - return paramsArr.length ? `?${paramsArr.join('&')}` : ''; | 49 | + return transData.path || ''; |
94 | } | 50 | } |
95 | } | 51 | } |
96 | 52 |
@@ -3,6 +3,80 @@ import $ from 'yoho-jquery'; | @@ -3,6 +3,80 @@ import $ from 'yoho-jquery'; | ||
3 | import tip from 'js/plugin/tip'; | 3 | import tip from 'js/plugin/tip'; |
4 | 4 | ||
5 | $(() => { | 5 | $(() => { |
6 | + let isStop = true; | ||
7 | + let rewardIndex = 0; | ||
8 | + let rewardName = ''; | ||
9 | + | ||
10 | + // 亮灯动画 | ||
11 | + const animateLight = function() { | ||
12 | + $('.reward-light').each(function() { | ||
13 | + if (!$(this).hasClass('active')) { | ||
14 | + $(this).addClass('active'); | ||
15 | + } | ||
16 | + }); | ||
17 | + }; | ||
18 | + | ||
19 | + // 停止亮灯动画 | ||
20 | + const stopAnimateLight = function() { | ||
21 | + $('.reward-light').each(function() { | ||
22 | + if ($(this).hasClass('active')) { | ||
23 | + $(this).removeClass('active'); | ||
24 | + } | ||
25 | + }); | ||
26 | + }; | ||
27 | + | ||
28 | + const showResult = function(result) { | ||
29 | + $('.reward-name').text(result); | ||
30 | + $('.received-wrapper').fadeIn(1000, function() { | ||
31 | + $(this).addClass('show'); | ||
32 | + $(document).on('click', '.go-use', () => { | ||
33 | + tip.show('请下载Yoho!Buy有货官方App,查看/使用优惠券'); | ||
34 | + }); | ||
35 | + }); | ||
36 | + }; | ||
37 | + | ||
38 | + // 停止轮盘 | ||
39 | + const stopRoller = function(index, times, spd) { | ||
40 | + isStop = true; | ||
41 | + $('.item').siblings().removeClass('active'); | ||
42 | + $('.item-' + index).addClass('active'); | ||
43 | + | ||
44 | + if (spd < 500) { | ||
45 | + spd += 20; | ||
46 | + } | ||
47 | + if (times > 0) { | ||
48 | + times -= 1; | ||
49 | + if (index < 7) { | ||
50 | + index += 1; | ||
51 | + } else { | ||
52 | + index = 0; | ||
53 | + } | ||
54 | + setTimeout(stopRoller, spd, index, times, spd); | ||
55 | + } else { | ||
56 | + stopAnimateLight(); | ||
57 | + showResult(rewardName); // 显示中奖结果 | ||
58 | + } | ||
59 | + }; | ||
60 | + | ||
61 | + // 转动轮盘 | ||
62 | + const roller = function(index, spd) { | ||
63 | + if (!isStop) { | ||
64 | + $('.item').siblings().removeClass('active'); | ||
65 | + $('.item-' + index).addClass('active'); | ||
66 | + if (index < 7) { | ||
67 | + index += 1; | ||
68 | + } else { | ||
69 | + index = 0; | ||
70 | + } | ||
71 | + if (spd > 50) { | ||
72 | + spd -= 10; | ||
73 | + } | ||
74 | + setTimeout(roller, spd, index, spd); | ||
75 | + } else { | ||
76 | + stopRoller(index, rewardIndex + 8 * 2 - index, spd); | ||
77 | + } | ||
78 | + }; | ||
79 | + | ||
6 | const $container = $('.redbag-user-container'), | 80 | const $container = $('.redbag-user-container'), |
7 | $msg = $('#msg'); | 81 | $msg = $('#msg'); |
8 | 82 | ||
@@ -17,40 +91,57 @@ $(() => { | @@ -17,40 +91,57 @@ $(() => { | ||
17 | } else { | 91 | } else { |
18 | let posting = false; | 92 | let posting = false; |
19 | 93 | ||
20 | - $(document).on('click', '.receiveRedBag', () => { | 94 | + $(document).on('click', '.receive-redbag', () => { |
21 | const shareCode = $container.data('sharecode'); | 95 | const shareCode = $container.data('sharecode'); |
22 | 96 | ||
23 | - if (!shareCode) { | ||
24 | - return; | ||
25 | - } | ||
26 | - if (posting) { | ||
27 | - return; | ||
28 | - } | ||
29 | - posting = true; | ||
30 | - $.ajax({ | ||
31 | - method: 'POST', | ||
32 | - url: '/activity/red-envelope/receive', | ||
33 | - data: { | ||
34 | - shareCode | ||
35 | - }, | ||
36 | - success: function(res) { | ||
37 | - if (res.code === 200) { | ||
38 | - setTimeout(() => { | ||
39 | - window.location.reload(); | ||
40 | - }, 500); | ||
41 | - } | ||
42 | - if (res.redirect) { | ||
43 | - setTimeout(() => { | ||
44 | - window.location.href = res.redirect + '?refer=' + encodeURIComponent(location.href); | ||
45 | - }, 500); | ||
46 | - } | ||
47 | - | ||
48 | - tip.show(res.message); | ||
49 | - }, | ||
50 | - complete() { | ||
51 | - posting = false; | 97 | + // 开始转动轮盘 |
98 | + if (isStop) { | ||
99 | + if (!shareCode) { | ||
100 | + return; | ||
52 | } | 101 | } |
53 | - }); | 102 | + if (posting) { |
103 | + return; | ||
104 | + } | ||
105 | + posting = true; | ||
106 | + $.ajax({ | ||
107 | + method: 'POST', | ||
108 | + url: '/activity/red-envelope/receive', | ||
109 | + data: { | ||
110 | + shareCode | ||
111 | + }, | ||
112 | + success: function(res) { | ||
113 | + console.log(res); | ||
114 | + if (res.redirect) { | ||
115 | + setTimeout(() => { | ||
116 | + window.location.href = res.redirect + '?refer=' + encodeURIComponent(location.href); | ||
117 | + }, 500); | ||
118 | + } | ||
119 | + if (res.code === 200) { | ||
120 | + isStop = false; | ||
121 | + roller(0, 200); // 开始转动 | ||
122 | + animateLight(); | ||
123 | + | ||
124 | + let rewardId = res.data.rewardId || 0; | ||
125 | + | ||
126 | + rewardName = res.data.rewardName || ''; | ||
127 | + | ||
128 | + setTimeout(function() { | ||
129 | + rewardIndex = parseInt($('#item_' + rewardId).data('index'), 10); | ||
130 | + console.log(rewardIndex); | ||
131 | + isStop = true; | ||
132 | + }, 3000); | ||
133 | + | ||
134 | + } else { | ||
135 | + tip.show(res.message); | ||
136 | + } | ||
137 | + }, | ||
138 | + complete() { | ||
139 | + posting = false; | ||
140 | + } | ||
141 | + }); | ||
142 | + } | ||
54 | }); | 143 | }); |
55 | } | 144 | } |
145 | + | ||
146 | + | ||
56 | }); | 147 | }); |
@@ -288,6 +288,8 @@ $.extend({ | @@ -288,6 +288,8 @@ $.extend({ | ||
288 | // 尝试打开 APP | 288 | // 尝试打开 APP |
289 | require('./common/open-app'); | 289 | require('./common/open-app'); |
290 | 290 | ||
291 | + // 尝试打开 MINIAPP | ||
292 | + require('./common/open-miniapp'); | ||
291 | }()); | 293 | }()); |
292 | 294 | ||
293 | $header.on('touchstart', 'a', function() { | 295 | $header.on('touchstart', 'a', function() { |
public/js/common/miniapp-path-rules.js
0 → 100644
1 | +const _isPlainObject = (obj) => { | ||
2 | + if (typeof(obj) !== 'object' || obj.nodeType || obj !== null && obj !== undefined && obj === obj.window) { // eslint-disable-line | ||
3 | + return false; | ||
4 | + } | ||
5 | + | ||
6 | + if (obj.constructor && | ||
7 | + !Object.prototype.hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) { | ||
8 | + return false; | ||
9 | + } | ||
10 | + | ||
11 | + return true; | ||
12 | +}; | ||
13 | + | ||
14 | +const _qsStringfy = (params) => { | ||
15 | + let paramsArr = []; | ||
16 | + | ||
17 | + if (params && _isPlainObject(params)) { | ||
18 | + for (let key in params) { | ||
19 | + if (params.hasOwnProperty(key)) { | ||
20 | + paramsArr.push(`${key}=${params[key]}`); | ||
21 | + } | ||
22 | + } | ||
23 | + } else { | ||
24 | + console.info('params is:', params); | ||
25 | + } | ||
26 | + | ||
27 | + return paramsArr.length ? `?${paramsArr.join('&')}` : ''; | ||
28 | +}; | ||
29 | + | ||
30 | + | ||
31 | +// 有货跳转规则转化为有货精选路由 | ||
32 | +const transToMiniappPath = (href) => { | ||
33 | + let path = ''; | ||
34 | + let openbyParamsArr = href.split(/openby:yohobuy(=|=)/); | ||
35 | + let paramsStr = openbyParamsArr[openbyParamsArr.length - 1]; | ||
36 | + let paramsObj = {}; | ||
37 | + | ||
38 | + try { | ||
39 | + paramsObj = JSON.parse(paramsStr); | ||
40 | + } catch (error) { | ||
41 | + console.error('paramsStr is: ', paramsStr); | ||
42 | + } | ||
43 | + | ||
44 | + switch (paramsObj.action) { | ||
45 | + case 'go.productDetail': // 商品详情页 | ||
46 | + if (paramsObj.params && paramsObj.params.product_skn) { | ||
47 | + path = `/pages/goodsDetail/goodsDetail?productSkn=${paramsObj.params.product_skn}&page_name=home`; | ||
48 | + } | ||
49 | + break; | ||
50 | + case 'go.list': // 列表页、专区 | ||
51 | + path = `/pages/goodsList/goodsList${_qsStringfy(paramsObj.params)}`; | ||
52 | + break; | ||
53 | + case 'go.poollist': // 商品池 | ||
54 | + path = `/pages/goodsList/productPool${_qsStringfy(paramsObj.params)}`; | ||
55 | + break; | ||
56 | + case 'go.h5': | ||
57 | + if (paramsObj.params && paramsObj.params.url) { | ||
58 | + path = `/pages/webview/webview?page_name=home&url=${paramsObj.params.url}${_qsStringfy(paramsObj.params.param)}`; // eslint-disable-line | ||
59 | + } | ||
60 | + break; | ||
61 | + case 'go.shop': | ||
62 | + path = `/pages/goodsList/brandStore?shopId=${paramsObj.params.shop_id}`; | ||
63 | + break; | ||
64 | + default: | ||
65 | + break; | ||
66 | + } | ||
67 | + | ||
68 | + return { | ||
69 | + path: path, | ||
70 | + action: paramsObj.action | ||
71 | + }; | ||
72 | +}; | ||
73 | + | ||
74 | +module.exports = { | ||
75 | + transToMiniappPath | ||
76 | +}; |
public/js/common/open-miniapp.js
0 → 100644
1 | +import {transToMiniappPath} from './miniapp-path-rules'; | ||
2 | + | ||
3 | +const jumpAction = ['go.productDetail', 'go.list', 'go.shop', 'go.poollist']; | ||
4 | +let retry = 6; | ||
5 | + | ||
6 | +function goMiniapp(apppath) { | ||
7 | + retry--; | ||
8 | + | ||
9 | + if (!window.wx) { | ||
10 | + if (retry > 0) { | ||
11 | + setTimeout(function() { | ||
12 | + goMiniapp(apppath); | ||
13 | + }, 300); | ||
14 | + } | ||
15 | + | ||
16 | + return; | ||
17 | + } | ||
18 | + | ||
19 | + let transData = transToMiniappPath(apppath); | ||
20 | + | ||
21 | + if (transData.path && jumpAction.indexOf(transData.action) >= 0) { | ||
22 | + window.wx.miniProgram.redirectTo({url: transData.path}); | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +function init() { | ||
27 | + if (window.__wxjs_environment !== 'miniprogram') { | ||
28 | + return; | ||
29 | + } | ||
30 | + | ||
31 | + // 添加小程序webview页面标识 | ||
32 | + const bodyClass = 'miniapp-body'; | ||
33 | + const $body = document.getElementsByTagName('body')[0]; | ||
34 | + let classNames = ($body.className || '').split(' '); | ||
35 | + | ||
36 | + if (classNames.indexOf(bodyClass) < 0) { | ||
37 | + classNames.push(bodyClass); | ||
38 | + } | ||
39 | + | ||
40 | + $body.className = classNames.join(' '); | ||
41 | + | ||
42 | + // 自动跳转至小程序对应页面 | ||
43 | + const appInfo = document.getElementById('main-wrap').dataset; | ||
44 | + | ||
45 | + if (appInfo.miniautojump && appInfo.apppath) { | ||
46 | + goMiniapp(appInfo.apppath); | ||
47 | + } | ||
48 | +} | ||
49 | + | ||
50 | +if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) { | ||
51 | + document.addEventListener('WeixinJSBridgeReady', init, false); | ||
52 | +} else { | ||
53 | + init(); | ||
54 | +} |
@@ -55,7 +55,7 @@ class Validate { | @@ -55,7 +55,7 @@ class Validate { | ||
55 | this.$container.addClass('hide').addClass('popup'); | 55 | this.$container.addClass('hide').addClass('popup'); |
56 | }); | 56 | }); |
57 | } else { | 57 | } else { |
58 | - this.render(container, options, validType.IMG_CHECK); | 58 | + tip.show('图形验证码加载失败,请刷新重试'); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | }); | 61 | }); |
1 | .redbag-user-container { | 1 | .redbag-user-container { |
2 | width: 100%; | 2 | width: 100%; |
3 | - background: url(http://img12.static.yhbimg.com/sns/2018/09/27/11/025d67e459f2b67afd343540569e56d7b9.jpg) no-repeat; | 3 | + background: url(https://img12.static.yhbimg.com/sns/2018/09/27/11/025d67e459f2b67afd343540569e56d7b9.jpg) no-repeat; |
4 | background-size: cover; | 4 | background-size: cover; |
5 | - padding-top: 244px; | ||
6 | 5 | ||
7 | .rewards-content { | 6 | .rewards-content { |
8 | position: relative; | 7 | position: relative; |
9 | overflow: hidden; | 8 | overflow: hidden; |
10 | padding-bottom: 100px; | 9 | padding-bottom: 100px; |
10 | + padding-top: 244px; | ||
11 | 11 | ||
12 | .cuo-icon { | 12 | .cuo-icon { |
13 | width: 284px; | 13 | width: 284px; |
14 | height: 111px; | 14 | height: 111px; |
15 | - top: 0; | 15 | + top: 260px; |
16 | right: 49px; | 16 | right: 49px; |
17 | - background: url(//img12.static.yhbimg.com/sns/2018/09/27/12/02598d832b6ecfae4ef6a18c3dd904e90c.png) no-repeat; | 17 | + background: url(https://img12.static.yhbimg.com/sns/2018/09/27/12/02598d832b6ecfae4ef6a18c3dd904e90c.png) no-repeat; |
18 | background-size: contain; | 18 | background-size: contain; |
19 | position: absolute; | 19 | position: absolute; |
20 | + z-index: 9; | ||
21 | + } | ||
22 | + | ||
23 | + .reward-container { | ||
24 | + position: relative; | ||
25 | + width: 750px; | ||
26 | + height: 666px; | ||
27 | + margin-top: 100px; | ||
28 | + } | ||
29 | + | ||
30 | + .reward-pannel { | ||
31 | + width: 750px; | ||
32 | + height: 666px; | ||
33 | + background-image: url(https://img11.static.yhbimg.com/article/2018/11/07/16/01e5493b18a5e50ca49887ce01c12e1643.png); | ||
34 | + background-size: 100% 100%; | ||
35 | + position: relative; | ||
36 | + } | ||
37 | + | ||
38 | + .reward-pannel .reward-light { | ||
39 | + width: 100px; | ||
40 | + height: 666px; | ||
41 | + background-image: url(https://img13.static.yhbimg.com/article/2018/11/12/11/02859c1385a0189a9c108682419348a9f9.png); | ||
42 | + background-size: cover; | ||
43 | + background-position: 0 0; | ||
44 | + position: absolute; | ||
45 | + | ||
46 | + &.left { | ||
47 | + left: 0; | ||
48 | + top: 0; | ||
49 | + } | ||
50 | + | ||
51 | + &.right { | ||
52 | + right: 0; | ||
53 | + top: 0; | ||
54 | + } | ||
55 | + | ||
56 | + &.active { | ||
57 | + -webkit-animation: reward-light-animate 0.5s steps(1) infinite; | ||
58 | + animation: reward-light-animate 0.5s steps(1) infinite; | ||
59 | + } | ||
60 | + } | ||
61 | + | ||
62 | + .reward-items { | ||
63 | + position: absolute; | ||
64 | + width: 594px; | ||
65 | + height: 598px; | ||
66 | + left: 50%; | ||
67 | + top: 50%; | ||
68 | + margin-left: -299px; | ||
69 | + margin-top: -299px; | ||
70 | + z-index: 9; | ||
71 | + | ||
72 | + .item { | ||
73 | + position: absolute; | ||
74 | + width: 186px; | ||
75 | + height: 170px; | ||
76 | + overflow: hidden; | ||
77 | + border-radius: 20px; | ||
78 | + | ||
79 | + &.active .item-mask { | ||
80 | + position: absolute; | ||
81 | + width: 100%; | ||
82 | + height: 100%; | ||
83 | + left: 0; | ||
84 | + top: 0; | ||
85 | + background-color: rgba(255, 214, 56, 0.5); | ||
86 | + z-index: 5; | ||
87 | + } | ||
88 | + } | ||
89 | + | ||
90 | + .item-0 { | ||
91 | + left: 10px; | ||
92 | + top: 20px; | ||
93 | + } | ||
94 | + | ||
95 | + .item-1 { | ||
96 | + left: 205px; | ||
97 | + top: 20px; | ||
98 | + } | ||
99 | + | ||
100 | + .item-2 { | ||
101 | + left: 400px; | ||
102 | + top: 20px; | ||
103 | + } | ||
104 | + | ||
105 | + .item-3 { | ||
106 | + left: 400px; | ||
107 | + top: 210px; | ||
108 | + } | ||
109 | + | ||
110 | + .item-4 { | ||
111 | + left: 400px; | ||
112 | + top: 400px; | ||
113 | + } | ||
114 | + | ||
115 | + .item-5 { | ||
116 | + left: 205px; | ||
117 | + top: 400px; | ||
118 | + } | ||
119 | + | ||
120 | + .item-6 { | ||
121 | + left: 10px; | ||
122 | + top: 400px; | ||
123 | + } | ||
124 | + | ||
125 | + .item-7 { | ||
126 | + left: 10px; | ||
127 | + top: 210px; | ||
128 | + } | ||
129 | + | ||
130 | + .receive-redbag { | ||
131 | + left: 205px; | ||
132 | + top: 210px; | ||
133 | + } | ||
20 | } | 134 | } |
21 | 135 | ||
22 | img { | 136 | img { |
23 | - width: 570px; | ||
24 | - height: 553px; | ||
25 | - overflow: hidden; | ||
26 | - margin-top: 130px; | 137 | + width: 100%; |
138 | + height: 100%; | ||
139 | + } | ||
140 | + } | ||
141 | + | ||
142 | + .received-wrapper { | ||
143 | + display: none; | ||
144 | + position: absolute; | ||
145 | + width: 100%; | ||
146 | + height: 100%; | ||
147 | + background-color: rgba(0, 0, 0, 0.7); | ||
148 | + z-index: 10; | ||
149 | + | ||
150 | + &.show { | ||
151 | + display: block !important; | ||
27 | } | 152 | } |
28 | } | 153 | } |
29 | 154 | ||
30 | .received-content { | 155 | .received-content { |
31 | - padding-top: 176px; | ||
32 | overflow: hidden; | 156 | overflow: hidden; |
33 | - padding-bottom: 160px; | ||
34 | - position: relative; | 157 | + position: absolute; |
158 | + width: 580px; | ||
159 | + left: 50%; | ||
160 | + top: 50%; | ||
161 | + margin-left: -292px; | ||
162 | + margin-top: -370px; | ||
163 | + background-color: #fff; | ||
164 | + border-radius: 20px; | ||
165 | + z-index: 10; | ||
166 | + | ||
167 | + .reward-pic { | ||
168 | + position: relative; | ||
169 | + width: 462px; | ||
170 | + height: 308px; | ||
171 | + margin: 20px auto 0 auto; | ||
172 | + background-image: url(//img11.static.yhbimg.com/article/2018/11/07/16/0137323a8972604cf08b056350f217adbb.png); | ||
173 | + background-size: 100% 100%; | ||
174 | + } | ||
175 | + | ||
176 | + p { | ||
177 | + display: block; | ||
178 | + width: 100%; | ||
179 | + font-size: 24px; | ||
180 | + text-align: center; | ||
181 | + margin: 0; | ||
182 | + padding: 5px 50px; | ||
183 | + line-height: 36px; | ||
184 | + font-weight: normal; | ||
185 | + font-family: "PingFang SC", Helvetica, Arial, sans-serif; | ||
186 | + } | ||
187 | + | ||
188 | + .reward-name { | ||
189 | + font-size: 30px; | ||
190 | + font-weight: bold; | ||
191 | + } | ||
192 | + | ||
193 | + .go-use { | ||
194 | + position: relative; | ||
195 | + display: block; | ||
196 | + width: 380px; | ||
197 | + height: 80px; | ||
198 | + margin: 20px auto; | ||
199 | + border-radius: 80px; | ||
200 | + background-color: #000; | ||
201 | + color: #fff; | ||
202 | + border: none !important; | ||
203 | + } | ||
35 | 204 | ||
36 | .use { | 205 | .use { |
37 | - width: 750px; | 206 | + width: 540px; |
38 | height: 443px; | 207 | height: 443px; |
208 | + margin: 0 auto; | ||
209 | + background-color: rgba(255, 255, 255, 0.5); | ||
39 | background-size: contain; | 210 | background-size: contain; |
40 | 211 | ||
41 | &.red-bag1 { | 212 | &.red-bag1 { |
@@ -66,16 +237,6 @@ | @@ -66,16 +237,6 @@ | ||
66 | height: 443px; | 237 | height: 443px; |
67 | } | 238 | } |
68 | } | 239 | } |
69 | - | ||
70 | - .go-use { | ||
71 | - position: absolute; | ||
72 | - width: 310px; | ||
73 | - height: 180px; | ||
74 | - top: 386px; | ||
75 | - left: 200px; | ||
76 | - background: none !important; | ||
77 | - border: none !important; | ||
78 | - } | ||
79 | } | 240 | } |
80 | 241 | ||
81 | .activity-rule { | 242 | .activity-rule { |
@@ -97,7 +258,7 @@ | @@ -97,7 +258,7 @@ | ||
97 | height: 91px; | 258 | height: 91px; |
98 | right: 33px; | 259 | right: 33px; |
99 | top: -39px; | 260 | top: -39px; |
100 | - background: url(http://img11.static.yhbimg.com/sns/2018/09/27/11/01c13a6c46302940f9c1656f5893236d97.png) no-repeat; | 261 | + background: url(https://img11.static.yhbimg.com/sns/2018/09/27/11/01c13a6c46302940f9c1656f5893236d97.png) no-repeat; |
101 | background-size: contain; | 262 | background-size: contain; |
102 | } | 263 | } |
103 | 264 | ||
@@ -141,3 +302,17 @@ | @@ -141,3 +302,17 @@ | ||
141 | } | 302 | } |
142 | } | 303 | } |
143 | } | 304 | } |
305 | + | ||
306 | +@keyframes reward-light-animate { | ||
307 | + 0% { | ||
308 | + background-position: 0 0; | ||
309 | + } | ||
310 | + | ||
311 | + 50% { | ||
312 | + background-position: 100% 0; | ||
313 | + } | ||
314 | + | ||
315 | + 100% { | ||
316 | + background-position: 0 0; | ||
317 | + } | ||
318 | +} |
@@ -11102,9 +11102,9 @@ yoho-md5@^2.0.0: | @@ -11102,9 +11102,9 @@ yoho-md5@^2.0.0: | ||
11102 | version "2.1.0" | 11102 | version "2.1.0" |
11103 | resolved "http://npm.yohops.com/yoho-md5/-/yoho-md5-2.1.0.tgz#f0c00d343f775e77952ebce0826863ac52e0ad50" | 11103 | resolved "http://npm.yohops.com/yoho-md5/-/yoho-md5-2.1.0.tgz#f0c00d343f775e77952ebce0826863ac52e0ad50" |
11104 | 11104 | ||
11105 | -yoho-node-lib@=0.6.33: | ||
11106 | - version "0.6.33" | ||
11107 | - resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.6.33.tgz#fca4dadedb80438d30d06fbb386d09912a4f9ca6" | 11105 | +yoho-node-lib@=0.6.34: |
11106 | + version "0.6.34" | ||
11107 | + resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.6.34.tgz#c650e06bfc530cf13c79cf4b3e08bc5d15345933" | ||
11108 | dependencies: | 11108 | dependencies: |
11109 | dnscache "^1.0.1" | 11109 | dnscache "^1.0.1" |
11110 | handlebars "^4.0.5" | 11110 | handlebars "^4.0.5" |
-
Please register or login to post a comment