ipConfig.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="zai-box">
  3. <scroll-view scroll-y class="page">
  4. <view class="IPSet">
  5. <span class="text-style"><u-button :plain="true" color="#18a5ff" size="small" :text="IPSet ? IPSet : '选择IP地址'"
  6. @tap="changeIP()"></u-button></span>
  7. <u-picker :show="ipShow" :columns="IpConfig" @cancel="ipShow = false" @confirm="selectIpAddr"
  8. keyName="label"></u-picker>
  9. </view>
  10. </scroll-view>
  11. </view>
  12. </template>
  13. <script>
  14. import configService from "@/common/service/config.service.js";
  15. export default {
  16. data() {
  17. return {
  18. ipShow: false,
  19. IPSet: "",
  20. IpConfig: [
  21. [
  22. { label: "大海则煤矿", value: "http://172.16.53.16:9999" },
  23. { label: "大柳塔井", value: "http://10.248.135.10:9999" },
  24. { label: "活鸡兔井", value: "http://10.248.135.121:9999" },
  25. { label: "寸草塔二矿", value: "http://10.246.63.5:9999" },
  26. { label: "乌兰木伦", value: "http://10.246.183.35:9999" },
  27. { label: "哈拉沟煤矿", value: "http://10.248.223.12:9999" },
  28. { label: "布尔台", value: "http://10.246.95.4:9999" },
  29. { label: "上湾", value: "http://10.246.167.205:9999" },
  30. { label: "锦界", value: "http://10.248.151.42:9999" },
  31. { label: "补连塔", value: "http://10.246.175.16:9999" },
  32. { label: "寸草塔", value: "http://10.246.23.171:9999" },
  33. { label: "柳塔", value: "http://10.246.87.121:9999" },
  34. { label: "石圪台", value: "http://10.246.191.13:9999" },
  35. { label: "榆家梁", value: "http://10.248.143.211:9999" },
  36. { label: "开发", value: "http://182.92.126.35:9999" },
  37. { label: "测试", value: "http://182.92.126.35:9998" },
  38. ],
  39. ],
  40. fromSetting: false, // 是否来自设置页
  41. ip: "",
  42. };
  43. },
  44. onLoad(options) {
  45. this.fromSetting = options.from === "settings"; // 判断来源
  46. this.ip = uni.getStorageSync("serverIP") || ""; // 读取已存IP
  47. },
  48. computed: {},
  49. methods: {
  50. selectIpAddr(e) {
  51. this.ipShow = false;
  52. this.ip = e.value[0].value;
  53. const fullURL = e.value[0].value;
  54. this.IPSet = e.value[0].label;
  55. configService.apiUrl = fullURL;
  56. uni.setStorageSync("selectedIP", true);
  57. uni.setStorageSync("apiUrl", fullURL);
  58. uni.setStorageSync("savedIP", true);
  59. // uni.showModal({
  60. // title: "提示",
  61. // content: fullURL,
  62. // cancelText: "取消",
  63. // confirmText: "确认",
  64. // });
  65. uni.redirectTo({
  66. url: "/pages/login/login?reload=" + 1,
  67. });
  68. },
  69. changeIP() {
  70. this.ipShow = true;
  71. },
  72. },
  73. beforeDestroy() { },
  74. };
  75. </script>
  76. <style>
  77. .login-paddingtop {
  78. padding-top: 300upx;
  79. }
  80. .zai-box {
  81. height: 100vh;
  82. background-image: url(/static/desk-img/loginBg.png);
  83. background-size: cover;
  84. padding: 0 20upx;
  85. padding-top: 100upx;
  86. position: relative;
  87. }
  88. .zai-logo {
  89. width: 200upx;
  90. height: 150px;
  91. }
  92. .zai-title {
  93. margin-top: 20upx;
  94. font-size: 58upx;
  95. color: #000000;
  96. text-align: center;
  97. }
  98. .input-placeholder,
  99. .zai-input {
  100. color: #94afce;
  101. }
  102. .zai-btn {
  103. background: #ff65a3;
  104. color: #fff;
  105. border: 0;
  106. border-radius: 100upx;
  107. font-size: 36upx;
  108. }
  109. .zai-btn:after {
  110. border: 0;
  111. }
  112. /*按钮点击效果*/
  113. .zai-btn.button-hover {
  114. transform: translate(1upx, 1upx);
  115. }
  116. .IPSet {
  117. display: flex;
  118. flex-direction: column;
  119. }
  120. .text-style {
  121. margin: 20px;
  122. }
  123. </style>