Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 45 additions & 31 deletions emnav/nav/Nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,31 @@
Check your email
</div>
</div>
<w-login
:show="loginStatus"
:close="closeLogin"
:success="loginSucFn"
:orgid="orgId"
:countrycodeAction="countrycodeAction"
:sendAction="sendAction"
:loginAction="loginAction"
:sendEnglishAction="sendEnglishAction"
:loginEnglishAction="loginEnglishAction"
:lang="lang"
:domain="domain"
:loginConfirmAction="confirmAction"
:loginRegisterAction="loginRegisterAction"
:resultJson="resultJson"
></w-login>
<div v-if="loginStatus">
<w-login
:show="loginStatus"
:close="closeLogin"
:success="loginSucFn"
:orgid="orgId"
:countrycodeAction="countrycodeAction"
:sendAction="sendAction"
:loginAction="loginAction"
:sendEnglishAction="sendEnglishAction"
:loginEnglishAction="loginEnglishAction"
:lang="lang"
:domain="domain"
:loginConfirmAction="confirmAction"
:loginRegisterAction="loginRegisterAction"
:resultJson="resultJson"
:oauthkey="oauthKey"
:oauthType="oauthType"
:wechatUrl="wechatUrl"
:bindWechatAction="bindWechatAction"
:wechatLoginAction="wechatLoginAction"
:autologinAction="autologinAction"
:isShowWechat="isShowWechat"
></w-login>
</div>
</div>
</template>

