guoyujie
7 天以前 f398ddd14530d2f0695865c8a4dede6205d91d09
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
    <view class="content" >
        <image class="logo" src="/static/favicon.ico"></image>
        <view class="text-area">
            <text class="title">NorthGlass_Scaner 初始化</text>
        </view>
        
        <view class="text-area" >
            <uni-easyinput
                class='input_1'
                style="text-align: center;"
                placeholder="请输入服务器ip" 
                :passwordIcon='false'
                v-model.trim="ipVal" 
                type="input" />
                
        </view>
        <view class="text-area" >
            <uni-easyinput
                class='input_1'
                style="text-align: center;"
                placeholder="请输入端口号" 
                :passwordIcon='false'
                v-model="portVal" 
                type="number" />
        </view>
        
        <view class="text-area" >
            <button @click="save" type="primary" size="mini">保存</button>
        </view>
        
        <view>
            <!-- 提示信息弹窗 -->
            <uni-popup ref="message" type="message">
                <uni-popup-message :type="msgType" :message="messageText" :duration="2000" />
            </uni-popup>
        </view>
    </view>
</template>
 
<script  setup>
    import {onMounted, reactive,ref} from "vue"
  import userInfo from '@/stores/userInfo'
    import request from '@/utils/request'
    import {ip,webPort} from '@/utils/config.js'
        import { debounce } from 'lodash'
    
  const store=userInfo()
    let searchUserList = ref({
        userName:null
    })
    let users = ref([])
    const message = ref(null)
    const type=ref('center')
    const msgType=ref('success')
    const messageText=ref('')
    const viewShow = ref(false)
    let ipVal = ref(null)
    let portVal = ref(null)
    
    onMounted(() => {
        
        if(uni.getStorageSync('port') === ""){
            portVal.value = 8086
        }else{
            portVal.value = uni.getStorageSync('port')
        }
    })
    
    
    
    //提示打开
    const messageToggle = (type,msg) =>{
        msgType.value = type
        messageText.value = msg
        message.value.open()
    }
    
    
    // const changeIP =async () => {
    //     const ipRegex = /^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
    //     if(ipRegex.test(ipVal.value)){
    //         await uni.setStorageSync('ip', ipVal.value);
    //         plus.runtime.restart()
            
    //     }else{
    //         messageToggle('error','请输入IP范围:0.0.0.0~255.255.255.255')
    //     }
    // }
 
const save = debounce(async() => {
    if(portVal.value === null || portVal.value === "" || ipVal === null || ipVal === ""){
         messageToggle('error','ip或端口号不能为空')
         return
    }
    await uni.setStorageSync('ip', ipVal.value);
    await uni.setStorageSync('port', portVal.value);
    plus.runtime.restart()
    
},200)
</script>
 
<style>
    /* .login{
        width: 100px;height: 45px;margin: 0 auto;
    } */
    .content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        margin-top: -30%;
    }
 
    .logo {
        height: 200rpx;
        width: 200rpx;
        margin-top: 200rpx;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 50rpx;
    }
 
    .text-area {
        display: flex;
        justify-content: center;
        padding-bottom: 1rem;
    }
</style>