common.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { setResources, setConfigs } from "@/store/common";
  2. import { API_CONFIGS, API_DEL_SESSION, API_GLOBAL_CONFIGS, API_STATIC_RESOURCES, API_SYSTEM_VERSION, API_UPLOAD_SESSION, API_USER_CLIENT, API_USER_LOCATION, APP_VERSION } from "./http/api";
  3. import { request } from "./http/request";
  4. import Taro from "@tarojs/taro";
  5. export const staticResources = () => (dispatch: any) => {
  6. request({
  7. url: API_STATIC_RESOURCES, method: 'GET', data: {}
  8. }).then(res => {
  9. // resolve(res);
  10. dispatch(setResources(res));
  11. })
  12. }
  13. export const systemVersion = () => {
  14. return new Promise((resolve, reject) => {
  15. var platform = Taro.getSystemInfoSync().platform == 'ios'?'IOS':'ANDROID'
  16. request({
  17. url: API_SYSTEM_VERSION + platform, method: 'GET', data: {}
  18. }).then(res => {
  19. resolve(res)
  20. }).catch(e => {
  21. reject(e)
  22. })
  23. })
  24. }
  25. export const gobalConfigs = () => (dispatch: any) => {
  26. request({
  27. url: API_GLOBAL_CONFIGS, method: 'GET', data: {
  28. keys: 'time_duration'
  29. }
  30. }).then(res => {
  31. // resolve(res);
  32. dispatch(setConfigs(res));
  33. })
  34. }
  35. export const clientInfo = (params) => {
  36. request({
  37. url: API_USER_CLIENT, method: 'POST', data: {
  38. ...params
  39. }
  40. }).then(res => {
  41. })
  42. }
  43. export const getConfigs = (params) => (dispatch: any) => {
  44. request({
  45. url: API_CONFIGS, method: 'GET', data: {
  46. keys: 'time_duration'
  47. }
  48. }).then(res => {
  49. // resolve(res);
  50. dispatch(setConfigs(res));
  51. })
  52. }
  53. export const uploadSessionKey = (params) => {
  54. request({
  55. url: API_UPLOAD_SESSION, method: 'POST', data: {
  56. ...params
  57. }
  58. }).then(res => {
  59. })
  60. }
  61. export const systemLocation = (params) => {
  62. return new Promise((resolve, reject) => {
  63. request({
  64. url: API_USER_LOCATION, method: 'POST', data: {
  65. ...params
  66. }
  67. }).then(res => {
  68. resolve(res)
  69. // dispatch(loginSuccess(res));
  70. }).catch(e => {
  71. reject(e)
  72. })
  73. })
  74. }
  75. export const delSession = (params) => {
  76. request({
  77. url: API_DEL_SESSION + '?type=WX_MP', method: 'DELETE', data: {
  78. ...params
  79. }
  80. }).then(_ => {
  81. Taro.showToast({
  82. title: '重置成功',
  83. icon: 'success',
  84. duration: 2000
  85. })
  86. })
  87. }