Expand Down Expand Up @@ -175,24 +184,37 @@ export default {
loginAction: String,
sendEnglishAction: String,
loginEnglishAction: String,
isShowWechat: Boolean,
// 登录相关 end
logoutAction: String,
langHandle: Function,
sendEmailEnglishAction: String,
confirmAction: String,
loginRegisterAction: String,
autologinAction: String,
wechatLoginAction: String,
wechatUrl: String,
bindWechatAction: String,
oauthkey: String,
oauthType: String,
resultJson: Object,
isLogin: [String, Boolean],
},
created() {
this.orgId = this.orgid;
this.lang = window.$cookie.get('locale') || 'zh_CN';
this.isChina = this.lang === 'zh_CN';
this.language = this.isChina ? 'English' : '中文';
this.loginFlg = this.isLogin;
// if (this.oauthType === 'bind') {
// this.loginStatus = true;
// }

this.getLoginStatus(this.orgId);
},
methods: {
getLoginStatus(orgId) {
this.loginFlg = !!window.$cookie.get(`Authorization?org_id=${orgId}`);
this.loginFlg = !!window.$cookie.get(`EMTOKEN_${orgId}`);
},
// 语言
languageFun() {
Expand Down Expand Up @@ -254,20 +276,9 @@ export default {
// 登录相关 end
// 退出
logoutFun() {
ajax({
type: 'GET',
action: `${this.logoutAction}?org_id=${this.orgId}`,
onSuccess: (res) => {
if (res.code === 10000) {
logoutpc(res, this.orgId, this, () => {
this.getLoginStatus(this.orgId);
this.$emit('logout');
});
} else {
this.handleAjaxError(res.message);
}
},
onError: this.handleAjaxError,
logoutpc(this.orgId, this, () => {
this.getLoginStatus(this.orgId);
this.$emit('logout');
});
},
// 关闭弹窗
Expand Down Expand Up @@ -320,6 +331,9 @@ export default {
this.orgId = val;
this.getLoginStatus(val);
},
isLogin() {
this.loginFlg = this.isLogin;
},
},
components: {
WLogin: login.PcTem,
Expand Down
59 changes: 15 additions & 44 deletions emnav/nav/logoutpc.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,19 @@
/* eslint-disable */
import jsonp from 'em-jsonp';
export default (orgId, self, callback) => {
const domainStr = self.domain || '';

const afterLogin = (callbackUrl, inow, self, callback) => {
let theIndex = inow;
const urlSplit = callbackUrl[theIndex].split('?');
const newUrl = urlSplit[0];
let data = urlSplit[1];
data = data.replace(/=/g, '":"').replace(/&/g, '","');
data = JSON.parse(`{"${data}"}`);
window.$jsonp({
url: newUrl,
data,
success: (res) => {
if (res.code === 10000) {
if (theIndex === 0) {
callback();
} else {
afterLogin(callbackUrl, --theIndex, self, callback);
}
} else {
if (self.$EmfeMessage) {
self.$EmfeMessage.error({
content: `${self.logut}失败`,
});
setTimeout(() => {
window.$cookie.remove(`EMTOKEN_${orgId}`, '/', domainStr);
window.$cookie.remove('EMTOKEN', '/', domainStr);

/* eslint-disable */
const keys = document.cookie.match(/[^ =;]+(?=\=)/g);
if(keys) {
for (var i = keys.length; i--;) {
if (keys[i].indexOf('EMTOKEN') > -1) {
window.$cookie.remove(keys[i], '/', domainStr);
}
}
},
error: () => {
if (self.$EmfeMessage) {
self.$EmfeMessage.error({
content: `${self.logut}失败`,
});
}
},
});
};

export default (result, orgId, self, callback) => {
afterLogin(result.data.url_list, result.data.url_list.length - 1, self, () => {
let domainStr = self.domain || '';

setTimeout(() => {
window.$cookie.remove(`Authorization?org_id=${orgId}`, '/', domainStr);
callback();
}, 100);
});
}
callback();
}, 100);
};
5 changes: 5 additions & 0 deletions emnav/nav/resultJson.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion emnav/nav/zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br>

<p>
<w-nav orgid="100015" :countrycodeAction="countrycodeAction" :sendAction="sendAction" :loginAction="loginAction" :sendEnglishAction="sendEnglishAction" :loginEnglishAction="loginEnglishAction" :logoutAction="loginEnglishAction" domain="" :sendEmailEnglishAction="loginAction" />
<w-nav orgid="100015" :countrycodeAction="countrycodeAction" :sendAction="sendAction" :loginAction="loginAction" :sendEnglishAction="sendEnglishAction" :loginEnglishAction="loginEnglishAction" :logoutAction="loginEnglishAction" domain="" :sendEmailEnglishAction="loginAction" :resultJson="resultJson"/>
</p>
<br>
<br>
Expand Down Expand Up @@ -49,6 +49,7 @@
<script>
import WLogin from 'emfelogin/dist/login/Login';
import WNav from './Nav';
import resultJson from './resultJson';

export default {
data() {
Expand All @@ -60,6 +61,7 @@ export default {
loginAction: 'https://www.easy-mock.com/mock/5ab386ecca15e11ded65b593/chinese/login',
sendEnglishAction: 'https://www.easy-mock.com/mock/5ab386ecca15e11ded65b593/chinese/smssend',
loginEnglishAction: 'https://www.easy-mock.com/mock/5ab386ecca15e11ded65b593/chinese/login',
resultJson,
};
},
components: {
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "emnav",
"version": "1.0.6",
"version": "2.5.0",
"description": "em 头部弹框业务组件",
"author": "李梦龙 <649076408@qq.com>",
"main": "dist/emnav.js",
Expand Down Expand Up @@ -53,7 +53,7 @@
"em-cookie": "^1.1.1",
"em-jsonp": "^1.0.4",
"em-normalize": "^1.0.2",
"emfelogin": "^0.0.8",
"emfelogin": "^1.3.0",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-friendly-formatter": "^4.0.0",
Expand Down Expand Up @@ -84,6 +84,7 @@
"markdown-it-anchor": "^4.0.0",
"markdown-it-container": "^2.0.0",
"mini-css-extract-plugin": "^0.4.0",
"natives": "^1.1.6",
"node-sass": "^4.8.3",
"opn": "^5.3.0",
"postcss": "^6.0.21",
Expand Down Expand Up @@ -128,5 +129,6 @@
"Android >= 4.0",
"last 2 versions",
"not ie <= 8"
]
],
"dependencies": {}
}
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3149,10 +3149,10 @@ em-normalize@^1.0.2:
resolved "https://registry.yarnpkg.com/em-normalize/-/em-normalize-1.0.2.tgz#fc12f05697d1c747f78f6670a66b4fcb63968435"
integrity sha512-udfC+9LCXZSN+xQX6nscang/e8w+YBtiuhs08YjBXjKZh3HEJp8ir/w4NCa1KkrRBbC67Su1l3pC8bAINHRbpw==

emfelogin@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/emfelogin/-/emfelogin-0.0.8.tgz#01e1957ea02e622625d51cca69e8379db23e147b"
integrity sha512-mHLJZNrHscZ6xLhM82her385qSyvuv5ZtYRH10PsrGChRPNSM4jl9wWak2jvkPeXczSyTqbHM273TfaUwzldng==
emfelogin@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/emfelogin/-/emfelogin-1.3.0.tgz#8d650e5d34020b640b43eb82ac2d74618b1cef4a"
integrity sha512-t/JLvXJUd7cKoKsL1FWgqV6itDk1DTOeTTIKu6PHHalQW6k3KtBQFAn0G6H6pEk+ygGUvxctsfEopn+1p7LZEA==

emojis-list@^2.0.0:
version "2.1.0"
Expand Down Expand Up @@ -7127,6 +7127,11 @@ natives@^1.1.0:
version "1.1.4"
resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.4.tgz#2f0f224fc9a7dd53407c7667c84cf8dbe773de58"

natives@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb"
integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==

natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
Expand Down