@@ -630,6 +637,32 @@ class Index extends Component {
)}
}
+
+ {/* 确权 仅在新建项目时 */}
+ {open_blockchain && projectsType === "deposit" &&
+
确权
+
{this.setState({tokenConTri:e.target.checked})}}>加入贡献值激励确权机制
+
+ {getFieldDecorator('blockchain_init', {
+ rules: [{
+ required: tokenConTri, message: '初始token值为一个不超过10000的正整数'
+ },
+ { validator: (rule,val,callback) =>{
+ if(val>10000){
+ callback('初始token值最大值10000');
+ }else{
+ callback();
+ }
+ }}],
+ })(
+
+ )}
+
+
}
+
注: 为必填项,否则为选填
diff --git a/src/forge/users/Index.jsx b/src/forge/users/Index.jsx
index d4d0ff6c..8ed8b1e4 100644
--- a/src/forge/users/Index.jsx
+++ b/src/forge/users/Index.jsx
@@ -24,7 +24,7 @@ export default withRouter(
secondRouter = props.location.pathname.split('/')[2];
}
- let userRouterArr = ['statistics', 'projects', 'notice', 'devops', 'organizes', 'info', 'following', 'followers', 'password' , "general"];
+ let userRouterArr = ['statistics', 'projects', 'notice', 'devops', 'organizes', 'info', 'following', 'followers', 'password' , "general", "blockchain"];
return (
diff --git a/src/forge/users/Index.scss b/src/forge/users/Index.scss
index 242ef640..bfd6518a 100644
--- a/src/forge/users/Index.scss
+++ b/src/forge/users/Index.scss
@@ -278,7 +278,7 @@ ul.ant-menu.menuStyle{
.infosRightMenu{
.ant-menu-item{
padding:0px;
- margin:0px 30px 0px 0px !important;
+ margin:0px 17px 0px 0px !important;
font-size: 17px;
height: 32px;
line-height: 0px;
diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js
index f44c9fa4..803c9745 100644
--- a/src/forge/users/Infos.js
+++ b/src/forge/users/Infos.js
@@ -63,6 +63,11 @@ const Personal = Loadable({
loading: Loading,
})
+// 贡献确权
+const Contribution = Loadable({
+ loader: () => import('./contribution/index'),
+ loading: Loading,
+})
class Infos extends Component {
constructor(props) {
@@ -108,6 +113,8 @@ class Infos extends Component {
this.setState({menuKey:undefined,route_type:"following"});
}else if(pathname === `/${username}/followers`){
this.setState({menuKey:undefined,route_type:"followers"});
+ }else if(pathname === `/${username}/blockchain`){
+ this.setState({menuKey:'7',route_type:undefined});
}else{
this.setState({menuKey:"6",route_type:undefined});
}
@@ -394,6 +401,10 @@ class Infos extends Component {
{ user && user.user_org_count && user.user_org_count > 0 ? ({user.user_org_count}):""}
+ {/* 当前用户+配置了贡献确权 */}
+ {current_user && user && user.login === current_user.login && current_user.open_blockchain &&
+ 贡献确权
+ }
}
{user && (
@@ -440,6 +451,12 @@ class Infos extends Component {
return ;
}}
>
+ {
+ return ;
+ }}
+ >
{/* {
diff --git a/src/forge/users/contribution/index.jsx b/src/forge/users/contribution/index.jsx
new file mode 100644
index 00000000..3fd80e11
--- /dev/null
+++ b/src/forge/users/contribution/index.jsx
@@ -0,0 +1,147 @@
+
+import React , { useEffect , useState } from 'react';
+import { Button, Dropdown, Input, Menu , message, Pagination } from 'antd';
+import Search from '../../Component/Search';
+import Item from '../Team-item';
+import Nodata from '../../Nodata';
+import axios from 'axios';
+import CheckProfile from '../../Component/ProfileModal/Profile';
+import './index.scss';
+import SearchUser from '../../Component/SearchUser';
+import { FlexAJ } from '../../Component/layout';
+
+// 个人中心-贡献确权
+function Contribution(props){
+ // 接口暂不支持分页
+ const limit = 15;
+ const [page, setPage] = useState(1);
+ const [total, setTotal] = useState(undefined);
+ // 转账列表
+ const [reload, setReload] = useState(undefined);
+ const [list, setList] = useState(undefined);
+ // 选项 1 转账 0 记录
+ const [ type, setType] = useState(1);
+ // 目标转账用户id/login
+ const [userLogin, setUserLogin] = useState({});
+ const [error1, setError1] = useState(undefined);
+ // 转账数值
+ const [tokenCount, setTokenCount] = useState({});
+ const [error2, setError2] = useState(undefined);
+ // 操作仓库id
+ const [proId, setProId] = useState(undefined);
+ const { checkIfLogin , showLoginDialog , current_user:{user_id, login}, current_user } = props;
+ console.log('current_user', current_user);
+ const {user} = props;
+
+ useEffect(()=>{
+ // token转账列表
+ axios.get(`/users/blockchain/balance.json`,{params: {user_id}}).then(res=>{
+ if(res && res.data){
+ setList(res.data.projects);
+ setTotal(res.data.total_count);
+ }
+ })
+ }, [reload])
+
+ useEffect(()=>{
+ if(user){
+ // 更改网页标题
+ const {username, login} = user;
+ document.title = `贡献确权-${username}/${login}`;
+ }
+ },[user])
+
+ // 目标转账用户
+ function getUser(id, login){
+ const userLoginObject = Object.assign(userLogin);
+ userLoginObject[id] = login;
+ setUserLogin(userLoginObject);
+ }
+
+ // token转账值
+ function setToken(id, token){
+ const tokenCountObject = Object.assign(tokenCount);
+ tokenCountObject[id] = token;
+ setTokenCount(tokenCountObject);
+ }
+
+ // 确认转账
+ function confirmTransfer(id, identifier, max){
+ setError1(undefined);
+ setError2(undefined);
+ setProId(id);
+ const userLoginById = userLogin[id];
+ const tokenCountById = tokenCount[id];
+ if(!userLoginById || !tokenCountById){
+ !userLoginById && setError1('请确定目标转账用户');
+ if(!tokenCountById){
+ setError2('请输入token数额');
+ }
+ }else if(!/^[1-9]+[0-9]*]*$/.test(tokenCountById) || tokenCountById>max){
+ setError2('转账token数额必须为不超过token总数的正整数');
+ }else{
+ console.log('userLogin', userLoginById, 'tokenCount', tokenCountById);
+ axios.post(`/users/blockchain/transfer`, {
+ owner_login: login,
+ project_identifier: identifier,
+ user_id,
+ transfer_amount: tokenCountById,
+ transfer_login: userLoginById,
+ payer_id: user_id,
+ project_id: id
+ }).then(res=>{
+ console.log('res', res);
+ if(res && res.data && res.data.status === 2){
+ setReload(Math.random());
+ message.success('转账成功');
+ }
+ })
+ }
+ }
+
+ return(
+ {/* 转账/记录切换 */}
+ {/*
*/}
+ {/* token转账 */}
+ {type ?
+ {list && list.length > 0 &&
+
项目名称
+
token总量
+
目标转账用户
+
转账token数额
+
操作
+
}
+ {list && !list.length &&
}
+ {list && list.map(item=>{return
+
{item.name}
+
{item.balance}
+
+
{getUser(item.id, login)}} width={"100%"} placeholder="搜索转账目标用户"/>
+ {proId === item.id && error1 && {error1}
}
+
+
+
{setToken(item.id, e.target.value)}} placeholder='请输入token数额'/>
+ {proId === item.id && error2 &&
{error2}
}
+
+
+
})}
+
:
+
+ 蒋宇航在GilLink/确实开源给你转账了1000个tiken
+ 6小时前
+
+
+ 蒋宇航在GilLink/确实开源给你转账了1000个tiken
+ 6小时前
+
+
}
+ {/* {total > limit &&
} */}
+
+ )
+}
+export default Contribution;
\ No newline at end of file
diff --git a/src/forge/users/contribution/index.scss b/src/forge/users/contribution/index.scss
new file mode 100644
index 00000000..ba3ee58a
--- /dev/null
+++ b/src/forge/users/contribution/index.scss
@@ -0,0 +1,79 @@
+.contHead{
+ &>.itemCont{
+ display: inline-block;
+ width:83px;
+ height:32px;
+ background-color:rgba(250, 251, 252, 0);
+ border:1px solid #d0d0d0;
+ border-radius:0px 4px 4px 0px;
+ text-align: center;
+ color: #333;
+ &:first-of-type{
+ border-radius:4px 0px 0px 4px;
+ border-right: none;
+ }
+ &:last-of-type{
+ border-left: none;
+ }
+ &.active{
+ border-color: $primary-color;
+ background-color: $primary-color;
+ color: white;
+ }
+ }
+}
+.contribution{
+ .flexCenterCont{
+ display: flex;
+ justify-content: space-between;
+ }
+ .contributionTable{
+ background-color:rgba(250, 252, 255, 0.89);
+ border-radius:4px 4px 0px 0px;
+ padding: 20px 20px 40px 20px;
+ }
+ .tableHeadTri{
+ color:#898d9d;
+ }
+ .transferAccount{
+ color:#40424a;
+ padding: 15px 0;
+ border-bottom: 1px solid #eee;
+ }
+ .tableColumn3, .tableColumn4{
+ width: 200px;
+ }
+ .tableColumn1{
+ width: 130px;
+ }
+ .tableColumn5{
+ width: 120px;
+ text-align: center;
+ }
+ .tableColumn2{
+ flex: 0.5;
+ }
+ .confirmTransfer{
+ border-color: $primary-color;
+ color: $primary-color;
+ }
+ .errorTipTri{
+ width: 400px;
+ color: red;
+ }
+}
+.record.contributionTable{
+ padding: 0px 20px;
+ .contributionRecordItem{
+ padding: 15px 0;
+ }
+ .contributionRecordItem+.contributionRecordItem{
+ border-top: 1px solid #eee;
+ }
+ .themeSpan{
+ color: $primary-color;
+ }
+}
+.paginationTri{
+ text-align: center;
+}
\ No newline at end of file