1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- var areaData = "[12,34]";//省数据
- var form;
- var $;
- var userInfo = layui.sessionData(window.hywa.sessionTable.tableName);
- if (JSON.stringify(userInfo) == '{}') {
- parent.location.href = window.hywa.jumpPage.login;
- } else {
- try {
- userInfo = userInfo.userData;
- } catch (err) {
- parent.location.href = window.hywa.jumpPage.login;
- }
- }
- layui.config({
- base: "../../js/"
- }).use(['form', 'layer', 'laytpl','md5'], function () {
- form = layui.form;
- var layer = layui.layer,
- laytpl = layui.laytpl,
- $ = layui.jquery,
- md5 = layui.md5;
- //添加验证规则
- form.verify({
- newPwd: [
- /^[\S]{6,12}$/,
- '密码必须6到12位,且不能出现空格'
- ],
- confirmPwd: function (value) {
- if ($("#oldPwd").val() != value) {
- return "两次输入密码不一致,请重新输入!";
- }
- }
- })
- userInfo.password = null;
- form.val("changePwd", userInfo);
- //修改密码
- form.on("submit(changePwdSub)", function (data) {
- var index = layer.msg('提交中,请稍候', {
- icon: 16,
- time: false,
- shade: 0.8
- });
- dataJson = $.extend({},userInfo,data.field);
- dataJson.guid = dataJson.userId;
- var time = 'b8d11ee289394be688ef3a4f6968efed';
- var result = btoa(dataJson.oldPasswd);
- time = time.substring(0, 8);
- var pass = md5.calcMD5(time);
- pass = pass.substring(0, 5);
- dataJson.oldPasswd = pass + result;
- delete dataJson.menus;
- $.ajax({
- type: 'post',
- url: 'changePassword',
- data: JSON.stringify(dataJson),
- contentType: 'application/json',
- success: function (res) {
- layer.close(index);
- if (!(res.code - 0)) {
- layer.msg(res.msg, {
- icon: 1
- });
- layer.close(index);
- }
- $(".pwd").val('');
- }
- });
- return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
- })
- var getTpl = demo.innerHTML,
- view = document.getElementById('view');
- laytpl(getTpl).render(userInfo, function (html) {
- view && (view.innerHTML = html);
- });
- })
|