Browse Source

glow

master
jiannibang 6 years ago
parent
commit
dafbe14164
  1. 120
      src/App.js
  2. 122
      src/App.scss
  3. BIN
      src/close.png
  4. 14
      src/components/product.jsx
  5. 34
      src/components/product.scss
  6. 10
      src/components/shop.scss
  7. 18
      src/data/Shops.js
  8. 146
      src/glow.scss
  9. BIN
      src/images/coupon/all.png
  10. BIN
      src/images/coupon/all1.png
  11. BIN
      src/images/coupon/drink.png
  12. BIN
      src/images/coupon/drink1.png
  13. BIN
      src/images/coupon/fresh.png
  14. BIN
      src/images/coupon/fresh1.png
  15. BIN
      src/images/coupon/nurse.png
  16. BIN
      src/images/coupon/nurse1.png
  17. BIN
      src/images/coupon/snack.png
  18. BIN
      src/images/coupon/snack1.png
  19. BIN
      src/images/coupon/母婴1.jpg
  20. BIN
      src/images/coupon/母婴2.jpg
  21. BIN
      src/images/coupon/母婴3.jpg
  22. BIN
      src/images/coupon/母婴4.jpg
  23. BIN
      src/images/coupon/母婴5.jpg
  24. BIN
      src/images/coupon/母婴6.jpg
  25. BIN
      src/images/coupon/生鲜1.jpg
  26. BIN
      src/images/coupon/生鲜2.jpg
  27. BIN
      src/images/coupon/生鲜3.jpg
  28. BIN
      src/images/coupon/生鲜4.jpg
  29. BIN
      src/images/coupon/生鲜5.jpg
  30. BIN
      src/images/coupon/生鲜6.jpg
  31. BIN
      src/images/coupon/零食1.jpg
  32. BIN
      src/images/coupon/零食2.jpg
  33. BIN
      src/images/coupon/零食3.jpg
  34. BIN
      src/images/coupon/零食4.jpg
  35. BIN
      src/images/coupon/零食5.jpg
  36. BIN
      src/images/coupon/零食6.jpg
  37. BIN
      src/images/coupon/饮料1.jpg
  38. BIN
      src/images/coupon/饮料2.jpg
  39. BIN
      src/images/coupon/饮料3.jpg
  40. BIN
      src/images/coupon/饮料4.jpg
  41. BIN
      src/images/coupon/饮料5.jpg
  42. BIN
      src/images/coupon/饮料6.jpg
  43. 10
      src/index.css
  44. 6
      src/models/Wall.js
  45. BIN
      src/open.png

120
src/App.js

