初始化
This commit is contained in:
commit
94a63bbcaa
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
dist/
|
||||
https/
|
||||
.git/
|
92
README.md
Normal file
92
README.md
Normal file
@ -0,0 +1,92 @@
|
||||
# web
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin http://bf3e40369d68/dianwutong_frontend/web.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
- [ ] [Set up project integrations](http://bf3e40369d68/dianwutong_frontend/web/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
12049
dwt-account/webpack-account/package-lock.json
generated
Normal file
12049
dwt-account/webpack-account/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
40
dwt-account/webpack-account/package.json
Normal file
40
dwt-account/webpack-account/package.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "webpack-account",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "login.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "set NODE_ENV=development&&webpack-dev-server --hot",
|
||||
"release": "set NODE_ENV=production&&webpack",
|
||||
"releaseTest": "set NODE_ENV=test&&webpack"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"install": "^0.10.2",
|
||||
"jquery": "^3.2.1",
|
||||
"npm": "^5.6.0",
|
||||
"rxjs": "^5.5.6",
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-loader": "^7.1.2",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"css-loader": "^0.28.10",
|
||||
"es6-promise-promise": "^1.0.0",
|
||||
"extract-text-webpack-plugin": "^3.0.2",
|
||||
"file-loader": "^1.1.6",
|
||||
"happypack": "^4.0.0",
|
||||
"html-webpack-layout-plugin": "0.0.2",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"node-sass": "^4.7.2",
|
||||
"sass-loader": "^6.0.7",
|
||||
"style-loader": "^0.19.1",
|
||||
"uglifyjs-webpack-plugin": "^1.1.6",
|
||||
"url-loader": "^0.6.2",
|
||||
"webpack-dev-server": "^2.9.7",
|
||||
"webpack-visualizer-plugin": "^0.1.11"
|
||||
}
|
||||
}
|
53
dwt-account/webpack-account/releaseHandlePlugin.js
Normal file
53
dwt-account/webpack-account/releaseHandlePlugin.js
Normal file
@ -0,0 +1,53 @@
|
||||
function ReleaseHandlePlugin(options) {
|
||||
this.env = options.env;
|
||||
}
|
||||
|
||||
ReleaseHandlePlugin.prototype.apply = function (complier) {
|
||||
complier.plugin('compilation', compilation => {
|
||||
|
||||
compilation.plugin('optimize-modules', modules => {
|
||||
modules.forEach(mod => {
|
||||
|
||||
try {
|
||||
if (this.env === 'test') {
|
||||
// mod._source._value = mod._source._value.replace(/api.dianwutong.com/g, 'api.test.dianwutong.com');
|
||||
mod._source._value = mod._source._value.replace(/account.dianwutong.com(:\d+)?/g, 'account.dianwutong.com');
|
||||
mod._source._value = mod._source._value.replace(/ems.dianwutong.com(:\d+)?/g, 'ems.dianwutong.com');
|
||||
mod._source._value = mod._source._value.replace(/edp.dianwutong.com(:\d+)?/g, 'edp.dianwutong.com');
|
||||
} else if (this.env === 'production') {
|
||||
mod._source._value = mod._source._value.replace(/api.dianwutong.com/g, 'api.saas.dianwutong.com');
|
||||
mod._source._value = mod._source._value.replace(/account.dianwutong.com(:\d+)?/g, 'account.saas.dianwutong.com');
|
||||
mod._source._value = mod._source._value.replace(/edp.dianwutong.com(:\d+)?/g, 'edp.saas.dianwutong.com');
|
||||
}
|
||||
console.log("替换成功")
|
||||
} catch (error) {
|
||||
console.error("替换失败")
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
compilation.plugin(
|
||||
'html-webpack-plugin-before-html-processing',
|
||||
(data, cb) => {
|
||||
let html = data.html;
|
||||
html = html.replace('<script type="text/javascript" src="build/dev/vendor.dll.js"></script>','');
|
||||
|
||||
if(this.env === 'test'){
|
||||
html = html.replace(/account.dianwutong.com(:\d+)?/g, 'account.test.dianwutong.com')
|
||||
}else if(this.env === 'production'){
|
||||
html = html.replace(/account.dianwutong.com(:\d+)?/g, 'account.saas.dianwutong.com')
|
||||
}
|
||||
|
||||
data.html = html;
|
||||
|
||||
cb(null, data)
|
||||
}
|
||||
)
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = ReleaseHandlePlugin;
|
2457
dwt-account/webpack-account/src/js/common/ui.js
Normal file
2457
dwt-account/webpack-account/src/js/common/ui.js
Normal file
File diff suppressed because it is too large
Load Diff
291
dwt-account/webpack-account/src/js/login/app.js
Normal file
291
dwt-account/webpack-account/src/js/login/app.js
Normal file
@ -0,0 +1,291 @@
|
||||
let $ = require('jquery');
|
||||
import { http } from '../utils/http.util';
|
||||
import { appUtil } from '../utils/app.util';
|
||||
import { cookie } from '../utils/cookie.util';
|
||||
|
||||
require('../../scss/login.scss');
|
||||
|
||||
const app = {
|
||||
init: {},
|
||||
bind: {},
|
||||
checkIn: {},
|
||||
}
|
||||
|
||||
app.init = function () {
|
||||
this.bind();
|
||||
this.canJump('ems');
|
||||
// 如果记住密码了
|
||||
let hasRemember = cookie.get('__rem');
|
||||
if (hasRemember) {
|
||||
let str = this.decodeString(hasRemember);
|
||||
let splits = str.split(',./');
|
||||
$("#username").val(splits[0]);
|
||||
$("#password").val(splits[1]);
|
||||
$("#remember").attr('checked', 'checked');
|
||||
}else {
|
||||
// 2018/9/3 update by guoyuanyuan
|
||||
// 没有记住密码时,清空页面密码和账号
|
||||
$('#username').val('');
|
||||
$('#password').val('');
|
||||
}
|
||||
}
|
||||
|
||||
app.bind = function () {
|
||||
$('#login').click(this.checkIn);
|
||||
// $('#experience').click(this.experience);
|
||||
}
|
||||
|
||||
app.checkIn = function () {
|
||||
|
||||
// Modify start 2018/8/30 14:12 kangzhi
|
||||
// 将输入的用户名和密码的首尾空格去掉
|
||||
let username = $('#username').val().trim();
|
||||
let password = $('#password').val().trim();
|
||||
// Modify end 2018/8/30 14:12 kangzhi
|
||||
|
||||
if (!username) {
|
||||
$("#tips").text('* 请填写用户名');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
$("#tips").text('* 请填写密码');
|
||||
return false;
|
||||
}
|
||||
|
||||
$("#tips").text('');
|
||||
http.post('/admin/rest/user/login', {
|
||||
userName: username,
|
||||
password: password
|
||||
}).subscribe(res => {
|
||||
if (res.code === 200) {
|
||||
// 如果点击了记住密码
|
||||
let isRemember = $("#remember").is(":checked");
|
||||
if (isRemember) {
|
||||
let str = username + ',./' + password;
|
||||
let code = app.encodeString(str);
|
||||
cookie.set('__rem', code, 30);
|
||||
} else if (!isRemember) {
|
||||
// 如果不记住了 就清空掉原来记住的
|
||||
cookie.set('__rem', null, -1);
|
||||
}
|
||||
const userType = parseInt(res.body.userType);
|
||||
|
||||
let url = '';
|
||||
if (userType === 2 || userType === 1) {
|
||||
// 如果是员工的话
|
||||
url = '/ems/rest/employee/role';
|
||||
} else if (userType === 3) {
|
||||
// 如果是客户
|
||||
url = '/ems/rest/customer/token';
|
||||
} else if(userType == 5){
|
||||
// 体验账号
|
||||
window.location.href = "http://edp.dianwutong.com:8081/frame.html";
|
||||
return;
|
||||
|
||||
}else {
|
||||
app.jump();
|
||||
return;
|
||||
}
|
||||
|
||||
http.get(url, {}).subscribe(res => {
|
||||
if (res.code === 200) {
|
||||
app.jump();
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
$("#tips").text('* 用户名或密码不正确');
|
||||
//清空掉原来记住的
|
||||
cookie.set('__rem', null, -1);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 客户体验
|
||||
app.experience = function () {
|
||||
http.post('/admin/rest/user/login_experience', {}).subscribe(res => {
|
||||
if (res.code === 200) {
|
||||
|
||||
let url = '/ems/rest/customer/token';
|
||||
|
||||
http.get(url, {}).subscribe(res1 => {
|
||||
if (res1.code === 200) {
|
||||
window.location.href = "http://edp.dianwutong.com:8081/frame.html";
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$("#tips").text('* 获取信息失败');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
app.jump = function () {
|
||||
// 从哪儿来 回哪儿去
|
||||
let from = appUtil.getParameter('from');
|
||||
|
||||
if (from) {
|
||||
from = unescape(from);
|
||||
}
|
||||
|
||||
// 是否具有跳转的权限 如果没有 则还是跳转到官网
|
||||
// if (/ems(\.test)?.dianwutong.com/.test(from) && this.canJump('ems')) {
|
||||
// window.location.href = from;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (/edp(\.test)?.dianwutong.com/.test(from) && this.canJump('edp')) {
|
||||
// window.location.href = from;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (/console(\.test)?.dianwutong.com/.test(from) && this.canJump('console')) {
|
||||
// window.location.href = from;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if (from) {
|
||||
window.location.href = from;
|
||||
} else {
|
||||
window.location.href = 'http://www.dianwutong.com'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检测账号能否登录某一网站
|
||||
app.canJump = function (website) {
|
||||
let ROLES = {
|
||||
'KH': 1, // 客户
|
||||
'ZTZ': 2, //巡检组团长
|
||||
'XJZZ': 3, //巡检组长
|
||||
'QXBZ': 4, //抢修班长
|
||||
'QXZZ': 5, //抢修组长
|
||||
'AQY': 6, //安全员
|
||||
'ZBZ': 7, //值班长
|
||||
'JKY': 8, //物料员,
|
||||
'KHJL': 9, //客户经理
|
||||
'GCS': 10, // 工程师,权限和值班长一致
|
||||
};
|
||||
|
||||
const webRoles = {
|
||||
'ems': [ROLES.QXBZ, ROLES.ZTZ, ROLES.AQY, ROLES.XJZZ, ROLES.QXZZ, ROLES.ZBZ],
|
||||
'edp': [ROLES.KH, ROLES.QXBZ, ROLES.ZTZ, ROLES.ZBZ, ROLES.GCS],
|
||||
'console': [ROLES.CONSOLE_ADMIN],
|
||||
'ems_admin': [ROLES.EMS_ADMIN]
|
||||
}
|
||||
|
||||
let roles = cookie.get('roles');
|
||||
!roles && (roles = '');
|
||||
roles = roles.split('a');
|
||||
|
||||
let isContainer = false;
|
||||
|
||||
let length = roles.length;
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (webRoles[website].indexOf(parseInt(roles[i])) !== -1) {
|
||||
isContainer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let userType = cookie.get('userType');
|
||||
|
||||
if (website === 'ems' && isContainer) {
|
||||
// 只有员工可以进去
|
||||
if (userType === '2') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (website === 'edp' && isContainer) {
|
||||
// 只有员工 和 客户可以进去 工程师也可以进去
|
||||
if (userType === '2' || userType === '3' || userType == '5' || userType === '1') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (website === 'console') {
|
||||
// 只有控制台管理员
|
||||
if (userType === '1') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 2018/9/3 update by guoyuanyuan
|
||||
// 重写了字符串加密方法
|
||||
/**
|
||||
* encodeString 加密程序
|
||||
* @param {Strng} str 待加密字符串
|
||||
* @param {Number} xor 异或值
|
||||
* @param {Number} hex 加密后的进制数
|
||||
* @return {Strng} 加密后的字符串
|
||||
*/
|
||||
app.encodeString = function (str, xor, hex) {
|
||||
|
||||
if (typeof str !== 'string' ) {
|
||||
return;
|
||||
}
|
||||
xor = xor?xor: 123;
|
||||
hex = hex?hex: 25;
|
||||
let resultList = [];
|
||||
hex = hex <= 25 ? hex : hex % 25;
|
||||
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
// 提取字符串每个字符的ascll码
|
||||
let charCode = str.charCodeAt(i);
|
||||
// 进行异或加密
|
||||
charCode = (charCode * 1) ^ xor;
|
||||
// 异或加密后的字符转成 hex 位数的字符串
|
||||
charCode = charCode.toString(hex);
|
||||
resultList.push(charCode);
|
||||
}
|
||||
|
||||
let splitStr = String.fromCharCode(hex + 97);
|
||||
let resultStr = resultList.join(splitStr);
|
||||
return resultStr;
|
||||
};
|
||||
|
||||
// 2018/9/3 update by guoyuanyuan
|
||||
// 重写了字符串解密方法
|
||||
|
||||
/**
|
||||
* decodeString 解密程序
|
||||
* @param {Strng} str 待加密字符串
|
||||
* @param {Number} xor 异或值
|
||||
* @param {Number} hex 加密后的进制数
|
||||
* @return {Strng} 加密后的字符串
|
||||
*/
|
||||
|
||||
app.decodeString = function (str, xor, hex) {
|
||||
if (typeof str !== 'string' ) {
|
||||
return;
|
||||
}
|
||||
xor = xor?xor: 123;
|
||||
hex = hex?hex: 25;
|
||||
let strCharList = [];
|
||||
let resultList = [];
|
||||
hex = hex <= 25 ? hex : hex % 25;
|
||||
// 解析出分割字符
|
||||
let splitStr = String.fromCharCode(hex + 97);
|
||||
// 分割出加密字符串的加密后的每个字符
|
||||
strCharList = str.split(splitStr);
|
||||
|
||||
for (let i = 0; i < strCharList.length; i++) {
|
||||
// 将加密后的每个字符转成加密后的ascll码
|
||||
let charCode = parseInt(strCharList[i], hex);
|
||||
// 异或解密出原字符的ascll码
|
||||
charCode = (charCode * 1) ^ xor;
|
||||
let strChar = String.fromCharCode(charCode);
|
||||
resultList.push(strChar);
|
||||
}
|
||||
let resultStr = resultList.join('');
|
||||
return resultStr;
|
||||
};
|
||||
|
||||
app.init();
|
22
dwt-account/webpack-account/src/js/reset-complete/app.js
Normal file
22
dwt-account/webpack-account/src/js/reset-complete/app.js
Normal file
@ -0,0 +1,22 @@
|
||||
require('../../scss/reset-complete.scss');
|
||||
let $ = require('jquery');
|
||||
import { cookie } from '../utils/cookie.util';
|
||||
import { appUtil } from '../utils/app.util';
|
||||
let app = {
|
||||
init: {}
|
||||
}
|
||||
|
||||
app.init = function () {
|
||||
this.bind();
|
||||
}
|
||||
|
||||
app.bind = function () {
|
||||
$('#login').click(function () {
|
||||
window.localStorage.removeItem('id');
|
||||
window.location.href = 'login.html?from='+appUtil.getParameter('from');
|
||||
})
|
||||
}
|
||||
|
||||
$(function () {
|
||||
app.init();
|
||||
})
|
63
dwt-account/webpack-account/src/js/reset-password/app.js
Normal file
63
dwt-account/webpack-account/src/js/reset-password/app.js
Normal file
@ -0,0 +1,63 @@
|
||||
require( '../../scss/reset-password.scss' );
|
||||
|
||||
let $ = require('jquery')
|
||||
import { helper } from './helper';
|
||||
import { appUtil } from '../utils/app.util';
|
||||
|
||||
|
||||
let app = {
|
||||
init:{},
|
||||
bind:{}
|
||||
}
|
||||
app.init = function () {
|
||||
this.bind();
|
||||
}
|
||||
|
||||
app.bind = function () {
|
||||
|
||||
$('#newPassword,#confirmPassword').keyup(function (e) {
|
||||
if(e.keyCode == 13){
|
||||
$('#confirm').click();
|
||||
}
|
||||
let newPassword = $.trim($('#newPassword').val());
|
||||
let confirmPassword = $.trim($('#confirmPassword').val());
|
||||
if(newPassword.length > 0 && confirmPassword.length > 0){
|
||||
|
||||
$('#confirm').addClass('able');
|
||||
}else {
|
||||
$('#confirm').removeClass('able');
|
||||
}
|
||||
})
|
||||
|
||||
//点击确定按钮
|
||||
$('#confirm').click(function () {
|
||||
$('#newPasswordTip').text('');
|
||||
$('#confirmPassword').text('');
|
||||
|
||||
let newPassword = $.trim($('#newPassword').val());
|
||||
let confirmPassword = $.trim($('#confirmPassword').val());
|
||||
|
||||
if(newPassword.length == 0){
|
||||
$('#newPasswordTip').text('请输入新密码');
|
||||
|
||||
}else if (confirmPassword.length == 0){
|
||||
$('#confirmPasswordTip').text('请确认新密码');
|
||||
}else if(newPassword != confirmPassword){
|
||||
$('#confirmPasswordTip').text('两次密码不一致');
|
||||
}else {
|
||||
//提交修改密码
|
||||
let id = window.localStorage.getItem('id');
|
||||
helper.resetPassword(newPassword,id)
|
||||
.then(function () {
|
||||
window.location.href = 'reset-complete.html?from=' + appUtil.getParameter('from');
|
||||
},function() {
|
||||
$('#confirmPasswordTip').text('密码修改失败');
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
$(function () {
|
||||
app.init();
|
||||
})
|
20
dwt-account/webpack-account/src/js/reset-password/helper.js
Normal file
20
dwt-account/webpack-account/src/js/reset-password/helper.js
Normal file
@ -0,0 +1,20 @@
|
||||
import { http } from '../utils/http.util';
|
||||
export let helper = {
|
||||
resetPassword:{}
|
||||
}
|
||||
helper.resetPassword = function (password,id) {
|
||||
const data = {
|
||||
password:password,
|
||||
userId:id
|
||||
}
|
||||
const path = "/admin/rest/user/forget/password";
|
||||
return new Promise(function (resolve,reject) {
|
||||
http.post(path, data).subscribe(function (res) {
|
||||
if(res.code == 200){
|
||||
resolve(res);
|
||||
}else {
|
||||
reject(res.code);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
124
dwt-account/webpack-account/src/js/update-password/app.js
Normal file
124
dwt-account/webpack-account/src/js/update-password/app.js
Normal file
@ -0,0 +1,124 @@
|
||||
require('../../scss/update-password.scss');
|
||||
let $ = require('jquery');
|
||||
|
||||
import { UI } from '../common/ui';
|
||||
import { http } from '../utils/http.util';
|
||||
import { cookie } from '../utils/cookie.util';
|
||||
import { appUtil } from '../utils/app.util';
|
||||
|
||||
|
||||
let local = {
|
||||
username: null,
|
||||
originPwd: null,
|
||||
newPwd: null,
|
||||
// 用户类型
|
||||
USER_TYPES: {
|
||||
'ADMIN': 1, // 管理员
|
||||
'EMPLOYEE': 2, // 员工
|
||||
'CUSTOMER': 3 // 客户
|
||||
}
|
||||
};
|
||||
$(function () {
|
||||
local.init();
|
||||
});
|
||||
local.init = function () {
|
||||
|
||||
// Add start 2018/9/26 16:00 kangzhi
|
||||
// 体验账户登录后无法显示修改账号密码页,避免体验账户通过直接输入地址跳转到修改页
|
||||
if (cookie.get('experience')) {
|
||||
$('body').html('体验账户无法显示本页面');
|
||||
return;
|
||||
}
|
||||
// Add start 2018/9/26 16:00 kangzhi
|
||||
|
||||
|
||||
this.username = cookie.get('userName');
|
||||
this.userType = cookie.get('userType');
|
||||
// Edit start 2018/9/26 16:02 kangzhi
|
||||
// cusName->userName
|
||||
this.realName = (this.userType == this.USER_TYPES.CUSTOMER ? cookie.get('userName') : decodeURI(cookie.get('employeeName')));
|
||||
// Edit end 2018/9/26 16:02 kangzhi
|
||||
$('#username').html(this.username);
|
||||
$('#realName').html(this.realName);
|
||||
local.bind();
|
||||
};
|
||||
local.bind = function () {
|
||||
|
||||
$('#newPwd,#newPwdConfirm,#pwd').on('keyup', function (e) {
|
||||
var pwd = $('#pwd').val();
|
||||
var newPwd = $('#newPwd').val();
|
||||
var newPwdConfirm = $('#newPwdConfirm').val();
|
||||
if (pwd && newPwd && newPwdConfirm) {
|
||||
$('#submit').addClass('active');
|
||||
}else {
|
||||
$('#submit').removeClass('active');
|
||||
}
|
||||
if (e.keyCode == 13) {
|
||||
$("#submit").click();
|
||||
}
|
||||
})
|
||||
|
||||
$('#submit').click(function () {
|
||||
$('#pwdTip').html('');
|
||||
$('#newPwdTip').html('');
|
||||
var pwd = $('#pwd').val();
|
||||
var newPwd = $('#newPwd').val();
|
||||
var newPwdConfirm = $('#newPwdConfirm').val();
|
||||
if (!pwd) {
|
||||
$('#pwdTip').html('原密码不能为空');
|
||||
return;
|
||||
}
|
||||
if (!newPwd) {
|
||||
$('#newPwdTip').html('新密码不能为空');
|
||||
return;
|
||||
}
|
||||
if (!newPwdConfirm) {
|
||||
$('#newPwdConfirmTip').html('请确认密码');
|
||||
return;
|
||||
}
|
||||
if (newPwd != newPwdConfirm) {
|
||||
$('#newPwdConfirmTip').html('两次密码不相同');
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPwd && pwd && newPwd == newPwdConfirm) {
|
||||
$('#pwdTip').html('');
|
||||
$('#newPwdTip').html('');
|
||||
$('#newPwdConfirmTip').html('');
|
||||
let data = {
|
||||
userName: local.username,
|
||||
oldPassword: pwd,
|
||||
newPassword: newPwd
|
||||
}
|
||||
let path = "/admin/rest/user/edit/password";
|
||||
http.post(path, data).subscribe(function (res) {
|
||||
if (res.code === 200) {
|
||||
UI.alert({
|
||||
'content': "密码已修改成功,请重新登录",
|
||||
'btn': '知道了',
|
||||
'callback': function () {
|
||||
local.logout();
|
||||
return;
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
$('#pwdTip').html('原密码不正确');
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
local.logout = function () {
|
||||
http.post('/admin/rest/user/logout', {}).subscribe(res => {
|
||||
if (res.code === 200) {
|
||||
cookie.deleteAll();
|
||||
window.location.href = 'http://account.dianwutong.com:8020/login.html?form='+appUtil.getParameter('from');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
67
dwt-account/webpack-account/src/js/utils/app.util.js
Normal file
67
dwt-account/webpack-account/src/js/utils/app.util.js
Normal file
@ -0,0 +1,67 @@
|
||||
const appUtil = {}
|
||||
|
||||
/**
|
||||
* 判断当前浏览器是否是IE浏览器
|
||||
*/
|
||||
appUtil.isIE = function(){
|
||||
var UA = navigator.userAgent;
|
||||
if(/Trident/i.test(UA)){
|
||||
if(/MSIE (\d{1,})/i.test(UA)){
|
||||
return RegExp.$1;
|
||||
}else if(/rv:(\d{1,})/i.test(UA)){
|
||||
return RegExp.$1;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* 对字符串加密
|
||||
* @param str
|
||||
* @returns {string}
|
||||
*/
|
||||
|
||||
appUtil.encodeString = function(str){
|
||||
var length = str.length;
|
||||
var code = '';
|
||||
|
||||
for(var i = 0; i < length; i++){
|
||||
console.log(((+i)+(+str.charAt(i))));
|
||||
code += String.fromCharCode(str.charCodeAt(i)+(i-length));
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
/***
|
||||
* encodeString的逆序操作
|
||||
* @param code
|
||||
* @returns {string}
|
||||
*/
|
||||
|
||||
appUtil.decodeString = function(code){
|
||||
var length = code.length;
|
||||
var str = '';
|
||||
|
||||
for(var i = 0; i < length; i++){
|
||||
str += String.fromCharCode(code.charCodeAt(i)-(i-length));
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/***
|
||||
* 从url上获取一个参数
|
||||
* @param name
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
appUtil.getParameter = function (name) {
|
||||
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if (r != null)return RegExp.$2;
|
||||
return null;
|
||||
};
|
||||
|
||||
exports.appUtil = appUtil;
|
53
dwt-account/webpack-account/src/js/utils/cookie.util.js
Normal file
53
dwt-account/webpack-account/src/js/utils/cookie.util.js
Normal file
@ -0,0 +1,53 @@
|
||||
const cookie = {}
|
||||
|
||||
cookie.get = function (key) {
|
||||
|
||||
let reg = '('+key+')=(.*?)(;|$|;\s)';
|
||||
reg = new RegExp(reg);
|
||||
if(reg.test(document.cookie)){
|
||||
return RegExp.$2;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置一个cookie
|
||||
* @param {string} key
|
||||
* @param {string} value
|
||||
* @param {number} expires
|
||||
* @param {string} path
|
||||
*/
|
||||
cookie.set = function (key, value, expires, path) {
|
||||
|
||||
let cookie = key + '=' + escape(value);
|
||||
|
||||
if(expires){
|
||||
const now = new Date();
|
||||
expires = now.setDate( now.getDate() + expires )
|
||||
cookie += ';expires='+ new Date(expires).toGMTString();
|
||||
}
|
||||
|
||||
if(path){
|
||||
cookie += ';path='+escape(path);
|
||||
}
|
||||
|
||||
document.cookie = cookie;
|
||||
}
|
||||
|
||||
cookie.delete = function (key, path) {
|
||||
cookie.set(key, null, -1, path);
|
||||
}
|
||||
|
||||
cookie.deleteAll = function () {
|
||||
let cookies = document.cookie.replace(/\s/, '').split(';');
|
||||
|
||||
for( let i=0; i<cookies.length; i++){
|
||||
let pairs = cookies[i].split('=');
|
||||
if(pairs && pairs[0]){
|
||||
cookie.delete(pairs[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.cookie = cookie;
|
224
dwt-account/webpack-account/src/js/utils/date.util.js
Normal file
224
dwt-account/webpack-account/src/js/utils/date.util.js
Normal file
@ -0,0 +1,224 @@
|
||||
function DateUtils(date) {
|
||||
|
||||
this.date = null;
|
||||
|
||||
/***
|
||||
* 设置日期
|
||||
*/
|
||||
this.setDate = function(date) {
|
||||
if (date instanceof Date) {
|
||||
this.date = date;
|
||||
} else if (typeof date == "date") {
|
||||
this.date = date;
|
||||
} else if (typeof date == "string") {
|
||||
date = date.replace(/\-/, '/');
|
||||
this.date = new Date(date);
|
||||
} else if (typeof date == "number") {
|
||||
this.date = new Date(date);
|
||||
} else {
|
||||
this.date = new Date();
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* 格式化字符串
|
||||
* date 可以是Date类型 或者字符串类型
|
||||
* format 是格式字符串
|
||||
* y 年
|
||||
* M 月
|
||||
* d 日
|
||||
* h 时
|
||||
* m 分钟
|
||||
* s 秒
|
||||
* S 毫秒
|
||||
* q 季度
|
||||
*/
|
||||
this.getFormattedDate = function(format) {
|
||||
if (!format) {
|
||||
format = "yyyy-MM-dd hh:mm:ss";
|
||||
}
|
||||
var o = {
|
||||
"M+": this.date.getMonth() + 1, //month
|
||||
"d+": this.date.getDate(), //day
|
||||
"h+": this.date.getHours(), //hour
|
||||
"m+": this.date.getMinutes(), //minute
|
||||
"s+": this.date.getSeconds(), //second
|
||||
"q+": Math.floor((this.date.getMonth() + 3) / 3), //quarter
|
||||
"S": this.date.getMilliseconds() //millisecond
|
||||
}
|
||||
|
||||
if (/(y+)/.test(format)) {
|
||||
format = format.replace(RegExp.$1, (this.date.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
}
|
||||
|
||||
for (var k in o) {
|
||||
if (new RegExp("(" + k + ")").test(format)) {
|
||||
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
|
||||
}
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断年份是否为润年
|
||||
*
|
||||
* @param {Number} year
|
||||
*/
|
||||
this.isLeapYear = function(year) {
|
||||
var year = year || this.date.getFullYear();
|
||||
return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
|
||||
}
|
||||
/**
|
||||
* 获取某一年份的某一月份的天数
|
||||
*
|
||||
* @param {Number} year
|
||||
* @param {Number} month
|
||||
*/
|
||||
this.getMonthDays = function(month,year) {
|
||||
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] || (this.isLeapYear(year) ? 29 : 28);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某年的某天是第几周
|
||||
* @param {Number}
|
||||
* @param {Number}
|
||||
* @param {Number}
|
||||
* @returns {Number}
|
||||
*/
|
||||
this.getWeek = function () {
|
||||
var year = this.date.getFullYear(),
|
||||
month = this.date.getMonth(),
|
||||
days = this.date.getDate();
|
||||
//那一天是那一年中的第多少天
|
||||
for (var i = 0; i < month; i++) {
|
||||
days += this.getMonthDays(i);
|
||||
}
|
||||
|
||||
//那一年第一天是星期几
|
||||
var yearFirstDay = new Date(year, 0, 1).getDay() || 7;
|
||||
|
||||
var week = null;
|
||||
if (yearFirstDay == 1) {
|
||||
week = Math.ceil(days / yearFirstDay);
|
||||
} else {
|
||||
days -= (7 - yearFirstDay + 1);
|
||||
week = Math.ceil(days / 7) + 1;
|
||||
}
|
||||
|
||||
return week;
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取毫秒数
|
||||
*/
|
||||
this.getMillisecond = function(){
|
||||
return this.date.valueOf();
|
||||
}
|
||||
|
||||
/***
|
||||
* 获取日期的毫秒数 00:00:00
|
||||
*/
|
||||
this.getFirstMillisecondOfDate = function () {
|
||||
var d = new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(), 0, 0, 0);
|
||||
return d.getTime();
|
||||
}
|
||||
/***
|
||||
* 获取日期的毫秒数 23:59:59
|
||||
*/
|
||||
this.getLastMillisecondOfDate = function () {
|
||||
var d = new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(), 23, 59, 59);
|
||||
return d.getTime();
|
||||
}
|
||||
/**
|
||||
* 获取日期的毫秒数 hour:00:00
|
||||
*/
|
||||
this.getFirstMillisecondOfHour = function () {
|
||||
var d = new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(), this.date.getHours(), 0, 0);
|
||||
return d.getTime();
|
||||
}
|
||||
/**
|
||||
* 获取日期的毫秒数 hour:59:59
|
||||
*/
|
||||
this.getLastMillisecondOfHour = function () {
|
||||
var d = new Date(this.date.getFullYear(), this.date.getMonth(), this.date.getDate(), this.date.getHours(), 59, 59);
|
||||
return d.getTime();
|
||||
}
|
||||
/**
|
||||
* 获取本月第一天的秒数
|
||||
*/
|
||||
this.getFirstMillisecondOfMonth = function () {
|
||||
var d = new Date(this.date.getFullYear(),this.date.getMonth(),1,0,0,0);
|
||||
return d.getTime();
|
||||
}
|
||||
/**
|
||||
* 获取本月最后一天的秒数
|
||||
*/
|
||||
this.getLastMillisecondOfMonth = function (year,month) {
|
||||
var day;
|
||||
var month = month || this.date.getMonth();
|
||||
var year = year || this.date.getFullYear();
|
||||
day = this.getMonthDays(month,year);
|
||||
var d = new Date(this.date.getFullYear(),this.date.getMonth(),day,23,59,59);
|
||||
return d.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取本年第一月第一天的秒数
|
||||
*/
|
||||
this.getFirstMillisecondOfYear = function () {
|
||||
var d = new Date(this.date.getFullYear(),0,1,0,0,0);
|
||||
return d.getTime();
|
||||
}
|
||||
/**
|
||||
* 获取本年最后一天的秒数
|
||||
*/
|
||||
this.getLastMillisecondOfYear = function () {
|
||||
var d = new Date(this.date.getFullYear(),11,31,23,59,59);
|
||||
return d.getTime();
|
||||
}
|
||||
/***
|
||||
* 计算第一个日期距离第二个日期多少天
|
||||
* 如果不传递第二个日期 默认是当前日期
|
||||
*/
|
||||
this.getDateDistance = function(date1, date2){
|
||||
var times1, times2;
|
||||
|
||||
if(!date1 || !(date1 instanceof Date)){
|
||||
return null;
|
||||
}
|
||||
if(!date2){
|
||||
date2 = new Date();
|
||||
}else if(!(date2 instanceof Date)){
|
||||
return null
|
||||
}
|
||||
|
||||
var d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
|
||||
var d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
||||
|
||||
return (d1-d2)/86400000;
|
||||
}
|
||||
|
||||
/***
|
||||
* 增加天数
|
||||
*/
|
||||
this.addDays = function(days) {
|
||||
var daysMilliSeconds = days*86400000;
|
||||
var targetMilliSeconds = this.date.valueOf()+daysMilliSeconds;
|
||||
this.date = new Date(targetMilliSeconds);
|
||||
};
|
||||
|
||||
/***
|
||||
* 减少天数
|
||||
*/
|
||||
this.subDays = function(days) {
|
||||
var daysMilliSeconds = days*86400000;
|
||||
var targetMilliSeconds = this.date.valueOf() - daysMilliSeconds;
|
||||
this.date = new Date(targetMilliSeconds);
|
||||
}
|
||||
|
||||
|
||||
//设置初始日期
|
||||
this.setDate(date);
|
||||
}
|
||||
|
||||
exports.dateUtil = new DateUtils();
|
177
dwt-account/webpack-account/src/js/utils/http.util.js
Normal file
177
dwt-account/webpack-account/src/js/utils/http.util.js
Normal file
@ -0,0 +1,177 @@
|
||||
import { Subject, Observable } from 'rxjs/Rx'
|
||||
import { Rx } from 'rxjs'
|
||||
import { cookie } from '../utils/cookie.util'
|
||||
|
||||
// const basePath = 'http://api.dianwutong.com';
|
||||
const basePath = 'https://api.saas.dianwutong.com'
|
||||
|
||||
const http = {}
|
||||
|
||||
/**
|
||||
* http post 请求
|
||||
* @param { string } url
|
||||
* @param { json } param
|
||||
*/
|
||||
|
||||
http.post = function (url, param) {
|
||||
|
||||
// 不传路径的话 直接返回
|
||||
|
||||
if (!url) {
|
||||
return Observable.create(ob => {
|
||||
throw new Error('路径不合法')
|
||||
})
|
||||
}
|
||||
|
||||
url = basePath + url
|
||||
param = param ? param : {}
|
||||
|
||||
// 如果有查找到token 在url中加入token
|
||||
const token = cookie.get('token')
|
||||
|
||||
if (token) {
|
||||
url = url + '?token=' + token
|
||||
}
|
||||
|
||||
|
||||
return Observable.ajax({
|
||||
url: url,
|
||||
method: 'POST',
|
||||
crossDomain: true,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: param
|
||||
}).map(e => {
|
||||
return e.response
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
http.get = function (url, param) {
|
||||
|
||||
// 不传路径的话 直接返回
|
||||
|
||||
if (!url) {
|
||||
return Observable.create(ob => {
|
||||
throw new Error('路径不合法')
|
||||
})
|
||||
}
|
||||
|
||||
let observable = new Subject()
|
||||
url = basePath + url
|
||||
|
||||
// 如果参数不为空 将参数拼接到url后面
|
||||
|
||||
let queries = []
|
||||
|
||||
// 如果已经登录 传入token
|
||||
|
||||
let token = cookie.get('token')
|
||||
|
||||
if (token) {
|
||||
queries.push('token=' + token)
|
||||
}
|
||||
|
||||
if (param) {
|
||||
for (var i in param) {
|
||||
if (param.hasOwnProperty(i)) {
|
||||
queries.push(i + '=' + param[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let queryString = queries.join('&')
|
||||
|
||||
if (queryString) {
|
||||
url = url + '?' + queryString
|
||||
}
|
||||
|
||||
return Observable.ajax({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
crossDomain: true,
|
||||
withCredentials: true,
|
||||
}).map(e => {
|
||||
return e.response
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* http post 请求
|
||||
* @param { string } url
|
||||
* @param { json } param
|
||||
*/
|
||||
|
||||
http.put = function (url, param) {
|
||||
|
||||
// 不传路径的话 直接返回
|
||||
|
||||
if (!url) {
|
||||
return Observable.create(ob => {
|
||||
throw new Error('路径不合法')
|
||||
})
|
||||
}
|
||||
|
||||
url = basePath + url
|
||||
|
||||
// 如果有查找到token 在url中加入token
|
||||
// TODO
|
||||
|
||||
// 如果有查找到token 在url中加入token
|
||||
const token = cookie.get('token')
|
||||
|
||||
if (token) {
|
||||
url = url + '?token=' + token
|
||||
}
|
||||
|
||||
param = param ? param : {}
|
||||
|
||||
return Observable.ajax({
|
||||
url: url,
|
||||
method: 'POST',
|
||||
crossDomain: true,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: param
|
||||
}).map(e => {
|
||||
return e.response
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
http.uploadFile = function (file, from, type) {
|
||||
var form = new FormData()
|
||||
|
||||
var fileName = 'img.' + file.type.split('/')[1]
|
||||
|
||||
form.append('file', file, fileName)
|
||||
form.append('from', from)
|
||||
form.append('type', type)
|
||||
|
||||
url = basePath + '/file_upload.do'
|
||||
|
||||
const token = cookie.get('token')
|
||||
|
||||
if (token) {
|
||||
url = url + '?token=' + token
|
||||
}
|
||||
|
||||
var param = {
|
||||
url: url,
|
||||
method: 'POST',
|
||||
contentType: 'application/json;charset=utf-8',
|
||||
body: form
|
||||
}
|
||||
return Rx.Observable.ajax(param).map(function (res) {
|
||||
if (res.status == 200) {
|
||||
return res.response
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
exports.http = http
|
139
dwt-account/webpack-account/src/js/verify-phone/app.js
Normal file
139
dwt-account/webpack-account/src/js/verify-phone/app.js
Normal file
@ -0,0 +1,139 @@
|
||||
require('../../scss/verify-phone.scss');
|
||||
let $ = require('jquery');
|
||||
|
||||
import { helper } from './helper';
|
||||
import { appUtil } from '../utils/app.util';
|
||||
|
||||
let app = {
|
||||
init: {},
|
||||
bind: {},
|
||||
isCountingDown: false,
|
||||
};
|
||||
app.init = function () {
|
||||
|
||||
this.bind();
|
||||
};
|
||||
|
||||
app.bind = function () {
|
||||
|
||||
var _this = app;
|
||||
let $countDown = $('#countDown');
|
||||
let $phoneNumber = $('#phoneNumber');
|
||||
let $phoneTip = $('#phoneTip');
|
||||
let $codeTip = $('#codeTip');
|
||||
let $codeNumber = $('#codeNumber');
|
||||
let $confirm = $('#confirm');
|
||||
|
||||
//点击获取验证码按钮
|
||||
|
||||
$countDown.on('click', function () {
|
||||
if (_this.isCountingDown) {
|
||||
return;
|
||||
}
|
||||
|
||||
//验证手机号码是否为空,如果为空,给出提示
|
||||
|
||||
let phoneNumber = $phoneNumber.val();
|
||||
if (!phoneNumber) {
|
||||
$phoneTip.html('请输入手机号');
|
||||
return;
|
||||
} else {
|
||||
$phoneTip.html('');
|
||||
|
||||
//手机号不为空 验证手机号是否正确 如果正确进行倒计时 不正确则给出提示
|
||||
|
||||
_this.verifyPhone(phoneNumber);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//监听手机号和验证码输入 不为空时改变提交按钮状态
|
||||
|
||||
$('#phoneNumber,#codeNumber').keyup(function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
$confirm.click();
|
||||
}
|
||||
let phoneNumber = $.trim($phoneNumber.val());
|
||||
let codeNumber = $.trim($codeNumber.val());
|
||||
|
||||
if (phoneNumber.length > 0 && codeNumber.length > 0) {
|
||||
$confirm.addClass('able');
|
||||
} else {
|
||||
$confirm.removeClass('able');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//点击确定按钮
|
||||
$confirm.on('click', function () {
|
||||
$phoneTip.text('');
|
||||
$codeTip.text('');
|
||||
let phoneNumber = $.trim($phoneNumber.val());
|
||||
let codeNumber = $.trim($codeNumber.val());
|
||||
|
||||
if (phoneNumber.length == 0) {
|
||||
$phoneTip.text('请填写手机号');
|
||||
return;
|
||||
} else if (codeNumber.length == 0) {
|
||||
$phoneTip.text('');
|
||||
$codeTip.text('请填写验证码');
|
||||
return;
|
||||
} else {
|
||||
helper.verifyPhone(phoneNumber, codeNumber)
|
||||
.then(function (res) {
|
||||
//存储id
|
||||
window.localStorage.setItem('id',escape (res.body))
|
||||
window.location.href = 'reset-password.html?from='+appUtil.getParameter('from');
|
||||
|
||||
|
||||
}, function () {
|
||||
$codeTip.text('验证码不正确');
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//验证手机号是否正确 如果正确进行倒计时 不正确则给出提示
|
||||
|
||||
app.verifyPhone = function (mobile) {
|
||||
let _this = app;
|
||||
let $phoneTip = $('#phoneTip');
|
||||
helper.getCode(mobile)
|
||||
.then(function (res) {
|
||||
$phoneTip.html('');
|
||||
_this.countDown();
|
||||
})
|
||||
.catch(function () {
|
||||
$phoneTip.html('手机号不正确');
|
||||
});
|
||||
};
|
||||
|
||||
//进行倒计时
|
||||
|
||||
app.countDown = function () {
|
||||
let _this = app;
|
||||
let $countDown = $('#countDown');
|
||||
var i = 60;
|
||||
_this.isCountingDown = true;
|
||||
countdown();
|
||||
function countdown() {
|
||||
i--;
|
||||
if (i <= 0) {
|
||||
$countDown.val('点击获取验证码');
|
||||
_this.isCountingDown = false;
|
||||
return;
|
||||
}
|
||||
$countDown.val(i + 's');
|
||||
if (timer) {
|
||||
window.clearTimeout(timer);
|
||||
}
|
||||
var timer = window.setTimeout(countdown, 1000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
$(function () {
|
||||
app.init();
|
||||
});
|
56
dwt-account/webpack-account/src/js/verify-phone/helper.js
Normal file
56
dwt-account/webpack-account/src/js/verify-phone/helper.js
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
import { http } from '../utils/http.util';
|
||||
|
||||
export var helper = {
|
||||
|
||||
checkIn : {},
|
||||
experience : {}
|
||||
|
||||
};
|
||||
|
||||
/***
|
||||
* 获取短信验证码
|
||||
* @param mobile
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
helper.getCode = function (mobile) {
|
||||
const data = {
|
||||
userName:mobile
|
||||
};
|
||||
let path = '/admin/rest/user/get/sms';
|
||||
|
||||
return new Promise(function (resolve,reject) {
|
||||
http.post(path,data).subscribe(function (res) {
|
||||
if(res.code == '200'){
|
||||
resolve(res);
|
||||
}else {
|
||||
reject(res.code);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 验证手机号和验证码是否正确
|
||||
*/
|
||||
|
||||
helper.verifyPhone = function (mobile,sms) {
|
||||
const data = {
|
||||
userName:mobile,
|
||||
code:sms
|
||||
};
|
||||
const path = '/admin/rest/user/sms/validate';
|
||||
return new Promise(function (resolve,reject) {
|
||||
http.post(path, data).subscribe(function (res) {
|
||||
|
||||
if(res.code == '200'){
|
||||
console.log(res)
|
||||
resolve(res);
|
||||
}else {
|
||||
console.log(88888888888)
|
||||
reject(res.code);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
18
dwt-account/webpack-account/src/scss/common.scss
Normal file
18
dwt-account/webpack-account/src/scss/common.scss
Normal file
@ -0,0 +1,18 @@
|
||||
body{
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
min-width: 1400px;
|
||||
animation: bodyFadeIn .2s linear forwards;
|
||||
}
|
||||
@keyframes bodyFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||