accountConfig.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="list">
  3. <view v-if="false">
  4. <view
  5. v-for="(item, key) in serverList"
  6. :key="key"
  7. class="card"
  8. @click="handleSwitchServer(item)"
  9. >
  10. {{ item }}
  11. </view>
  12. </view>
  13. <view class="form">
  14. <div class="row">
  15. <text style="height: 40px;line-height: 40px;">协议</text>
  16. <input v-model="form.deal" placeholder="请输入协议" style="height: 40px;line-height: 40px;">
  17. </div>
  18. <div class="row">
  19. <text style="height: 40px;line-height: 40px;">IP</text>
  20. <input v-model="form.ip" placeholder="请输入IP" style="height: 40px;line-height: 40px;">
  21. </div>
  22. <div class="row">
  23. <text style="height: 40px;line-height: 40px;">端口</text>
  24. <input v-model="form.port" placeholder="请输入端口" style="height: 40px;line-height: 40px;">
  25. </div>
  26. </view>
  27. <view
  28. class="card-list-item"
  29. style="margin: 12px 0;display: grid;grid-template-columns: 1fr;grid-template-rows: 1fr;"
  30. >
  31. <button
  32. type="primary"
  33. style="width: calc(100% - 8px);margin: 0 4px;"
  34. @click="handleSaveServerConfig"
  35. >保存配置</button>
  36. <button
  37. type="primary"
  38. style="width: calc(100% - 8px);margin: 4px;"
  39. @click="handleReadServerConfig"
  40. >读取配置</button>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. getFileStorage,
  47. setFileStorage
  48. } from '@/unit/fileStorage.js'
  49. export default {
  50. data() {
  51. return {
  52. form: {
  53. port: '',
  54. ip: '',
  55. deal: ''
  56. }
  57. // url: 'http://47.107.70.17:48080', // 测试环境'
  58. // url: 'http://113.105.183.190:48081', // UAT
  59. // url: 'http://218.2.10.30:48080', // 生产环境
  60. }
  61. },
  62. mounted() {
  63. // this.handleReadServerConfig();
  64. },
  65. methods: {
  66. goHome: function() {
  67. uni.navigateTo({
  68. url: '/pages/login/loginPage'
  69. })
  70. },
  71. handleSwitchServer: function(item) {
  72. uni.$baseUrl = item
  73. },
  74. handleReadServerConfig: function() {
  75. // #ifdef APP-PLUS
  76. getFileStorage('serverConfig.txt')
  77. .then(data => {
  78. if (data == null) {
  79. this.form = {
  80. port: '',
  81. ip: '',
  82. deal: ''
  83. }
  84. } else {
  85. Object.assign(this.form, JSON.parse(data))
  86. }
  87. })
  88. // #endif
  89. },
  90. handleSaveServerConfig: function() {
  91. // #ifdef APP-PLUS
  92. setFileStorage('serverConfig.txt', 0, this.form)
  93. // #endif
  94. uni.$baseUrl = this.form.deal + '://' + this.form.ip + ':' + this.form.port
  95. uni.showToast({
  96. title: '保存成功,当前服务为:' + uni.$baseUrl,
  97. duration: 1000,
  98. icon: 'none'
  99. })
  100. setTimeout(() => {
  101. uni.navigateTo({
  102. url: '/pages/login/loginPage'
  103. })
  104. }, 600)
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. uni-page {
  111. background-color: gray;
  112. }
  113. .gui-header-leader-btns {
  114. color: white;
  115. font-size: 24px !important;
  116. margin-left: 24rpx;
  117. }
  118. .list {
  119. .card {
  120. height: 35px;
  121. line-height: 35px;
  122. margin: 4px 12px;
  123. padding: 0 8px;
  124. border-radius: 8px;
  125. font-size: 14px;
  126. font-weight: bold;
  127. font-family: Arial, Helvetica, sans-serif;
  128. background-color: skyblue;
  129. }
  130. }
  131. .form {
  132. height: calc(100vh - 120px);
  133. background-color: #e9e9ea;
  134. .row {
  135. height: 80px;
  136. padding: 0 12px 4px 12px;
  137. margin-bottom: 2px;
  138. background-color: white;
  139. uni-text:nth-of-type(1) {
  140. font-size: 16px;
  141. font-weight: bold;
  142. height: 40px;
  143. line-height: 40px;
  144. }
  145. }
  146. }
  147. </style>