field.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {
  2. http,
  3. Method
  4. } from '@/utils/request.js';
  5. // 使用storage模块的方法设置登录状态为false
  6. import storage from "@/utils/storage.js";
  7. const request = http.request;
  8. /**
  9. * 获取用户关联的地块列表
  10. * @param {number} pageNum - 页码
  11. * @param {number} pageSize - 每页数量
  12. * @returns {Promise}
  13. */
  14. export function fetchUserFieldList(pageNum = 1, pageSize = 10) {
  15. const user = storage.getUserInfo();
  16. return http.request({
  17. url: 'uniapp/field/list/user',
  18. method: Method.POST,
  19. data: {
  20. userId: user.userId,
  21. params: {
  22. pageNum: pageNum,
  23. pageSize: pageSize
  24. }
  25. }
  26. });
  27. }
  28. /**
  29. * 获取当前登录用户默认地块
  30. */
  31. export function getUserCurrentField() {
  32. const user = storage.getUserInfo();
  33. return http.request({
  34. url: `uniapp/field/current/user/${user.userId}`,
  35. method: Method.GET,
  36. });
  37. }
  38. /**
  39. * 根据当前登录用户搜索关联地块
  40. * @param keyWord 搜索关键词
  41. */
  42. export function searchUserField(data) {
  43. console.log("da",data);
  44. const user = storage.getUserInfo();
  45. return http.request({
  46. url: 'uniapp/field/search/user',
  47. method: Method.POST,
  48. data:{
  49. userId: user.userId,
  50. params: {
  51. keyword:data.keyword,
  52. pageNum: data.pageNum,
  53. pageSize: data.pageSize
  54. }
  55. }
  56. });
  57. }
  58. /**
  59. * 根据当前登录用户统计地块信息
  60. */
  61. export function countUserPlots() {
  62. const user = storage.getUserInfo();
  63. return http.request({
  64. url: `uniapp/field/count/${user.userId}`,
  65. method: Method.GET,
  66. });
  67. }