serveConfig.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view id="serveConfig">
  3. <view class="top">
  4. <u-icon name="arrow-left" size="17px" color="#000" :bold="true" @click="navigateTo"></u-icon>
  5. </view>
  6. <view class="content">
  7. <text class="title">设置服务器地址</text>
  8. <!-- <u-icon class="icons" name="scan" color="#2a98ff" size="22"></u-icon>
  9. <text class="setting" @tap="goSeverConfig"> 扫码添加 </text> -->
  10. </view>
  11. <view class="bottom">
  12. <u-input v-model="linkUrl" placeholder="服务器地址(必填)" border="none" clearable> </u-input>
  13. <u-button type="primary" style="width: 100%; height: 45px; font-size: 17px; margin-top: 20px" @click="handleSubmit()" shape="circle"> 保 存</u-button>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
  19. import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
  20. import publicStore from "@/store/modules/public.js";
  21. const newPublicStore = publicStore();
  22. const { proxy } = getCurrentInstance();
  23. const dataList = reactive({
  24. linkUrl: "", //链接地址
  25. });
  26. const uForm = ref(null);
  27. const { linkUrl } = toRefs(dataList);
  28. /**
  29. * @提交
  30. * @按钮点击事件
  31. */
  32. function handleSubmit() {
  33. if (!linkUrl.value) {
  34. proxy.$modal.msg("请输入链接地址");
  35. return;
  36. }
  37. if (!/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/.test(linkUrl.value)) {
  38. proxy.$modal.msg("请输入正确的链接地址");
  39. return;
  40. }
  41. newPublicStore.serveUrl = linkUrl.value;
  42. navigateTo();
  43. }
  44. /**
  45. * @跳转登录
  46. */
  47. function navigateTo() {
  48. uni.navigateTo({
  49. url: "/pages/login",
  50. });
  51. }
  52. onLoad((options) => {
  53. if (newPublicStore.serveUrl) {
  54. linkUrl.value = newPublicStore.serveUrl;
  55. }
  56. });
  57. </script>
  58. <style>
  59. body,
  60. uni-page-body,
  61. uni-page-refresh {
  62. background-color: #ffffff;
  63. }
  64. </style>
  65. <style lang="scss" scoped>
  66. #serveConfig {
  67. position: relative;
  68. z-index: 1;
  69. width: 100%;
  70. padding: 0 40px;
  71. margin: auto;
  72. padding-top: 20%;
  73. .top {
  74. }
  75. .content {
  76. display: flex;
  77. margin: 30px 0;
  78. .title {
  79. margin: auto auto auto 0;
  80. color: #000;
  81. font-size: 18px;
  82. }
  83. .icons {
  84. margin: auto 5px auto 0;
  85. }
  86. .setting {
  87. color: #2a98ff;
  88. margin: auto 0;
  89. }
  90. }
  91. .bottom {
  92. :deep(.u-input) {
  93. height: 45px;
  94. border-radius: 8px;
  95. padding: 5px 12px !important;
  96. border: 0 !important;
  97. // border-color: #000 !important;
  98. // border-color: gray !important;
  99. // background-color: rgba(255, 255, 255, 0.1) !important;
  100. background-color: #f5f6fa !important;
  101. }
  102. :deep(.input-placeholder) {
  103. color: #a0a4af;
  104. }
  105. :deep(.uni-input-wrapper) {
  106. font-size: 16px;
  107. }
  108. :deep(.u-input__content__field-wrapper__field) {
  109. height: 30px;
  110. line-height: 30px;
  111. }
  112. :deep(.uni-input-input) {
  113. // padding:8px
  114. }
  115. :deep(.u-line) {
  116. display: none !important;
  117. }
  118. }
  119. }
  120. </style>