inviteLogin.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <div class="container" v-loading="loading">
  3. <div class="loginOut" v-show="showLoadingOut">
  4. <span @click="loginOut">退出登录</span>
  5. </div>
  6. <!-- <div class="i_box" v-if="steps == 1">
  7. <div class="i_box_top">
  8. <div><span>请输入随机码进入项目课程</span></div>
  9. <div><span>账号登陆</span></div>
  10. <img src="../../../assets/icon/inviteLogin/password.png" alt="">
  11. </div>
  12. <div class="i_box_login">
  13. <el-input v-model="icode" placeholder="请输入随机码" class="input"></el-input>
  14. <div @click="nextSteps" class="button">确 定</div>
  15. </div>
  16. </div>
  17. <div class="i_box" v-if="steps == 2">
  18. <div class="i_box_top">
  19. <div><span>{{ res.school }}</span></div>
  20. <div><span>欢迎回来!</span></div>
  21. <img src="../../../assets/icon/inviteLogin/school.png" style="bottom: -40px;" alt="">
  22. </div>
  23. <div class="i_box_login2">
  24. <div v-for="item in classJuri" @click="login(item.userid,(item.name ? item.name : item.username))" :key="item.userid">{{ item.name ? item.name :
  25. item.username }}</div>
  26. <div v-if="!classJuri.length" class="none">此班级暂无学生</div>
  27. <el-select v-model="userid" placeholder="选择姓名" filterable class="select">
  28. <el-option v-for="item in classJuri" :key="item.userid" :label="item.name ? item.name : item.username"
  29. :value="item.userid">
  30. </el-option>
  31. </el-select>
  32. <div @click="login" class="button">登 录</div>
  33. </div>
  34. </div> -->
  35. <div class="c-box">
  36. <div class="c-b-left"></div>
  37. <div class="c-b-right">
  38. <div class="c-b-r-closeArea" v-if="steps == 2" @click.stop="steps = 1">
  39. <span class="el-icon-back c-b-r-ca-btn"></span>
  40. </div>
  41. <div class="c-b-r-main" v-if="steps == 1">
  42. <div class="c-b-r-m-title">欢迎登录!</div>
  43. <div class="c-b-r-m-form">
  44. <div class="c-b-r-m-f-label">课程识别码</div>
  45. <div class="c-b-r-m-f-input">
  46. <el-input v-model="icode" placeholder="请输入课程识别码" append="这是个测试" :class="[showErrMsg?'showErrMsg':'']"></el-input>
  47. <div class="c-b-r-m-f-i-errMsg" v-if="showErrMsg">
  48. <span class="el-icon-warning-outline"></span>
  49. {{ errMsg }}
  50. </div>
  51. </div>
  52. </div>
  53. <div :class="['c-b-r-m-btn',btnActive?'c-b-r-m-btnActive':'']" @click.stop="nextSteps">下一步</div>
  54. </div>
  55. <div class="c-b-r-main" v-if="steps == 2">
  56. <div class="c-b-r-m-title">请选择您的姓名</div>
  57. <div class="c-b-r-m-chooseNameArea">
  58. <!-- <div class="c-b-r-m-cna-none">此班级暂无学生</div> -->
  59. <div v-if="!classJuri.length" class="c-b-r-m-cna-none">此班级暂无学生</div>
  60. <div v-for="item in classJuri" :class="['c-b-r-m-cna-item',chooseData.userid==item.userid?'c-b-r-m-cna-itemActive':'']" @click="choose(item.userid,(item.name ? item.name : item.username))" :key="item.userid">{{ item.name ? item.name :item.username }}</div>
  61. </div>
  62. <!-- -->
  63. <el-button class="c-b-r-m-loginBtn" type="primary" v-if="classJuri.length" @click.stop="login(chooseData.userid,chooseData.username)">确认登录</el-button>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. steps: 1,
  74. icode: "",
  75. userid: "",
  76. options: [],
  77. loading: false,
  78. res: {},
  79. classJuri: [],
  80. code: this.$route.query.code,
  81. courseId:"",
  82. showErrMsg:false,
  83. errMsg:"",
  84. chooseData:{},
  85. showLoadingOut:false,
  86. }
  87. },
  88. computed:{
  89. btnActive(){
  90. // return this.icode!='';
  91. return /^\d+$/.test(this.icode);
  92. },
  93. },
  94. watch:{
  95. icode(newValue,oldValue){
  96. this.showErrMsg = false;
  97. this.errMsg = "";
  98. }
  99. },
  100. methods: {
  101. // selectSnameByCid
  102. nextSteps() {
  103. // let reg = /^[A-Za-z0-9]{2,}$/
  104. // let reg = /^[0-9]{2,}$/
  105. if(!this.btnActive || this.showErrMsg)return;
  106. let reg = /^\d+$/
  107. if (!reg.test(this.icode)) {
  108. this.setErrMsg("请正确填写识别码")
  109. // this.$message.error("请正确填写随机码")
  110. return;
  111. }
  112. let params = {
  113. code: this.icode,
  114. oid: this.code,
  115. // oid:"16ace517-b5c7-4168-a9bb-a9e0035df840"
  116. // oid:"0fec3a8a-ad04-11ed-b13d-005056b86db5" //测试
  117. };
  118. this.loading = true
  119. this.ajax
  120. // .get(this.$store.state.api + "selectCourseByIc2", params)
  121. .get(this.$store.state.api + "selectCourseByIc2SZ", params)
  122. .then(res => {
  123. this.loading = false;
  124. if (res.data.length && res.data[0].length) {
  125. this.res = res.data[0][0]
  126. this.courseId = res.data[0][0].courseId
  127. this.getClass(res.data[0][0].classid)
  128. } else {
  129. this.setErrMsg("不存在此识别码")
  130. // this.$message.error("不存在此随机码")
  131. }
  132. })
  133. .catch(err => {
  134. console.error(err);
  135. });
  136. },
  137. getClass(classId) {
  138. let params = {
  139. cid: classId,
  140. };
  141. this.ajax
  142. .get(this.$store.state.api + "selectSnameByCid", params)
  143. .then((res) => {
  144. this.classJuri = res.data[0];
  145. this.steps = 2
  146. })
  147. .catch((err) => {
  148. console.error(err);
  149. });
  150. },
  151. login(userid,username) {
  152. let courseid = this.courseId
  153. this.$confirm(`确定登录${username}的账号吗?`, "提示", {
  154. confirmButtonText: "确定",
  155. cancelButtonText: "取消",
  156. type: "warning",
  157. })
  158. .then(() => {
  159. window.topU.postMessage(
  160. {
  161. tools: "inviteLogin",
  162. userid: userid,
  163. courseId: courseid
  164. },
  165. "*"
  166. );
  167. })
  168. .catch(() => { });
  169. },
  170. // 选择学生
  171. choose(userid,username){
  172. this.chooseData = {
  173. userid: userid,
  174. username: username
  175. }
  176. },
  177. // 设置错误信息
  178. setErrMsg(msg){
  179. this.showErrMsg = true;
  180. this.errMsg = msg;
  181. },
  182. loginOut(){
  183. window.topU.postMessage({
  184. tools:"logout"
  185. },"*")
  186. },
  187. },
  188. mounted(){
  189. setInterval(() => {
  190. window.topU.postMessage({
  191. tools:"getLogin"
  192. },"*")
  193. console.log("获取getLogin")
  194. }, 2000);
  195. window.addEventListener("message",(e)=>{
  196. let data = e.data;
  197. console.log("message",e)
  198. if(data.tools && data.tools=='getLogin'){
  199. if(data.type===2){
  200. this.showLoadingOut = false;
  201. }else if(data.type===1){
  202. this.showLoadingOut = true;
  203. }
  204. }
  205. })
  206. }
  207. }
  208. </script>
  209. <style scoped>
  210. .container {
  211. width: 100vw;
  212. height: 100vh;
  213. overflow: hidden;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. background: url("../../../assets/inviteLoginSZBG.png") no-repeat;
  218. background-size: 100% 100%;
  219. position: relative;
  220. }
  221. .c-box{
  222. width: 75%;
  223. height: 75%;
  224. border-radius: 12px;
  225. background-color: #4B88F5;
  226. overflow: hidden;
  227. display: flex;
  228. }
  229. .c-b-left{
  230. flex: 1;
  231. height: 100%;
  232. background: url("../../../assets/inviteLoginSZImage.png") no-repeat;
  233. background-size: cover;
  234. background-position: center;
  235. }
  236. .c-b-right{
  237. flex: 1;
  238. height: 100%;
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. background-color: white;
  243. position: relative;
  244. overflow-x:hidden ;
  245. }
  246. .c-b-r-closeArea{
  247. width: 120px;
  248. height: 120px;
  249. position: absolute;
  250. right: -45px;
  251. top: -45px;
  252. border-radius: 50%;
  253. background-color: #3681FC;
  254. }
  255. .c-b-r-ca-btn{
  256. position: absolute;
  257. bottom: 30px;
  258. left: 30px;
  259. color: white;
  260. cursor: pointer;
  261. font-size: 1.5em;
  262. }
  263. .c-b-r-main{
  264. width: 80%;
  265. height: 80%;
  266. overflow: auto;;
  267. }
  268. .c-b-r-m-title{
  269. font-size: 28px;
  270. font-weight: bold;
  271. }
  272. .c-b-r-m-form{
  273. width: 100%;
  274. height: auto;
  275. margin-top: 40px;
  276. }
  277. .c-b-r-m-f-label{
  278. font-size: 14px;
  279. font-weight: bold;
  280. margin-bottom: 5px;
  281. }
  282. .c-b-r-m-f-input{
  283. position: relative;
  284. }
  285. .c-b-r-m-f-input>>>.el-input__inner{
  286. background-color: #F0F2F5 !important;
  287. height: 52px;
  288. border-radius: 6px;
  289. }
  290. .showErrMsg>>>.el-input__inner{
  291. color: #EE3E3E !important;
  292. }
  293. .c-b-r-m-f-i-errMsg{
  294. position: absolute;
  295. right: 10px;
  296. color: #EE3E3E;
  297. font-size: 14px;
  298. height: 100%;
  299. display: flex;
  300. align-items: center;
  301. top: 0;
  302. }
  303. .el-icon-warning-outline>span{
  304. margin-right: 10px !important;
  305. }
  306. .c-b-r-m-btn{
  307. width: 92px;
  308. height: 36px;
  309. box-sizing: border-box;
  310. border-radius: 6px;
  311. border: solid 1px #C2D9FE;
  312. display: flex;
  313. justify-content: center;
  314. align-items: center;
  315. font-size: 20px;
  316. color: #C2D9FE;
  317. transition: .3s;
  318. margin-top: 10px;
  319. cursor:not-allowed;
  320. }
  321. .c-b-r-m-btnActive{
  322. border-color: #68A1FD;
  323. color: #68A1FD;
  324. cursor: pointer;
  325. }
  326. .c-b-r-m-chooseNameArea{
  327. width: 100%;
  328. max-height: 70%;
  329. height: auto;
  330. /* max-height: 300px; */
  331. margin-top: 20px;
  332. display: flex;
  333. flex-wrap: wrap;
  334. overflow: auto;
  335. }
  336. .c-b-r-m-cna-none{
  337. font-size: 20px;
  338. margin-top: 30px;
  339. font-weight: bold;
  340. }
  341. .c-b-r-m-cna-item{
  342. width: auto;
  343. padding: 4px 6px;
  344. background-color: #F0F2F5;
  345. color: #000000;
  346. box-sizing: border-box;
  347. border:solid 1px #E7E7E7;
  348. border-radius: 3px;
  349. font-size: 14px;
  350. transition: .3s;
  351. cursor: pointer;
  352. margin-right: 10px;
  353. margin-bottom: 10px;
  354. }
  355. .c-b-r-m-cna-itemActive{
  356. background-color: #E0EAFB;
  357. color:#3681FC;
  358. border-color: #3681FC;
  359. }
  360. .c-b-r-m-loginBtn{
  361. width: 100%;
  362. height: 56px;
  363. font-size: 20px;
  364. margin-top: 20px;
  365. }
  366. /* .i_box {
  367. height: 100%;
  368. width: 100%;
  369. }
  370. .i_box_top {
  371. height: 145px;
  372. width: 100%;
  373. overflow: hidden;
  374. position: relative;
  375. background: #fff;
  376. box-sizing: border-box;
  377. padding: 20px;
  378. }
  379. .i_box_top>div:nth-child(1) {
  380. color: rgb(147, 147, 147);
  381. }
  382. .i_box_top>div:nth-child(2) {
  383. font-size: 28px;
  384. color: rgb(78, 138, 218);
  385. margin-top: 5px;
  386. }
  387. .i_box_top>img {
  388. position: absolute;
  389. right: 30px;
  390. bottom: -60px;
  391. width: 150px;
  392. }
  393. .i_box_login {
  394. height: calc(100% - 145px);
  395. width: 100%;
  396. background: linear-gradient(90deg, #477cd7, #65b9fc);
  397. display: flex;
  398. flex-direction: column;
  399. align-items: center;
  400. padding: 50px 20px;
  401. box-sizing: border-box;
  402. align-content: flex-start;
  403. }
  404. .i_box_login2 {
  405. height: calc(100% - 145px);
  406. background: linear-gradient(90deg, #477cd7, #65b9fc);
  407. width: 100%;
  408. display: flex;
  409. flex-wrap: wrap;
  410. overflow: auto;
  411. padding-bottom: 10px;
  412. box-sizing: border-box;
  413. align-content: flex-start;
  414. }
  415. .i_box_login2 div{
  416. cursor: pointer;
  417. width: 80px;
  418. text-align: center;
  419. height: 30px;
  420. line-height: 30px;
  421. padding: 0 5px;
  422. overflow: hidden;
  423. background: rgb(225, 237, 255);
  424. margin: 10px 9px 0;
  425. color: rgb(37 124 255);
  426. border-radius: 5px;
  427. box-sizing: border-box;
  428. text-overflow: ellipsis;
  429. }
  430. .i_box_login .input {}
  431. .i_box_login .select {
  432. width: 100%;
  433. }
  434. .i_box_login .button {
  435. margin-top: 30px;
  436. background: rgb(100, 100, 100);
  437. cursor: pointer;
  438. color: #fff;
  439. padding: 10px 50px;
  440. border-radius: 5px;
  441. }
  442. .none{
  443. width: 100% !important;
  444. height: 100% !important;
  445. background: unset !important;
  446. color: #fff !important;
  447. display: flex !important;
  448. align-items: center !important;
  449. justify-content: center !important;
  450. margin: 0 !important;
  451. } */
  452. .loginOut{
  453. position: absolute;
  454. right: 30px;
  455. top: 30px;
  456. width: auto;
  457. height: auto;
  458. display: flex;
  459. justify-content: center;
  460. align-items: center;
  461. }
  462. .loginOut>span{
  463. font-size: 24px;
  464. color: #fff;
  465. font-weight: bold;
  466. cursor: pointer;
  467. }
  468. </style>