Authored by 李奇

奖品为空页添加

@@ -2,6 +2,7 @@ import React, {PureComponent} from 'react'; @@ -2,6 +2,7 @@ import React, {PureComponent} from 'react';
2 import './index.scss' 2 import './index.scss'
3 import {prize} from '../../api'; 3 import {prize} from '../../api';
4 import yaSDK from 'yoho-activity-sdk'; 4 import yaSDK from 'yoho-activity-sdk';
  5 +import config from '../../config';
5 import TipModal from '../components/tip-modal'; 6 import TipModal from '../components/tip-modal';
6 7
7 8
@@ -10,19 +11,7 @@ export default class Prize extends PureComponent { @@ -10,19 +11,7 @@ export default class Prize extends PureComponent {
10 document.title ='我的奖品'; 11 document.title ='我的奖品';
11 super(props); 12 super(props);
12 this.state = { 13 this.state = {
13 - prizes: [  
14 - {  
15 - id: 1,  
16 - type: 2  
17 - }, {  
18 - id: 2,  
19 - type: 3  
20 -  
21 - }, {  
22 - id: 3,  
23 - type: 4  
24 - }  
25 - ], 14 + prizes: [],
26 showModal: false, 15 showModal: false,
27 modalTip: '请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服', 16 modalTip: '请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服请联系客服',
28 modalBtnText: '确定' 17 modalBtnText: '确定'
@@ -30,7 +19,6 @@ export default class Prize extends PureComponent { @@ -30,7 +19,6 @@ export default class Prize extends PureComponent {
30 } 19 }
31 20
32 detail = (event, prize) => { 21 detail = (event, prize) => {
33 - console.log('查看详情');  
34 const type = prize.type; 22 const type = prize.type;
35 23
36 if (type === 4) { 24 if (type === 4) {
@@ -51,38 +39,41 @@ export default class Prize extends PureComponent { @@ -51,38 +39,41 @@ export default class Prize extends PureComponent {
51 }); 39 });
52 }; 40 };
53 41
  42 + backTry = (e) => {
  43 + yaSDK.link(e);
  44 + };
  45 +
54 componentDidMount() { 46 componentDidMount() {
55 - yaSDK.getUid().then(uid => {  
56 - prize({ 47 + yaSDK.getUid().then(async uid => {
  48 + let result = await prize({
57 act_id: +yaSDK.getQueryObj().actId, 49 act_id: +yaSDK.getQueryObj().actId,
58 uid: uid || +yaSDK.getQueryObj().uid 50 uid: uid || +yaSDK.getQueryObj().uid
59 - }) 51 + });
  52 +
  53 + this.setState({
  54 + prizes: result.data
  55 + });
60 }) 56 })
61 } 57 }
62 58
63 render() { 59 render() {
64 let {showModal, modalTip, modalBtnText} = this.state; 60 let {showModal, modalTip, modalBtnText} = this.state;
  61 + let backUrl = `${document.location.protocol}//${document.location.host}${config.routerPath}/home.html?actId=${yaSDK.getQueryObj().actId}`;
65 62
66 - let couponLink;  
67 - let redEnvelopeLink;  
68 -  
69 - if (yaSDK.env !== 'miniprogram') {  
70 - couponLink = 'https://m.yohobuy.com/home/coupons?openby:yohobuy={"action":"go.coupon"}';  
71 - redEnvelopeLink = 'https://activity.yoho.cn/feature/3221.html?title=我的红包&openby:yohobuy={"action":"go.mineredpackage"}';  
72 - } else {  
73 - // TODO 小程序红包优惠券链接  
74 - } 63 + let couponLink = 'https://m.yohobuy.com/home/coupons?openby:yohobuy={"action":"go.coupon"}';
  64 + let redEnvelopeLink = 'https://activity.yoho.cn/feature/3221.html?title=我的红包&openby:yohobuy={"action":"go.mineredpackage"}';
75 65
76 return ( 66 return (
77 <div className="my-prize-wrap"> 67 <div className="my-prize-wrap">
78 { 68 {
  69 + this.state.prizes.length ? (
79 this.state.prizes.map(prize => { 70 this.state.prizes.map(prize => {
80 return ( 71 return (
81 <div className="prize-item" key={prize.id}> 72 <div className="prize-item" key={prize.id}>
82 <div className="item-top"> 73 <div className="item-top">
83 - <img src="http://img11.static.yhbimg.com/yhb-img01/2018/10/11/10/0157b624efd3c0db2e2b0c1c5b84a1fff7.png" className="prize-img"/> 74 + <img src={prize.img} className="prize-img"/>
84 <div className="prize-info"> 75 <div className="prize-info">
85 - <div className="prize-name">OFF-WHITE x Nike Air and nnAir and nnAir and nnAir and nnAir and nnAir and nn</div> 76 + <div className="prize-name">{prize.name}</div>
86 <div className="got-time">中奖时间:2018-10-12 20:20</div> 77 <div className="got-time">中奖时间:2018-10-12 20:20</div>
87 </div> 78 </div>
88 </div> 79 </div>
@@ -95,7 +86,14 @@ export default class Prize extends PureComponent { @@ -95,7 +86,14 @@ export default class Prize extends PureComponent {
95 </div> 86 </div>
96 </div> 87 </div>
97 ) 88 )
98 - }) 89 + })) : (
  90 + <div className="empty-prize">
  91 + <img className="empty-img" src="http://img11.static.yhbimg.com/yhb-img01/2018/10/15/17/01a6e21ead7c45efdc7ba902de73218854.png" alt=""/>
  92 + <div className="empty-tip">您暂时没有奖品</div>
  93 + <div className="back-try" onClick={(event) => this.backTry(event)} data-type="other"
  94 + data-url={backUrl}>去抽奖</div>
  95 + </div>
  96 + )
99 } 97 }
100 { 98 {
101 showModal ? <TipModal tip={modalTip} btnText={modalBtnText} confirm={() => {this.confirm()}} /> : '' 99 showModal ? <TipModal tip={modalTip} btnText={modalBtnText} confirm={() => {this.confirm()}} /> : ''
@@ -85,4 +85,37 @@ body { @@ -85,4 +85,37 @@ body {
85 height: 30px; 85 height: 30px;
86 } 86 }
87 } 87 }
  88 +
  89 + .empty-prize {
  90 + text-align: center;
  91 + padding-top: 272px;
  92 +
  93 + .empty-img {
  94 + width: 180px;
  95 + height: 180px;
  96 + }
  97 +
  98 + .empty-tip {
  99 + font-family: PingFang-SC-Regular;
  100 + font-size: 24px;
  101 + color: #444444;
  102 + letter-spacing: 0;
  103 + text-align: center;
  104 + margin-top: 60px;
  105 + }
  106 +
  107 + .back-try {
  108 + height: 80px;
  109 + width: 426px;
  110 + margin: 130px auto 0;
  111 + background: #363636;
  112 + border-radius: 2px;
  113 + font-family: PingFang-SC-Regular;
  114 + font-size: 28px;
  115 + color: #FFFFFF;
  116 + letter-spacing: 0;
  117 + text-align: center;
  118 + line-height: 80px;
  119 + }
  120 + }
88 } 121 }