Account-overview.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. import React from 'react';
  2. import { Card, Button, Modal, Input, message, Spin } from 'antd';
  3. import { $Axios, $AxiosGet } from '../../common/publish';
  4. import '../Account-overview/Account-overview.scss'
  5. import axios from "axios";
  6. import sz1 from '../../images/sz1.jpg';
  7. import sz2 from '../../images/sz2.jpg';
  8. import sz4 from '../../images/sz4.jpg';
  9. export default class AccountOverview extends React.Component {
  10. constructor(props) {
  11. super(props)
  12. this.state = {
  13. headTxt: '财务管理 > 账户概览',
  14. data: '',
  15. yestdayTrade: '',
  16. preMonthTrade: '',
  17. btnsType: 1,
  18. isModalVisible: false,
  19. Password: '',
  20. colors: '',
  21. contactPhone: '',
  22. num: 60,
  23. t: '',
  24. lodings: false
  25. }
  26. }
  27. componentDidMount() {
  28. this.initData()
  29. }
  30. initData() {
  31. let that_ = this;
  32. that_.setState({
  33. lodings: false
  34. })
  35. let url = '/payment/merchant.query.groovy'
  36. let params = {
  37. action: 'queryGeneral',//查询商户概览信息
  38. merchantNo : JSON.parse(localStorage.getItem('userData')).merchantNo,//入网的appname、社群name、商户号等(香香或者嘉旺提供)
  39. merchantType : JSON.parse(localStorage.getItem('userData')).merchantType, //入网来源,2:app或社群 3:商户或店铺(香香或者嘉旺提供)
  40. }
  41. $Axios('get', url, params, (res) => {
  42. let status = res.data.head.status;
  43. if (status == 200) {
  44. let data = res.data.body;
  45. let yestdayTrade = res.data.body.yestdayTrade; //昨日收支
  46. let preMonthTrade = res.data.body.preMonthTrade;//上月收支
  47. that_.setState({
  48. data: data,
  49. yestdayTrade: yestdayTrade,
  50. preMonthTrade: preMonthTrade,
  51. contactPhone: data.contactPhone,
  52. lodings : true
  53. })
  54. }
  55. })
  56. }
  57. onBtnClick_1() {
  58. this.setState({
  59. btnsType: 1
  60. })
  61. }
  62. onBtnClick_2(e) {
  63. this.setState({
  64. btnsType: 2
  65. })
  66. }
  67. initData_tk() {
  68. let that_ = this;
  69. let url = '/payment/merchant.pwd.update.groovy'
  70. let params = {
  71. action: 'queryGeneral',//查询商户概览信息
  72. merchantNo : JSON.parse(localStorage.getItem('userData')).merchantNo,//入网的appname、社群name、商户号等(香香或者嘉旺提供)
  73. merchantType : JSON.parse(localStorage.getItem('userData')).merchantType, //入网来源,2:app或社群 3:商户或店铺(香香或者嘉旺提供)
  74. }
  75. $Axios('get', url, params, (res) => {
  76. let status = res.data.head.status;
  77. if (status == 200) {
  78. let data = res.data.body;
  79. let yestdayTrade = res.data.body.yestdayTrade; //昨日收支
  80. let preMonthTrade = res.data.body.preMonthTrade;//上月收支
  81. let parentAppName = res.data.body.parentAppName
  82. that_.setState({
  83. data: data,
  84. yestdayTrade: yestdayTrade,
  85. preMonthTrade: preMonthTrade,
  86. parentAppName : parentAppName
  87. })
  88. }
  89. })
  90. }
  91. onBtnClick_0() {
  92. this.setState({
  93. isModalVisible: true
  94. })
  95. }
  96. handleOk_c() {
  97. this.setState({
  98. isModalVisible: false
  99. })
  100. }
  101. handleOk() {
  102. this.submits();
  103. }
  104. submits() {
  105. if (document.getElementById("pwd").value !== '') {
  106. if (document.getElementById("cfPassword").value !== '') {
  107. if (document.getElementById("num1").value !== '') {
  108. if (document.getElementById("pwd").value == document.getElementById("cfPassword").value) {
  109. let that_ = this;
  110. let url = '/payment/merchant.pwd.update.groovy'
  111. let params = {
  112. id: this.state.data.id,//商户id
  113. pfAppName : this.state.parentAppName,// 新增参数
  114. pwd: document.getElementById("pwd").value,//密码
  115. mobile: this.state.data.contactPhone,//手机号
  116. code: document.getElementById("num1").value,//验证码
  117. }
  118. $Axios('get', url, params, (res) => {
  119. let status = res.data.head.status;
  120. if (status == 200) {
  121. message.info('提交成功!');
  122. that_.setState({
  123. isModalVisible: false
  124. });
  125. } else {
  126. message.info('提交失败!');
  127. }
  128. })
  129. } else {
  130. message.info('支付密码内容不一致!');
  131. }
  132. } else {
  133. message.info('请输入验证码!');
  134. }
  135. } else {
  136. message.info('请输入确认支付密码!');
  137. }
  138. } else {
  139. message.info('请输入支付密码!');
  140. }
  141. }
  142. handleOk_yzm() {
  143. let url = '/d3api2/user/sendMobileVerify.groovy'
  144. let that_ = this;
  145. let Params = {
  146. mobile: this.state.data.contactPhone,//手机号
  147. // mobile : 17600982892,//手机号
  148. pfAppName: JSON.parse(localStorage.getItem('userData')).pfAppName,//包名
  149. pfAppName : this.state.parentAppName,// 新增参数
  150. eventType: 51
  151. }
  152. $AxiosGet('get', url, Params, (res) => {
  153. let status = res.data.head.status;
  154. if (status == 200) {
  155. message.info('验证码发送成功,请注意查收!');
  156. let t = setInterval(function () {
  157. let nums = that_.djsNum();
  158. that_.setState({
  159. num: nums
  160. });
  161. if (nums == 0) {
  162. clearInterval(that_.state.t);
  163. that_.setState({
  164. t: '',
  165. num: 60
  166. });
  167. }
  168. }, 1000);
  169. that_.setState({
  170. t: t
  171. });
  172. }
  173. });
  174. }
  175. djsNum() {
  176. let that_ = this;
  177. let num = this.state.num
  178. num--
  179. return num
  180. }
  181. inputChange1(e) {
  182. }
  183. colorChange(e) {
  184. let s = this.colorTxt(e.target.value);
  185. this.setState({
  186. Password: e.target.value,
  187. colors: s
  188. });
  189. }
  190. colorTxt(value) {
  191. // 0: 表示第一个级别 1:表示第二个级别 2:表示第三个级别
  192. // 3: 表示第四个级别 4:表示第五个级别
  193. let modes = 0;
  194. if (value.length < 6) {//最初级别
  195. return modes;
  196. }
  197. if (/\d/.test(value)) {//如果用户输入的密码 包含了数字
  198. modes++;
  199. }
  200. if (/[a-z]/.test(value)) {//如果用户输入的密码 包含了小写的a到z
  201. modes++;
  202. }
  203. if (/[A-Z]/.test(value)) {//如果用户输入的密码 包含了大写的A到Z
  204. modes++;
  205. }
  206. if (/\W/.test(value)) {//如果是非数字 字母 下划线
  207. modes++;
  208. }
  209. switch (modes) {
  210. case 1:
  211. return 1;
  212. break;
  213. case 2:
  214. return 2;
  215. break;
  216. case 3:
  217. return 3;
  218. break;
  219. case 4:
  220. return 4;
  221. break;
  222. }
  223. }
  224. render() {
  225. const { headTxt, preMonthTrade, yestdayTrade, data, btnsType, isModalVisible, colors, num, t, lodings } = this.state;
  226. return (
  227. <div className='wrap_table'>
  228. <div className='header_center'>
  229. {headTxt}
  230. </div>
  231. <div className='query_table'
  232. style={{
  233. padding: '30px'
  234. }}
  235. >
  236. <Card title="企业账户" extra={<a href="#" onClick={this.onBtnClick_0.bind(this)}>设置/修改支付密码</a>} style={{ width: 400, display: 'inline-block' }}>
  237. {
  238. lodings == false && <div style={{ width: '100%', height: '120px', float: 'left', textAlign: 'center', lineHeight: '120px' }}>
  239. <Spin tip="加载中请稍后..."></Spin>
  240. </div>
  241. }
  242. {
  243. lodings == true && <div>
  244. <div style={{ width: '30%', height: '120px', float: 'left', marginRight: '5%' }}>
  245. <img src={sz1} alt="" />
  246. </div>
  247. <div style={{ width: '65%', height: '120px', float: 'left' }}>
  248. <div style={{ lineHeight: '120px' }}>账户余额 : {data.withdrawBalance}</div>
  249. </div>
  250. </div>
  251. }
  252. </Card>
  253. <Card title="入网信息" extra={<a href="#"></a>} style={{ width: 400, display: 'inline-block', marginLeft: '20px' }}>
  254. {
  255. lodings == false && <div style={{ width: '100%', height: '120px', float: 'left', textAlign: 'center', lineHeight: '120px' }}>
  256. <Spin tip="加载中请稍后..."></Spin>
  257. </div>
  258. }
  259. {
  260. lodings == true && <div>
  261. <div style={{ width: '30%', height: '120px', float: 'left', marginRight: '5%' }}>
  262. <img style={{ width: '100%', height: '100%' }} src={sz4} alt="" />
  263. </div>
  264. <div style={{ width: '65%', height: '120px', float: 'left' }}>
  265. <div style={{ lineHeight: '40px' }}>商户编号 : {data.merchantId == '' ? '--' : data.merchantId}</div>
  266. <div style={{ lineHeight: '40px' }}>商户名称 : {JSON.parse(localStorage.getItem('userData')).org_name}</div>
  267. <div style={{ lineHeight: '40px' }}>商户邮箱 : {data.contactEmail == '' ? '--' : data.contactEmail}</div>
  268. </div>
  269. </div>
  270. }
  271. </Card>
  272. <Card title="收支汇总" extra={<a href="#"></a>} style={{ width: 400, display: 'inline-block', marginLeft: '20px' }}>
  273. {
  274. lodings == false && <div style={{ width: '100%', height: '120px', float: 'left', textAlign: 'center', lineHeight: '120px' }}>
  275. <Spin tip="加载中请稍后..."></Spin>
  276. </div>
  277. }
  278. {
  279. lodings == true && <div>
  280. <div style={{ width: '30%', height: '120', float: 'left', marginRight: '5%' }}>
  281. <img style={{ width: '100%', height: '100%' }} src={sz2} alt="" />
  282. </div>
  283. <div style={{ width: '65%', height: '120', float: 'left' }}>
  284. <div style={{ width: '100%', height: '40px', float: 'left' }}>
  285. <Button className='btns' type={btnsType == 1 ? 'primary' : 'default'} onClick={this.onBtnClick_1.bind(this)}>昨日收支</Button>
  286. <Button className='btns' type={btnsType == 2 ? 'primary' : 'default'} onClick={this.onBtnClick_2.bind(this)}>上月收支</Button>
  287. </div>
  288. <div>已收入总额 : {btnsType == 1 ? yestdayTrade.income : preMonthTrade.income}</div>
  289. <div>待收入总额 : {btnsType == 1 ? yestdayTrade.incomeing : preMonthTrade.incomeing}</div>
  290. <div>支出总额 : {btnsType == 1 ? yestdayTrade.expense : preMonthTrade.expense}</div>
  291. <div>手续费 : {btnsType == 1 ? yestdayTrade.fee : preMonthTrade.fee}</div>
  292. </div>
  293. </div>
  294. }
  295. </Card>
  296. </div>
  297. <Modal title="设置/修改密码"
  298. wrapClassName={'webs'}
  299. footer={[
  300. <Button key="submit" type="primary" onClick={this.handleOk.bind(this)}>
  301. 确定
  302. </Button>,
  303. ]}
  304. visible={isModalVisible}
  305. closable={true}
  306. mask={true}
  307. onCancel={this.handleOk_c.bind(this)}
  308. // onOk={this.handleOk}
  309. >
  310. <div>
  311. <div className='c-ls'>
  312. <div className='titles_tk'>手机号 :</div>
  313. <div className='titles_num'><Input id='orderNo' disabled={true} defaultValue={data.contactPhone == '' ? '未获取到手机号' : data.contactPhone} /></div>
  314. {t == '' && <Button key="submit" type="primary" onClick={this.handleOk_yzm.bind(this)}>
  315. 获取验证码
  316. </Button>}
  317. {t !== '' && <Button key="submitNum" type="primary" style={{ width: '102px' }} disabled={true}>{num}</Button>}
  318. </div>
  319. <div className='c-ls'>
  320. <div className='titles_tk'>验证码 :</div>
  321. <div className='titles_yzm'><Input className='inputs' id='num1' autocomplete="off" maxLength={6} onChange={(e) => this.inputChange1(e)} /></div>
  322. </div>
  323. <div className='c-ls'>
  324. <div className='titles_tk'>支付密码 :</div>
  325. <div className='titles_num'>
  326. <Input.Password id='pwd' defaultValue='' onChange={(e) => this.colorChange(e)} placeholder="请输入支付密码" />
  327. </div>
  328. <div className='titles_num' style={{ marginLeft: '130px', color: '#ccc' }}>8-20位,必须由数字和字母混合组成</div>
  329. </div>
  330. <div className='c-ls'>
  331. <div className='titles_tk'></div>
  332. <div className='titles_pas' style={{ backgroundColor: colors == 1 ? '#76EE00' : '', }}>差</div>
  333. <div className='titles_pas' style={{ backgroundColor: colors == 2 ? '#FFD700' : '', }}>弱</div>
  334. <div className='titles_pas' style={{ backgroundColor: colors == 3 ? '#FF0000' : '', }}>中</div>
  335. <div className='titles_pas' style={{ backgroundColor: colors == 4 ? '#CD0000' : '', }}>强</div>
  336. </div>
  337. <div className='c-ls'>
  338. <div className='titles_tk'>确认支付密码 :</div>
  339. <div className='titles_num'><Input.Password id='cfPassword' autocomplete="off" placeholder="再次输入支付密码" /></div>
  340. </div>
  341. </div>
  342. </Modal>
  343. </div>
  344. )
  345. }
  346. }