app.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import apiUrl from './common/api.js'
  2. import numfn from "./common/common"
  3. App({
  4. globaldata: {
  5. corpId: "",
  6. serverurl: 'https://rismanage3.pacsonline.cn',
  7. authCode: '',
  8. apiUrl: apiUrl
  9. },
  10. // 封装网络请求
  11. https(httpstype, url, data, type) {
  12. dd.showLoading();
  13. let endurl;
  14. let headers = {}
  15. endurl = encodeURI(this.globaldata.serverurl + url);
  16. headers = {
  17. "Content-Type": 'application/json;charset=utf-8',
  18. Authorization: 'Bearer ' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI1ZDVjOTkwODY1NmZmODAwYTE3ZTExNzUiLCJyYW5kb20iOiJjNjJhNWE2ZDk3OTliMTE1IiwidXNlcm5hbWUiOiLnlJjkuJzkuJwiLCJpYXQiOjE1NjY0NDE4OTR9.LZFdeYmNUCes-xF2HdFIGER4xVddDYn4RvtI3n1kLzs'
  19. }
  20. return new Promise((resolve, reject) => {
  21. dd.httpRequest({
  22. headers: headers,
  23. url: endurl,
  24. method: httpstype,
  25. data: data,
  26. dataType: 'json',
  27. success: (res) => {
  28. if (res.data.msg && res.data.msg != 'ok') {
  29. dd.showToast({
  30. content: res.data.msg,
  31. duration: 3000
  32. });
  33. return
  34. }
  35. resolve(res)
  36. },
  37. fail: (res) => {
  38. reject(res)
  39. },
  40. complete: (res) => {
  41. dd.hideLoading()
  42. }
  43. })
  44. })
  45. },
  46. onLaunch(options) {
  47. // 第一次打开
  48. // debugger
  49. // options.query == {number:1}
  50. this.globaldata.corpId = options.query.corpId;
  51. console.info('App onLaunch');
  52. },
  53. onShow(options) {
  54. // 从后台被 scheme 重新打开
  55. // options.query == {number:1}
  56. },
  57. });