common.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. const { request } = require('./request')
  2. /**
  3. * 获取验证码
  4. * @param obj
  5. * @returns {Promise<unknown>}
  6. */
  7. export const sendCode = (obj) => request({
  8. url: '/api/send/code',
  9. method: 'POST',
  10. data: {
  11. 'phone': obj.phone, // 手机号码
  12. 'type': obj.type // 1注册2登录3修改密码
  13. },
  14. showLoading: false
  15. })
  16. /**
  17. * 小程序手机号登录
  18. * @param obj
  19. * @returns {Promise<*>}
  20. */
  21. export const miniPhoneLogin = (obj) => request({
  22. url: '/api/user/mini/phone/login',
  23. method: 'POST',
  24. data: {
  25. 'code': obj.wxCode, // 小程序授权code
  26. 'user_phone': obj.cellphone, // 手机号
  27. 'user_code': obj.code // 验证码
  28. },
  29. showLoading: false
  30. })
  31. /**
  32. * 小程序原生登录
  33. * @param obj
  34. * @returns {Promise<*>}
  35. */
  36. export const miniLogin = (obj) => request({
  37. url: '/api/user/mini/login',
  38. method: 'POST',
  39. data: {
  40. 'code': obj.wxCode, // 小程序授权code
  41. 'encryptedData': obj.encryptedData, // 加密数据
  42. 'iv': obj.iv // iv
  43. }
  44. })
  45. /**
  46. * 获取用户信息
  47. * @returns {Promise<unknown>}
  48. */
  49. export const getUserInfo = () => request({
  50. url: '/api/user/info',
  51. method: 'POST',
  52. showLoading: false
  53. }, false)
  54. /**
  55. * 更新用户信息
  56. * @param obj
  57. * @returns {Promise<unknown>}
  58. */
  59. export const updateUserInfo = (obj) => request({
  60. url: '/api/user/update/info',
  61. method: 'POST',
  62. data: {
  63. // 'user_nickname': 'sd', // 用户昵称
  64. // 'user_head_img_url': 'sdsff', // 用户头像
  65. // 'user_sex': 1, // 性别(1男2女)
  66. // 'user_address': 'sdsdsdsugddug', // 地址
  67. ...obj
  68. },
  69. showLoading: true
  70. })
  71. /**
  72. * 用户退出登录接口
  73. * @returns {Promise<unknown>}
  74. */
  75. export const userLoginOut = () => request({
  76. url: '/api/user/login/out',
  77. method: 'POST',
  78. showLoading: false
  79. })
  80. /**
  81. * 商品分类
  82. * @returns {Promise<*>}
  83. */
  84. export const getProductCategoryList = () => request({
  85. url: '/api/shop/product/category/list',
  86. method: 'POST',
  87. showLoading: true
  88. })
  89. /**
  90. * 商品品牌
  91. * @returns {Promise<*>}
  92. */
  93. export const getProductBrandList = () => request({
  94. url: '/api/shop/product/brand/list',
  95. method: 'POST',
  96. showLoading: true
  97. })
  98. /**
  99. * 供应商详情
  100. * @param shopId
  101. * @returns {Promise<*>}
  102. */
  103. export const getShopDetail = (shopId) => request({
  104. url: '/api/user/home/shop/detail',
  105. method: 'POST',
  106. data: {
  107. shop_id: shopId
  108. },
  109. showLoading: true
  110. })
  111. /**
  112. * 系统配置
  113. * @returns {Promise<*>}
  114. */
  115. export const getSystemConfig = () => request({
  116. url: '/api/system/config',
  117. method: 'POST',
  118. showLoading: false
  119. }, false)