Skip to content

Commit

Permalink
Merge branch 'v3'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/utils/config.js
  • Loading branch information
yuanjunliang committed Jun 8, 2018
2 parents 792e751 + f372018 commit ee1f045
Show file tree
Hide file tree
Showing 25 changed files with 433 additions and 155 deletions.
2 changes: 2 additions & 0 deletions README.md
@@ -1,5 +1,7 @@
# ![Bottos Logo](https://github.com/Bottos-project/wallet/blob/master/pic/logo.png)

[![License](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://opensource.org/licenses/GPL-3.0)

Bottos web wallet is an application to transfer Bottos tokens such as BTO . It provides an AI data market, which allows user exchange and store AI data assets.
## Block browsing

Expand Down
1 change: 0 additions & 1 deletion main.js
Expand Up @@ -59,7 +59,6 @@ function createWindow () {
protocol: 'file:',
slashes: true
}))
win.webContents.openDevTools()
}


Expand Down
6 changes: 3 additions & 3 deletions package.json
@@ -1,11 +1,11 @@
{
"name": "BottosWallet",
"version": "3.0.0-beta.1",
"publishDate": "2018-6-7",
"version": "3.0.0",
"publishDate": "2018-6-8",
"private": true,
"main": "main.js",
"homepage": ".",
"DEV": true,
"DEV": false,
"MOCK": false,
"description": "Bottos Wallet",
"author": {
Expand Down
2 changes: 0 additions & 2 deletions src/components/BTFavoriteStar.js
Expand Up @@ -27,8 +27,6 @@ import collectionState, { getTimeSecond } from "@/tools/sessionStorage";
// 下面是加签的 api
import { favoritePack } from '@/lib/msgpack/BTPackManager'

const { messageProtoEncode, queryProtoEncode } = require('@/lib/proto/index');

const lockTimeSecond = 10

export async function getFavReqParam(favoriteParam) {
Expand Down
7 changes: 4 additions & 3 deletions src/components/BTHeader.js
Expand Up @@ -32,7 +32,7 @@ import messages from "../locales/messages";
const HeaderMessages = messages.Header;
const MenuMessages = messages.Menu;

const pkg = require('../../package.json')
// const pkg = require('../../package.json')

class BTHeader extends PureComponent{
constructor(props){
Expand Down Expand Up @@ -110,11 +110,12 @@ class BTHeader extends PureComponent{

}

render(){
render() {
// console.log('btheader render');
const { account_info } = this.props
return(
<div className="container header">
<div style={{position: 'absolute', top: 0, right: 10}}>v: {pkg.version}</div>
{/* <div style={{position: 'absolute', top: 0, right: 10}}>v: {pkg.version}</div> */}

<div className="logoStyle">
<img src="./img/logo.svg" alt=""/>
Expand Down
13 changes: 9 additions & 4 deletions src/components/CustomTabBar/index.js
Expand Up @@ -33,10 +33,12 @@ function Tab(props) {
class CustomTabBar extends PureComponent {
constructor(props) {
super(props);
this.state = {
activeKey: props.activeKey || ''
};
let activeKey = props.activeKey != undefined ? props.activeKey : (
props.defaultActiveKey != undefined ? props.defaultActiveKey : ''
)
this.state = { activeKey }
}

handleChange = (activeKey) => {
this.setState({ activeKey });
var onChange = this.props.onChange;
Expand All @@ -45,8 +47,10 @@ class CustomTabBar extends PureComponent {
onChange(activeKey, value);
}
}

render() {
const { keyMap, activeKey, children, style } = this.props
let { keyMap, activeKey, children, style } = this.props
activeKey = activeKey != undefined ? activeKey : this.state.activeKey
var list = []
for (var key in keyMap) {
list.push(
Expand All @@ -69,6 +73,7 @@ CustomTabBar.defaultProps = {
CustomTabBar.propTypes = {
keyMap: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
activeKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
defaultActiveKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChange: PropTypes.func,
style: PropTypes.object
};
Expand Down
7 changes: 6 additions & 1 deletion src/components/LoginOrRegister/Register.js
Expand Up @@ -218,6 +218,8 @@ class Regist extends PureComponent{
this.props.setSpin(false)
return
}
console.log('response', response);
console.log('response.code', response.code);
if (response.code == 1) {

let postData = {
Expand Down Expand Up @@ -254,12 +256,15 @@ class Regist extends PureComponent{
message.warning(window.localeInfo["Header.VerificationCodeWrong"]);

}else if(response.code == 1004){
console.log('response.code', response.code);
this.props.setSpin(false)
console.log('details', JSON.parse(res.details));
this.requestVerificationCode()
message.error(window.localeInfo["Header.AccountHasAlreadyExisted"]);
}else{
this.props.setSpin(false)
console.log(JSON.parse(res.details));
console.log('details', JSON.parse(res.details));
this.requestVerificationCode()
message.error(window.localeInfo["Header.FailedRegister"]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/styles.less
Expand Up @@ -39,7 +39,7 @@

> a {
margin: 0 15px;
width: 54px;
width: 52px;
text-align: center;
> span {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Assets/index.js
Expand Up @@ -77,7 +77,7 @@ class BTAssets extends Component {
<div className='container column'>
<CustomTabBar onChange={this.handleChange} keyMap={arTypeKeyMap} activeKey={this.state.activeKey} />
<List
grid={{ gutter: 16, column: 4 }}
grid={{ gutter: 16, column: 4, xxl: 5 }}
dataSource={this.state.dataSource}
renderItem={item => (
<List.Item>
Expand Down
17 changes: 14 additions & 3 deletions src/containers/Dashboard/index.js
Expand Up @@ -63,8 +63,17 @@ export default class BTDashboard extends PureComponent {
}

getAccount = () => {
BTFetch('/dashboard/getAccountNumByDay', 'post').then(res => {
if (res && res.code == 1) {
BTFetch('/dashboard/getAccountNumByDay', 'post')
.then(res => {
if (!res) {
throw new Error('getAccountNumByDay error')
}

if (res.code == 408) {
setTimeout(this.getAccount.bind(this), 1000);
return ;
}
if (res.code == 1) {
if (res.data.length == 0) {
return;
}
Expand All @@ -80,7 +89,9 @@ export default class BTDashboard extends PureComponent {
type: <FormattedMessage {...DashboardMessages.Registration}/>,
})
}
});
}).catch(err => {
console.error(err);
})
}

exchangeNum = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Demand/index.js
Expand Up @@ -77,7 +77,7 @@ export default class BTDemand extends PureComponent{
<div className='container column'>
<CustomTabBar onChange={this.handleChange} keyMap={arTypeKeyMap} activeKey={this.state.activeKey} />
<List
grid={{ gutter: 16, column: 4 }}
grid={{ gutter: 16, column: 4, xxl: 5 }}
dataSource={this.state.dataSource}
renderItem={(item)=> (
<List.Item>
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Demand/subviews/BTRequirementItemDetail.js
Expand Up @@ -185,7 +185,7 @@ export default class BTRequirementItemDetail extends PureComponent{

<div className="headAndShop">
<h1>{data.requirement_name}</h1>
<BTFavoriteStar isFavorite={data.is_collection} type='requirement' id={data.requirement_id} />
{/* <BTFavoriteStar isFavorite={data.is_collection} type='requirement' id={data.requirement_id} /> */}
</div>

<p>
Expand Down
1 change: 0 additions & 1 deletion src/containers/Profile/Asset/index.js
Expand Up @@ -23,7 +23,6 @@ import './styles.less';

import BTPublishedAssets from './subviews/BTPublishedAssets'
import BTHaveBought from "./subviews/BTHaveBought"
import BTFetch from "../../../utils/BTFetch";
import { FormattedMessage } from 'react-intl'
import messages from '../../../locales/messages'
const PersonalAssetMessages = messages.PersonalAsset;
Expand Down
143 changes: 30 additions & 113 deletions src/containers/Profile/Collect/index.js
Expand Up @@ -19,8 +19,10 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {hashHistory} from 'react-router'
import { Button, Popconfirm } from 'antd'
import BTTable from '@/components/BTTable'
import { Popconfirm, Tabs } from 'antd'
import CustomTabBar from '@/components/CustomTabBar'
import FavoriteAssetList from './subviews/FavoriteAssetList'
import FavoriteReqList from "./subviews/FavoriteReqList"

import BTFetch from '@/utils/BTFetch'
import { getSignaturedParam } from '@/utils/BTCommonApi'
Expand All @@ -32,130 +34,45 @@ import { getFavReqParam } from '@/components/BTFavoriteStar'
import {FormattedMessage} from 'react-intl'
import messages from '@/locales/messages'

const TabPane = Tabs.TabPane;
const CollectMessages = messages.Collect;

function lookFor(asset_id) {
BTFetch('/asset/QueryAssetByID', 'post', {asset_id, sender: getAccount().username})
.then(res => {
if(res.code == 1){
console.log(res.data)
if (res.data) {
hashHistory.push({
pathname:'/assets/detail',
state:res.data
})
}
} else {
window.message.error(window.localeInfo["Header.FailedQuery"]);
}
})
.catch(error => {
window.message.error(window.localeInfo["Header.FailedQuery"]);
})
}

function getColumns() {
return [
{ title: <FormattedMessage {...CollectMessages.GoodName}/>, dataIndex: 'goods_name' },
{ title: <FormattedMessage {...CollectMessages.From}/>, dataIndex: 'username'},
{ title: <FormattedMessage {...CollectMessages.Time}/>, dataIndex: 'time',
render: getDateAndTime
},
{ title: <FormattedMessage {...CollectMessages.Delete}/>, key:'x',
render: (item) =>
<Popconfirm
title={<FormattedMessage {...CollectMessages.SureToDelete} />}
onConfirm={() => {
console.log('this', this);
this.onDelete(item)
}}
okText={<FormattedMessage {...CollectMessages.OK} />}
cancelText={<FormattedMessage {...CollectMessages.Cancel} />}
>
<a href="#">
<FormattedMessage {...CollectMessages.Delete}/>
</a>
</Popconfirm>
,
},
{
title: <FormattedMessage {...CollectMessages.ViewTheDetails}/>, dataIndex: 'goods_id',
render:(asset_id) =>
<Button onClick={() => lookFor(asset_id)}><FormattedMessage {...CollectMessages.View}/></Button>
},
]
}

// "assetType": 0,
// const keyMap = ['asset', 'requirement']
const keyMap = [
<FormattedMessage {...CollectMessages.Asset} />,
<FormattedMessage {...CollectMessages.Demand} />,
]

class BTCollect extends Component {
constructor(props) {
super(props);
this.state = {
index: 0,
id: ''
activeKey: '0'
};
this.columns = getColumns.call(this)

this.onDelete = this.onDelete.bind(this)
this.dataChange = this.dataChange.bind(this)
}

async onDelete(good_info) {
console.log(good_info)
// packmsg
let favoriteParam = {
"Username": getAccount().username,
"GoodsId": good_info.goods_id,
"GoodsType": good_info.goodsType || 'asset',
"OpType": 3, // 3 是删除
}
// console.log('favoriteParam', favoriteParam);
let fetchParam = await getFavReqParam(favoriteParam)

BTFetch('/user/favorite', 'post', fetchParam)
.then(res => {
if (res.code == 1) {
// let data = this.state.data
console.log('good_info.goods_id', good_info.goods_id);
this.setState({
index: this.state.index + 1,
id: good_info.goods_id
});
window.message.success(window.localeInfo["Asset.DeleteCollect"])
} else {
window.message.error(window.localeInfo["Asset.FailedCollect"])
}
}).catch(err => {
console.error('delete error', err);
})

}

dataChange(state) {
// console.log('state', state);
const { dataSource, total } = state
// console.log('this.state', this.state);
let data = dataSource.filter(o => o.goods_id != this.state.id)
// console.log('data', data);
return {...state, dataSource: data, total: total - 1 }
handleChange = (activeKey, value) => {
this.setState({ activeKey });
// this.getPagination(1, this.props.pageSize, activeKey)
}

render() {
return <BTTable
columns={this.columns}
rowKey='goods_id'
url='/user/GetFavorite'
options={{
...getSignaturedParam(getAccount()),
goods_type: 'asset' // asset 或者 requirement
}}
index={this.state.index}
catchError={(err) => console.error(error)}
dataChange={this.dataChange}
{...this.props}
/>
return (
<div className='container column'>
{/* <CustomTabBar onChange={this.handleChange} keyMap={keyMap} activeKey={this.state.activeKey} /> */}

{/* <Tabs className="tabs" activeKey={this.state.activeKey}>
<TabPane tab={<FormattedMessage {...CollectMessages.Asset} />} key="0"> */}
<FavoriteAssetList />
{/* </TabPane>
<TabPane tab={<FormattedMessage {...CollectMessages.Demand} />} key="1" >
<FavoriteReqList />
</TabPane>
</Tabs> */}

</div>
)
}
}

export default BTCollect
export default FavoriteAssetList

0 comments on commit ee1f045

Please sign in to comment.