net.vue
1.96 KB
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
<template>
<view class="wrap">
<view class="content">
<view class="current">
目前:{{current}}
</view>
<view class="inp">
<input type="text" v-model="ip" placeholder="请输入网络地址" />
</view>
<view class="btn">
<button class="b-c" type="warn" @tap="defa">默认</button>
<button class="b-c" type="warn" @tap="set" >设置</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
ip: '',
current: 'http://work.huahengweld.com/nwms',
}
},
onBackPress() {
this.$prePage().changeUrl(this.current)
},
onLoad() {
try {
const url = uni.getStorageSync('base_url');
if (url) {
this.current = url
}
} catch (e) {
// error
}
},
methods: {
defa() {
this.ip="http://work.huahengweld.com/nwms";
},
set() {
if(this.ip.trim()) {
this.current = this.ip;
this.ip='';
this.$wx.showToast({title:'设置成功!'})
}else {
this.$wx.showToast({title:'网络地址不能为空!'})
}
try {
uni.setStorageSync('base_url', this.current);
} catch (e) {
// error
}
}
},
}
</script>
<style lang="scss" scoped>
.wrap {
position: fixed;
width: 100%;
height: 100%;
background-color: $uni-bg-color;
.content {
position: absolute;
top: 5%;
left: 70rpx;
right: 70rpx;
.current {
margin: 0 0 $uni-spacing-col-lg $uni-spacing-row-lg;
margin-left: $uni-spacing-row-lg;
font-size: $uni-font-size-lg;
color: #e64340;
font-weight: bold;
}
.inp {
border-radius: 50rpx;
box-shadow: 0 0 60rpx 0 rgba(43, 86, 112, .1);
input {
padding: 30rpx;
font-size: $uni-font-size-base;
}
}
.btn {
.b-c {
width: 100%;
height: 100rpx;
line-height: 100rpx;
text-align: center;
margin: 50rpx auto 0;
border: none;
border-radius: 50rpx;
font-size: 30rpx;
}
}
}
}
</style>