net.vue 1.96 KB
<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>