@ -11,6 +11,9 @@ import touchIcon from "./touch.png";
import model from "./model-stride16.json"; import model from "./model-stride16.json";
import moment from "moment"; import moment from "moment";
import "moment/locale/zh-cn"; import "moment/locale/zh-cn";
import images from "./images/coupon/image-helper";
import Product from "./components/product";
import "./glow.scss";
moment.locale("zh-cn"); moment.locale("zh-cn");
const videoWidth = 600; const videoWidth = 600;
@ -33,8 +36,16 @@ const App = () => {
const [minutes, setMinutes] = useState(0); const [minutes, setMinutes] = useState(0);
const [seconds, setSeconds] = useState(0); const [seconds, setSeconds] = useState(0);
const shop = shops[shopIndex]; const shop = shops[shopIndex];
const {
categories,
categoryIconMap,
categoryProductsMap,
categoryIcon1Map,
} = shop;
const [itemData, setItem] = useState(null); const [itemData, setItem] = useState(null);
const [resetTimer, setResetTimer] = useState(null); const [resetTimer, setResetTimer] = useState(null);
const [showMenu, setShowMenu] = useState(false);
const [currentTab, setCurrentTab] = useState(null);
useEffect(() => { useEffect(() => {
if (!posenetModel) { if (!posenetModel) {
@ -75,7 +86,7 @@ const App = () => {
} }
}, [video]); }, [video]);
const initWall = () => {
const initWall = async () => {
const { items, imgWidth, imgHeight } = shop; const { items, imgWidth, imgHeight } = shop;
const wall = new Wall({ const wall = new Wall({
items, items,
@ -93,7 +104,7 @@ const App = () => {
useEffect(() => { useEffect(() => {
if (seconds) { if (seconds) {
if (posenetModel && video && !item)
if (posenetModel && video && !item && !showMenu)
posenetModel posenetModel
.estimatePoses(video, { .estimatePoses(video, {
flipHorizontal: true, flipHorizontal: true,
@ -119,7 +130,7 @@ const App = () => {
if (wall && sphere) { if (wall && sphere) {
wall.attachSphere(sphere); wall.attachSphere(sphere);
} }
}, [wall]);
}, [wall, sphere]);
useEffect(() => { useEffect(() => {
if (!sphere) { if (!sphere) {
@ -131,7 +142,10 @@ const App = () => {
width, width,
}); });
setSphere(sphere); setSphere(sphere);
initWall();
} else {
initWall().then((wall) => {
wall.attachSphere(sphere);
});
} }
}, [sphere]); }, [sphere]);
@ -153,11 +167,13 @@ const App = () => {
item = null; item = null;
setItem(item); setItem(item);
sphere.displacement = displacement; sphere.displacement = displacement;
if (showMenu) setShowMenu(false);
setCurrentTab(null);
}; };
const startTiming = () => { const startTiming = () => {
if (resetTimer) clearInterval(resetTimer); if (resetTimer) clearInterval(resetTimer);
setResetTimer(setInterval(unFocus, 60 * 10 * 1000));
setResetTimer(setInterval(unFocus, 60 * 1000));
}; };
// useEffect(() => { // useEffect(() => {
// if (minutes > 0) { // if (minutes > 0) {
@ -196,12 +212,29 @@ const App = () => {
</div> </div>
</div> </div>
<video id="video"></video> <video id="video"></video>
{list.map(([key, el, i]) => (
{list.map(([key, el]) => (
<div <div
className="block-wrapper" className="block-wrapper"
key={`${key}_${i}`}
key={key}
style={{ ...el.style, backgroundImage: "none" }} style={{ ...el.style, backgroundImage: "none" }}
> >
<div
className={
"wrapper" +
(Number(key) % 60 === 0
? " AchievementIconWrapper LegendaryAchievement"
: "")
}
>
{Number(key) % 60 === 0 && (
<div className="AchievementIconGlowContainerRoot">
<div className="AchievementIconGlowContainer">
<div className="AchievementIconGlow"></div>
</div>
</div>
)}
{Number(key) % 60 === 0 && <div className="fakeIcon"></div>}
</div>
<div <div
className="block" className="block"
style={{ backgroundImage: el.style.backgroundImage }} style={{ backgroundImage: el.style.backgroundImage }}
@ -230,9 +263,78 @@ const App = () => {
className={"mist" + (itemData ? "" : " inactive")} className={"mist" + (itemData ? "" : " inactive")}
style={sphere.style} style={sphere.style}
> >
<div className={"ball" + (!itemData ? " small" : "")}></div>
{!showMenu && (
<div className={"ball" + (!itemData ? " small" : "")}></div>
)}
{itemData && <Shop data={itemData} unFocus={unFocus}></Shop>} {itemData && <Shop data={itemData} unFocus={unFocus}></Shop>}
{!itemData && <img className="touch-icon" src={touchIcon}></img>}
{!itemData && !showMenu && (
<img className="touch-icon" src={touchIcon}></img>
)}
</div>
)}
{(itemData || showMenu) && (
<div className={"sideBar" + (itemData ? " open" : " close")}>
<div
className="click-area"
onClick={() => {
if (itemData) {
setShowMenu(true);
setItem(null);
} else {
unFocus();
}
}}
></div>
</div>
)}
{showMenu && (
<div className="menu row">
<div className="side">
<div className="cats col">
{[
{ icon: images["all"], title: "全部商品", name: null },
...categories.map((cat) => ({
icon: categoryIconMap[cat],
title: cat + "品类",
name: cat,
})),
].map((tab) => (
<div
key={tab.name}
className={
"cat row" + (currentTab === tab.name ? " active" : "")
}
onClick={() => setCurrentTab(tab.name)}
>
<img src={tab.icon}></img>
<div> {tab.title}</div>
</div>
))}
</div>
</div>
<div className="main">
{categories
.filter((cat) =>
currentTab === null ? true : cat === currentTab
)
.map((name) => {
const products = categoryProductsMap[name];
const icon = categoryIcon1Map[name];
return (
<div className="cat">
<div className="cat-name">{name}</div>
{products.map((name) => (
<Product
url={images[name]}
icon={icon}
name={name}
meta={"abcd"}
></Product>
))}
</div>
);
})}
</div>
</div> </div>
)} )}
</div> </div>

122
src/App.scss

@ -12,6 +12,124 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow: hidden; overflow: hidden;
.menu {
position: absolute;
width: 100%;
height: 100%;
z-index: 99;
.side {
flex: 0 0 290px;
padding: 450px 40px 0 35px;
.cats {
width: 216px;
background: rgba(0, 0, 0, 0.8);
border-radius: 10px;
padding: 12px;
.cat {
height: 70px;
line-height: 70px;
vertical-align: middle;
font-size: 18px;
font-family: SourceHanSansCN, SourceHanSansCN-Bold;
font-weight: 700;
color: #fff;
&.active {
background: #797ae0;
border-radius: 6px;
}
img {
width: 20px;
height: 20px;
margin: auto 37px auto 25px;
}
}
}
}
.main {
flex: 0 0 709px;
height: 100vh;
overflow-y: scroll;
padding-top: 400px;
text-align: left;
.cat {
.cat-name {
margin-bottom: 12px;
font-size: 36px;
font-family: FZLTCHK;
text-align: left;
color: #fff;
line-height: 41px;
text-shadow: #3e3a39 0 0 10px;
}
.prod {
margin-right: 16px;
margin-bottom: 24px;
}
}
.cat + .cat {
margin-top: 56px;
}
&::-webkit-scrollbar {
display: none;
}
}
&::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 700px;
z-index: -1;
background: linear-gradient(180deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
}
&::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 700px;
z-index: -1;
background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.7));
}
}
.sideBar {
@keyframes sideBarEnter {
from {
right: -60px;
}
to {
right: 0;
}
}
animation: 0.25s sideBarEnter ease-in;
position: absolute;
right: 0;
top: 0;
width: 80px;
height: 100vh;
z-index: 100;
background-size: cover;
background-position: center;
&.open {
background-image: url(./open.png);
}
&.close {
background-image: url(./close.png);
}
.click-area {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: auto;
width: 60px;
height: 60px;
}
}
.header { .header {
position: absolute; position: absolute;
top: 44px; top: 44px;
@ -67,10 +185,8 @@
} }
.block-wrapper { .block-wrapper {
position: absolute; position: absolute;
// border: 1px solid rgb(224, 224, 224);
opacity: 1; opacity: 1;
&::before {
content: "";
.wrapper {
position: absolute; position: absolute;
top: -5px; top: -5px;
left: -5px; left: -5px;

BIN
src/close.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

14
src/components/product.jsx

@ -0,0 +1,14 @@
import React from "react";
import "./product.scss";
const Product = ({ url, name, meta, icon }) => (
<div className="prod col">
<img src={url} className="avatar" />
<div className="row name">{name}</div>
<div className="row sub">
<div className="meta">{meta}</div>
<div className="fill"></div>
<img className="icon" src={icon}></img>
</div>
</div>
);
export default Product;

34
src/components/product.scss

@ -0,0 +1,34 @@
.prod {
display: inline-block;
width: 200px;
height: 259px;
background: #ffffff;
border-radius: 6px;
padding: 10px;
.avatar {
width: 180px;
height: 180px;
}
.name {
font-size: 18px;
font-family: FZLTHK;
text-align: left;
color: #3e3a39;
line-height: 21px;
margin-top: 19px;
}
.sub {
font-size: 24px;
font-family: ChaletComprime, ChaletComprime-CologneSixty;
font-weight: CologneSixty;
text-align: left;
color: #7f7673;
line-height: 24px;
vertical-align: middle;
}
.icon {
margin: auto;
width: 20px;
height: 20px;
}
}

10
src/components/shop.scss

@ -5,16 +5,6 @@
box-sizing: border-box; box-sizing: border-box;
padding: 50px; padding: 50px;
padding-top: 203px; padding-top: 203px;
.row {
display: flex;
}
.col {
display: flex;
flex-direction: column;
}
.fill {
flex: 1;
}
@keyframes fadeIn { @keyframes fadeIn {
from { from {
opacity: 0; opacity: 0;

18
src/data/Shops.js

@ -12,6 +12,24 @@ const shops = [
母婴: coupon["c3"], 母婴: coupon["c3"],
生鲜: coupon["c4"], 生鲜: coupon["c4"],
}, },
categoryIconMap: {
零食: coupon["snack"],
饮料: coupon["drink"],
母婴: coupon["nurse"],
生鲜: coupon["fresh"],
},
categoryIcon1Map: {
零食: coupon["snack1"],
饮料: coupon["drink1"],
母婴: coupon["nurse1"],
生鲜: coupon["fresh1"],
},
categoryProductsMap: {
零食: ["零食1", "零食2", "零食3", "零食4", "零食5", "零食6"],
饮料: ["饮料1", "饮料2", "饮料3", "饮料4", "饮料5", "饮料6"],
母婴: ["母婴1", "母婴2", "母婴3", "母婴4", "母婴5", "母婴6"],
生鲜: ["生鲜1", "生鲜2", "生鲜3", "生鲜4", "生鲜5", "生鲜6"],
},
items: [ items: [
{ {
id: 1, id: 1,

146
src/glow.scss

File diff suppressed because one or more lines are too long

BIN
src/images/coupon/all.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

BIN
src/images/coupon/all1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

BIN
src/images/coupon/drink.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

BIN
src/images/coupon/drink1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

BIN
src/images/coupon/fresh.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

BIN
src/images/coupon/fresh1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

BIN
src/images/coupon/nurse.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

BIN
src/images/coupon/nurse1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

BIN
src/images/coupon/snack.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

BIN
src/images/coupon/snack1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
src/images/coupon/母婴1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
src/images/coupon/母婴2.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
src/images/coupon/母婴3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
src/images/coupon/母婴4.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
src/images/coupon/母婴5.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
src/images/coupon/母婴6.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
src/images/coupon/生鲜1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
src/images/coupon/生鲜2.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
src/images/coupon/生鲜3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
src/images/coupon/生鲜4.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
src/images/coupon/生鲜5.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
src/images/coupon/生鲜6.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
src/images/coupon/零食1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
src/images/coupon/零食2.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
src/images/coupon/零食3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
src/images/coupon/零食4.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
src/images/coupon/零食5.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
src/images/coupon/零食6.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
src/images/coupon/饮料1.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
src/images/coupon/饮料2.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
src/images/coupon/饮料3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
src/images/coupon/饮料4.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
src/images/coupon/饮料5.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
src/images/coupon/饮料6.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

10
src/index.css

@ -15,3 +15,13 @@ code {
font-family: "ChaletComprime"; font-family: "ChaletComprime";
src: url("./Chalet\ Comprime\ Cologne\ Sixty.ttf") format("truetype"); src: url("./Chalet\ Comprime\ Cologne\ Sixty.ttf") format("truetype");
} }
.row {
display: flex;
}
.col {
display: flex;
flex-direction: column;
}
.fill {
flex: 1;
}

6
src/models/Wall.js

@ -4,7 +4,7 @@ import Stats from "stats.js";
const stats = new Stats(); const stats = new Stats();
stats.showPanel(0); stats.showPanel(0);
document.body.appendChild(stats.dom);
// document.body.appendChild(stats.dom);
export const easeIn = BezierEasing(0.5, 0.16, 0.74, 0.38); export const easeIn = BezierEasing(0.5, 0.16, 0.74, 0.38);
export const easeOut = BezierEasing(0, 0, 0.58, 1); export const easeOut = BezierEasing(0, 0, 0.58, 1);
@ -50,7 +50,6 @@ class El {
} }
update() {} update() {}
} }
class Row { class Row {
q = []; q = [];
est; est;
@ -183,7 +182,8 @@ export default class Wall {
} }
getNext() { getNext() {
const { items } = this; const { items } = this;
const next = items[this.index];
const index = Math.floor(Math.random() * items.length);
const next = items[index];
this.index++; this.index++;
if (this.index === items.length) this.index = 0; if (this.index === items.length) this.index = 0;
return next; return next;

BIN
src/open.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Loading…
Cancel
Save