72e555a7 by 任超

style:cookie修改

1 parent 73cd4304
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网上“一窗办事”登记系统</title>
......@@ -39,7 +40,8 @@
</a>
</li>
<li>
<a class="cardItem" href="./staticViews/convenienceService/certificateVerification.html" title="证书核验">
<a class="cardItem" href="./staticViews/convenienceService/certificateVerification.html"
title="证书核验">
<img src="./staticImages/zshy.png" alt="证书核验">
证书核验
</a>
......@@ -374,5 +376,4 @@
<script type="text/javascript" src="./staticJs/down.js"></script>
<script type="text/javascript" src="./staticJs/common.js"></script>
<script type="text/javascript" src="./staticJs/pageHome.js"></script>
</html>
......
......@@ -38,24 +38,44 @@ function GetQueryString(name) {
var r = window.location.search.substr(1).match(reg);
if (r != null) return (r[2]); return null;
}
// 存储cookie
function setCookie(name, resdata, duration) {
var date = new Date();
date.setTime(date.getTime() + duration * 12 * 3600 * 1000);
document.cookie = name + "=" + JSON.stringify(resdata) + ";expires=" + date.toGMTString() + "; path=/";
};
// function setCookie(name, resdata, duration) {
// var date = new Date();
// date.setTime(date.getTime() + duration * 12 * 3600 * 1000);
// document.cookie = name + "=" + JSON.stringify(resdata) + ";expires=" + date.toGMTString() + "; path=/";
// };
// function getCookie() {
// var str = document.cookie;
// if (str == '') {
// return false
// } else {
// var arr = str.split(';')
// var arr1 = arr[0].replace(/(\s)+/g, '').split('=');
// return JSON.parse(arr1[1]);
// }
// };
//获取cookie
function getCookie() {
var str = document.cookie;
if (str == '') {
return false
// sessionStorage
function getItem(key) {
let item = sessionStorage.getItem(key)
// 这点要判断是字符串还是对象
let result = /^[{\[].*[}\]]$/g.test(item)
if (result) {
return JSON.parse(item)
} else {
var arr = str.split(';')
var arr1 = arr[0].replace(/(\s)+/g, '').split('=');
return JSON.parse(arr1[1]);
return item
}
};
}
function setItem(key, value) {
// 这点要判断是字符串还是对象
if (typeof value == "string") {
sessionStorage.setItem(key, value)
} else {
let item = JSON.stringify(value)
sessionStorage.setItem(key, item)
}
}
/*
* 验证手机号码
*/
......
......@@ -7,10 +7,10 @@ layui.use('element', function () {
});
});
$(function(){
$('#username').text(getCookie().username)
$('#phone').text(getCookie().phone)
$('#zjhm').text(getCookie().zjhm)
$('#recordtime').text(getCookie().recordtime)
$('#username').text(getItem('myCookie').username)
$('#phone').text(getItem('myCookie').phone)
$('#zjhm').text(getItem('myCookie').zjhm)
$('#recordtime').text(getItem('myCookie').recordtime)
$('#hellotime').text(getTimeState())
})
function getTimeState(){
......
......@@ -30,7 +30,6 @@ $(document).on('click', '#loginButton', function () {
var password = $('#IDcard').val();
userLoginRequest.phone = username;
userLoginRequest.password = password;
delCookie();
clicklogin(userLoginRequest);
});
function fetchDataReview() {
......@@ -40,7 +39,6 @@ function fetchDataReview() {
layer.confirm('此操作将进行注销', {
btn: ['是', '否'] //按钮
}, function () {
delCookie();
$('.loginButton').addClass('PersonLogin');
window.open('' + localhostPaht + '/index.html', '_self');
$('.loginAfter').hide();
......@@ -55,8 +53,8 @@ function fetchDataReview() {
$(function () {
fetchDataReview();
if (getCookie('myCookie').username) {
$('.loginButton').html(getCookie('myCookie').username);
if (getItem('myCookie') && getItem('myCookie').username) {
$('.loginButton').html(getItem('myCookie').username);
$('.loginButton').removeClass('PersonLogin')
$('.personalCenter').addClass('show');
$('.loginAfter').show();
......@@ -79,9 +77,9 @@ function delCookie() {
function clicklogin(data) {
$.ajax({
type: "post", //提交方式
type: "post",
url: portal.api_url + "/protal/users/login",//路径
headers: {//***关键******
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
dataType: "json",
......@@ -90,10 +88,10 @@ function clicklogin(data) {
if (result.code == 200 && result.data !== null) {
$('.loginAfter').show();
$('.isLogin').hide();
setCookie('myCookie', result.data, 0.05);
setItem('myCookie', result.data)
$('.loginButton').removeClass('PersonLogin')
$('.personalCenter').addClass('show');
$('.loginButton').html(getCookie('myCookie').username);
$('.loginButton').html(result.data.username);
layer.closeAll();
} else if (result.code == 210) {
layer.msg(result.message);
......@@ -109,7 +107,7 @@ $(document).on('click', '#registerButton', function () {
// 点击判断是否登录
function isLogin() {
let login1;
if (getCookie('myCookie').username) {
if (getItem('myCookie') && getItem('myCookie').username) {
login1 = true;
} else {
login();
......
......@@ -32,8 +32,8 @@ function bugSearch() {
}
// 初始化数据
function fetchDataReview(){
console.log(getCookie('myCookie'))
let userInfo = getCookie('myCookie');
console.log(getItem('myCookie'))
let userInfo = getItem('myCookie');
$('#sqrxm').text(userInfo.username);
if(userInfo.zjzl=='1') {
$('#zjzl').text('身份证');
......@@ -172,7 +172,7 @@ function addCreatSLSQ(jsondata) {
"bsmQl": jsondata.bsm_ql,
"ywid": business.ywid,
"businessNo": business.businessno,
"userid": getCookie().userid
"userid": getItem('myCookie').userid
};
$.ajax({
type: "post", //提交方式
......
......@@ -25,7 +25,7 @@ $(function () {
// 买方信息
var listItem;
let userInfo = [];
userInfo.push(getCookie('myCookie'));
userInfo.push(getItem('myCookie'));
if(list.sqrList && list.sqrList.length>0) {
for (var i = 0; i < list.sqrList.length; i++) {
listItem = '<li>'
......
......@@ -26,7 +26,7 @@ function fetchDataReview() {
// 买方信息
var listItem;
let userInfo = [];
userInfo.push(getCookie('myCookie'));
userInfo.push(getItem('myCookie'));
$('#informationList').empty();
if (list.sqrList && list.sqrList.length > 0) {
for (var i = 0; i < list.sqrList.length; i++) {
......
......@@ -137,7 +137,7 @@ function loadSqrDetail() {
}
} else {
let userInfo = getCookie('myCookie');
let userInfo = getItem('myCookie');
$('#userName').text(userInfo.username);
$('#idCard').text(userInfo.zjhm);
$('#phone').text(userInfo.phone);
......@@ -432,7 +432,7 @@ function _saveSQR() {
// 申请人信息
var d = {}, sqrList = [], tobj = {} , tLists = [];
var t = $('.sqrList').serializeArray();
d.userid = getCookie('myCookie').userid;
d.userid = getItem('myCookie').userid;
sqrList.push(d);
t.forEach((item, index) => {
console.log(item)
......
......@@ -41,7 +41,7 @@ function _taxVerification(bsm_slsq, businessno) {
}
// 买方信息
let userInfo = [];
userInfo.push(getCookie('myCookie'));
userInfo.push(getItem('myCookie'));
if(data.sqrList && data.sqrList.length>0) {
for (var i = 0; i < data.sqrList.length; i++) {
listItem = '<li>'
......
......@@ -56,8 +56,8 @@ $(function () {
});
});
})
$('#zjhm').text(getCookie().zjhm)
$('#username').text(getCookie().username )
$('#zjhm').text(getItem('myCookie').zjhm)
$('#username').text(getItem('myCookie').username )
})
// 列表操作
......@@ -88,7 +88,7 @@ function _applyBusinessWiat(currentPage = 1) {
url: portal.api_url + "/portal/WorkBoxService/applyBusinessWait",//路径
dataType: "json",
data: {
"userId": getCookie().userid,
"userId": getItem('myCookie').userid,
"currentPage": currentPage,
"pageSize": 10
},
......@@ -111,7 +111,7 @@ function _applyBusinessIn(currentPage = 1) {
url: portal.api_url + "/portal/WorkBoxService/applyBusinessIn",//路径
dataType: "json",
data: {
"userId": getCookie().userid,
"userId": getItem('myCookie').userid,
"currentPage": currentPage,
"pageSize": 10
},
......@@ -135,7 +135,7 @@ function _applyBusinessEnd(currentPage = 1) {
url: portal.api_url + "/portal/WorkBoxService/applyBusinessEnd",//路径
dataType: "json",
data: {
"userId": getCookie().userid,
"userId": getItem('myCookie').userid,
"currentPage": currentPage,
"pageSize": 10
},
......@@ -159,7 +159,7 @@ function _applyBusinessRecord(currentPage = 1) {
url: portal.api_url + "/portal/WorkBoxService/applyBusinessRecord",//路径
dataType: "json",
data: {
"userId": getCookie().userid,
"userId": getItem('myCookie').userid,
"currentPage": currentPage,
"pageSize": 10
},
......@@ -206,7 +206,6 @@ function paged(pageCount, curr) {
, theme: '#0091FF'
, jump: function (obj, first) {
if (!first) {
console.log(obj.curr)
_applyBusinessRecord(obj.curr);
}
}
......@@ -299,5 +298,5 @@ function getTimeState(){
var dataList = {
"list": [],
"userid": getCookie().userid
"userid": getItem('myCookie').userid
};
\ No newline at end of file
......
......@@ -3,8 +3,8 @@ layui.use('element', function () {
});
$(function () {
_initData();
$('#zjhm').text(getCookie().zjhm);
$('#username').text(getCookie().username);
$('#zjhm').text(getItem('myCookie').zjhm);
$('#username').text(getItem('myCookie').username);
$(document).on("click", ".business", function (e) {
window.open("./businessGuideDeatil.html?ywid=" + $(this).attr('ywid') + "")
......@@ -77,7 +77,7 @@ $(document).on("click", ".cancel_reservation", function (e) {
layer.confirm('此操作将取消预约', {
btn: ['是', '否'] //按钮
}, function () {
_cancleAppointment($(that).attr('appointmentId'), $(that).attr('jgid'), $(that).attr('periodRulesId'), getCookie('myCookie').userid)
_cancleAppointment($(that).attr('appointmentId'), $(that).attr('jgid'), $(that).attr('periodRulesId'), getItem('myCookie').userid)
}, function () {
layer.msg('已取消');
});
......@@ -140,5 +140,5 @@ function paged(pageCount, curr) {
}
var dataList = {
"userid": getCookie().userid
"userid": getItem('myCookie').userid
};
\ No newline at end of file
......
......@@ -74,7 +74,7 @@ function getAppointmentPeriodAndBusiness(bookingDate) {
portal.api_url + "/portal/appointmentmh/getAppointmentPeriodAndBusiness", //
data: {
jgid: GetQueryString("jgid"),
userid: getCookie().userid,
userid: getItem('myCookie').userid,
bookingDate: bookingDate,
},
dataType: "json",
......@@ -161,7 +161,7 @@ function checkAppointment() {
portal.api_url + "/portal/appointmentmh/checkAppointment",
data: {
jgid: GetQueryString("jgid"),
userid: getCookie().userid,
userid: getItem('myCookie').userid,
},
dataType: "json",
//数据,这里使用的是Json格式进行传输
......@@ -200,9 +200,9 @@ function handle(id) {
content:
'<div class="infoContent">' +
"<ul>" +
"<li><span>姓名</span>:" + getCookie().username + "</li>" +
"<li><span>身份证号</span>:" + getCookie().zjhm + "</li>" +
"<li><span>联系电话</span>:" + getCookie().phone + "</li>" +
"<li><span>姓名</span>:" + getItem('myCookie').username + "</li>" +
"<li><span>身份证号</span>:" + getItem('myCookie').zjhm + "</li>" +
"<li><span>联系电话</span>:" + getItem('myCookie').phone + "</li>" +
"</ul>" +
'<div class="listItem"><h3>大厅名称:</h3>' +
hallname +
......@@ -226,7 +226,7 @@ function makeAppointment(id) {
var paramsobj = {}
paramsobj.jgid = GetQueryString("jgid");
paramsobj.periodRulesId = id;
paramsobj.userid = getCookie().userid;
paramsobj.userid = getItem('myCookie').userid;
$.ajax({
type: "post", //提交方式
async: false,
......