developerTools.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. },
  16. init() {
  17. this.setData({
  18. runtimeEnvironment: _Http.ENV == 'develop' ? '开发环境' : '生产环境',
  19. "baseUrl": _Http.baseUrl,
  20. urls: _Http.urls,
  21. verification: false
  22. })
  23. },
  24. onInput(e) {
  25. this.setData({
  26. password: e.detail
  27. })
  28. },
  29. enterInto() {
  30. if (this.data.password != 'jxys@12345') return wx.showToast({
  31. title: '密码错误',
  32. icon: "none"
  33. })
  34. this.init()
  35. },
  36. onChange({
  37. detail
  38. }) {
  39. console.log(detail)
  40. let that = this;
  41. wx.showModal({
  42. title: '提示',
  43. content: `是否确定将服务地址修改为“${detail}”?`,
  44. complete: (res) => {
  45. if (res.cancel) that.setData({
  46. baseUrl: that.data.baseUrl
  47. })
  48. if (res.confirm) {
  49. that.setData({
  50. baseUrl: detail
  51. })
  52. _Http.baseUrl = detail;
  53. wx.showToast({
  54. title: '修改成功',
  55. })
  56. }
  57. }
  58. })
  59. }
  60. })