developerTools.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. let _Http = getApp().globalData.http
  2. Page({
  3. data: {
  4. verification: false,
  5. password: ""
  6. },
  7. onLoad(options) {
  8. if (_Http.ENV != 'develop') {
  9. this.setData({
  10. verification: true
  11. })
  12. } else {
  13. this.init();
  14. }
  15. this.setData({
  16. logins: wx.getStorageSync('logins') || []
  17. })
  18. },
  19. init() {
  20. this.setData({
  21. runtimeEnvironment: _Http.ENV == 'develop' ? '开发环境' : '生产环境',
  22. "baseUrl": _Http.baseUrl,
  23. urls: _Http.urls,
  24. verification: false
  25. })
  26. },
  27. onInput(e) {
  28. this.setData({
  29. password: e.detail
  30. })
  31. },
  32. enterInto() {
  33. if (this.data.password != 'jxys@12345') return wx.showToast({
  34. title: '密码错误',
  35. icon: "none"
  36. })
  37. this.init()
  38. },
  39. onChange({
  40. detail
  41. }) {
  42. console.log(detail)
  43. let that = this;
  44. wx.showModal({
  45. title: getApp().globalData.Language.getMapText('提示'),
  46. content: `是否确定将服务地址修改为“${detail}”?`,
  47. cancelText: getApp().globalData.Language.getMapText('取消'),
  48. confirmText: getApp().globalData.Language.getMapText('确定'),
  49. complete: (res) => {
  50. if (res.cancel) that.setData({
  51. baseUrl: that.data.baseUrl
  52. })
  53. if (res.confirm) {
  54. that.setData({
  55. baseUrl: detail
  56. })
  57. _Http.baseUrl = detail;
  58. wx.showToast({
  59. title: getApp().globalData.Language.getMapText('修改成功'),
  60. })
  61. }
  62. }
  63. })
  64. },
  65. quickLogin(e) {
  66. let {
  67. item
  68. } = e.currentTarget.dataset, page = getCurrentPages()[0].selectComponent("#login"), that = this;
  69. if (item.baseUrl != _Http.baseUrl) {
  70. wx.showModal({
  71. title: '提示',
  72. content: `是否确定将服务地址修改为“${item.baseUrl}”?`,
  73. cancelText: "取消",
  74. confirmText: "确定登录",
  75. complete: (res) => {
  76. if (res.confirm) {
  77. that.setData({
  78. baseUrl: item.baseUrl
  79. })
  80. _Http.baseUrl = item.baseUrl;
  81. page.setData({
  82. ...item
  83. })
  84. page.allowOrNot();
  85. page.handleLogin();
  86. }
  87. }
  88. })
  89. } else {
  90. page.setData({
  91. ...item
  92. })
  93. page.allowOrNot();
  94. page.handleLogin();
  95. }
  96. }
  97. })