index.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import http, { takeBackUrl } from '@/utils/http';
  2. import DictCache from '@/utils/dict';
  3. import { stringify } from 'qs';
  4. /**
  5. * 忘记密码
  6. * page func
  7. * parameter: { }
  8. * @param parameter
  9. * @returns {*}
  10. */
  11. export function forgetPwd(parameter) {
  12. return http({
  13. url: '/ignores/forget-pwd',
  14. method: 'put',
  15. data: parameter
  16. });
  17. }
  18. /**
  19. * 获取图片验证码
  20. */
  21. export function getCode(data) {
  22. return http({
  23. url: '/service/sms/sendSms',
  24. method: 'POST',
  25. data
  26. });
  27. }
  28. /**
  29. * 获取用户详情,包括权限
  30. */
  31. export function getUserInfo() {
  32. return http({
  33. url: '/upms/users/info',
  34. method: 'get'
  35. });
  36. }
  37. /**
  38. * 获取用户详情
  39. */
  40. export function getUserInfoModel() {
  41. return http({
  42. url: '/upms/users/info/model',
  43. method: 'get'
  44. });
  45. }
  46. /**
  47. * 退出登录
  48. */
  49. export function userLogout() {
  50. return http({
  51. url: '/upms/users/logout',
  52. method: 'delete'
  53. });
  54. }
  55. /**
  56. * 获取数据词典
  57. */
  58. export function getDictData() {
  59. return http({
  60. url: '/upms/dicts/data',
  61. method: 'get'
  62. });
  63. }
  64. /**
  65. * 登录
  66. */
  67. export function mobileLogin(data) {
  68. return new Promise((resolve, reject) => {
  69. http({
  70. url: '/oauth/token',
  71. method: 'GET',
  72. data
  73. })
  74. .then(res => {
  75. // 存入用户信息
  76. // 获取用户信息
  77. // TODO future 没有做容错,完成再调试
  78. // 存入token
  79. uni.setStorage({
  80. key: 'accessToken',
  81. data: res.data.access_token,
  82. success: function () {
  83. // 获取词典
  84. getDictData().then(response => {
  85. // 登录前由操作拦截/401 记录了来源页(如扫码进入的设备详情),优先回跳,避免用户重新扫码
  86. const backUrl = takeBackUrl();
  87. if (backUrl) {
  88. uni.redirectTo({
  89. url: backUrl,
  90. fail: function () {
  91. uni.switchTab({ url: '/pages/tidings/tidings' });
  92. }
  93. });
  94. } else {
  95. uni.switchTab({ url: '/pages/tidings/tidings' });
  96. }
  97. uni.setStorage({
  98. key: DictCache.BASE_DATA_CACHE,
  99. data: response.data,
  100. success: function () {}
  101. });
  102. });
  103. // 获取登录人信息 这一步可以不用,移动端可以在使用用户的时候再获取,这个方法是留着渲染动态路由的
  104. getUserInfo().then(response => {
  105. uni.setStorage({
  106. key: 'userInfo',
  107. data: response.data,
  108. success: function () {
  109. resolve(res);
  110. }
  111. });
  112. });
  113. }
  114. });
  115. })
  116. .catch(err => reject(err));
  117. });
  118. }
  119. /**
  120. * fetch single func
  121. * parameter: { }
  122. * @param parameter
  123. * @returns {*}
  124. */
  125. export function fetchSbInfoIgnores(parameter) {
  126. return http({
  127. url: '/ignores/sb/' + parameter.id,
  128. method: 'get',
  129. headers: {
  130. 'Content-Type': 'application/json;charset=UTF-8'
  131. }
  132. });
  133. }
  134. /**
  135. * 更新设备图片
  136. */
  137. export function updateSbInfoImagesIgnores (parameter) {
  138. return http({
  139. url: '/ignores/sb/images/' + parameter.id,
  140. method: 'PUT',
  141. data: parameter
  142. })
  143. }
  144. /**
  145. * 添加报修
  146. */
  147. export function addRepairApplicationFormIgnores (parameter) {
  148. return http({
  149. url: '/ignores/repair/add',
  150. method: 'POST',
  151. headers: {
  152. 'Accept': 'application/json',
  153. 'Content-Type': 'application/json;charset=UTF-8'
  154. },
  155. data: parameter
  156. })
  157. }
  158. /**
  159. * page func
  160. * parameter: { }
  161. * @param parameter
  162. * @returns {*}
  163. */
  164. export function getSbTaskIgnores (parameter) {
  165. return http({
  166. url: '/ignores/sb/task2/' + parameter.id,
  167. method: 'get',
  168. headers: {
  169. 'Content-Type': 'application/json;charset=UTF-8'
  170. }
  171. })
  172. }
  173. // /**
  174. // * page func
  175. // * parameter: { }
  176. // * @param parameter
  177. // * @returns {*}
  178. // */
  179. // export function getSbTaskIgnores (parameter) {
  180. // return http({
  181. // url: '/ignores/sb/task/' + parameter.id,
  182. // method: 'get',
  183. // headers: {
  184. // 'Content-Type': 'application/json;charset=UTF-8'
  185. // }
  186. // })
  187. // }
  188. export function getCheckJobPageIgnores (parameter) {
  189. return http({
  190. url: '/ignores/check/sb/jobs/page?' + stringify(parameter),
  191. method: 'get',
  192. headers: {
  193. 'Content-Type': 'application/json;charset=UTF-8'
  194. }
  195. })
  196. }
  197. export function fetchCheckJobIgnores (parameter) {
  198. return http({
  199. url: '/ignores/check/jobs/' + parameter.id,
  200. method: 'get',
  201. headers: {
  202. 'Content-Type': 'application/json;charset=UTF-8'
  203. }
  204. })
  205. }
  206. export function executeJobIgnores (parameter) {
  207. return http({
  208. url: '/ignores/check/jobs/execute',
  209. method: 'PUT',
  210. data: parameter
  211. })
  212. }
  213. export function finishJobIgnores (parameter) {
  214. return http({
  215. url: '/ignores/check/jobs/finish',
  216. method: 'PUT',
  217. data: parameter
  218. })
  219. }
  220. /**
  221. * 添加设备状态变更记录
  222. */
  223. export function addSbStatusLogIgnores (parameter) {
  224. return http({
  225. url: '/ignores/sb/status-logs',
  226. method: 'POST',
  227. headers: {
  228. 'Accept': 'application/json',
  229. 'Content-Type': 'application/json;charset=UTF-8'
  230. },
  231. data: parameter
  232. })
  233. }
  234. export function getCheckJobDetail (parameter) {
  235. return http({
  236. url: '/check/jobs/getCheckJobVO/detail?' + stringify(parameter),
  237. method: 'get',
  238. headers: {
  239. 'Content-Type': 'application/json;charset=UTF-8'
  240. }
  241. })
  242. }
  243. export function getCheckJob (parameter) {
  244. return http({
  245. url: '/check/jobs/getCheckJobVO?' + stringify(parameter),
  246. method: 'get',
  247. headers: {
  248. 'Content-Type': 'application/json;charset=UTF-8'
  249. }
  250. })
  251. }