Commit f4156156 authored by zL's avatar zL

重构部分代码提交

parent 41b85030
...@@ -2177,6 +2177,15 @@ ...@@ -2177,6 +2177,15 @@
"integrity": "sha1-oXs6jqgRBg501H0wYSJACtRJeuI=", "integrity": "sha1-oXs6jqgRBg501H0wYSJACtRJeuI=",
"dev": true "dev": true
}, },
"axios": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz",
"integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=",
"requires": {
"follow-redirects": "^1.3.0",
"is-buffer": "^1.1.5"
}
},
"babel-code-frame": { "babel-code-frame": {
"version": "6.26.0", "version": "6.26.0",
"resolved": "https://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz", "resolved": "https://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz",
...@@ -5021,8 +5030,7 @@ ...@@ -5021,8 +5030,7 @@
"follow-redirects": { "follow-redirects": {
"version": "1.12.1", "version": "1.12.1",
"resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.12.1.tgz", "resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.12.1.tgz",
"integrity": "sha1-3lSmIFMRuT1gOY68Ac9wFWgjErY=", "integrity": "sha1-3lSmIFMRuT1gOY68Ac9wFWgjErY="
"dev": true
}, },
"for-in": { "for-in": {
"version": "1.0.2", "version": "1.0.2",
...@@ -5875,8 +5883,7 @@ ...@@ -5875,8 +5883,7 @@
"is-buffer": { "is-buffer": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "https://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz", "resolved": "https://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz",
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4="
"dev": true
}, },
"is-callable": { "is-callable": {
"version": "1.2.0", "version": "1.2.0",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
"dev:refactoring": "vue-cli-service serve --mode refactoring_test" "dev:refactoring": "vue-cli-service serve --mode refactoring_test"
}, },
"dependencies": { "dependencies": {
"axios": "^0.18.0",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"element-ui": "^2.13.2", "element-ui": "^2.13.2",
...@@ -32,4 +33,4 @@ ...@@ -32,4 +33,4 @@
"last 2 versions", "last 2 versions",
"not dead" "not dead"
] ]
} }
\ No newline at end of file
This diff is collapsed.
//const isProd = process.env.VUE_APP_CURRENTMODE ==='prod';
const configModules = { const configModules = {
// slc正式环境
// "prod": {
// CHAIN_BROWSER_URL_PREFIX: 'https://www.lian33.com/',
// INERFACE_URL_PREFIX: 'https://go.zhaobi.xyz',
// INERFACE_URL_SUBPREFIX: 'traceability',
// MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
// PLATFORM_ID: 'febcbaae13751f7f8e44c2f107afb08d',
// TencentCaptcha_MESSAGE_APPID: "2012039037",
// TencentCaptcha_PASSLOGIN_APPID: "2029098605",
// BLOCKCHAIN_BROWSERS: 'https://www.lian33.com/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/main/main.ts',
// // 模板来源
// template: './public/main/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// },
// // slc测试环境
// "_test": {
// CHAIN_BROWSER_URL_PREFIX: 'http://47.114.159.142:9021/',
// INERFACE_URL_PREFIX: 'http://fd.33.cn:1134',
// INERFACE_URL_SUBPREFIX: 'traceability',
// MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
// PLATFORM_ID: '1e1312e4488a635c4103c27e7c9b847c',
// TencentCaptcha_MESSAGE_APPID: "2012039037",
// TencentCaptcha_PASSLOGIN_APPID: "2029098605",
// BLOCKCHAIN_BROWSERS: 'http://47.114.159.142:9021/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/main/main.ts',
// // 模板来源
// template: './public/main/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// },
// "_zkjc": {
// CHAIN_BROWSER_URL_PREFIX: 'http://47.114.159.142:9021/',
// INERFACE_URL_PREFIX: 'http://fd.33.cn:1134',
// INERFACE_URL_SUBPREFIX: 'traceability',
// MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
// PLATFORM_ID: '1e1312e4488a635c4103c27e7c9b847c',
// TencentCaptcha_MESSAGE_APPID: "2012039037",
// TencentCaptcha_PASSLOGIN_APPID: "2029098605",
// BLOCKCHAIN_BROWSERS: 'http://47.114.159.142:9021/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/zkjc/main.ts',
// // 模板来源
// template: './public/zkjc/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// },
// // 项目方正式环境
// "hl_prod": {
// CHAIN_BROWSER_URL_PREFIX: 'https://sclllq.hlczsl.com/',
// INERFACE_URL_PREFIX: 'https://api.hlczsl.com',
// INERFACE_URL_SUBPREFIX: 'traceability',
// MAINNET_BLOCKCHAIN_BROWSER: 'http://mainnet.hlchain.net/addressDetail',
// PLATFORM_ID: '69ff495a7d616c3c77c61f8968abf18f',
// TencentCaptcha_MESSAGE_APPID: "2075578219",
// TencentCaptcha_PASSLOGIN_APPID: "2085858149",
// BLOCKCHAIN_BROWSERS: 'https://sclllq.hlczsl.com/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/hl/main.ts',
// // 模板来源
// template: './public/hl/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// },
// // hl测试环境
// "hl_test": {
// CHAIN_BROWSER_URL_PREFIX: 'http://47.74.211.31:9021/',
// INERFACE_URL_PREFIX: 'http://fd.33.cn:1134', //公共登录接口
// INERFACE_URL_SUBPREFIX: 'sinotraceability',
// MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
// PLATFORM_ID: '1e1312e4488a635c4103c27e7c9b847c',
// TencentCaptcha_MESSAGE_APPID: "2012039037",
// TencentCaptcha_PASSLOGIN_APPID: "2029098605",
// BLOCKCHAIN_BROWSERS: 'http://47.74.211.31:9021/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/hl/main.ts',
// // 模板来源
// template: './public/hl/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// },
// // 中链
// "zl_prod": {
// CHAIN_BROWSER_URL_PREFIX: 'http://121.196.15.154:80/',
// INERFACE_URL_PREFIX: 'https://www.chainwords.net/root',
// INERFACE_URL_SUBPREFIX: 'sinotraceability',
// MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
// PLATFORM_ID: '9c2c684b71bbcf996338ec50a40685df',
// TencentCaptcha_MESSAGE_APPID: "2046967931",
// TencentCaptcha_PASSLOGIN_APPID: "2049534336",
// BLOCKCHAIN_BROWSERS: 'http://121.196.15.154:80/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/zl/main.ts',
// // 模板来源
// template: './public/zl/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// },
// // 中链测试环境
// "zl_test": {
// CHAIN_BROWSER_URL_PREFIX: 'http://47.74.211.31:9021/',
// INERFACE_URL_PREFIX: 'http://fd.33.cn:1134', //公共登录接口
// INERFACE_URL_SUBPREFIX: 'sinotraceability',
// MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
// PLATFORM_ID: 'c28cbd398a61e9022fd6a6835a57dc50',
// TencentCaptcha_MESSAGE_APPID: "2012039037",
// TencentCaptcha_PASSLOGIN_APPID: "2029098605",
// BLOCKCHAIN_BROWSERS: 'http://47.74.211.31:9021/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/zl/main.ts',
// // 模板来源
// template: './public/zl/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// },
// 重构--test // 重构--test
"refactoring_test": { "refactoring_test": {
CHAIN_BROWSER_URL_PREFIX: 'http://47.114.159.142:9033/', CHAIN_BROWSER_URL_PREFIX: 'http://120.26.174.69:9032/',
INERFACE_URL_PREFIX: '118.89.159.234:46789', INERFACE_URL_PREFIX: 'http://172.16.101.87:46789',
MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
PLATFORM_ID: 'c28cbd398a61e9022fd6a6835a57dc50',
BLOCKCHAIN_BROWSERS: 'http://47.114.159.142:9033/',
/** /**
* 网站入口配置 * 网站入口配置
*/ */
...@@ -171,28 +14,6 @@ const configModules = { ...@@ -171,28 +14,6 @@ const configModules = {
// 在 dist/index.html 的输出 // 在 dist/index.html 的输出
filename: 'index.html' filename: 'index.html'
} }
} },
// 上古环境
// "sg_prod": {
// CHAIN_BROWSER_URL_PREFIX: 'https://llq.sngoa.com/',
// INERFACE_URL_PREFIX: 'https://llq.sngoa.com/root',
// INERFACE_URL_SUBPREFIX: 'traceability', //ok
// MAINNET_BLOCKCHAIN_BROWSER: 'https://mainnet.bityuan.com/address',
// PLATFORM_ID: '65cf74cb1519023664d944759c5a7586', //ok
// TencentCaptcha_MESSAGE_APPID: "2040811804",
// TencentCaptcha_PASSLOGIN_APPID: "2017272423",
// BLOCKCHAIN_BROWSERS: 'https://llq.sngoa.com/',
// /**
// * 网站入口配置
// */
// INDEX: {
// // page 的入口
// entry: './src/entry/sg/main.ts',
// // 模板来源
// template: './public/sg/index.html',
// // 在 dist/index.html 的输出
// filename: 'index.html'
// }
// }
} }
exports.model = configModules[process.env.VUE_APP_CURRENTMODE] exports.model = configModules[process.env.VUE_APP_CURRENTMODE]
\ No newline at end of file
<template>
<div>
<span class="sign-box-type" @click="$emit('phone-email')">手机登录 ></span>
<h1>邮箱登录</h1>
<div class="tip">
您还可以进行
<span @click="changeLogin">{{loginMethod}}</span>&nbsp;登录
</div>
<div>
<el-input
placeholder="请输入邮箱地址"
class="input-box"
v-model.trim="email"
@input="email=email.replace(/[\u4e00-\u9fa5]/ig,'')"
/>
<!-- code输入框 -->
<div class="el-input input-box input-box__code" v-if="loginType===1">
<input
type="text"
maxlength="9"
autocomplete="off"
v-model.trim="code"
@input="code=code.replace(/[^\d]/g,'')"
class="el-input__inner"
placeholder="请输入邮箱验证码"
/>
<div
class="btn"
@click="getCode"
>{{curIntervalSeconds === 0 ? '发送验证码' : curIntervalSeconds + '秒后重新发送'}}</div>
</div>
<!-- 密码输入框 -->
<div class="el-input input-box input-password" v-if="loginType===0">
<input
:type="[openOrClose?'password':'text']"
maxlength="30"
autocomplete="off"
v-model.trim="password"
@input="password=password.replace(/[\u4e00-\u9fa5]/ig,'')"
class="el-input__inner"
placeholder="请输入密码"
/>
<div class="icon" @click="changeOpen">
<i class="iconfont" :class="[openOrClose?'iconYJ':'iconYC']"></i>
</div>
</div>
<!-- 底部登录按钮 -->
<div class="sign-in-btn" @click="loginStart">登录</div>
<!-- 记住密码or设置密码等 -->
<div class="operation-box" v-if="loginType===0">
<div class="left-link-zone">
<el-checkbox v-model="isAutoLogin">记住密码</el-checkbox>
</div>
<div class="right-link-zone">
<a href="javascript:void(0)" class="set-up" @click="SetPassword(2)">设置密码</a>
<a href="javascript:void(0)" @click="SetPassword(3)">忘记密码</a>
</div>
</div>
</div>
</div>
</template>
<script>
import * as storage from "@/entry/refactoring/plugins/storage";
import { GO_URLS } from "@/config/URLS";
let CryptoJS = require("crypto-js");
export default {
data() {
return {
email: "",
code: "",
maxIntervalSeconds: 60,
curIntervalSeconds: 0,
isAutoLogin: false,
loginMethod: "邮箱验证码",
loginType: 0,
openOrClose: true,
password: "",
isclick: true,
};
},
watch: {},
created() {
if (
typeof localStorage.ciphertext === "string" &&
localStorage.ciphertext.length === 0
) {
//本地存在ciphertext,但是没有值,需要清除缓存
localStorage.removeItem("ciphertext");
this.isAutoLogin = false;
} else if (
typeof localStorage.ciphertext === "string" &&
localStorage.ciphertext.length > 0
) {
//"属性和值同时存在"
let ciphertext = localStorage.ciphertext;
let bytes = CryptoJS.AES.decrypt(ciphertext.toString(), "secret key 123");
let json = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
if (json.login_type === 2) {
this.email = json.email;
this.password = json.pwd;
this.isAutoLogin = true;
}
}
},
methods: {
// 检查是否设置过密码
async checkisSetPwd() {
const res = await this.$ajax({
url: GO_URLS.isSetPwd,
type: "post",
params: {
email: this.email,
},
});
if (res) {
if (res.data && res.data.is_set_pwd === 0) {
this.loginType = 1;
} else {
this.loginType = 0;
}
// 0 未设置密码, 1有密码
}
},
// Email检测
checkEmail() {
if (
!/^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/.test(
this.email
)
) {
this.$message.error("邮箱地址有误,请重填");
return false;
} else {
return true;
}
},
// 获取验证码
async getCode() {
if (!this.checkEmail()) return;
if (this.curIntervalSeconds > 0) return;
const res = await this.$ajax({
type: "post",
url: GO_URLS.sendEmail,
params: {
email: this.email,
template_id: 0,
},
});
if (res) {
this.$message({
message: "验证码已发送,请注意查看邮箱",
type: "success",
});
this.curIntervalSeconds = this.maxIntervalSeconds;
this.intervalHandle = setInterval(() => {
if (this.curIntervalSeconds > 0) {
this.curIntervalSeconds--;
} else {
clearInterval(this.intervalHandle);
}
}, 1000);
}
},
// 设置密码
SetPassword(type) {
this.$store.commit("updateBusinessType", type);
this.$emit("SetPassword");
},
// email+验证码登录
async loginStart() {
if (this.isclick) {
this.isclick = false;
if (!this.checkEmail()) {
this.isclick = true;
return;
}
if (this.loginType === 1 && this.code.length < 1) {
this.$message.error("请输入邮箱验证码");
this.isclick = true;
return;
}
if (this.loginType === 0 && this.password === "") {
this.$message.error("请输入密码");
this.isclick = true;
return;
}
var params = {};
if (this.loginType === 1) {
params = {
login_type: 3,
email: this.email,
code: this.code,
};
} else {
params = {
login_type: 2,
email: this.email,
pwd: this.$md5(
String(this.password) + this.$md5(String(this.password.length))
),
};
}
const res = await this.$ajax({
type: "post",
url: GO_URLS.login,
params: params,
});
this.isclick = true;
if (res && res.data) {
sessionStorage.setItem("login_type", 2);
storage.setLogin(res.data, params, this.isAutoLogin);
this.$router.push({ path: "/categoryManage" });
}
}
},
// 是否显示密码
changeOpen() {
this.openOrClose = !this.openOrClose;
},
// 改变登录方式
changeLogin() {
// login_type 0:手机号+密码 1:手机号+验证码 2:邮箱+密码 3:邮箱验+证码
if (this.loginType === 0) {
this.loginType = 1;
this.loginMethod = "邮箱密码";
} else if (this.loginType === 1) {
this.loginType = 0;
this.loginMethod = "邮箱验证码";
}
},
},
};
</script>
<style lang="less" scoped>
.sign-in-btn {
width: 441px;
height: 44px;
background: rgba(63, 121, 254, 1);
border-radius: 4px;
font-size: 14px;
cursor: pointer;
line-height: 44px;
color: white;
text-align: center;
&:hover {
box-shadow: 0px 2px 6px 0px #4a90e2;
}
}
.operation-box {
margin-top: 40px;
.left-link-zone {
float: left;
text-decoration: none;
}
.right-link-zone {
float: right;
a {
font-size: 14px;
color: rgba(121, 125, 132, 1);
text-decoration: none;
}
.set-up {
border-right: 1px solid #797d84;
padding-right: 8px;
margin-right: 8px;
}
}
}
.input-box__code {
position: relative;
.btn {
width: 104px;
position: absolute;
right: 10px;
top: 10px;
text-align: center;
color: #989fa5;
line-height: 25px;
font-size: 12px;
cursor: pointer;
height: 25px;
background: rgba(244, 244, 244, 1);
border-radius: 3px;
}
}
.input-password {
position: relative;
.icon {
cursor: pointer;
position: absolute;
right: 10px;
top: 0;
width: 18px;
line-height: 2.8;
height: 100%;
}
}
.input-box {
margin-bottom: 16px;
/deep/ .el-input__inner {
height: 44px !important;
&::-webkit-input-placeholder {
/* WebKit browsers */
color: #797d84;
}
&:-moz-placeholder {
color: #797d84;
}
&::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: #797d84;
}
&:-ms-input-placeholder {
/* Internet Explorer 10+ */
color: #797d84;
}
}
}
.tip {
height: 20px;
font-size: 14px;
font-weight: 400;
color: rgba(121, 125, 132, 1);
line-height: 20px;
margin-bottom: 24px;
span {
color: #3f79fe;
cursor: pointer;
}
}
.sign-box-type {
position: absolute;
top: 34px;
right: 32px;
font-size: 14px;
color: #5386fb;
cursor: pointer;
}
h1 {
font-size: 30px;
font-weight: 400;
color: rgba(53, 53, 53, 1);
line-height: 42px;
text-align: center;
margin: 0;
margin-top: 96px;
margin-bottom: 36px;
}
</style>
\ No newline at end of file
<template>
<div>
<span class="sign-box-type" @click="$emit('change-email')">邮箱登录 ></span>
<h1>手机登录</h1>
<div class="tip">
您还可以进行
<span @click="changeLogin">{{loginMethod}}</span>&nbsp;登录
</div>
<div>
<el-input
placeholder="请输入手机号"
class="input-box"
v-model.trim="phone"
maxlength="11"
@input="phone=phone.replace(/[^\d]/g,'')"
/>
<!-- code输入框 -->
<div class="el-input input-box input-box__code" v-if="loginType===1">
<input
type="text"
maxlength="9"
autocomplete="off"
v-model.trim="code"
@input="code=code.replace(/[^\d]/g,'')"
class="el-input__inner"
placeholder="请输入短信验证码"
/>
<div
class="btn"
@click="getCode"
>{{curIntervalSeconds === 0 ? '发送验证码' : curIntervalSeconds + '秒后重新发送'}}</div>
</div>
<!-- 密码输入框 -->
<div class="el-input input-box input-password" v-if="loginType===0">
<input
:type="[openOrClose?'password':'text']"
maxlength="30"
autocomplete="off"
v-model.trim="password"
@input="password=password.replace(/[\u4e00-\u9fa5]/ig,'')"
class="el-input__inner"
placeholder="请输入密码"
/>
<div class="icon" @click="changeOpen">
<i class="iconfont" :class="[openOrClose?'iconYJ':'iconYC']"></i>
</div>
</div>
<!-- 底部登录按钮 -->
<div class="sign-in-btn" @click="loginStart">登录</div>
<!-- 记住密码or设置密码等 -->
<div class="operation-box" v-if="loginType===0">
<div class="left-link-zone">
<el-checkbox v-model="isAutoLogin">记住密码</el-checkbox>
</div>
<div class="right-link-zone">
<a href="javascript:void(0)" class="set-up" @click="SetPassword(0)">设置密码</a>
<a href="javascript:void(0)" @click="SetPassword(1)">忘记密码</a>
</div>
</div>
</div>
</div>
</template>
<script>
import * as storage from "@/entry/refactoring/plugins/storage";
import { GO_URLS } from "@/config/URLS";
let CryptoJS = require("crypto-js");
export default {
data() {
return {
phone: "",
code: "",
maxIntervalSeconds: 60,
curIntervalSeconds: 0,
isAutoLogin: false,
loginMethod: "手机验证码",
loginType: 0,
openOrClose: true,
password: "",
isclick: true,
};
},
watch: {
// 电话号码的变化
phone: function (val) {
if (val.length === 11) {
if (!this.checkPhone()) return;
this.checkisSetPwd();
}
},
},
created() {
if (
typeof localStorage.ciphertext === "string" &&
localStorage.ciphertext.length === 0
) {
//本地存在ciphertext,但是没有值,需要清除缓存
localStorage.removeItem("ciphertext");
this.isAutoLogin = false;
} else if (
typeof localStorage.ciphertext === "string" &&
localStorage.ciphertext.length > 0
) {
//"属性和值同时存在"
let ciphertext = localStorage.ciphertext;
let bytes = CryptoJS.AES.decrypt(ciphertext.toString(), "secret key 123");
let json = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
if (json.login_type === 0) {
this.phone = json.phone;
this.password = json.pwd;
this.isAutoLogin = true;
}
}
},
methods: {
// 检查是否设置过密码
async checkisSetPwd() {
const res = await this.$ajax({
url: GO_URLS.isSetPwd,
type: "post",
params: {
phone: this.phone,
},
});
if (res) {
if (res.data && res.data.is_set_pwd === 0) {
this.loginType = 1;
} else {
this.loginType = 0;
}
// 0 未设置密码, 1有密码
}
},
// 电话检测
checkPhone() {
if (!/^1[3456789]\d{9}$/.test(this.phone)) {
this.$message.error("手机号码有误,请重填");
return false;
} else {
return true;
}
},
// 获取验证码
async getCode() {
if (!this.checkPhone()) return;
if (this.curIntervalSeconds > 0) return;
const res = await this.$ajax({
type: "post",
url: GO_URLS.sendSms,
params: {
phone: this.phone,
template_id: 0,
},
});
if (res) {
this.$message({
message: "短信已发送",
type: "success",
});
this.curIntervalSeconds = this.maxIntervalSeconds;
this.intervalHandle = setInterval(() => {
if (this.curIntervalSeconds > 0) {
this.curIntervalSeconds--;
} else {
clearInterval(this.intervalHandle);
}
}, 1000);
}
},
// 设置密码
SetPassword(type) {
this.$store.commit("updateBusinessType", type);
this.$emit("SetPassword");
},
// 电话+验证码登录
async loginStart() {
if (this.isclick) {
this.isclick = false;
//下面添加需要执行的事件
if (!this.checkPhone()) {
this.isclick = true;
return;
}
if (this.loginType === 1 && this.code.length < 1) {
this.$message.error("请输入短信验证码");
this.isclick = true;
return;
}
if (this.loginType === 0 && this.password === "") {
this.$message.error("请输入密码");
this.isclick = true;
return;
}
var params = {};
if (this.loginType === 1) {
params = {
login_type: 1,
phone: this.phone,
code: this.code,
};
} else {
params = {
login_type: 0,
phone: this.phone,
pwd: this.$md5(
String(this.password) + this.$md5(String(this.password.length))
),
};
}
const res = await this.$ajax({
type: "post",
url: GO_URLS.login,
params: params,
});
this.isclick = true;
if (res && res.data) {
sessionStorage.setItem("login_type", 1);
storage.setLogin(res.data, params, this.isAutoLogin);
this.$router.push({ path: "/categoryManage" });
}
}
},
// 是否显示密码
changeOpen() {
this.openOrClose = !this.openOrClose;
},
// 改变登录方式
changeLogin() {
// login_type 0:手机号+密码 1:手机号+验证码 2:邮箱+密码 3:邮箱验+证码
if (this.loginType === 0) {
this.loginType = 1;
this.loginMethod = "账号密码";
} else if (this.loginType === 1) {
this.loginType = 0;
this.loginMethod = "手机验证码";
}
},
},
};
</script>
<style lang="less" scoped>
.sign-in-btn {
width: 441px;
height: 44px;
background: rgba(63, 121, 254, 1);
border-radius: 4px;
font-size: 14px;
cursor: pointer;
line-height: 44px;
color: white;
text-align: center;
&:hover {
box-shadow: 0px 2px 6px 0px #4a90e2;
}
}
.operation-box {
margin-top: 40px;
.left-link-zone {
float: left;
text-decoration: none;
}
.right-link-zone {
float: right;
a {
font-size: 14px;
color: rgba(121, 125, 132, 1);
text-decoration: none;
}
.set-up {
border-right: 1px solid #797d84;
padding-right: 8px;
margin-right: 8px;
}
}
}
.input-box__code {
position: relative;
.btn {
width: 104px;
position: absolute;
right: 10px;
top: 10px;
text-align: center;
color: #989fa5;
line-height: 25px;
font-size: 12px;
cursor: pointer;
height: 25px;
background: rgba(244, 244, 244, 1);
border-radius: 3px;
}
}
.input-password {
position: relative;
.icon {
cursor: pointer;
position: absolute;
right: 10px;
top: 0;
width: 18px;
line-height: 2.8;
height: 100%;
}
}
.input-box {
margin-bottom: 16px;
/deep/ .el-input__inner {
height: 44px !important;
&::-webkit-input-placeholder {
/* WebKit browsers */
color: #797d84;
}
&:-moz-placeholder {
color: #797d84;
}
&::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: #797d84;
}
&:-ms-input-placeholder {
/* Internet Explorer 10+ */
color: #797d84;
}
}
}
.tip {
height: 20px;
font-size: 14px;
font-weight: 400;
color: rgba(121, 125, 132, 1);
line-height: 20px;
margin-bottom: 24px;
span {
color: #3f79fe;
cursor: pointer;
}
}
.sign-box-type {
position: absolute;
top: 34px;
right: 32px;
font-size: 14px;
color: #5386fb;
cursor: pointer;
}
h1 {
font-size: 30px;
font-weight: 400;
color: rgba(53, 53, 53, 1);
line-height: 42px;
text-align: center;
margin: 0;
margin-top: 96px;
margin-bottom: 36px;
}
</style>
\ No newline at end of file
This diff is collapsed.
// // import '../../class-component-hooks';
// import Vue from 'vue';
// import App from './App.vue';
// import router from './router';
// import axiosPlugin from './plugins/axios-plugin';
// import '../../plugins/element.js';
// import ElementUI from 'element-ui';
// // import store from './store';
// // import vueTencentCaptcha from '@carpenter/vue-tencent-captcha';
// // import Gfilters from '@/utils/tool/filter';
// // Vue.use(vueTencentCaptcha);
// Vue.use(ElementUI);
// Vue.use(axiosPlugin);
// Vue.config.productionTip = false;
// // Gfilters(Vue);
// new Vue({
// router,
// // store,
// render: h => h(App),
// }).$mount('#app');
// import '../../class-component-hooks'; // import '../../class-component-hooks';
import Vue from 'vue'; import Vue from 'vue';
import App from './App.vue'; import App from './App.vue';
import router from './router'; import router from './router';
// import axiosPlugin from './plugins/axios-plugin'; import axiosPlugin from './plugins/axios-plugin';
// import '../../plugins/element.js'; import '../../plugins/element.js';
import ElementUI from 'element-ui'; import ElementUI from 'element-ui';
// import store from './store'; import store from './store';
// import md5 from 'js-md5'
// Vue.prototype.$md5 = md5
// import vueTencentCaptcha from '@carpenter/vue-tencent-captcha'; // import vueTencentCaptcha from '@carpenter/vue-tencent-captcha';
// import Gfilters from '@/utils/tool/filter'; // import Gfilters from '@/utils/tool/filter';
// Vue.use(vueTencentCaptcha); // Vue.use(vueTencentCaptcha);
Vue.use(ElementUI); Vue.use(ElementUI);
// Vue.use(axiosPlugin); Vue.use(axiosPlugin);
Vue.config.productionTip = false; Vue.config.productionTip = false;
// Gfilters(Vue); // Gfilters(Vue);
new Vue({ new Vue({
router, router,
// store, store,
render: h => h(App), render: h => h(App),
}).$mount('#app'); }).$mount('#app');
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
import { Message } from 'element-ui';
let router: any = null;
router = require('@/entry/refactoring/router');
import { getLoginCode } from './storage';
export interface ResBase {
code: number;
data: any;
msg: string;
}
// get请求
export interface GetParam {
type: 'get' | 'delete';
url: string;
params?: { [key: string]: any };
header?: Object;
config?: Object;
}
// post请求
export interface PostParam {
type: 'post' | 'put' | 'patch' | 'delete';
url: string;
params?: Object;
header?: Object;
config?: Object;
}
//获取对象的长度
function length(o: object) {
var count = 0;
for (var i in o) {
count++;
}
return count;
};
// ajax
async function ajax(param: PostParam | GetParam) {
try {
const type = param.type.toLowerCase();
const result: AxiosRequestConfig = {
method: type,
url: param.url,
params: {},
headers: {
Authorization: 'Bearer ' + getLoginCode(),
...(param.header || {}),
},
...(param.config || {}),
};
if (param.params) {
if (['get'].includes(type)) {
let restfulUrl = param.url + `?`;
const params = (param as GetParam).params || [];
let num = length(params)
Object.keys(params).forEach(function (key) {
if (num === 1) {
restfulUrl += `${key}=${params[key]}`;
} else {
restfulUrl += `${key}=${params[key]}&`;
num--
}
});
result.url = restfulUrl;
}
else {
result.data = param.params;
}
}
// 返回res
const res: AxiosResponse<ResBase> = await axios(result);
if (res.data.code === 200) { // mock 为 0
return res.data || {};
}
else if (res.data.code == 403) {
Message.warning('登录过期,请刷新页面');
// cleanLogin();
sessionStorage.removeItem("user");
router.push({ path: "/" });
return null;
}
else {
Message(res.data.msg);
return null;
}
} catch (e) {
if (axios.isCancel(e)) {
return null;
}
Message.error('网络异常');
}
}
export {
ajax,
};
export default {
install(Vue: any, funcName: string = '$ajax') {
Object.defineProperty(Vue.prototype, funcName, { value: ajax });
},
};
// import store from '../store/index';
let CryptoJS = require("crypto-js"); let CryptoJS = require("crypto-js");
// const prefix = 'Slc';
// 设置本地数据
// function setLocalItem(key: string, value: any) {
// key = `${prefix}-${key}`;
// value = JSON.stringify(value || '');
// localStorage.setItem(key, value);
// }
// 获取本地数据
// function getLocalItem(key: string) {
// key = `${prefix}-${key}`;
// const data: any = localStorage.getItem(key);
// try {
// return JSON.parse(data);
// } catch (error) {
// }
// return null;
// }
// 清除本地数据
// function removeItem(key: string) {
// if (!key) {
// localStorage.clear();
// }
// key = `${prefix}-${key}`;
// localStorage.removeItem(key);
// }
// 登录&&保存密码至本地 // 登录&&保存密码至本地
export function setLogin(data: Object, params: { export function setLogin(data: Object, params: {
login_type: number, phone: string, pwd: string login_type: number, phone: string, pwd: string
...@@ -53,15 +27,4 @@ export function getLoginCode() { ...@@ -53,15 +27,4 @@ export function getLoginCode() {
return null; return null;
} }
} }
// 获取用户所有信息
export function getLoginName() {
if (sessionStorage.getItem('user')) {
return sessionStorage.getItem('user')
} else {
return null;
}
}
// 退出登录
// export function cleanLogin() {
// removeItem('user');
// }
...@@ -12,12 +12,12 @@ let router = new Router({ // todo 移除旧页面 ...@@ -12,12 +12,12 @@ let router = new Router({ // todo 移除旧页面
name: 'home', name: 'home',
component: () => import('./views/Home.vue'), component: () => import('./views/Home.vue'),
}, },
// 新增部分 // 登录
// { {
// path: '/signIn', path: '/signIn',
// name: 'signIn', name: 'signIn',
// component: () => import('./views/SignIn.vue'), component: () => import('./views/SignIn.vue'),
// }, },
// { // {
// path: '/main', // path: '/main',
// component: () => import(/* webpackChunkName: "main" */ './views/Main.vue'), // component: () => import(/* webpackChunkName: "main" */ './views/Main.vue'),
......
<template>
<div class="sign-in">
<div class="img"></div>
<div class="fixed">
<div class="background-left"></div>
<div class="sign-in-box">
<!-- 手机+密码登录模块 -->
<phone-login
v-if="showPlg"
@change-email="changeEmail"
@SetPassword="showPlg=false;showSpd=true"
></phone-login>
<!-- email登录模块 -->
<email-login
v-if="showEmail"
@phone-email="phoneEmail"
@SetPassword="showEmail=false;showSpd=true"
></email-login>
<!-- 设置密码模块 -->
<set-password v-if="showSpd" @showLogin="showLogin"></set-password>
</div>
</div>
</div>
</template>
<script>
import * as storage from "@/entry/refactoring/plugins/storage";
import { GO_URLS } from "@/config/URLS";
import SetPassword from "@/entry/refactoring/components/signin/setPassword.vue";
import PhoneLogin from "@/entry/refactoring/components/signin/phoneLogin.vue";
import EmailLogin from "@/entry/refactoring/components/signin/emailLogin.vue";
export default {
data() {
return {
showSpd: false, //设置密码
showPlg: true, //手机登录
showEmail: false, // 邮箱登录
};
},
components: {
SetPassword,
PhoneLogin,
EmailLogin,
},
computed: {
getType: function () {
return this.$store.state.businessType;
},
},
methods: {
showLogin() {
this.showSpd = false;
if (this.getType === 0 || this.getType === 1) {
this.showPlg = true;
} else {
this.showEmail = true;
}
},
// 切换至email登录
changeEmail() {
this.showEmail = true;
this.showPlg = false;
},
// 切换至手机登录
phoneEmail() {
this.showEmail = false;
this.showPlg = true;
},
},
};
</script>
<style lang="less" scoped>
.sign-in {
position: relative;
background: #ececec;
}
.img {
position: absolute;
left: 26px;
top: 14px;
width: 100px;
height: 30px;
background: url("../images/logo.png") no-repeat center;
background-size: 100% 100%;
}
.fixed {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 895px;
box-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.07);
}
.sign-in-box {
width: 443px;
height: 554px;
background: rgba(255, 255, 255, 1);
border-radius: 4px;
padding: 0 26px;
float: left;
position: relative;
}
.background-left {
background: url("../images/login_bg.png") no-repeat center;
background-size: 100%;
float: left;
background-color: #faf8fd;
height: 554px;
width: 400px;
}
</style>
\ No newline at end of file
import Vue from 'vue';
import {
Button,
Container,
Header,
Aside,
Main,
Menu,
Submenu,
MenuItem,
MenuItemGroup,
Table,
TableColumn,
Input,
Notification,
Form,
FormItem,
Row,
Col,
Select,
Option,
Switch,
InputNumber,
Tree,
Tag,
Steps,
Step,
Cascader,
Upload,
Loading,
} from 'element-ui';
Vue.use(Button);
Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Menu);
Vue.use(Submenu);
Vue.use(MenuItem);
Vue.use(MenuItemGroup);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(Input);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Row);
Vue.use(Col);
Vue.use(Select);
Vue.use(Option);
Vue.use(Switch);
Vue.use(InputNumber);
Vue.use(Tree);
Vue.use(Tag);
Vue.use(Steps);
Vue.use(Step);
Vue.use(Cascader);
Vue.use(Upload);
Vue.use(Loading);
Vue.prototype.$notify = Notification;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment