ipConfig.vue 3.4 KB

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