index.js
4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import React, { Component } from 'react';
import { connect } from 'dva';
import { Tabs, Toast, ActionSheet } from 'antd-mobile';
import shareHide from "../../utils/shareHide";
import Templates from './templates';
import MyList from './mylist';
import css from './css.less';
const isIPhone = new RegExp('\\biPhone\\b|\\biPod\\b', 'i').test(window.navigator.userAgent);
let wrapProps;
if (isIPhone) {
wrapProps = {
onTouchStart: e => e.preventDefault(),
};
}
class Index extends Component{
constructor(props) {
super(props);
this.state = {
templates: [],
mylist: [],
isloading: false,
userId:null,
}
}
componentDidMount() {
document.title = '邀请函';
const _this = this;
const userId = localStorage.id ? localStorage.id : null;
Toast.loading('loading...', 1000);
shareHide();
this.setState({ userId })
this.props.dispatch({
type: 'Invitation/GetInvitationTmpsList',
payload: {},
callback(res) {
_this.setState({ templates: res })
Toast.hide();
}
})
this.props.dispatch({
type: 'Invitation/GetMyInvitList',
payload: {
createName: userId ? userId : ''
},
callback(res) {
_this.setState({ mylist: res, isloading: true })
}
})
}
invitationEdit = (data) => {
this.props.history.push({ pathname: "/invitation/addEdit" });
data.specificLocation = JSON.parse(data.specificLocation);
sessionStorage.setItem('invitationInfo', JSON.stringify(data));
}
invitationDel = (id) => {
const BUTTONS = ['删除', '取消'];
ActionSheet.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: BUTTONS.length - 1,
destructiveButtonIndex: BUTTONS.length - 2,
// title: '删除',
message: '确定删除此邀请函?',
maskClosable: true,
'data-seed': 'logId',
wrapProps,
},
(buttonIndex) => {
if (buttonIndex === 0) {
const _this = this;
_this.props.dispatch({
type: 'Invitation/del',
payload: {
id
},
callback(res) {
if (res.status === true) {
_this.props.dispatch({
type: 'Invitation/GetMyInvitList',
payload: {
createName: _this.state.userId ? _this.state.userId : ''
},
callback(data) {
_this.setState({ mylist: data })
}
})
}
Toast.info(res.message, 1);
}
})
}
});
}
invitationPrev = (id) => {
this.props.history.push({ pathname: "/invitation/preview", search: 'isprev=2&id=' + id });
}
addInvitation = (itm) => {
if (this.state.mylist.length >= 20) {
Toast.fail('邀请函数量过多,请删除不需要的邀请函',2);
} else {
this.props.history.push({ pathname: "/invitation/addEdit" })
sessionStorage.setItem('invitationInfo', JSON.stringify({ invitationId: itm.id, invitationPath: itm.invitationPath }))
}
}
render() {
let check = 0
if(sessionStorage.getItem("key") == '我的'){
check = 1
}
return <div className={css.invitationWrap} style={{ background: '#fff' }}>
<Tabs
tabs={[{ title: '所有模板', sub: '1' }, { title: '我的', sub: '2' }]}
initialPage ={check}
onChange={(t, i) => {
let checkTab = t.title;
sessionStorage.setItem( "key", checkTab);
// if (i === 0 && this.state.clientList.length === 0) { this.getClientUnpassList(); } else if (this.state.cientListed.length === 0){
// this.getClientPassedList();
// }
}}
>
<div>
<div className={css.splitline}></div>
<Templates
templates={this.state.templates}
addInvitation={this.addInvitation}
/>
</div>
<div className={(this.state.isloading && this.state.mylist.length === 0 ? css.noInfo : '')}>
<div className={css.splitline}></div>
<MyList
mylist={this.state.mylist}
invitationPrev={this.invitationPrev}
invitationEdit={this.invitationEdit}
invitationDel={this.invitationDel}
/>
</div>
</Tabs>
</div>
}
}
export default connect()(Index);