Browse Source

table static page

master
tangmingyou 4 years ago
parent
commit
db2ad36c9f
  1. 3
      config/dev.js
  2. 1
      package.json
  3. 1
      src/assets/icon/add-2.svg
  4. 1
      src/assets/icon/coin-1.svg
  5. 1
      src/assets/icon/suit-0.svg
  6. 1
      src/assets/icon/suit-1.svg
  7. 1
      src/assets/icon/suit-2.svg
  8. 1
      src/assets/icon/suit-3.svg
  9. 25
      src/components/card.jsx
  10. 24
      src/components/style/card.scss
  11. 2
      src/components/title.jsx
  12. 9
      src/pages/new_table/new_table.jsx
  13. 37
      src/pages/new_table/new_table.scss
  14. 55
      src/pages/table/table.jsx
  15. 111
      src/pages/table/table.scss
  16. 2
      yarn.lock

3
config/dev.js

@ -9,7 +9,8 @@ module.exports = {
mini: {},
h5: {
devServer: {
host: '0.0.0.0',
// host: '0.0.0.0',
host: '192.168.3.102',
port: 10086,
// 设置代理来解决 H5 请求的跨域问题
proxy: {

1
package.json

@ -47,6 +47,7 @@
"@tarojs/shared": "3.5.11",
"@tarojs/taro": "3.5.11",
"@tarojs/taro-h5": "3.5.11",
"classnames": "^2.3.2",
"promise.prototype.finally": "^3.1.4",
"protobufjs": "^7.1.2",
"react": "^18.0.0",

1
src/assets/icon/add-2.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="85" height="85" viewBox="0 0 85 85"><defs><clipPath id="master_svg0_84_10290"><rect x="0" y="0" width="85" height="85" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_84_10290)"><g><path d="M38.958251953125,38.958343505859375L38.958251953125,17.708343505859375L46.041551953125,17.708343505859375L46.041551953125,38.958343505859375L67.29155195312501,38.958343505859375L67.29155195312501,46.041643505859376L46.041551953125,46.041643505859376L46.041551953125,67.29164350585938L38.958251953125,67.29164350585938L38.958251953125,46.041643505859376L17.708251953125,46.041643505859376L17.708251953125,38.958343505859375L38.958251953125,38.958343505859375Z" fill="#FFFFFF" fill-opacity="1"/></g></g></svg>

After

Width:  |  Height:  |  Size: 822 B

1
src/assets/icon/coin-1.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="29" height="28" viewBox="0 0 29 28"><g><path d="M17.3953,0.00000133529C22.8622,-0.00251736,27.5887,3.68237,28.7391,8.84402C29.8896,14.0057,27.1517,19.2424,22.1679,21.4125C18.8269,28.5463,9.13201,30.2531,3.39956,24.7167C-2.33289,19.1804,-0.565631,9.81724,6.82081,6.59052C8.69752,2.57851,12.8347,0.00000166911,17.3953,0.00000133529ZM13.046,9.80107L10.1465,9.80107L10.1465,11.2012C8.18773,11.1966,6.57957,12.696,6.51529,14.5867C6.45101,16.4775,7.95388,18.0755,9.90878,18.195L10.1465,18.202L13.046,18.202L13.1765,18.2132C13.5214,18.2735,13.7722,18.5635,13.7722,18.9021C13.7722,19.2406,13.5214,19.5306,13.1765,19.5909L13.046,19.6021L7.24704,19.6021L7.24704,22.4025L10.1465,22.4025L10.1465,23.8026L13.046,23.8026L13.046,22.4025C15.0049,22.4071,16.613,20.9077,16.6773,19.0169C16.7416,17.1262,15.2387,15.5282,13.2838,15.4087L13.046,15.4017L10.1465,15.4017L10.0161,15.3905C9.67115,15.3302,9.42033,15.0401,9.42033,14.7016C9.42033,14.3631,9.67115,14.073,10.0161,14.0127L10.1465,14.0015L15.9455,14.0015L15.9455,11.2012L13.046,11.2012L13.046,9.80107ZM17.3953,2.80031C14.9105,2.7975,12.5437,3.82368,10.8946,5.61882C17.8442,5.21137,23.5967,10.7678,23.174,17.4795C25.8727,15.1622,26.8083,11.4756,25.525,8.21571C24.2411,4.95543,21.0058,2.80031,17.3953,2.80031Z" fill="#FFFFFF" fill-opacity="1"/></g></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

1
src/assets/icon/suit-0.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="20" height="26" viewBox="0 0 20 26"><g style="mix-blend-mode:passthrough"><path d="M19.99,12.9935L10,0L0.00995067,12.9935L0,12.9935L0.00497534,13L0,13.0065L0.00995067,13.0065L10,26L19.99,13.0065L20,13.0065L19.995,13L20,12.9935L19.99,12.9935Z" fill-rule="evenodd" fill="#FF4400" fill-opacity="1"/></g></svg>

After

Width:  |  Height:  |  Size: 422 B

1
src/assets/icon/suit-1.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="23" height="21.999996185302734" viewBox="0 0 23 21.999996185302734"><g style="mix-blend-mode:passthrough"><path d="M17.9663,7.16607C17.9886,6.94708,18,6.72487,18,6.5C18,2.91015,15.0899,0,11.5,0C7.91015,0,5,2.91015,5,6.5C5,6.72487,5.01142,6.94708,5.03371,7.16606C2.15004,7.83093,0,10.4144,0,13.5C0,17.0899,2.91015,20,6.5,20C8.44371,20,10.1882,19.1468,11.3793,17.7946C11.0187,19.3726,9.942,20.7859,8,22L14.5,22C13.2575,21.4805,12.3237,20.1311,11.7173,17.9018C12.9051,19.1918,14.6082,20,16.5,20C20.0899,20,23,17.0899,23,13.5C23,10.4144,20.85,7.83093,17.9663,7.16607Z" fill-rule="evenodd" fill="#000000" fill-opacity="1"/></g></svg>

After

Width:  |  Height:  |  Size: 744 B

1
src/assets/icon/suit-2.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="20" height="18.5" viewBox="0 0 20 18.5"><g><path d="M14.5,0C17.538,0,20,2.5,20,6C20,13,12.5,17,10,18.5C7.5,17,0,13,0,6C0,2.5,2.5,0,5.5,0C7.36,0,9,1,10,2C11,1,12.64,0,14.5,0Z" fill="#FF4A0E" fill-opacity="1"/></g></svg>

After

Width:  |  Height:  |  Size: 334 B

1
src/assets/icon/suit-3.svg

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="17.999998092651367" height="21.999996185302734" viewBox="0 0 17.999998092651367 21.999996185302734"><g style="mix-blend-mode:passthrough"><path d="M8.92206,17.089C6.92386,19.0627,3.89262,18.9684,1.99374,16.7891C0.07107000000000002,14.5806,0.0047719999999999985,11.0634,1.79314,8.7692L9.001,0.5L16.2072,8.7692C17.9955,11.0634,17.9284,14.5865,16.0066,16.7891C14.1305,18.9374,11.1584,19.0626,9.15481,17.1645C9.75876,19.5356,10.714,20.9623,12,21.5L5.5,21.5C7.52596,20.2334,8.61017,18.75,8.92206,17.089Z" fill-rule="evenodd" fill="#000000" fill-opacity="1"/><path d="M9.49846,16.5392Q9.2461,19.7477,5.76506,21.924L5.5,21.5L5.5,21L12,21L12,21.5L11.8071,21.9613Q9.43948,20.9714,8.51093,16.604L9,16.5L9.49846,16.5392ZM8.50154,16.4608L8.77194,13.023L9.48907,16.396Q10.30865,20.2509,12.1929,21.0387L14.492,22L3.75705,22L5.23494,21.076Q8.288689999999999,19.1669,8.50154,16.4608ZM16.383200000000002,17.118Q14.7993,18.9317,12.5466,18.9979Q10.30015,19.0638,8.64108,17.36L8.9993,17.0111L9.3578,17.3597Q7.70229,19.0625,5.45474,18.9979Q3.1986,18.933,1.61677,17.1176Q0.059917,15.3293,0.001933000000000018,12.8229Q-0.055786,10.3278,1.398793,8.4618L1.407219,8.451L9.00104,-0.261L16.5931,8.45101L16.6015,8.4618Q18.056,10.32766,17.9981,12.8251Q17.9399,15.3338,16.3833,17.1178L16.383200000000002,17.118ZM15.6298,16.4604Q16.9485,14.949,16.9983,12.8019Q17.048,10.6611,15.8128,9.0766L16.2072,8.7692L15.8302,9.09769L8.62405,0.8284929999999999L9.001,0.5L9.37791,0.8285370000000001L2.17005,9.09774L1.79314,8.7692L2.18748,9.0766Q0.952196,10.6613,1.001666,12.7997Q1.051296,14.9451,2.37071,16.4606Q3.66495,17.946,5.48348,17.9983Q7.29168,18.0503,8.64081,16.6626L8.99903,16.2941L9.35753,16.6623Q10.7101,18.0513,12.5173,17.9983Q14.3334,17.945,15.63,16.4602L15.6298,16.4604Z" fill="#000000" fill-opacity="1"/></g></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

25
src/components/card.jsx

@ -0,0 +1,25 @@
import React from 'react'
import { View, Text, Image } from '@tarojs/components'
import Taro from '@tarojs/taro'
import './style/card.scss'
import suit0Icon from '@/assets/icon/suit-0.svg'
import suit1Icon from '@/assets/icon/suit-1.svg'
import suit2Icon from '@/assets/icon/suit-2.svg'
import suit3Icon from '@/assets/icon/suit-3.svg'
const suits = [suit0Icon, suit1Icon, suit2Icon, suit3Icon];
const dots = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"];
function Card(props) {
const {w, h, dot, suit} = props;
return (
<View className="card" style={{width: Taro.pxTransform(w || 42), height: h || 58}}>
<View className="dot"><Text style={{color: suit%2===0?'#FF4A0E':'#000'}}>{dots[dot || 0]}</Text></View>
<View className="suit-wrap"><Image className="suit" src={suits[suit || 0]} /></View>
</View>
)
}
export default Card

24
src/components/style/card.scss

@ -0,0 +1,24 @@
.card {
border-radius: 5px;
border: 1px solid #000;
position: relative;
display: flex;
justify-content: center;
align-items: center;
background-color: #fff;
.dot {
position: absolute;
font-size: 14px;
left: 6px;
top: 2px;
font-weight: bold;
}
.suit-wrap {
margin-top: 5px;
}
.suit {
height: 18px;
width: auto;
}
}

2
src/components/title.jsx

@ -1,7 +1,5 @@
import React from 'react'
import { View, Text, Image } from '@tarojs/components'
// import { AtIcon } from 'taro-ui'
import { Icon } from '@nutui/nutui-react-taro';
import { navigateBack } from '@/utils/application'
import left from '@/assets/icon/left-1.svg'
import './style/title.scss'

9
src/pages/new_table/new_table.jsx

@ -6,6 +6,7 @@ import './new_table.scss'
import Title from '@/components/title'
import userIcon from '@/assets/icon/user-2.svg'
import closeIcon from '@/assets/icon/close-1.svg'
import addIcon from '@/assets/icon/add-2.svg'
function NewTable() {
const {username, nickname, avatar} = useSelector(state => state.user);
@ -29,7 +30,9 @@ function NewTable() {
<View key={i} className="playerRow">
{
row.map((player, j) => (
<View key={j} className="player-wrap">
player.index === 5
? <View key={j} className='player empty-player'><Image className="empty-icon" src={addIcon} /></View>
: <View key={j} className="player-wrap">
<View className="player-icon"><Image className="player-icon-img" src={userIcon} /></View>
<View className="close-icon"><Image className="close-icon-img" src={closeIcon} /></View>
<View className="player">
@ -48,8 +51,8 @@ function NewTable() {
<View className="nickname"><Text>{nickname}</Text></View>
</View>
</View>
<View>
<Button>CREATE</Button>
<View className='submit-btn-wrap'>
<Button className='submit-btn'>CREATE</Button>
</View>
</View>
</View>

37
src/pages/new_table/new_table.scss

@ -16,10 +16,18 @@
}
.player {
width: 159px;
height: 101px;
height: 114px;
background-color: #EE914E;
text-align: center;
line-height: 101px;
line-height: 114px;
}
.empty-player {
background-color: #D8D8D8;
}
.empty-icon {
width: 85px;
height: 85px;
margin: 14.5px 0;
}
.player-icon {
height: 50px;
@ -57,6 +65,7 @@
width: 405px;
height: 83px;
background-color: #EE914E;
display: flex;
}
.avatar-wrap {
@ -67,4 +76,28 @@
width: 66px;
height: 66px;
}
.nickname {
font-size: 12px;
color: #fff;
// line-height: 40px;
// text-decoration: underline;
border-bottom: 1px solid #fff;
height: 26px;
margin-left: 13px;
margin-top: 10px;
}
.submit-btn-wrap {
}
.submit-btn {
width: 360px;
height: 42px;
background-color: #EE914E;
border-radius: 16px;
font-size: 16px;
line-height: 42px;
color: #fff;
font-weight: bold;
margin-top: 29px;
}
}

55
src/pages/table/table.jsx

@ -1,15 +1,58 @@
import React, { Component, useState } from 'react'
import {View, Text} from '@tarojs/components'
import { View, Text, Image } from '@tarojs/components'
import { useSelector } from 'react-redux'
import cnames from 'classnames'
import './table.scss'
import Title from '@/components/title'
import Card from '@/components/card'
import coinIcon from '@/assets/icon/coin-1.svg'
function Table() {
return (
<View>
<Text>Table!!</Text>
</View>
)
const {username, nickname, avatar} = useSelector(state => state.user);
const players = [1, 2, 3, 4, 5, 6];
const playerRows = players.reduce((arr, item, idx) => {
const row = parseInt(idx / 2);
let rowArr = arr[row] || [];
rowArr[idx % 2] = { index: idx, item };
arr[row] = rowArr;
parseInt()
return arr;
}, []);
return (
<View className="tab">
<Title title="GAME" />
{
playerRows.map((row, i) => (
<View key={i} className="playerRow">
{
row.map((player, j) => (
<View key={j} className="player-wrap">
<View className={cnames("player-no",{"player-no-running": player.index===1})}><Text>#{player.index}</Text></View>
<View className="card1"><Card w={42} h={48} dot={12} suit={2} /></View>
<View className="card2"><Card w={42} h={48} dot={12} suit={3} /></View>
<View className="player">
<View className="avatar-wrap"><Image className="avatar" src={avatar} /></View>
<View className="player-name"><Text>Player{player.item}</Text></View>
</View>
<View className="wallet-wrap">
<View className="wallet">
<View className="wallet-icon"><Image className="wallet-icon-img" src={coinIcon} /></View>
<View className="wallet-amount"><Text>3,000,000</Text></View>
</View>
<View className="pct"><Text>25%</Text></View>
</View>
</View>
))
}
</View>
))
}
</View>
)
}
export default Table

111
src/pages/table/table.scss

@ -0,0 +1,111 @@
.tab {
.playerRow {
display: flex;
justify-content: space-between;
// align-content: space-around;
flex-flow: row wrap;
// width: 405px;
margin: 46px 26px 0 26px;
}
.player-wrap {
// flex: 0 0 50%;
position: relative;
}
.player-no {
position: absolute;
top: -25px;
color: #fff;
font-size: 14px;
height: 23px;
width: 23px;
line-height: 23px;
background-color: #807878;
border-radius: 50%;
text-align: center;
}
.player-no-running {
font-weight: bold;
color: #fff;
background-color: #EE914E;
}
.card1, .card2 {
position: absolute;
z-index: 999;
top: -27px;
}
.card1 {
left: 60px;
}
.card2 {
left: 104px;
}
.player {
width: 153px;
height: 69px;
background-color: #EE914E;
// text-align: center;
// line-height: 114px;
display: flex;
// padding: 10px 4px;
border: 1px solid #000;
border-radius: 5px;
}
.avatar-wrap {
margin: 10px 0 10px 4px;
}
.avatar {
border-radius: 5px;
height: 50px;
width: 50px;
}
.player-name {
font-size: 12px;
line-height: 20px;
height: 22px;
color: #fff;
font-weight: bold;
width: 82px;
border-bottom: 1px solid #fff;
margin-top: 36px;
margin-left: 8px;
}
.wallet-wrap {
display: flex;
margin-top: 3px;
}
.wallet {
display: flex;
background-color: #EE914E;
width: 100px;
height: 18px;
border-radius: 5px;
justify-content: space-between;
box-sizing: border-box;
padding: 0 4px;
}
.wallet-icon {
//margin: 2px 0 2px 4px;
line-height: 22px;
}
.wallet-icon-img {
width: 14px;
height: 14px;
}
.wallet-amount {
font-size: 12px;
color: #fff;
line-height: 18px;
}
.pct {
background-color: #807878;
font-size: 12px;
line-height: 18px;
width: 50px;
border-radius: 5px;
text-align: center;
color: #fff;
margin-left: 5px;
}
}

2
yarn.lock

@ -3825,7 +3825,7 @@ class-utils@^0.3.5:
isobject "^3.0.0"
static-extend "^0.1.1"
classnames@^2.2.5, classnames@^2.3.1:
classnames@^2.2.5, classnames@^2.3.1, classnames@^2.3.2:
version "2.3.2"
resolved "https://registry.npmmirror.com/classnames/-/classnames-2.3.2.tgz#351d813bf0137fcc6a76a16b88208d2560a0d924"
integrity sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==

Loading…
Cancel
Save