|
@@ -0,0 +1,200 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<meta charset="UTF-8">
|
|
|
+<html>
|
|
|
+
|
|
|
+<head>
|
|
|
+ <title>景宁教育魔方</title>
|
|
|
+ <!-- 这个必须引入的啊,钉钉的前端js SDK, 使用框架的请自行参照开发文档 -->
|
|
|
+ <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.7.13/dingtalk.open.js"></script>
|
|
|
+ <!-- 这个jquery 想不想引入自己决定,没什么影响 -->
|
|
|
+ <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
|
|
|
+ <style type="text/css">
|
|
|
+ .loading {
|
|
|
+ position: fixed;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ z-index: 100;
|
|
|
+ background: url("loading.gif") center no-repeat rgba(255, 255, 255, .55);
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+
|
|
|
+ <!--TODO...替换成之前亲亲云的一个登录中转过度loading-->
|
|
|
+ <div class="loading"></div>
|
|
|
+ <!--<div id="user_info" style="color: #000;font-size: 15px;position: fixed;left: 0;top: 0;width: 100%;height: 100%;z-index: 150"></div>-->
|
|
|
+ <!--<hr>-->
|
|
|
+ <!--<h1>教育魔方-免登验证-线上环境</h1>-->
|
|
|
+ <!--<p>当前页面的url:</p>-->
|
|
|
+ <!--<p id="url"></p>-->
|
|
|
+ <!--<br>-->
|
|
|
+ <!--<p>解析url,获取的corpID:</p>-->
|
|
|
+ <!--<p id="corpId"></p>-->
|
|
|
+ <!--<br>-->
|
|
|
+ <!--<p>SDK初始化获取的code:</p>-->
|
|
|
+ <!--<p id="code"></p>-->
|
|
|
+ <!--<br>-->
|
|
|
+ <!--<p>请求我们服务端,登录返回的结果:</p>-->
|
|
|
+ <p id="myresponse"></p>
|
|
|
+
|
|
|
+ <script type="text/javascript">
|
|
|
+ let login_obj = {
|
|
|
+ url: '',
|
|
|
+ code: '',
|
|
|
+ api: ''
|
|
|
+ };
|
|
|
+ if (location.href.includes('.bozedu.')) {
|
|
|
+ login_obj = {
|
|
|
+ url: 'https://daily-cube.zjedu.com',
|
|
|
+ code: 'suitemie4qeftvmhnufp1',
|
|
|
+ api: 'http://jnjymf_api.bozedu.top'
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ login_obj = {
|
|
|
+ url: 'https://cube.zjedu.com',
|
|
|
+ code: 'suiteecoywfohhm68lkix',
|
|
|
+ api: 'http://60.188.226.44:8090'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $(function () {
|
|
|
+ var params = new Object();
|
|
|
+ params = GetRequest();
|
|
|
+ // if (localStorage.getItem('userInfo')) {
|
|
|
+ // localStorage.removeItem('userInfo');
|
|
|
+ // }
|
|
|
+ localStorage.clear()
|
|
|
+
|
|
|
+ // debug
|
|
|
+ // {
|
|
|
+ // var corpId = params.corpId ? params.corpId : '';
|
|
|
+ // var tag = params.tag ? params.tag : '';
|
|
|
+ // let follow = '';
|
|
|
+ // const t = tag.split('_');
|
|
|
+ // if (t.length > 1) {
|
|
|
+ // tag = t.splice(0, 1)[0];
|
|
|
+ // follow = t.join('/');
|
|
|
+ // }
|
|
|
+ // window.open('http://localhost:3000/' + (follow ? ('#/' + follow) : ''), '_blank');
|
|
|
+ // }
|
|
|
+
|
|
|
+ console.log('init ', '2023/7/13 10:30:01')
|
|
|
+ var corpId = params.corpId ? params.corpId : '';
|
|
|
+ var tag = params.tag ? params.tag : '';
|
|
|
+ let follow = '';
|
|
|
+ const t = tag.split('_');
|
|
|
+ if (t.length > 1) {
|
|
|
+ tag = t.splice(0, 1)[0];
|
|
|
+ follow = t.join('/');
|
|
|
+ }
|
|
|
+ if (params.debug || follow == '') {
|
|
|
+ localStorage.setItem('debug', '1')
|
|
|
+ }
|
|
|
+ // debug area
|
|
|
+ if (tag === 'hlwxx') {
|
|
|
+ console.log('href : ', '/app/hlwxx/#/autoLogin?user_id=' + 'userInfo.user_id')
|
|
|
+ } else {
|
|
|
+ console.log('href : ', '/app/' + tag + '/' + (follow ? ('#/' + follow) : ''))
|
|
|
+ }
|
|
|
+ // 钉钉sdk 初始化
|
|
|
+ // dd.ready参数为回调函数,在环境准备就绪时触发,jsapi的调用需要保证在该回调函数触发后调用,否则无效。
|
|
|
+ dd.ready(function () {
|
|
|
+
|
|
|
+ //使用SDK 获取免登授权码
|
|
|
+ dd.runtime.permission.requestAuthCode({
|
|
|
+ corpId: corpId,
|
|
|
+ onSuccess: function (result) {
|
|
|
+ var code = result.code;
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ //TODO...下面的域名要从配置文件中获取,不写死
|
|
|
+ url: login_obj.url + '/user/api/v1/login/autoLogin',
|
|
|
+ contentType: "application/json;charset=utf-8",
|
|
|
+ data: JSON.stringify({ code: code, accessKey: login_obj.code, corpId: corpId }),
|
|
|
+ dataType: "json",
|
|
|
+ success: function (response) {
|
|
|
+ // $('#user_info').html('22222'+ JSON.stringify(response.data));
|
|
|
+ if (response.success == false) {
|
|
|
+ alert(JSON.stringify(response.msg) + JSON.stringify(response.code));
|
|
|
+ } else {
|
|
|
+ //TODO...开始
|
|
|
+ $.ajax({
|
|
|
+ type: 'POST',
|
|
|
+ url: login_obj.api + '/user/main/login',
|
|
|
+ // contentType: "application/json;charset=utf-8",
|
|
|
+ data: {
|
|
|
+ cubeinfo: JSON.stringify(response.data)
|
|
|
+ },
|
|
|
+ dataType: "json",
|
|
|
+ success: (res) => {
|
|
|
+ if (res.code == 1) {
|
|
|
+ const userInfo = res.data
|
|
|
+ console.log('userInfo : ', userInfo)
|
|
|
+ if (tag === 'hlwxx') {
|
|
|
+ location.href = '/app/hlwxx/#/autoLogin?user_id=' + userInfo.user_id
|
|
|
+ } else {
|
|
|
+ if ((!Array.isArray(userInfo.user_org.length)) && userInfo.user_org.length == 0) {
|
|
|
+ alert('账号未绑定机构,您没有权限访问该应用')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // uo_type 2是学校 1是教育局
|
|
|
+ const uo_type = userInfo.user_org[userInfo.user_org.length - 1].uo_type
|
|
|
+ if (uo_type == '1' && tag.startsWith('xd')) {
|
|
|
+ alert('您是教育局用户,无法访问该应用')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (uo_type == '2' && tag.startsWith('jd')) {
|
|
|
+ alert('您是学校用户,无法访问该应用')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ localStorage.setItem('userInfo', JSON.stringify(res.data));
|
|
|
+ location.href = '/app/' + tag + '/' + (follow ? ('#/' + follow) : '');
|
|
|
+ // location.href = 'test.html';}
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ alert(res.msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function (re) {
|
|
|
+ alert("失败" + JSON.stringify(res));
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //TODO...结束
|
|
|
+ }
|
|
|
+ // alert("成功" + JSON.stringify(response));
|
|
|
+ //成功以后将response.data的信息提交给 本地用户获取接口(开发中),初始化登录用户信息
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ error: function (response) {
|
|
|
+ alert("失败" + JSON.stringify(response));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onFail: function (err) {
|
|
|
+ // 调用失败时回调
|
|
|
+ alert("requestAuthCode失败" + JSON.stringify(err));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ })
|
|
|
+ function GetRequest() {
|
|
|
+ var url = location.search;
|
|
|
+ var theRequest = new Object();
|
|
|
+ if (url.indexOf("?") != -1) {
|
|
|
+ var str = url.substr(1);
|
|
|
+ strs = str.split("&");
|
|
|
+ for (var i = 0; i < strs.length; i++) {
|
|
|
+ theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return theRequest;
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|