日记 2022-5-4(vue技术图片64)

日记 2022-5-4(vue技术图片64),第1张

自身夯实:

登录功能:iview/element ui 表单校验,验证登录,flex布局 , vuex信息获取与存储,样式穿透

<Form action ref="formInline" :model="formInline" :rules="ruleInline">
	<FormItem prop="ID">
		<Input type="text" v-model="formInline.ID" placeholder="账号">
		<img src="../../assets/images/user.png" style="width: 40px; height: 40px;" alt=""
			slot="prepend">
		Input>
	FormItem>
	<FormItem prop="PW">
		<Input type="password" v-model="formInline.PW" @keyup.native.enter="toLogin('formInline')"
			placeholder="密码">
		<img src="../../assets/images/password.png" style="width: 40px; height: 40px;" alt=""
			slot="prepend">
		Input>
	FormItem>
	<FormItem prop="code" class="form-item-code">
		<Input type="text" v-model="formInline.code" @keyup.native.enter="toLogin('formInline')"
			placeholder="验证码" class="code-input">
		<img src="../../assets/images/login-code.png" style="width: 40px; height: 40px;" alt=""
			slot="prepend">
		Input>
		<div id="v_container" class="flex-row-center-center" @click="changeCode">
			<img :src="'data:image/png;base64,' + codeImg" v-show="codeImg" alt="">
		div>

	FormItem>
	<FormItem class="checked-pw">
		<Checkbox size="large" v-model="checked">记住密码Checkbox>
	FormItem>
	<FormItem>
		<Button type="primary" @click="toLogin('formInline')">登录Button>
	FormItem>
Form>
toLogin(formInline) {
			let _this = this;
			this.$refs[formInline].validate(valid => {
				if (valid) {
					this.loading = true;
					_this.axios({
						method: "POST",
						url: apiLogin,
						data: {
							username: this.formInline.ID.trim(),
							password: this.formInline.PW.trim(),
							code: this.formInline.code,
							uuid: this.formInline.uuid,
						}
					}).then(res => {
						_this.loading = false;
						if (res.status == 200) {
							/* 判断是否为该县级用户 */
							if (res.data.User._ORG_.LVL == 1 && res.data.User._ORG_._AREA_.NAME != mapInfo.prv) {
								return _this.$Message.success("账号不存在!");
							} else if (res.data.User._ORG_.LVL == 2 && res.data.User._ORG_._AREA_.NAME != mapInfo.city) {
								return _this.$Message.success("账号不存在!");
							} else if (res.data.User._ORG_.LVL == 3 && res.data.User._ORG_._AREA_.NAME != mapInfo.cnty) {
								return _this.$Message.success("账号不存在!");
							} else if (res.data.User._ORG_.LVL == 4 && res.data.User._ORG_._AREA_.FULLNAME.split('`')[2] != mapInfo.cnty) {
								return _this.$Message.success("账号不存在!");
							}
							_this.$store.commit("set_token", res.data.Token);
							_this.$store.commit("set_userInfo", res.data.User);
							_this.$store.dispatch("getRSCS", {
								Token: res.data.Token,
							});//获取水库规模筛选数据

							localStorage.setItem('systemName_' + mapInfo.cnty, res.data.User._ORG_.SYS_NAME || mapInfo.SYSTEM_NAME);
							_this.$store.commit('set_system_name', res.data.User._ORG_.SYS_NAME || mapInfo.SYSTEM_NAME);
							_this.$store.dispatch("getArea");//获取水库地区筛选数据
							_this.savePW();//记住密码
							_this.goHome();
							_this.$Message.success("登录成功!");
						} else {
							_this.$Message.error(res.data.m);
						}
					})
						.catch(error => {
							_this.loading = false;
							error ? _this.$Message.error(error.data.m) : _this.$Message.error('请求失败');
						});
				} else {
					_this.$Message.error("登录失败!");
				}
			});
		},
//校验提示文字
>>>.ivu-form-item-error-tip {
	color: #fff;
	font-size: 14px;
}
自身遗忘:

页面获取路由信息

this.$router.options.routes.filter(item => !item.hidden)

css flex:1
大概意思:在当前区域该元素占比为1
MDN

get新知识:

图片转换64:什么是图片转换64

自结:将一张图片数据编码成一串字符串,使用该字符串代替图像地址url

<img :src="'data:image/png;base64,' + codeImg" v-show="codeImg" alt="">
/* 
// 验证码
 */
changeCode() {
	this.axios({
		method: "GET",
		url: captchaImage,
	}).then(res => {
		if (res.data.code == 200) {
			this.formInline.uuid = res.data.uuid;
			this.codeImg = res.data.img;//这里就是图片编码字符串
		} else {
			_this.$Message.error("请求失败,请稍后重试!");
		}
	})
		.catch(error => {
			this.$Message.error("请求失败,请稍后重试!");
			console.log(error);
		});
},
img: "R0lGODlhWgAcAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzAC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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="

input slot 插槽

<Input type="password" v-model="formInline.PW" @keyup.native.enter="toLogin('formInline')"
placeholder="密码">
<img src="../../assets/images/password.png" style="width: 40px; height: 40px;" alt=""
slot="prepend">
Input>

slot=“prepend” 放置图片代替以前放置图标

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/869437.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-13
下一篇 2022-05-13

发表评论

登录后才能评论

评论列表(0条)

保存