api.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {
  2. HTTP
  3. } from './Http.js'
  4. class ApiModel extends HTTP {
  5. loginbywechat(data) {
  6. return this.request({
  7. url: "/loginbywechat",
  8. data
  9. })
  10. }
  11. /* 登录 */
  12. login(data) {
  13. return this.request({
  14. url: "/loginbyaccount",
  15. data
  16. })
  17. }
  18. /* 验证码登录 */
  19. plogin(data) {
  20. return this.request({
  21. url: "/login",
  22. data
  23. })
  24. }
  25. /* 获取验证码 */
  26. getpassword(data) {
  27. return this.request({
  28. url: "/getpassword",
  29. data
  30. })
  31. }
  32. /* 有状态通用 */
  33. basic(data, loading = true) {
  34. data.accesstoken = wx.getStorageSync('userMsg').token;
  35. return this.request({
  36. url: "",
  37. data,
  38. loading
  39. })
  40. }
  41. /* 无状态 */
  42. base(data, loading = true) {
  43. return this.request({
  44. url: "",
  45. data,
  46. loading
  47. })
  48. }
  49. /* 退出登录 */
  50. logout() {
  51. let data = {
  52. accesstoken: wx.getStorageSync('userMsg').token
  53. }
  54. return this.request({
  55. url: "/logout",
  56. data
  57. })
  58. }
  59. /* 获取地区code */
  60. getLocationCode() {
  61. return this.request({
  62. url: "/getforward?url=" + encodeURIComponent("http://www.nmc.cn/rest/position"),
  63. data: {},
  64. method: "GET",
  65. header: {
  66. "Access-Control-Allow-Origin": "*"
  67. }
  68. })
  69. }
  70. }
  71. export {
  72. ApiModel
  73. }