CasLogin.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <div class="login">
  3. <div class="login_wrapper">
  4. <div class="login_form">
  5. <h3 style="text-align: center; margin-top: 30px">单点登录</h3>
  6. <div class="separator" />
  7. <div class="selectItem">
  8. <label for="">客户端</label>
  9. <select
  10. v-model="internet"
  11. name="language-choice"
  12. class="form-control"
  13. style="width: 100%"
  14. >
  15. <option value="pc">电脑端</option>
  16. <option value="mobile">移动端</option>
  17. <option value="propass">Propass</option>
  18. </select>
  19. </div>
  20. <div class="selectItem">
  21. <label>语言</label>
  22. <select
  23. v-model="languageSelected"
  24. name="language-choice"
  25. class="form-control"
  26. style="width: 100%"
  27. >
  28. <option value="zh-CN">中文</option>
  29. <option value="en-US">English</option>
  30. </select>
  31. </div>
  32. <button
  33. class="btn btn-default"
  34. style="width: 100%"
  35. @click="azureCasLogin"
  36. >
  37. 确认
  38. </button>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import Common from '../common/Common.js';
  45. import LoginServicer from './LoginServicer.js';
  46. export default {
  47. data: function () {
  48. return {
  49. internet: 'pc',
  50. languageSelected: 'zh-CN',
  51. };
  52. },
  53. mounted() {
  54. this.ticket = this.$route.query.ticket;
  55. this.redirect_uri = this.$route.query.serviceUrl;
  56. this.authSettingNo = this.$route.query.authSettingNo;
  57. },
  58. methods: {
  59. // 单点登录
  60. azureCasLogin: function () {
  61. let _self = this;
  62. const params = {
  63. ticket: _self.ticket,
  64. redirect_uri: _self.redirect_uri,
  65. authSettingNo: _self.authSettingNo,
  66. languageId: _self.languageSelected,
  67. };
  68. $.ajax({
  69. url: Common.getApiURL('CasLogin/login'),
  70. type: 'post',
  71. async: true,
  72. data: params,
  73. success: function (loginInfoData) {
  74. if (loginInfoData.errorCode == 0) {
  75. // _self.setTokenClient();
  76. LoginServicer.setLoginInfo(loginInfoData.data);
  77. if (_self.internet === 'pc') {
  78. localStorage.setItem('allowSound', false);
  79. window.location.href =
  80. Common.getRootPath() + '/#/desktop/dashboard';
  81. } else if (_self.internet === 'mobile') {
  82. window.location.href =
  83. Common.getRootPath() + '/app.html#/desktop/moduleSelect';
  84. } else {
  85. window.location.href =
  86. Common.getRootPath() + '/propass.html#/propassapp/menu';
  87. }
  88. } else {
  89. Notify.error(
  90. _self.$t('lang.login.loginFailure'),
  91. loginInfoData.errorMessage,
  92. );
  93. }
  94. },
  95. error: function (XMLHttpRequest, textStatus, errorThrown) {
  96. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  97. },
  98. });
  99. },
  100. //设置 TokenClient
  101. setTokenClient: function () {
  102. $.ajax({
  103. url: Common.getApiURL('TokenClientResource/saveTokenClient'),
  104. type: 'post',
  105. dataType: 'json',
  106. contentType: 'application/json',
  107. beforeSend: function (request) {
  108. request.setRequestHeader('token', localStorage.getItem('#token'));
  109. request.setRequestHeader(
  110. 'account',
  111. localStorage.getItem('#accountId'),
  112. );
  113. },
  114. success: function (baseObjectResponse) {
  115. console.log(baseObjectResponse, 'token添加成功');
  116. },
  117. error: function (XMLHttpRequest, textStatus, errorThrown) {
  118. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  119. },
  120. });
  121. },
  122. },
  123. };
  124. </script>
  125. <style scoped>
  126. .login_wrapper {
  127. margin: 0px auto;
  128. padding-top: 5%;
  129. max-width: 350px;
  130. position: relative;
  131. }
  132. .login_form {
  133. top: 0px;
  134. width: 100%;
  135. }
  136. #login_box {
  137. width: 40%;
  138. height: 400px;
  139. margin: auto;
  140. margin-top: 4%;
  141. text-align: center;
  142. border-radius: 10px;
  143. padding: 50px 50px;
  144. border: 1px solid #dddddd;
  145. }
  146. h2 {
  147. margin-top: 5%;
  148. }
  149. .selectItem {
  150. display: flex;
  151. align-items: center;
  152. margin: 16px 0 16px 0;
  153. }
  154. .selectItem > label {
  155. width: 100px;
  156. text-align: left;
  157. font-size: 15px !important;
  158. color: rgba(0, 0, 0, 0.6);
  159. }
  160. .confirmBtn {
  161. margin-top: 50px;
  162. width: 60%;
  163. height: 30px;
  164. border-radius: 6px;
  165. border: 1px solid #e6e6e6;
  166. text-align: center;
  167. line-height: 30px;
  168. font-size: 15px;
  169. color: #333;
  170. background-color: #f7f7f7;
  171. text-decoration: none;
  172. font-weight: 400;
  173. user-select: none;
  174. }
  175. .confirmBtn:hover {
  176. background-color: #eaeaea;
  177. border-color: #adadad;
  178. background-position: 0 -15px;
  179. }
  180. .form-control {
  181. width: 74%;
  182. display: block;
  183. width: 75%;
  184. height: 34px;
  185. padding: 6px 12px;
  186. font-size: 14px;
  187. line-height: 1.42857143;
  188. color: #555555;
  189. background-color: #fff;
  190. background-image: none;
  191. border: 1px solid #ccc;
  192. border-radius: 4px;
  193. }
  194. .separator {
  195. border-top: 1px solid #d8d8d8;
  196. margin-top: 10px;
  197. padding-top: 10px;
  198. }
  199. </style>