Authored by 李奇

UI dev

import React from 'react';
import './index.scss';
export default class BottomButtons extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="comp-bottom-btns-wrap">
<a href="" className="button-item">
<img className="btn-item-bg" src=""/>
</a>
<a href="" className="button-item"></a>
<a href="" className="button-item"></a>
</div>
)
}
}
\ No newline at end of file
... ...
.comp-bottom-btns-wrap {
display: flex;
position: absolute;
top: 1100px;
left: 0;
right: 0;
height: 88px;
padding: 0 40px;
box-sizing: border-box;
.button-item {
display: inline-block;
flex: 1;
margin-left: 20px;
border: 1px solid red;
box-sizing: border-box;
&:first-child {
margin-left: 0;
}
}
}
\ No newline at end of file
... ...
... ... @@ -4,37 +4,34 @@ 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 yaSDK from 'yoho-activity-sdk';
import config from '../../config';
import cookie from 'react-cookies';
import LazyLoad from 'react-lazy-load'
import {
Link
} from 'react-router-dom'
import BottomButtons from '../components/bottom-buttons';
const {actId} = getQueryObj();
export default class wheelSurf extends PureComponent {
constructor(props) {
document.title ='大转盘'
document.title ='大转盘';
super(props);
this.state = {
initial: true,
pending: false, // 抽奖中
startEnd: false,
isEnding: false, // 即将停止
conf: {
// 默认数据
loading: ''
}
};
// 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 () => {
... ... @@ -58,140 +55,57 @@ export default class wheelSurf extends PureComponent {
}
};
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});
start = async () => {
console.log('抽奖开始');
let uid = cookie.load('app_uid') || getQueryObj().uid || 0;
if(!uid || !parseInt(uid)){
return;
}
};
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: '大转盘'
}
let result = await start({
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({env: "miniprogram"});
}
};
scrollTop = () => {
let _this = this;
let timer = setTimeout(function () {
window.scrollBy(0, -100);
if (window.pageYOffset <= 0) {
clearTimeout(timer);
} else {
_this.scrollTop();
if (result.code === 200) {
this.setState({
conf: result.data
})
}
}, 20);
};
render() {
const {conf, isEnding} = this.state;
if (!conf.id) {
return (
<div className="home-wrap">
<img className="main-bg" src={this.state.conf.loading + '?imageslim'}/>
</div>
)
}
return (
<div className="home-wrap">
<img className="main-bg" src={this.state.conf.main_bg + '?imageslim'}/>
<img className="main-bg" src={conf.main_bg + '?imageslim'}/>
{conf.rule_btn_bg ? (<Link to={`${config.routerPath}/rule.html`}><img className="rule-btn" src={conf.rule_btn_bg + '?imageslim'}/></Link>) : ''}
{conf.share_btn_bg ? (<img className="share-btn" src={conf.share_btn_bg + '?imageslim'}/>): ''}
<img className="wheel-bg" src={conf.wheel_bg + '?imageslim'}/>
<img className="wheel-bg-surf-layer" src={conf.wheel_bg}/>
<img onClick={()=>{this.start()}} className="start-btn-bg" src={conf.prize_btn_bg}/>
{isEnding ? (<img className="prize-hit-bg" src={conf.win_prize_bg}/>) : ''}
{isEnding ? (<img className="prize-hit-start-bg" src={conf.prize_btn_bg}/>) : ''}
<BottomButtons className="button-btns"/>
</div>
)
}
... ...
.home-wrap {
position: relative;
width: 100%;
height: 100%;
overflow-x: hidden;
... ... @@ -7,4 +8,52 @@
width: 750px;
height: auto;
}
.wheel-bg,
.wheel-bg-surf-layer {
position: absolute;
top: 280px;
left: 50%;
width: 630px;
height: 630px;
margin-left: -315px;
}
.prize-hit-bg {
position: absolute;
top: 0;
width: 750px;
}
.start-btn-bg, .prize-hit-start-bg {
position: absolute;
top: 486px;
left: 50%;
width: 200px;
height: 218px;
margin-left: -100px;
}
.rule-btn {
position: absolute;
top: 14px;
left: 14px;
width: 154px;
height: 62px;
}
.share-btn {
position: absolute;
top: 14px;
right: 14px;
width: 154px;
height: 62px;
}
.bottom-btns {
position: absolute;
top: 1100px;
left: 0;
right: 0;
}
}
\ No newline at end of file
... ...
import React, {PureComponent} from 'react';
import './index.scss'
export default class wheelSurf extends PureComponent {
export default class Rule extends PureComponent {
constructor(props) {
document.title ='活动规则说明';
super(props);
}
render() {
return (
<div className="rule-wrap">
... ...
... ... @@ -45,7 +45,6 @@
"compression-webpack-plugin": "^1.1.11",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"mini-css-extract-plugin":"^0.4.3",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"html-withimg-loader": "^0.1.16",
... ... @@ -64,7 +63,8 @@
"webpack": "^4.17.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.3",
"webpack-merge": "^4.1.4"
"webpack-merge": "^4.1.4",
"yoho-activity-sdk": "^1.0.2"
},
"author": "陈峰 <feng.chen@yoho.cn>",
"license": "ISC",
... ...
... ... @@ -363,12 +363,6 @@ async@^1.5.2:
version "1.5.2"
resolved "http://npm.yohops.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
async@^2.4.1:
version "2.6.1"
resolved "http://npm.yohops.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610"
dependencies:
lodash "^4.17.10"
asynckit@^0.4.0:
version "0.4.0"
resolved "http://npm.yohops.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
... ... @@ -2500,15 +2494,6 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"
extract-text-webpack-plugin@^4.0.0-beta.0:
version "4.0.0-beta.0"
resolved "http://npm.yohops.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-4.0.0-beta.0.tgz#f7361d7ff430b42961f8d1321ba8c1757b5d4c42"
dependencies:
async "^2.4.1"
loader-utils "^1.1.0"
schema-utils "^0.4.5"
webpack-sources "^1.1.0"
extsprintf@1.3.0:
version "1.3.0"
resolved "http://npm.yohops.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
... ... @@ -2626,8 +2611,8 @@ flush-write-stream@^1.0.0:
readable-stream "^2.0.4"
follow-redirects@^1.0.0:
version "1.5.8"
resolved "http://npm.yohops.com/follow-redirects/-/follow-redirects-1.5.8.tgz#1dbfe13e45ad969f813e86c00e5296f525c885a1"
version "1.5.9"
resolved "http://npm.yohops.com/follow-redirects/-/follow-redirects-1.5.9.tgz#c9ed9d748b814a39535716e531b9196a845d89c6"
dependencies:
debug "=3.1.0"
... ... @@ -2988,8 +2973,8 @@ hpack.js@^2.1.6:
wbuf "^1.1.0"
html-comment-regex@^1.1.0:
version "1.1.1"
resolved "http://npm.yohops.com/html-comment-regex/-/html-comment-regex-1.1.1.tgz#668b93776eaae55ebde8f3ad464b307a4963625e"
version "1.1.2"
resolved "http://npm.yohops.com/html-comment-regex/-/html-comment-regex-1.1.2.tgz#97d4688aeb5c81886a364faa0cad1dda14d433a7"
html-entities@^1.2.0:
version "1.2.1"
... ... @@ -3892,14 +3877,6 @@ mimic-fn@^1.0.0:
version "1.2.0"
resolved "http://npm.yohops.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
mini-css-extract-plugin@^0.4.3:
version "0.4.3"
resolved "http://npm.yohops.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.4.3.tgz#98d60fcc5d228c3e36a9bd15a1d6816d6580beb8"
dependencies:
loader-utils "^1.1.0"
schema-utils "^1.0.0"
webpack-sources "^1.1.0"
minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
version "1.0.1"
resolved "http://npm.yohops.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
... ... @@ -6524,3 +6501,7 @@ yargs@^7.0.0:
which-module "^1.0.0"
y18n "^3.2.1"
yargs-parser "^5.0.0"
yoho-activity-sdk@^1.0.2:
version "1.0.2"
resolved "http://npm.yohops.com/yoho-activity-sdk/-/yoho-activity-sdk-1.0.2.tgz#82f2e00c2bc11514b9243c9940273e2990d0c27c"
... ...