ipConfig.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. {
  35. label: "大柳塔井",
  36. value: "http://10.248.135.10:9999",
  37. code: "dlt",
  38. },
  39. {
  40. label: "活鸡兔井",
  41. value: "http://10.248.135.121:9999",
  42. code: "hjt",
  43. },
  44. {
  45. label: "寸草塔二矿",
  46. value: "http://10.246.63.5:9999",
  47. code: "cctr",
  48. },
  49. {
  50. label: "乌兰木伦",
  51. value: "http://10.246.183.35:9999",
  52. code: "wlml",
  53. },
  54. {
  55. label: "哈拉沟煤矿",
  56. value: "http://10.248.223.12:9999",
  57. code: "hlg",
  58. },
  59. { label: "布尔台", value: "http://10.246.95.4:9999", code: "brt" },
  60. { label: "上湾", value: "http://10.246.167.205:9999", code: "sw" },
  61. { label: "锦界", value: "http://10.248.151.42:9999", code: "jj" },
  62. { label: "补连塔", value: "http://10.246.175.16:9999", code: "blt" },
  63. { label: "寸草塔", value: "http://10.246.23.171:9999", code: "cct" },
  64. { label: "柳塔", value: "http://10.246.87.121:9999", code: "lt" },
  65. { label: "石圪台", value: "http://10.246.191.13:9999", code: "sgt" },
  66. { label: "榆家梁", value: "http://10.248.143.211:9999", code: "yjl" },
  67. { label: "保德", value: "http://10.248.210.152:9999", code: "bd" },
  68. ],
  69. ],
  70. fromSetting: false, // 是否来自设置页
  71. ip: "",
  72. };
  73. },
  74. onLoad(options) {
  75. this.fromSetting = options.from === "settings"; // 判断来源
  76. this.ip = uni.getStorageSync("serverIP") || ""; // 读取已存IP
  77. },
  78. computed: {},
  79. methods: {
  80. selectIpAddr(e) {
  81. this.ipShow = false;
  82. this.ip = e.value[0].value;
  83. const fullURL = e.value[0].value;
  84. console.log(fullURL, "fullURL");
  85. const apicode = e.value[0].code;
  86. console.log(apicode, "9900");
  87. this.IPSet = e.value[0].label;
  88. configService.apiUrl = fullURL;
  89. uni.setStorageSync("selectedIP", true);
  90. uni.setStorageSync("apiCode", apicode);
  91. uni.setStorageSync("apiUrl", fullURL);
  92. // uni.showModal({
  93. // title: "提示",
  94. // content: fullURL,
  95. // cancelText: "取消",
  96. // confirmText: "确认",
  97. // });
  98. uni.redirectTo({
  99. url: "/pages/login/login?reload=" + 1,
  100. });
  101. },
  102. changeIP() {
  103. this.ipShow = true;
  104. },
  105. },
  106. beforeDestroy() {},
  107. };
  108. </script>
  109. <style>
  110. .login-paddingtop {
  111. padding-top: 300upx;
  112. }
  113. .zai-box {
  114. height: 100vh;
  115. background-image: url(/static/desk-img/loginBg.png);
  116. background-size: cover;
  117. padding: 0 20upx;
  118. padding-top: 100upx;
  119. position: relative;
  120. }
  121. .zai-logo {
  122. width: 200upx;
  123. height: 150px;
  124. }
  125. .zai-title {
  126. margin-top: 20upx;
  127. font-size: 58upx;
  128. color: #000000;
  129. text-align: center;
  130. }
  131. .input-placeholder,
  132. .zai-input {
  133. color: #94afce;
  134. }
  135. .zai-btn {
  136. background: #ff65a3;
  137. color: #fff;
  138. border: 0;
  139. border-radius: 100upx;
  140. font-size: 36upx;
  141. }
  142. .zai-btn:after {
  143. border: 0;
  144. }
  145. /*按钮点击效果*/
  146. .zai-btn.button-hover {
  147. transform: translate(1upx, 1upx);
  148. }
  149. .IPSet {
  150. display: flex;
  151. flex-direction: column;
  152. }
  153. .text-style {
  154. margin: 20px;
  155. }
  156. </style>