heyujie
2021-06-07 8f8155aa4c83f7c2577ac123add550766b6a7ce3
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<template>
    <view class="content">
        <uni-nav-bar left-icon="back" left-text="返回" @clickLeft="goBack" title="通用设置" statusBar="true"></uni-nav-bar>
        <view class="setting-content">
            <view class="title">
                服务器设置
            </view>
            <view class="uni-form-item uni-column">
                <view class="title">地址:</view>
                <input class="uni-input" v-model="mq_ip"/>
                <!-- <IPInput :ip="sys_ip" @on-blur="sys_ip= arguments[0]"></IPInput> -->
            </view>
            <view class="uni-form-item uni-column">
                <view class="title">端口:</view>
                <input class="uni-input" v-model="mq_port" />
            </view>
        </view>
        <view class="setting-content">
            <view class="title">
                视频及图片服务设置
            </view>
            <view class="uni-form-item uni-column">
                <view class="title">地址:</view>
                <!-- <input class="uni-input" focus placeholder="IP地址" /> --><input class="uni-input" v-model="pic_ip"/>
                <!-- <IPInput :ip="pic_ip" @on-blur="pic_ip= arguments[0]"></IPInput> -->
            </view>
            <view class="uni-form-item uni-column">
                <view class="title">端口:</view>
                <input class="uni-input" v-model="pic_port" placeholder="" />
            </view>
        </view>
        <button type="default" @tap="commit">确认</button>
        <!-- <uni-popup ref="popup" type="center" background-color="#fff" :animation="false">中间弹出 Popup</uni-popup> -->
        <uni-popup ref="popup" type="message">
            <uni-popup-message type="success" message="修改成功" :duration="2000"></uni-popup-message>
        </uni-popup>
        <uni-popup ref="popup1" type="message">
            <uni-popup-message type="error" message="连接失败" :duration="2000"></uni-popup-message>
        </uni-popup>
    </view>
</template>
 
<script>
    import imagePopper from "@/components/imagePopper.vue"
    import IPInput from "@/components/IPInput.vue"
    export default {
        components: {
            imagePopper,
            IPInput
        },
        data() {
            return {
                mq_ip: "",
                pic_ip: "",
                mq_port: "",
                pic_port:""
            }
        },
        onShow() {
            [this.mq_ip, this.mq_port] = getApp().globalData.mqUrl.split(":");
            console.log(this.mq_ip, this.mq_port);
            [this.pic_ip, this.pic_port] = getApp().globalData.resourseUrl.split(":");
            console.log(this.pic_ip, this.pic_port);
        },
        mounted() {
        
            uni.$on("connectStatus", (data) => {
                console.log('connectStatus')
                // data.status ? this.$refs.popup.open('top') :
                //     this.$refs.popup1.open('top')
            })
        },
        onBackPress(e) {
            console.log(e);
            uni.navigateTo({
                url: '/pages/index/index'
            })
            // return true
        },
 
        methods: {
            goBack() {
                uni.navigateTo({
                    url: "../index/index"
                })
            },
            commit() {
                uni.$emit('changeClientIP', {
                    host: `${this.mq_ip}:${this.mq_port}`
                })
                getApp().globalData.resourseUrl = `${this.pic_ip}:${this.pic_port}`
                getApp().globalData.requestVideoUrl = `${this.pic_ip}:9000`
                uni.setStorage({
                    key:"mqUrl",
                    data: `${this.mq_ip}:${this.mq_port}`,
                    success: () => {
                        console.log("mqUrl存入数据库")
                    }
                })
                uni.setStorage({
                    key: 'resourseUrl',
                    data:`${this.pic_ip}:${this.pic_port}`,
                    success: function () {
                        console.log('resourseUrl存入数据库');
                    }
                });
                uni.setStorage({
                    key: 'requestVideoUrl',
                    data:`${this.pic_ip}:9000`,
                    success: function () {
                        console.log('requestVideoUrl存入数据库');
                    }
                });
                 this.$refs.popup.open('top')
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .uni-input {
        border: 1px solid black;
    }
 
    page {
        background-color: rgba(243, 244, 246, 1);
    }
 
    .uni-form-item {
        display: flex;
        align-items: center;
        // justify-content: space-around;
        margin-top: 20px;
    }
 
    .setting-content {
        padding: 40rpx 40rpx;
 
        .title {
            min-width: 80rpx;
        }
 
        .uni-input {
            border: 1px solid #dcdfe6;
            background: #fff;padding:0  20rpx;    width: 72%;
 
        }
 
        uni-input {
            display: block;
            font-size: 16px;
            line-height: 1.8em;
            height: 1.8em;
            min-height: 1.8em;
            overflow: hidden;
        }
 
        .uni-input-input {
            padding-left: 20rpx;
        }
    }
 
    uni-button[type=default] {
        color: #fff;
 
        background-color: rgba(239, 128, 72, 1);
        /* position: absolute; */
        /* bottom: 0; */
        position: absolute;
        bottom: 50px;
        left: calc(50% - 40%);
        width: 80%;
    }
 
    uni-button:after {
        border: 0;
    }
 
    uni-button {
        font-size: 16px;
        line-height: 2.4;
        border-radius: 15px;
    }
</style>