提交 418b4222 编写于 作者: guangjun.yang's avatar guangjun.yang

修改cookies写法

详情样式
上级 17308912
......@@ -78,11 +78,11 @@ export default {
// background: #fff;
position: absolute;
right: 0;
bottom: 0;
bottom: -18px;
display: flex;
align-items: center;
padding-left: 30px;
background: linear-gradient(90deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, 1));
// padding-left: 30px;
// background: linear-gradient(90deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, 1));
img {
position: relative;
top: 1px;
......
......@@ -205,28 +205,36 @@ export function isWeiXin() {
}
}
export const setCookie = (cname, cvalue, exdays = 30, domain = '.yunqueyi.com') => { //yunqueyi.com
let d = new Date(), expires = '';
if (BUILD_ENV === 'dev') {
domain = window.location.hostname;
export const setCookie = (name, value, time) => {
var expires = 30 * 24 * 60 * 60 * 1000; //一天
var date = new Date(+new Date() + expires);
if (time) {
document.cookie =
name +
'=' +
escape(value) +
'; path=/' +
';expires=' +
date.toUTCString();
} else {
document.cookie = name + '=' + escape(value) + '; path=/';
}
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
expires = `expires=${d.toUTCString()}`;
document.cookie = `${cname}=${cvalue};path=/;${expires};domain=${domain}`;
}
export const getCookie = (cname) => {
const reg = new RegExp('(^| )' + cname + '=([^;]*)(;|$)');
const arr = document.cookie.match(reg);
return arr ? unescape(arr[2]) : null;
}
export const delCookie = (cname) => {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(cname);
if (cval != null) {
document.cookie = 'token=; path=/; expires=' + new Date(0).toUTCString();
document.cookie = 'token=; path=/; domain=.yunqueyi.com; expires=' + new Date(0).toUTCString();
};
export const delCookie = key => {
var expires = -1 * 24 * 60 * 60 * 1000; //一天
var date = new Date(+new Date() + expires);
document.cookie =
key + '=' + escape('') + '; path=/' + ';expires=' + date.toUTCString(); //这里只需要把Cookie保质期退回一天便可以删除
};
export const getCookie = key => {
var cookieArr = document.cookie.split('; ');
for (var i = 0; i < cookieArr.length; i++) {
var arr = cookieArr[i].split('=');
if (arr[0] === key) {
return arr[1];
}
}
}
\ No newline at end of file
return '';
};
\ No newline at end of file
......@@ -17,6 +17,7 @@
</div> -->
<!-- <CourseCovers></CourseCovers> -->
<!-- <div @click="testDialog">testDialog</div> -->
<CourseIntro :intro="intro"></CourseIntro>
<BriefIntro></BriefIntro>
</div>
</template>
......@@ -28,11 +29,13 @@ import CommonErrorTips from "@/components/course/common-error-tips";
import CourseButton from "@/components/course/course-button";
import CourseCovers from "@/components/course/course-covers";
import BriefIntro from "@/components/course/brief-intro";
import CourseIntro from "@/components/course/course-intro";
export default {
data() {
return {
isShowDialog: true,
intro: "更多其他课程,请前往鹊医App学习更多其他课程,请前往鹊医App学习更多其他课程,请前往鹊医App学习更多其他课程,请前往鹊医App学习更多其他课程,请前往鹊医App学习更多其他课程,请前往鹊医App学习更多其他课程,请前往鹊医App学习"
};
},
components: {
......@@ -42,7 +45,8 @@ export default {
// CommonErrorTips,
// CourseButton,
// CourseCovers,
BriefIntro
BriefIntro,
CourseIntro
},
mounted() {
// Toast
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册