Add Cookie of inviter id perist (#15)
This commit is contained in:
1 parent
37a66dc419
commit
be42c390be
4 files changed
+57
-1
No files matched your search
+18
-1
@@ -8,6 +8,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElConfigProvider } from 'element-plus';
|
||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
|
||||
import { getDomain, getPath, setCookie } from './utils';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -15,8 +16,24 @@ export default defineComponent({
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
locale: zhCn
|
||||
locale: zhCn,
|
||||
inviterId: this.$route.query.inviter_id?.toString()
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onSetCookie() {
|
||||
// set inviter to cookies to persist
|
||||
if (this.inviterId) {
|
||||
// current date + 7 days
|
||||
const expiration = new Date();
|
||||
expiration.setDate(expiration.getDate() + 7);
|
||||
setCookie('INVITER_ID', this.inviterId, {
|
||||
domain: getDomain(),
|
||||
path: getPath(),
|
||||
expires: expiration
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in new issue
Block a user