Compare commits
7 Commits
master
...
dev-little
Author | SHA1 | Date |
---|---|---|
|
4a45135148 | 3 years ago |
|
d9c2e8e82f | 3 years ago |
|
8fa6720b43 | 3 years ago |
|
f9d4c6dc5c | 3 years ago |
|
c73d13cdaf | 3 years ago |
|
e1669c8591 | 3 years ago |
|
b640a9a29b | 3 years ago |
3 changed files with 123 additions and 0 deletions
@ -0,0 +1,113 @@ |
|||
<template> |
|||
<div class="App" v-if="isPhone"> |
|||
<p>请在电脑上打开</p> |
|||
</div> |
|||
<div class="App" v-else> |
|||
<img :src="userInfo.avatar" class="avatar" /> |
|||
<p>{{ userInfo.name }}员工:登陆成功</p> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { requestPost } from "@/js/dai/request"; |
|||
import * as dd from "dingtalk-jsapi"; |
|||
import axios from "axios"; |
|||
|
|||
export default { |
|||
data() { |
|||
return { |
|||
userInfo: { |
|||
avatar: |
|||
"https://img.alicdn.com/imgextra/i3/O1CN01Mpftes1gwqxuL0ZQE_!!6000000004207-2-tps-240-240.png", |
|||
name: "尊敬的", |
|||
}, |
|||
isPhone: false, |
|||
}; |
|||
}, |
|||
created() { |
|||
this.init(); |
|||
}, |
|||
|
|||
methods: { |
|||
init() { |
|||
// 判断如果手机端,就提示电脑打开 |
|||
if ( |
|||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( |
|||
navigator.userAgent |
|||
) |
|||
) { |
|||
this.isPhone = true; |
|||
return; |
|||
} |
|||
|
|||
// ready后才能操作 |
|||
dd.ready(() => { |
|||
let corpId = "dingd1e19e397c754c7735c2f4657eb6378f"; |
|||
alert("ready:" + corpId); |
|||
// dd.ready参数为回调函数,在 环境准备就绪时触发,jsapi的调用需要保证在该回调函数触发后调用,否则无效。 |
|||
dd.runtime.permission.requestAuthCode({ |
|||
corpId: corpId, //三方企业ID |
|||
onSuccess: function (result) { |
|||
alert("requestAuthCode:onSuccess" + result.code); |
|||
// 替换成后端服务域名 |
|||
const domain = "https://epmet-test.elinkservice.cn/api"; |
|||
|
|||
axios |
|||
.post(domain + "/auth/thirdlogin/govlogin-internalding", { |
|||
authCode: result.code, |
|||
miniAppId: "5000000003100489", |
|||
}) |
|||
.then((response) => { |
|||
alert("token:" + JSON.stringify(response)); |
|||
dd.biz.util.openLink({ |
|||
url: |
|||
"https://epmet-test.elinkservice.cn/epmet-oper-gov/#/?token=" + |
|||
response.data.data.token, //要打开链接的地址 |
|||
onSuccess: function (result) { |
|||
alert("openLink:" + result); |
|||
// window.close(); |
|||
}, |
|||
onFail: function (err) {}, |
|||
}); |
|||
}) |
|||
.catch((error) => { |
|||
alert("登录失败,请稍后重试!"); |
|||
console.log(error.message); |
|||
}); |
|||
}, |
|||
onFail: function (err) { |
|||
alert("登录失败:" + JSON.stringify(err)); |
|||
}, |
|||
}); |
|||
|
|||
// pc不支持,没啥用 |
|||
// dd.biz.auth.requestAuthInfo({ |
|||
// authorizeType: 1, |
|||
// ext: '{"dataType":1,"fieldScope":["mobile","mainOrgName"]}', |
|||
// onSuccess: (res) => { |
|||
// console.log(res); |
|||
// alert("requestAuthInfo:" + JSON.stringify(res)); |
|||
// }, |
|||
// onFail: (err) => { |
|||
// console.log(err); |
|||
// }, |
|||
// }); |
|||
}); |
|||
}, |
|||
}, |
|||
}; |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.App { |
|||
text-align: center; |
|||
padding: 24px; |
|||
} |
|||
|
|||
.avatar { |
|||
width: 48px; |
|||
height: 48px; |
|||
border-radius: 8px; |
|||
overflow: hidden; |
|||
} |
|||
</style> |
Loading…
Reference in new issue