server.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view class="content">
  3. <view class="logo">
  4. <!-- <image style="height:104rpx;width:104rpx" src="/static/czzn-img/login/logo.jpg" mode="aspectFit" /> -->
  5. <view class="app-name">{{$t('login.e')}}</view>
  6. </view>
  7. <view style="margin:0 auto;height:104rpx">
  8. <u-radio-group v-model="serverForm.type" >
  9. <!-- #ifndef MP-WEIXIN-->
  10. <u-radio name="1" :label="$t('base.common.tenant')"></u-radio>
  11. <!-- #endif -->
  12. <!-- #ifdef MP-WEIXIN-->
  13. <u-radio name="2" :label="$t('base.common.cloud')"></u-radio>
  14. <!-- #endif -->
  15. </u-radio-group>
  16. </view>
  17. <view class="inp_box">
  18. <view class="inp_box">
  19. <view @click="showPopup('popupServicePrefixName')" style="padding-left:10px">{{serverForm.prefix}}://
  20. </view>
  21. <input type="text" class="ip" v-model.trim="serverForm.ip" :placeholder="this.$t('login.ip')" />
  22. <input type="text" class="port" v-model.trim="serverForm.port" :placeholder="this.$t('login.port')" />
  23. </view>
  24. </view>
  25. <view class="btn-wrap">
  26. <button class="bind-btn" @click="submit('serverForm')">{{$t('base.common.submit')}}
  27. </button>
  28. </view>
  29. <PopupSelect ref="popupServicePrefixName" :hasSearch='false' style="width:100px" :option="serverPrefixList"
  30. @onConfirm="onServicePrefixConfirm" />
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. changeUrl
  36. } from '../../utils/config.js'
  37. import PopupSelect from '../../components/popup-select/index'
  38. export default {
  39. components: {
  40. PopupSelect
  41. },
  42. data() {
  43. return {
  44. time: 0,
  45. timer: '',
  46. isGetCode: false,
  47. option: [{
  48. text: '',
  49. value: 1,
  50. }],
  51. serverForm: {
  52. type: "2",
  53. ip: "",
  54. prefix: "http",
  55. port: "",
  56. },
  57. serverPrefixList: [{
  58. value: "http",
  59. text: "http"
  60. },
  61. {
  62. value: "https",
  63. text: "https"
  64. }
  65. ],
  66. }
  67. },
  68. onLoad(options) {
  69. if (uni.getStorageSync('server')) {
  70. this.serverForm = uni.getStorageSync('server')
  71. }
  72. //<!-- #ifndef MP-WEIXIN-->
  73. this.serverForm.type='1'
  74. //<!-- #endif -->
  75. },
  76. watch: {
  77. // "serverForm.type": function(item,oldItem) {
  78. // debugger
  79. // console.log(item,oldItem,this.serverForm.ip)
  80. // if (item == 2) {
  81. // if (this.serverForm.ip=="") {
  82. // this.serverForm.ip = 'https://saas.createtobest.com'
  83. // }
  84. // }
  85. // if(oldItem==2 && item==1){
  86. // this.serverForm.ip=""
  87. // }
  88. // }
  89. },
  90. methods: {
  91. showPopup(refs) {
  92. this.$refs[refs].showPicker = true
  93. },
  94. onServicePrefixConfirm(value) {
  95. var name = ''
  96. if (value.value) {
  97. name = value.value
  98. }
  99. this.serverForm.prefix = name
  100. },
  101. // onFormTypeChange(item) {
  102. // console.log("选择的信息为、", item);
  103. // //
  104. // if (item == 2) {
  105. // this.serverForm.ip = 'https://saas.createtobest.com'
  106. // } else {
  107. // if (uni.getStorageSync('serverAddress')) {
  108. // this.serverForm.ip = uni.getStorageSync('serverAddress')
  109. // if (this.serverForm.ip == "https://saas.createtobest.com") {
  110. // this.serverForm.ip = ""
  111. // }
  112. // } else {
  113. // this.serverForm.ip = ""
  114. // }
  115. // }
  116. // },
  117. backLogin() {
  118. changeUrl();
  119. uni.reLaunch({
  120. url: "/pages/login/login"
  121. })
  122. },
  123. submit() {
  124. console.log("输入的信息。", this.serverForm);
  125. if (!this.serverForm.ip) {
  126. uni.showToast({
  127. title: this.$t('login.ipPlaceholder'),
  128. icon: 'none',
  129. duration: 2000
  130. })
  131. return;
  132. }
  133. var address = this.serverForm.prefix + "://" + this.serverForm.ip;
  134. if (this.serverForm.port) {
  135. address = address + ":" + this.serverForm.port
  136. }
  137. uni.setStorageSync('server', this.serverForm);
  138. uni.setStorageSync('serverStatus', this.serverForm.type);
  139. uni.setStorageSync('serverAddress', address);
  140. uni.setStorageSync('serverPrefix', this.serverForm.type == 1 ? "/admin" : "/ymt");
  141. this.backLogin();
  142. }
  143. }
  144. }
  145. </script>
  146. <style>
  147. /* #ifndef APP-NVUE */
  148. view {
  149. display: flex;
  150. box-sizing: border-box;
  151. flex-direction: column;
  152. }
  153. page {
  154. box-sizing: border-box;
  155. padding: 0rpx 48rpx 80rpx;
  156. height: 100%;
  157. }
  158. /* #endif*/
  159. </style>
  160. <style lang="scss" scoped>
  161. @import '../../common/css/login.scss';
  162. .bgc {
  163. position: absolute;
  164. height: 77%;
  165. width: 160%;
  166. bottom: 0;
  167. left: -30%;
  168. z-index: -50;
  169. background-color: #4680F9;
  170. border-top-left-radius: 200px;
  171. border-top-right-radius: 200px;
  172. }
  173. </style>