Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.27 KB | None | 0 0
  1. /* eslint-disable */
  2. import React from 'react';
  3. import connect from '@vkontakte/vk-connect';
  4. import { View, platform, ModalRoot, ModalPage, Div, Button, ScreenSpinner, HeaderButton, TabbarItem, Epic, Tabbar, FormLayoutGroup, ModalPageHeader, Input, FormLayout, Alert} from '@vkontakte/vkui';
  5. import '@vkontakte/vkui/dist/vkui.css';
  6. import './panels/assets/css/background.css';
  7. import Icon24Dismiss from '@vkontakte/icons/dist/24/dismiss';
  8. import Icon24Home from '@vkontakte/icons/dist/24/home';
  9. import Icon24Bug from '@vkontakte/icons/dist/24/bug';
  10.  
  11. import Home from './panels/Home';
  12. import Persik from './panels/Persik';
  13. import House from './panels/House';
  14. import Pet from './panels/Pet';
  15. import MyPet from './panels/MyPet';
  16. import MyHouse from './panels/MyHouse';
  17. import Dop from './panels/Dop';
  18. import Top from './panels/Top';
  19. import Reit from './panels/Reit';
  20. import Sett from './panels/Sett';
  21. import ChangeNickname from './panels/ChangeNickname';
  22. import Transfer from './panels/Transfer';
  23. import Katalog from './panels/Katalog';
  24. import Imus from './panels/Imus';
  25.  
  26. const MODAL_PAGE_FILTERS = 'filters';
  27.  
  28. import Upgrade from './panels/Upgrade';
  29.  
  30. function openTab(url) {
  31.  
  32. // Create link in memory
  33.  
  34. let a = window.document.createElement("a");
  35.  
  36. a.target = '_blank';
  37.  
  38. a.href = url;
  39.  
  40. // Dispatch fake click
  41.  
  42. let e = window.document.createEvent("MouseEvents");
  43.  
  44. e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  45.  
  46. a.dispatchEvent(e);
  47.  
  48. };
  49.  
  50.  
  51.  
  52. class App extends React.Component {
  53. constructor(props) {
  54. super(props);
  55.  
  56. this.state = {
  57. activePanel: 'home',
  58. fetchedUser: null,
  59. userAcc: null,
  60. activeTab6: 'all',
  61. clicks: 0,
  62. reputation: 0,
  63. speed: 0,
  64. activeModal: null,
  65. aspeed: 0,
  66. priv: null,
  67. name: false,
  68. popout: null,
  69. calcRep: 0,
  70. nick: null,
  71. toid: 0,
  72. history: 0,
  73. history1: null,
  74. history2: null,
  75. history3: null,
  76. history4: null,
  77. history5: null,
  78. history6: null,
  79. history7: null,
  80. history8: null,
  81. history9: null,
  82. activeStory: 'home',
  83. history10: null,
  84. h_id1: 0,
  85. h_id2: 0,
  86. h_id3: 0,
  87. h_id4: 0,
  88. h_id5: 0,
  89. h_id6: 0,
  90. h_id7: 0,
  91. h_id8: 0,
  92. h_id9: 0,
  93. h_id10: 0,
  94. h_s1: 0,
  95. h_s2: 0,
  96. h_s3: 0,
  97. h_s4: 0,
  98. h_s5: 0,
  99. h_s6: 0,
  100. h_s7: 0,
  101. h_s8: 0,
  102. h_s9: 0,
  103. h_s10: 0,
  104. viv: 0,
  105. v1: null,
  106. v2: null,
  107. v3: null,
  108. v4: null,
  109. v5: null,
  110. v6: null,
  111. v7: null,
  112. v8: null,
  113. v9: null,
  114. v10: null,
  115. v_id1: 0,
  116. v_id2: 0,
  117. v_id3: 0,
  118. v_id4: 0,
  119. v_id5: 0,
  120. v_id6: 0,
  121. v_id7: 0,
  122. v_id8: 0,
  123. v_id9: 0,
  124. v_id10: 0,
  125. v_s1: 0,
  126. v_s2: 0,
  127. v_s3: 0,
  128. v_s4: 0,
  129. modalHistory: [],
  130. v_s5: 0,
  131. v_s6: 0,
  132. v_s7: 0,
  133. v_s8: 0,
  134. v_s9: 0,
  135. v_s10: 0,
  136. transferCoins: 0,
  137. usersTop: null,
  138. groupsTop: null,
  139. activeTabUpgrades: 'click',
  140. activeTabTop: 'users',
  141. upgradesOne: null,
  142. upgradesTwo: null,
  143. sp: 0
  144. };
  145. this.openDefault = this.openDefault.bind(this);
  146. this.closePopout = this.closePopout.bind(this);
  147. this.handleReputationChange = this.handleReputationChange.bind(this);
  148. this.handleReputationSubmit = this.handleReputationSubmit.bind(this);
  149. this.handleNickChange = this.handleNickChange.bind(this);
  150. this.handleNickSubmit = this.handleNickSubmit.bind(this);
  151. this.handleTransferChange = this.handleTransferChange.bind(this);
  152. this.handleTransferSubmit = this.handleTransferSubmit.bind(this);
  153. this.buyPet = this.buyPet.bind(this);
  154. this.sellPet = this.sellPet.bind(this);
  155. this.pohodPet = this.pohodPet.bind(this);
  156. this.buyHouse = this.buyHouse.bind(this);
  157. this.onStoryChange = this.onStoryChange.bind(this);
  158. this.sellHouse = this.sellHouse.bind(this);
  159. this.pohodHouse = this.pohodHouse.bind(this);
  160. this.setActiveTabUpgrades = this.setActiveTabUpgrades.bind(this);
  161. this.setActiveTabTop = this.setActiveTabTop.bind(this);
  162. this.buyUpgrade = this.buyUpgrade.bind(this);
  163. this.getUpgradesOne = this.getUpgradesOne.bind(this);
  164. this.getUpgradesTwo = this.getUpgradesTwo.bind(this);
  165. this.autoMine = this.autoMine.bind(this);
  166. this.modalBack = () => {
  167. this.setActiveModal(this.state.modalHistory[this.state.modalHistory.length - 2]);
  168. }
  169. }
  170.  
  171. setActiveModal(activeModal) {
  172. activeModal = activeModal || null;
  173. let modalHistory = this.state.modalHistory ? [...this.state.modalHistory] : [];
  174.  
  175. if (activeModal === null) {
  176. modalHistory = [];
  177. } else if (modalHistory.indexOf(activeModal) !== -1) {
  178. modalHistory = modalHistory.splice(0, modalHistory.indexOf(activeModal) + 1);
  179. } else {
  180. modalHistory.push(activeModal);
  181. }
  182.  
  183. this.setState({
  184. activeModal,
  185. modalHistory
  186. });
  187. };
  188.  
  189.  
  190. openDefault(title, msg, actions) {
  191. this.setState({
  192. popout:
  193. <Alert
  194. actions={[actions]}
  195. onClose={this.closePopout}
  196. >
  197. <h2>{title}</h2>
  198. <p>{msg}</p>
  199. </Alert>
  200. });
  201. }
  202.  
  203. closePopout() {
  204. this.setState({ popout: null });
  205. }
  206.  
  207. componentDidMount() {
  208. connect.subscribe((e) => {
  209. switch (e.detail.type) {
  210. case 'VKWebAppGetUserInfoResult':
  211. this.setState({ fetchedUser: e.detail.data });
  212. console.log(e.detail.data)
  213. this.createUser(e.detail.data);
  214. this.setState({ popout: <ScreenSpinner /> });
  215. setTimeout(() => { this.setState({ popout: null }) }, 2000);
  216. this.getUsersTop();
  217. this.getGroupsTop();
  218. this.getUpgradesOne()
  219. this.getUpgradesTwo()
  220. break;
  221. case 'VKWebAppShowWallPostBoxResult':
  222.  
  223. break;
  224. default:
  225. console.log(e.detail.type);
  226. }
  227. });
  228. connect.send('VKWebAppGetUserInfo', {});
  229. console.log(window.location)
  230. setInterval(() => {
  231. this.autoMine();
  232. this.getUsersTop();
  233. this.getGroupsTop();
  234. console.log(1);
  235. }, 1000)
  236. }
  237.  
  238. go = (e) => {
  239. this.setState({ popout: <ScreenSpinner /> });
  240. setTimeout(() => { this.setState({ popout: null }) }, 1500);
  241. this.setState({ activePanel: e.currentTarget.dataset.to })
  242. if(e.currentTarget.dataset.to === "top") {
  243. this.getUsersTop();
  244. this.getGroupsTop();
  245. }
  246. }
  247.  
  248. createUser = (data) => {
  249. fetch("/api.php", {
  250. method: 'post',
  251. headers: {
  252. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  253. },
  254. body: `method=user.create`
  255. })
  256. .then((response) => response.json())
  257. .then((response) => {
  258. this.setState({ history: response.history })
  259. this.setState({ history1: response.history1 })
  260. this.setState({ history2: response.history2 })
  261. this.setState({ history3: response.history3 })
  262. this.setState({ history4: response.history4 })
  263. this.setState({ history5: response.history5 })
  264. this.setState({ history6: response.history6 })
  265. this.setState({ history7: response.history7 })
  266. this.setState({ history8: response.history8 })
  267. this.setState({ history9: response.history9 })
  268. this.setState({ history10: response.history10 })
  269. this.setState({ h_id1: response.h_id1 })
  270. this.setState({ h_id2: response.h_id2 })
  271. this.setState({ h_id3: response.h_id3 })
  272. this.setState({ h_id4: response.h_id4 })
  273. this.setState({ h_id5: response.h_id5 })
  274. this.setState({ h_id7: response.h_id7 })
  275. this.setState({ h_id8: response.h_id8 })
  276. this.setState({ h_id9: response.h_id9 })
  277. this.setState({ h_id10: response.h_id10 })
  278. this.setState({ h_id6: response.h_id6 })
  279. this.setState({ h_s1: response.h_s1 })
  280. this.setState({ h_s2: response.h_s2 })
  281. this.setState({ h_s3: response.h_s3 })
  282. this.setState({ h_s4: response.h_s4 })
  283. this.setState({ h_s5: response.h_s5 })
  284. this.setState({ h_s6: response.h_s6 })
  285. this.setState({ h_s7: response.h_s7 })
  286. this.setState({ h_s8: response.h_s8 })
  287. this.setState({ h_s9: response.h_s9 })
  288. this.setState({ h_s10: response.h_s10 })
  289. this.setState({ viv: response.viv })
  290. this.setState({ v1: response.v1 })
  291. this.setState({ v2: response.v2 })
  292. this.setState({ v3: response.v3 })
  293. this.setState({ v4: response.v4 })
  294. this.setState({ v5: response.v5 })
  295. this.setState({ v6: response.v6 })
  296. this.setState({ v7: response.v7 })
  297. this.setState({ v8: response.v8 })
  298. this.setState({ v9: response.v9 })
  299. this.setState({ v10: response.v10 })
  300. this.setState({ v_id1: response.v_id1 })
  301. this.setState({ v_id2: response.v_id2 })
  302. this.setState({ v_id3: response.v_id3 })
  303. this.setState({ v_id4: response.v_id4 })
  304. this.setState({ v_id5: response.v_id5 })
  305. this.setState({ v_id7: response.v_id7 })
  306. this.setState({ v_id8: response.v_id8 })
  307. this.setState({ v_id9: response.v_id9 })
  308. this.setState({ v_id10: response.v_id10 })
  309. this.setState({ v_id6: response.v_id6 })
  310. this.setState({ v_s1: response.v_s1 })
  311. this.setState({ v_s2: response.v_s2 })
  312. this.setState({ v_s3: response.v_s3 })
  313. this.setState({ v_s4: response.v_s4 })
  314. this.setState({ v_s5: response.v_s5 })
  315. this.setState({ v_s6: response.v_s6 })
  316. this.setState({ v_s7: response.v_s7 })
  317. this.setState({ v_s8: response.v_s8 })
  318. this.setState({ v_s9: response.v_s9 })
  319. this.setState({ v_s10: response.v_s10 })
  320. // console.log(response)
  321. this.setState({ userAcc: response })
  322. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  323. //console.log(this.state.userAcc)
  324. })
  325. .catch((error) => {
  326. console.log(error)
  327. })
  328. }
  329.  
  330. updateUserClicks = async (id) => {
  331. fetch("/api.php", {
  332. method: 'post',
  333. headers: {
  334. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  335. },
  336. body: `method=user.update.click&user_vk=${id}`
  337. })
  338. .then((response) => response.json())
  339. .then((response) => {
  340. //console.log('user', response)
  341. this.setState({ userAcc: response })
  342. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  343. this.setState({ history: response.history })
  344. this.setState({ history1: response.history1 })
  345. this.setState({ history2: response.history2 })
  346. this.setState({ history3: response.history3 })
  347. this.setState({ history4: response.history4 })
  348. this.setState({ history5: response.history5 })
  349. this.setState({ history6: response.history6 })
  350. this.setState({ history7: response.history7 })
  351. this.setState({ history8: response.history8 })
  352. this.setState({ history9: response.history9 })
  353. this.setState({ history10: response.history10 })
  354. this.setState({ h_id1: response.h_id1 })
  355. this.setState({ h_id2: response.h_id2 })
  356. this.setState({ h_id3: response.h_id3 })
  357. this.setState({ h_id4: response.h_id4 })
  358. this.setState({ h_id5: response.h_id5 })
  359. this.setState({ h_id7: response.h_id7 })
  360. this.setState({ h_id8: response.h_id8 })
  361. this.setState({ h_id9: response.h_id9 })
  362. this.setState({ h_id10: response.h_id10 })
  363. this.setState({ h_id6: response.h_id6 })
  364. this.setState({ h_s1: response.h_s1 })
  365. this.setState({ h_s2: response.h_s2 })
  366. this.setState({ h_s3: response.h_s3 })
  367. this.setState({ h_s4: response.h_s4 })
  368. this.setState({ h_s5: response.h_s5 })
  369. this.setState({ h_s6: response.h_s6 })
  370. this.setState({ h_s7: response.h_s7 })
  371. this.setState({ h_s8: response.h_s8 })
  372. this.setState({ h_s9: response.h_s9 })
  373. this.setState({ h_s10: response.h_s10 })
  374. this.setState({ viv: response.viv })
  375. this.setState({ v1: response.v1 })
  376. this.setState({ v2: response.v2 })
  377. this.setState({ v3: response.v3 })
  378. this.setState({ v4: response.v4 })
  379. this.setState({ v5: response.v5 })
  380. this.setState({ v6: response.v6 })
  381. this.setState({ v7: response.v7 })
  382. this.setState({ v8: response.v8 })
  383. this.setState({ v9: response.v9 })
  384. this.setState({ v10: response.v10 })
  385. this.setState({ v_id1: response.v_id1 })
  386. this.setState({ v_id2: response.v_id2 })
  387. this.setState({ v_id3: response.v_id3 })
  388. this.setState({ v_id4: response.v_id4 })
  389. this.setState({ v_id5: response.v_id5 })
  390. this.setState({ v_id7: response.v_id7 })
  391. this.setState({ v_id8: response.v_id8 })
  392. this.setState({ v_id9: response.v_id9 })
  393. this.setState({ v_id10: response.v_id10 })
  394. this.setState({ v_id6: response.v_id6 })
  395. this.setState({ v_s1: response.v_s1 })
  396. this.setState({ v_s2: response.v_s2 })
  397. this.setState({ v_s3: response.v_s3 })
  398. this.setState({ v_s4: response.v_s4 })
  399. this.setState({ v_s5: response.v_s5 })
  400. this.setState({ v_s6: response.v_s6 })
  401. this.setState({ v_s7: response.v_s7 })
  402. this.setState({ v_s8: response.v_s8 })
  403. this.setState({ v_s9: response.v_s9 })
  404. this.setState({ v_s10: response.v_s10 })
  405. })
  406. .catch((error) => {
  407. console.error(error)
  408. })
  409. }
  410.  
  411. updateUserReputation = (id, reputation) => {
  412. fetch("/api.php", {
  413. method: 'post',
  414. headers: {
  415. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  416. },
  417. body: `method=user.update.reputation&user_vk=${id}&reputation_new=${reputation}`
  418. })
  419. .then((response) => response.json())
  420. .then((response) => {
  421. //console.log(response)
  422. switch (response.status) {
  423. case 'success':
  424. this.openDefault("Успех", response.msg, {
  425. title: 'ОК',
  426. autoclose: true,
  427. })
  428. break;
  429. case 'error':
  430. this.openDefault("Ошибка", response.msg, {
  431. title: 'ОК',
  432. autoclose: true,
  433. style: "destructive"
  434. })
  435. break;
  436. default: break;
  437. }
  438. this.setState({ userAcc: response })
  439. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  440. this.setState({ history: response.history })
  441. this.setState({ history1: response.history1 })
  442. this.setState({ history2: response.history2 })
  443. this.setState({ history3: response.history3 })
  444. this.setState({ history4: response.history4 })
  445. this.setState({ history5: response.history5 })
  446. this.setState({ history6: response.history6 })
  447. this.setState({ history7: response.history7 })
  448. this.setState({ history8: response.history8 })
  449. this.setState({ history9: response.history9 })
  450. this.setState({ history10: response.history10 })
  451. this.setState({ h_id1: response.h_id1 })
  452. this.setState({ h_id2: response.h_id2 })
  453. this.setState({ h_id3: response.h_id3 })
  454. this.setState({ h_id4: response.h_id4 })
  455. this.setState({ h_id5: response.h_id5 })
  456. this.setState({ h_id7: response.h_id7 })
  457. this.setState({ h_id8: response.h_id8 })
  458. this.setState({ h_id9: response.h_id9 })
  459. this.setState({ h_id10: response.h_id10 })
  460. this.setState({ h_id6: response.h_id6 })
  461. this.setState({ h_s1: response.h_s1 })
  462. this.setState({ h_s2: response.h_s2 })
  463. this.setState({ h_s3: response.h_s3 })
  464. this.setState({ h_s4: response.h_s4 })
  465. this.setState({ h_s5: response.h_s5 })
  466. this.setState({ h_s6: response.h_s6 })
  467. this.setState({ h_s7: response.h_s7 })
  468. this.setState({ h_s8: response.h_s8 })
  469. this.setState({ h_s9: response.h_s9 })
  470. this.setState({ h_s10: response.h_s10 })
  471. this.setState({ viv: response.viv })
  472. this.setState({ v1: response.v1 })
  473. this.setState({ v2: response.v2 })
  474. this.setState({ v3: response.v3 })
  475. this.setState({ v4: response.v4 })
  476. this.setState({ v5: response.v5 })
  477. this.setState({ v6: response.v6 })
  478. this.setState({ v7: response.v7 })
  479. this.setState({ v8: response.v8 })
  480. this.setState({ v9: response.v9 })
  481. this.setState({ v10: response.v10 })
  482. this.setState({ v_id1: response.v_id1 })
  483. this.setState({ v_id2: response.v_id2 })
  484. this.setState({ v_id3: response.v_id3 })
  485. this.setState({ v_id4: response.v_id4 })
  486. this.setState({ v_id5: response.v_id5 })
  487. this.setState({ v_id7: response.v_id7 })
  488. this.setState({ v_id8: response.v_id8 })
  489. this.setState({ v_id9: response.v_id9 })
  490. this.setState({ v_id10: response.v_id10 })
  491. this.setState({ v_id6: response.v_id6 })
  492. this.setState({ v_s1: response.v_s1 })
  493. this.setState({ v_s2: response.v_s2 })
  494. this.setState({ v_s3: response.v_s3 })
  495. this.setState({ v_s4: response.v_s4 })
  496. this.setState({ v_s5: response.v_s5 })
  497. this.setState({ v_s6: response.v_s6 })
  498. this.setState({ v_s7: response.v_s7 })
  499. this.setState({ v_s8: response.v_s8 })
  500. this.setState({ v_s9: response.v_s9 })
  501. this.setState({ v_s10: response.v_s10 })
  502. })
  503. .catch((error) => {
  504. console.error(error)
  505. })
  506. }
  507.  
  508. updateUserNickname = (id, nickname) => {
  509. fetch("/api.php", {
  510. method: 'post',
  511. headers: {
  512. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  513. },
  514. body: `method=user.update.nickname&user_vk=${id}&nickname=${nickname}`
  515. })
  516. .then((response) => response.json())
  517. .then((response) => {
  518. //console.log(response)
  519. switch (response.status) {
  520. case 'success':
  521. this.openDefault("Успех", response.msg, {
  522. title: 'ОК',
  523. autoclose: true,
  524. })
  525. break;
  526. case 'error':
  527. this.openDefault("Ошибка", response.msg, {
  528. title: 'ОК',
  529. autoclose: true,
  530. style: "destructive"
  531. })
  532. break;
  533. default: break;
  534. }
  535. this.setState({ userAcc: response })
  536. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  537. })
  538. .catch((error) => {
  539. console.error(error)
  540. })
  541. }
  542.  
  543. addv = () => {
  544. connect.send("VKWebAppAddToCommunity", {});
  545. }
  546.  
  547. sendTransfer = async (id, toid, count) => {
  548. fetch("/api.php", {
  549. method: 'post',
  550. headers: {
  551. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  552. },
  553. body: `method=user.send.transfer&user_vk=${id}&toid=${toid}&count=${count}`
  554. })
  555. .then((response) => response.json())
  556. .then((response) => {
  557. //console.log(response)
  558. switch (response.status) {
  559. case 'success':
  560. this.openDefault("Успех", response.msg, {
  561. title: 'ОК',
  562. autoclose: true,
  563. })
  564. break;
  565. case 'error':
  566. this.openDefault("Ошибка", response.msg, {
  567. title: 'ОК',
  568. autoclose: true,
  569. style: "destructive"
  570. })
  571. break;
  572. default: break;
  573. }
  574. this.setState({ userAcc: response })
  575. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  576. this.setState({ history: response.history })
  577. this.setState({ history1: response.history1 })
  578. this.setState({ history2: response.history2 })
  579. this.setState({ history3: response.history3 })
  580. this.setState({ history4: response.history4 })
  581. this.setState({ history5: response.history5 })
  582. this.setState({ history6: response.history6 })
  583. this.setState({ history7: response.history7 })
  584. this.setState({ history8: response.history8 })
  585. this.setState({ history9: response.history9 })
  586. this.setState({ history10: response.history10 })
  587. this.setState({ h_id1: response.h_id1 })
  588. this.setState({ h_id2: response.h_id2 })
  589. this.setState({ h_id3: response.h_id3 })
  590. this.setState({ h_id4: response.h_id4 })
  591. this.setState({ h_id5: response.h_id5 })
  592. this.setState({ h_id7: response.h_id7 })
  593. this.setState({ h_id8: response.h_id8 })
  594. this.setState({ h_id9: response.h_id9 })
  595. this.setState({ h_id10: response.h_id10 })
  596. this.setState({ h_id6: response.h_id6 })
  597. this.setState({ h_s1: response.h_s1 })
  598. this.setState({ h_s2: response.h_s2 })
  599. this.setState({ h_s3: response.h_s3 })
  600. this.setState({ h_s4: response.h_s4 })
  601. this.setState({ h_s5: response.h_s5 })
  602. this.setState({ h_s6: response.h_s6 })
  603. this.setState({ h_s7: response.h_s7 })
  604. this.setState({ h_s8: response.h_s8 })
  605. this.setState({ h_s9: response.h_s9 })
  606. this.setState({ h_s10: response.h_s10 })
  607. this.setState({ viv: response.viv })
  608. this.setState({ v1: response.v1 })
  609. this.setState({ v2: response.v2 })
  610. this.setState({ v3: response.v3 })
  611. this.setState({ v4: response.v4 })
  612. this.setState({ v5: response.v5 })
  613. this.setState({ v6: response.v6 })
  614. this.setState({ v7: response.v7 })
  615. this.setState({ v8: response.v8 })
  616. this.setState({ v9: response.v9 })
  617. this.setState({ v10: response.v10 })
  618. this.setState({ v_id1: response.v_id1 })
  619. this.setState({ v_id2: response.v_id2 })
  620. this.setState({ v_id3: response.v_id3 })
  621. this.setState({ v_id4: response.v_id4 })
  622. this.setState({ v_id5: response.v_id5 })
  623. this.setState({ v_id7: response.v_id7 })
  624. this.setState({ v_id8: response.v_id8 })
  625. this.setState({ v_id9: response.v_id9 })
  626. this.setState({ v_id10: response.v_id10 })
  627. this.setState({ v_id6: response.v_id6 })
  628. this.setState({ v_s1: response.v_s1 })
  629. this.setState({ v_s2: response.v_s2 })
  630. this.setState({ v_s3: response.v_s3 })
  631. this.setState({ v_s4: response.v_s4 })
  632. this.setState({ v_s5: response.v_s5 })
  633. this.setState({ v_s6: response.v_s6 })
  634. this.setState({ v_s7: response.v_s7 })
  635. this.setState({ v_s8: response.v_s8 })
  636. this.setState({ v_s9: response.v_s9 })
  637. this.setState({ v_s10: response.v_s10 })
  638. })
  639. .catch((error) => {
  640. console.error(error)
  641. })
  642. }
  643.  
  644. getUsersTop = async () => {
  645. fetch("/api.php", {
  646. method: 'post',
  647. headers: {
  648. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  649. },
  650. body: `method=get.users.top`
  651. })
  652. .then((response) => response.json())
  653. .then((response) => {
  654. this.setState({ usersTop: response })
  655. })
  656. .catch((error) => {
  657. console.error(error)
  658. })
  659. }
  660.  
  661. getGroupsTop = () => {
  662. fetch("/api.php", {
  663. method: 'post',
  664. headers: {
  665. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  666. },
  667. body: `method=get.groups.top`
  668. })
  669. .then((response) => response.json())
  670. .then((response) => {
  671. this.setState({ groupsTop: response });
  672. })
  673. .catch((error) => {
  674. console.error(error)
  675. })
  676. }
  677.  
  678. handleReputationChange(event) {
  679. const price = event.target.value;
  680. this.setState({ calcRep: price * 50000 });
  681. this.setState({ sp: price });
  682. }
  683.  
  684. handleReputationSubmit(event) {
  685. if (this.state.clicks < 50000) {
  686. this.openDefault("Ошибка!!", "Недостаточно денег для покупки рейтинга. Курс: 1 rate = 50000 coins", {
  687. title: 'ОК',
  688. autoclose: true,
  689. style: "destructive"
  690. })
  691. }
  692. else {
  693. this.updateUserReputation(this.state.fetchedUser.id, this.state.sp)
  694. }
  695. event.preventDefault();
  696. }
  697.  
  698. handleNickChange(event) {
  699. //console.log(event.target)
  700. this.setState({ nick: event.target.value})
  701. }
  702.  
  703. handleNickSubmit(event) {
  704. if (this.state.nick === null || this.state.nick === "") {
  705. return this.openDefault("Ошибка", "Введите ник", {
  706. title: 'ОК',
  707. autoclose: true,
  708. style: "destructive"
  709. })
  710. }
  711. else this.updateUserNickname(this.state.fetchedUser.id, this.state.nick)
  712. event.preventDefault();
  713. }
  714.  
  715. handleTransferChange(event) {
  716. //console.log(event.target)
  717. const target = event.target;
  718. const name = target.name;
  719. const value = target.value;
  720. this.setState({ [name]: value })
  721. }
  722.  
  723. handleTransferSubmit(event) {
  724. if (this.state.toid === 0 && this.state.transferCoins === 0) return false
  725. else this.sendTransfer(this.state.fetchedUser.id, this.state.toId, this.state.transferCoins)
  726. event.preventDefault();
  727. }
  728.  
  729. buyPet(pet_id) {
  730. fetch("/api.php", {
  731. method: 'post',
  732. headers: {
  733. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  734. },
  735. body: `method=user.buy.pet&user_vk=${this.state.fetchedUser.id}&pet_id=${pet_id}`
  736. })
  737. .then((response) => response.json())
  738. .then((response) => {
  739. //console.log(response)
  740. switch(response.status) {
  741. case 'success':
  742. this.openDefault("Успех", response.msg, {
  743. title: 'ОК',
  744. autoclose: true,
  745. })
  746. break;
  747. case 'error':
  748. this.openDefault("Ошибка", response.msg, {
  749. title: 'ОК',
  750. autoclose: true,
  751. style: "destructive"
  752. })
  753. break;
  754. default: break;
  755. }
  756. this.setState({ userAcc: response })
  757. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  758. })
  759. .catch((error) => {
  760. console.error(error)
  761. })
  762. }
  763.  
  764. sellPet(pet_id) {
  765. fetch("/api.php", {
  766. method: 'post',
  767. headers: {
  768. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  769. },
  770. body: `method=user.sell.pet&user_vk=${this.state.fetchedUser.id}&pet_id=${pet_id}`
  771. })
  772. .then((response) => response.json())
  773. .then((response) => {
  774. //console.log(response)
  775. switch (response.status) {
  776. case 'success':
  777. this.openDefault("Успех", response.msg, {
  778. title: 'ОК',
  779. autoclose: true,
  780. })
  781. break;
  782. case 'error':
  783. this.openDefault("Ошибка", response.msg, {
  784. title: 'ОК',
  785. autoclose: true,
  786. style: "destructive"
  787. })
  788. break;
  789. default: break;
  790. }
  791. this.setState({ userAcc: response })
  792. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  793. this.setState({ activePanel: "home" })
  794. })
  795. .catch((error) => {
  796. console.error(error)
  797. })
  798. }
  799.  
  800. pohodPet() {
  801. fetch("/api.php", {
  802. method: 'post',
  803. headers: {
  804. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  805. },
  806. body: `method=user.pohod.pet&user_vk=${this.state.fetchedUser.id}`
  807. })
  808. .then((response) => response.json())
  809. .then((response) => {
  810. //console.log(response)
  811. switch (response.status) {
  812. case 'success':
  813. this.openDefault("Успех", response.msg, {
  814. title: 'ОК',
  815. autoclose: true,
  816. })
  817. break;
  818. case 'error':
  819. this.openDefault("Ошибка", response.msg, {
  820. title: 'ОК',
  821. autoclose: true,
  822. style: "destructive"
  823. })
  824. break;
  825. default: break;
  826. }
  827. this.setState({ userAcc: response })
  828. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  829. })
  830. .catch((error) => {
  831. console.error(error)
  832. })
  833. }
  834.  
  835.  
  836. buyHouse(house_id) {
  837. fetch("/api.php", {
  838. method: 'post',
  839. headers: {
  840. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  841. },
  842. body: `method=user.buy.house&user_vk=${this.state.fetchedUser.id}&house_id=${house_id}`
  843. })
  844. .then((response) => response.json())
  845. .then((response) => {
  846. //console.log(response)
  847. switch(response.status) {
  848. case 'success':
  849. this.openDefault("Успех", response.msg, {
  850. title: 'ОК',
  851. autoclose: true,
  852. })
  853. break;
  854. case 'error':
  855. this.openDefault("Ошибка", response.msg, {
  856. title: 'ОК',
  857. autoclose: true,
  858. style: "destructive"
  859. })
  860. break;
  861. default: break;
  862. }
  863. this.setState({ userAcc: response })
  864. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  865. })
  866. .catch((error) => {
  867. console.error(error)
  868. })
  869. }
  870.  
  871. sellHouse(house_id) {
  872. fetch("/api.php", {
  873. method: 'post',
  874. headers: {
  875. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  876. },
  877. body: `method=user.sell.house&user_vk=${this.state.fetchedUser.id}&house_id=${house_id}`
  878. })
  879. .then((response) => response.json())
  880. .then((response) => {
  881. //console.log(response)
  882. switch (response.status) {
  883. case 'success':
  884. this.openDefault("Успех", response.msg, {
  885. title: 'ОК',
  886. autoclose: true,
  887. })
  888. break;
  889. case 'error':
  890. this.openDefault("Ошибка", response.msg, {
  891. title: 'ОК',
  892. autoclose: true,
  893. style: "destructive"
  894. })
  895. break;
  896. default: break;
  897. }
  898. this.setState({ userAcc: response })
  899. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  900. this.setState({ activePanel: "home" })
  901. })
  902. .catch((error) => {
  903. console.error(error)
  904. })
  905. }
  906.  
  907. pohodHouse() {
  908. fetch("/api.php", {
  909. method: 'post',
  910. headers: {
  911. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  912. },
  913. body: `method=user.pohod.house&user_vk=${this.state.fetchedUser.id}`
  914. })
  915. .then((response) => response.json())
  916. .then((response) => {
  917. //console.log(response)
  918. switch (response.status) {
  919. case 'success':
  920. this.openDefault("Успех", response.msg, {
  921. title: 'ОК',
  922. autoclose: true,
  923. })
  924. break;
  925. case 'error':
  926. this.openDefault("Ошибка", response.msg, {
  927. title: 'ОК',
  928. autoclose: true,
  929. style: "destructive"
  930. })
  931. break;
  932. default: break;
  933. }
  934. this.setState({ userAcc: response })
  935. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  936. })
  937. .catch((error) => {
  938. console.error(error)
  939. })
  940. }
  941.  
  942. buyUpgrade(type, name) {
  943. fetch("/api.php", {
  944. method: 'post',
  945. headers: {
  946. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  947. },
  948. body: `method=user.buy.upgrade&user_vk=${this.state.fetchedUser.id}&type=${type}&up_name=${name}`
  949. })
  950. .then((response) => response.json())
  951. .then((response) => {
  952. //console.log(response)
  953. switch(response.status) {
  954. case 'error':
  955. this.openDefault("Ошибка", response.msg, {
  956. title: 'ОК',
  957. autoclose: true,
  958. style: "destructive"
  959. })
  960. break;
  961. }
  962. this.setState({ userAcc: response })
  963. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  964. this.getUpgradesOne()
  965. this.getUpgradesTwo()
  966. })
  967. .catch((error) => {
  968. console.error(error)
  969. })
  970. }
  971.  
  972.  
  973. getUpgradesOne() {
  974. fetch("/api.php", {
  975. method: 'post',
  976. headers: {
  977. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  978. },
  979. body: `method=get.upgrades.one`
  980. })
  981. .then((response) => response.json())
  982. .then((response) => {
  983. console.log(response)
  984. this.setState({ upgradesOne: response });
  985. })
  986. .catch((error) => {
  987. console.error(error)
  988. })
  989. }
  990.  
  991.  
  992. getUpgradesTwo() {
  993. fetch("/api.php", {
  994. method: 'post',
  995. headers: {
  996. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  997. },
  998. body: `method=get.upgrades.two`
  999. })
  1000. .then((response) => response.json())
  1001. .then((response) => {
  1002. console.log(response)
  1003. this.setState({ upgradesTwo: response });
  1004. })
  1005. .catch((error) => {
  1006. console.error(error)
  1007. })
  1008. }
  1009.  
  1010. autoMine() {
  1011. fetch("/api.php", {
  1012. method: 'post',
  1013. headers: {
  1014. "Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  1015. },
  1016. body: `method=user.auto.mine&user_vk=${this.state.fetchedUser.id}`
  1017. })
  1018. .then((response) => response.json())
  1019. .then((response) => {
  1020. console.log(response)
  1021. this.setState({ userAcc: response })
  1022. this.setState({ clicks: response.clicks, reputation: response.reputation, speed: response.speed, aspeed: response.aspeed })
  1023. })
  1024. .catch((error) => {
  1025. console.error(error)
  1026. })
  1027. }
  1028. setActiveTabUpgrades = (value) => {
  1029. this.setState({ activeTabUpgrades: `${value}` });
  1030. }
  1031.  
  1032. setActiveTabTop = (value) => {
  1033. this.setState({ activeTabTop: `${value}` });
  1034. }
  1035.  
  1036.  
  1037. add1 = () => {
  1038. this.updateUserClicks(this.state.fetchedUser.id)
  1039. }
  1040.  
  1041.  
  1042. dark = () => {
  1043. document.body.setAttribute( 'scheme','client_dark' );
  1044. }
  1045.  
  1046. light = () => {
  1047. document.body.setAttribute( 'scheme','client_light' );
  1048. }
  1049.  
  1050. onStoryChange (e) {
  1051. this.setState({ activeStory: e.currentTarget.dataset.story })
  1052. this.setState({ popout: <ScreenSpinner /> });
  1053. setTimeout(() => { this.setState({ popout: null }) }, 200);
  1054. }
  1055.  
  1056.  
  1057. render() {
  1058. const osname = platform();
  1059. const { go, nickname, fetchedUser, user, onClick, usersTop, userAcc, name, updateUserNickname, id, email, purpose} = this.props;
  1060. const modal = (
  1061. <ModalRoot activeModal={this.state.activeModal}>
  1062. <ModalPage
  1063. id={MODAL_PAGE_FILTERS}
  1064. onClose={this.modalBack}
  1065. header={
  1066. <ModalPageHeader
  1067. right={<HeaderButton onClick={this.modalBack}><Icon24Dismiss className="CellIconCustom" /></HeaderButton>}
  1068. >
  1069. Дополнительно
  1070. </ModalPageHeader>
  1071. }
  1072. >
  1073. <Div>
  1074. <Button size="xl" onClick={this.addv} level="commerce">Добавить в сообщество</Button>
  1075. </Div>
  1076. <Div style={{display: 'flex'}}>
  1077. <Button size="l" onClick={() => openTab("https://vk.com/supp_fastclick")} stretched level="secondary" style={{ marginRight: 8 }}>Поддержка</Button>
  1078. <Button size="l" onClick={() => openTab("https://vk.com/fast__click")} stretched level="secondary">Группа</Button>
  1079. </Div>
  1080. </ModalPage>
  1081.  
  1082.  
  1083. </ModalRoot>
  1084. );
  1085. return (
  1086. <View popout={this.state.popout} activePanel={this.state.activePanel}>
  1087. <Home id="home" modal={modal} this={this} addv={this.addv} add1={this.add1} userAcc={this.state.userAcc} dark={this.dark} light={this.light} clicks={this.state.clicks} speed={this.state.speed} aspeed={this.state.aspeed} reputation={this.state.reputation} name={this.name} fetchedUser={this.state.fetchedUser} go={this.go} />
  1088. <Persik id="persik" go={this.go} name={this.name} fetchedUser={this.state.fetchedUser} userAcc={this.state.userAcc} />
  1089. <Transfer id="Transfer" go={this.go} clicks={this.state.clicks} handleTransferChange={this.handleTransferChange} handleTransferSubmit={this.handleTransferSubmit} userAcc={this.state.userAcc} />
  1090. <House id="house" go={this.go} buy={this.buyHouse} />
  1091. <Imus id="imus" go={this.go} />
  1092. <MyHouse id="myHouse" go={this.go} userAcc={this.state.userAcc} sell={this.sellHouse} pohod={this.pohodHouse} />
  1093. <MyPet id="myPet" go={this.go} userAcc={this.state.userAcc} sell={this.sellPet} pohod={this.pohodPet} />
  1094. <Upgrade id="upgrades" userAcc={this.state.userAcc} sell={this.sellHouse} pohod={this.pohodHouse} buy={this.buyHouse} upgradesOne={this.state.upgradesOne} upgradesTwo={this.state.upgradesTwo} go={this.go} activeTab={this.state.activeTabUpgrades} setTab={this.setActiveTabUpgrades} buyUpgrade={this.buyUpgrade} />
  1095. <Pet id="pet" go={this.go} buy={this.buyPet} />
  1096. <Dop id="dop" go={this.go} />
  1097. <Top id="top" go={this.go} usersTop={this.state.usersTop} groupsTop={this.state.groupsTop} activeTab={this.state.activeTabTop} setTab={this.setActiveTabTop} />
  1098. <Reit id="reit" clicks={this.state.clicks} reputation={this.state.reputation} go={this.go} handleReputationChange={this.handleReputationChange} handleReputationSubmit={this.handleReputationSubmit} calcRep={this.state.calcRep} />
  1099. <Sett id="sett" go={this.go} dark={this.dark} light={this.light} />
  1100. <ChangeNickname id="changeNickname" go={this.go} handleNickChange={this.handleNickChange} handleNickSubmit={this.handleNickSubmit} userAcc={this.state.userAcc} />
  1101. <Katalog id="katalog" go={this.go} />
  1102. </View>
  1103. );
  1104. }
  1105. }
  1106.  
  1107. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement