|
|
import React, {PureComponent} from 'react';
|
|
|
import './index.scss'
|
|
|
import {conf, start} from '../../api'
|
|
|
import {getQueryObj, linkToMiniApp, invokeMethod, parseUrl} from '../../../../common/utils';
|
|
|
import wxshare from '../../../../common/wxshare'
|
|
|
import wx from 'weixin-js-sdk';
|
|
|
import config from '../../config';
|
|
|
import cookie from 'react-cookies';
|
|
|
import LazyLoad from 'react-lazy-load'
|
|
|
|
|
|
const {actId} = getQueryObj();
|
|
|
|
|
|
export default class wheelSurf extends PureComponent {
|
|
|
constructor(props) {
|
|
|
document.title ='活动规则说明'
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
env: '',
|
|
|
url: ''
|
|
|
}
|
|
|
// this.collect = this.collect.bind(this);
|
|
|
this.init();
|
|
|
|
|
|
// 微信分享
|
|
|
// let shareData={
|
|
|
// title: '国潮崛起年,中西碰撞博出位!',
|
|
|
// imgUrl: 'https://img01.yohoboys.com/o_1cnilugbs15ajak1gfo1d2h1p348.png?imageView2/1/w/200/h/200',
|
|
|
// desc: '这里有一份中西潮流榜单,请收好!',
|
|
|
// link: 'https://ad.yoho.cn/html5/2018/09/guochao/guochao.html',
|
|
|
// success: function () {
|
|
|
//
|
|
|
// }
|
|
|
// }
|
|
|
// wxshare(shareData);
|
|
|
}
|
|
|
|
|
|
init = async () => {
|
|
|
let uid = cookie.load('app_uid') || getQueryObj().uid || 0;
|
|
|
if(!uid || !parseInt(uid)){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
let result = await conf({
|
|
|
actId,
|
|
|
uid: uid,
|
|
|
sessionKey: cookie.load('app_session_key') || getQueryObj().session_key || '',
|
|
|
sessionType: cookie.load('app_client_type') || '',
|
|
|
appVersion: cookie.load('app_version') || ''
|
|
|
});
|
|
|
this.setState({
|
|
|
storage: result.data
|
|
|
})
|
|
|
}
|
|
|
|
|
|
collect = async (id) => {
|
|
|
//判断是否是clicked
|
|
|
if (this.state.storage[id]) {
|
|
|
return;
|
|
|
} else {
|
|
|
//判断用户登陆 未登陆跳登陆
|
|
|
if (!parseInt(getQueryObj().uid)) {
|
|
|
if (this.state.env === 'miniprogram') {
|
|
|
return wx.miniProgram.switchTab({url: '/pages/userCenter/userCenter'});
|
|
|
}
|
|
|
else {
|
|
|
return this.goLogin('http://ad.yoho.cn/html5/2018/09/guochao/guochao.html')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//发送请求
|
|
|
let result = await collectApi({
|
|
|
id: id,
|
|
|
uid: cookie.load('app_uid') || getQueryObj().uid || 0,
|
|
|
sessionKey: cookie.load('app_session_key') || getQueryObj().session_key || '',
|
|
|
sessionType: cookie.load('app_client_type') || '',
|
|
|
appVersion: cookie.load('app_version') || ''
|
|
|
});
|
|
|
if (!result.result)
|
|
|
return;
|
|
|
//替换图标
|
|
|
let storage = this.state.storage;
|
|
|
storage[id] = true;
|
|
|
this.setState({
|
|
|
storage
|
|
|
})
|
|
|
this.forceUpdate();
|
|
|
}
|
|
|
};
|
|
|
goLogin = (refer, data) => {
|
|
|
let url;
|
|
|
|
|
|
if (refer.indexOf('//') === 0) {
|
|
|
refer = location.protocol + refer;
|
|
|
}
|
|
|
|
|
|
url = 'http://m.yohobuy.com/signin.html?refer=' + encodeURIComponent(refer);
|
|
|
refer = parseUrl(refer || location.href);
|
|
|
if (this.state.env == 'app') {
|
|
|
if (/Android/i.test(navigator.userAgent || '')) {
|
|
|
if (url.indexOf('?') < 0) {
|
|
|
url += '?appLogin=1';
|
|
|
}
|
|
|
if (location.href.indexOf('&openby') >= 0) {
|
|
|
url = url.substring(0, url.indexOf('&openby'));
|
|
|
}
|
|
|
url += '&';
|
|
|
} else {
|
|
|
if (location.href.indexOf('#openby') >= 0) {
|
|
|
url = url.substring(0, url.indexOf('#openby'));
|
|
|
}
|
|
|
url += '#';
|
|
|
}
|
|
|
url += 'openby:yohobuy=' + (data || JSON.stringify({
|
|
|
action: 'go.weblogin',
|
|
|
params: {
|
|
|
priority: 'N',
|
|
|
jumpurl: {
|
|
|
url: refer.path,
|
|
|
param: refer.query
|
|
|
},
|
|
|
needlogout: 'Y'
|
|
|
}
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
this.setState({url: url}, () => {
|
|
|
document.getElementById('url').click();
|
|
|
});
|
|
|
return false;
|
|
|
};
|
|
|
componentDidMount = () => {
|
|
|
window.addEventListener('scroll', this.handleScroll);
|
|
|
this.wxReady();
|
|
|
};
|
|
|
|
|
|
componentWillUnmount = () => {
|
|
|
window.removeEventListener('scroll', this.handleScroll);
|
|
|
};
|
|
|
|
|
|
handleScroll = () => {
|
|
|
let _this = this;
|
|
|
if (window.pageYOffset > 100) {
|
|
|
_this.setState({display: true});
|
|
|
} else {
|
|
|
_this.setState({display: false});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
wxReady = async () => {
|
|
|
let envFlag = window.__wxjs_environment;
|
|
|
if (!envFlag && navigator.userAgent.match(/yohobuy/i)) {
|
|
|
document.addEventListener('deviceready', function () {
|
|
|
});
|
|
|
this.setState({env: "app"});
|
|
|
} else if (!envFlag && navigator.userAgent.match(/miniProgram/i)) {
|
|
|
this.setState({env: "miniprogram"});
|
|
|
envFlag = true
|
|
|
} else {
|
|
|
this.setState({env: 'h5'})
|
|
|
}
|
|
|
if (envFlag == 'miniprogram') {
|
|
|
if (wx.miniProgram.postMessage) {
|
|
|
wx.miniProgram.postMessage({
|
|
|
data: {
|
|
|
title: '活动规则说明'
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
this.setState({env: "miniprogram"});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
scrollTop = () => {
|
|
|
let _this = this;
|
|
|
let timer = setTimeout(function () {
|
|
|
window.scrollBy(0, -100);
|
|
|
if (window.pageYOffset <= 0) {
|
|
|
clearTimeout(timer);
|
|
|
} else {
|
|
|
_this.scrollTop();
|
|
|
}
|
|
|
}, 20);
|
|
|
};
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
<div className="wrap">
|
|
|
|
|
|
<div className="rule-wrap">
|
|
|
<p className="rule-title">活动规则:</p>
|
|
|
<p className="rule-line">1、活动时间:2018年5月12日—2019年3月31日。</p>
|
|
|
<p className="rule-line">2、活动规则:活动期间,用户每天可获得5次抽奖机会,每次抽奖消耗10积分,按照50%中奖概率随机出奖。</p>
|
|
|
<p className="rule-line">3、活动同一用户:同一支付宝账号、身份证、实名认证、终端设备、手机号等均视为同一用户条件。</p>
|
|
|
<p className="rule-line">4、奖品查询:中奖后若要查看,以每次抽奖领取页展示为准。</p>
|
|
|
<p className="rule-line">5、奖品使用规则:请依各项奖品说明为准。</p>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
...
|
...
|
|