developerTools.js 2.8 KB

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