index.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. const backIsTab = uni.getStorageSync('login_back_is_tab');
  88. uni.removeStorageSync('login_back_is_tab');
  89. if (backUrl) {
  90. if (backIsTab) {
  91. // tabBar 页面必须用 switchTab,redirectTo 无法跳转
  92. uni.switchTab({
  93. url: backUrl.split('?')[0],
  94. fail: function () {
  95. uni.switchTab({ url: '/pages/tidings/tidings' });
  96. }
  97. });
  98. } else {
  99. uni.redirectTo({
  100. url: backUrl,
  101. fail: function () {
  102. // redirectTo 失败(可能是 tabBar 页面),降级为 switchTab
  103. uni.switchTab({
  104. url: backUrl.split('?')[0],
  105. fail: function () {
  106. uni.switchTab({ url: '/pages/tidings/tidings' });
  107. }
  108. });
  109. }
  110. });
  111. }
  112. } else {
  113. uni.switchTab({ url: '/pages/tidings/tidings' });
  114. }
  115. uni.setStorage({
  116. key: DictCache.BASE_DATA_CACHE,
  117. data: response.data,
  118. success: function () {}
  119. });
  120. });
  121. // 获取登录人信息 这一步可以不用,移动端可以在使用用户的时候再获取,这个方法是留着渲染动态路由的
  122. getUserInfo().then(response => {
  123. uni.setStorage({
  124. key: 'userInfo',
  125. data: response.data,
  126. success: function () {
  127. resolve(res);
  128. }
  129. });
  130. });
  131. }
  132. });
  133. })
  134. .catch(err => reject(err));
  135. });
  136. }
  137. /**
  138. * fetch single func
  139. * parameter: { }
  140. * @param parameter
  141. * @returns {*}
  142. */
  143. export function fetchSbInfoIgnores(parameter) {
  144. return http({
  145. url: '/ignores/sb/' + parameter.id,
  146. method: 'get',
  147. headers: {
  148. 'Content-Type': 'application/json;charset=UTF-8'
  149. }
  150. });
  151. }
  152. /**
  153. * 更新设备图片
  154. */
  155. export function updateSbInfoImagesIgnores (parameter) {
  156. return http({
  157. url: '/ignores/sb/images/' + parameter.id,
  158. method: 'PUT',
  159. data: parameter
  160. })
  161. }
  162. /**
  163. * 添加报修
  164. */
  165. export function addRepairApplicationFormIgnores (parameter) {
  166. return http({
  167. url: '/ignores/repair/add',
  168. method: 'POST',
  169. headers: {
  170. 'Accept': 'application/json',
  171. 'Content-Type': 'application/json;charset=UTF-8'
  172. },
  173. data: parameter
  174. })
  175. }
  176. /**
  177. * page func
  178. * parameter: { }
  179. * @param parameter
  180. * @returns {*}
  181. */
  182. export function getSbTaskIgnores (parameter) {
  183. return http({
  184. url: '/ignores/sb/task2/' + parameter.id,
  185. method: 'get',
  186. headers: {
  187. 'Content-Type': 'application/json;charset=UTF-8'
  188. }
  189. })
  190. }
  191. // /**
  192. // * page func
  193. // * parameter: { }
  194. // * @param parameter
  195. // * @returns {*}
  196. // */
  197. // export function getSbTaskIgnores (parameter) {
  198. // return http({
  199. // url: '/ignores/sb/task/' + parameter.id,
  200. // method: 'get',
  201. // headers: {
  202. // 'Content-Type': 'application/json;charset=UTF-8'
  203. // }
  204. // })
  205. // }
  206. export function getCheckJobPageIgnores (parameter) {
  207. return http({
  208. url: '/ignores/check/sb/jobs/page?' + stringify(parameter),
  209. method: 'get',
  210. headers: {
  211. 'Content-Type': 'application/json;charset=UTF-8'
  212. }
  213. })
  214. }
  215. export function fetchCheckJobIgnores (parameter) {
  216. return http({
  217. url: '/ignores/check/jobs/' + parameter.id,
  218. method: 'get',
  219. headers: {
  220. 'Content-Type': 'application/json;charset=UTF-8'
  221. }
  222. })
  223. }
  224. export function executeJobIgnores (parameter) {
  225. return http({
  226. url: '/ignores/check/jobs/execute',
  227. method: 'PUT',
  228. data: parameter
  229. })
  230. }
  231. export function finishJobIgnores (parameter) {
  232. return http({
  233. url: '/ignores/check/jobs/finish',
  234. method: 'PUT',
  235. data: parameter
  236. })
  237. }
  238. /**
  239. * 添加设备状态变更记录
  240. */
  241. export function addSbStatusLogIgnores (parameter) {
  242. return http({
  243. url: '/ignores/sb/status-logs',
  244. method: 'POST',
  245. headers: {
  246. 'Accept': 'application/json',
  247. 'Content-Type': 'application/json;charset=UTF-8'
  248. },
  249. data: parameter
  250. })
  251. }
  252. export function getCheckJobDetail (parameter) {
  253. return http({
  254. url: '/check/jobs/getCheckJobVO/detail?' + stringify(parameter),
  255. method: 'get',
  256. headers: {
  257. 'Content-Type': 'application/json;charset=UTF-8'
  258. }
  259. })
  260. }
  261. export function getCheckJob (parameter) {
  262. return http({
  263. url: '/check/jobs/getCheckJobVO?' + stringify(parameter),
  264. method: 'get',
  265. headers: {
  266. 'Content-Type': 'application/json;charset=UTF-8'
  267. }
  268. })
  269. }