loginByPWD.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="df jcc fdc">
  3. <view class="login-righttitle">密码登录</view>
  4. <view class="fdc df jcc loginByPWD-listbox">
  5. <!-- 账号 -->
  6. <view class="df loginByPWD-inputbox aic">
  7. <view class="loginByPWD-inputbox-icon">
  8. <img class="df" src="../../assets/login/loginIcon2.png" />
  9. </view>
  10. <input @focus="inputFocus" class="loginByPWD-inputbox-input" type="text" placeholder="账号" @input="onAccountInput" />
  11. </view>
  12. <!-- 横线 -->
  13. <view class="loginByPWD-line"></view>
  14. <!-- 密码 -->
  15. <view class="df loginByPWD-inputbox aic">
  16. <view class="loginByPWD-inputbox-icon">
  17. <img class="df" src="../../assets/login/loginIcon1.png" />
  18. </view>
  19. <input @focus="inputFocus" class="loginByPWD-inputbox-input" type="password" placeholder="密码" @input="onPWDInput" />
  20. </view>
  21. <!-- 横线 -->
  22. <view class="loginByPWD-line"></view>
  23. <!-- 支持使用实验空间账号登录 -->
  24. <view class="df aic loginByPWD-tip1box">
  25. <view class="loginByPWD-tip1box-checkbox df aic">
  26. <img src="../../assets/login/loginIcon3.png" />
  27. </view>
  28. <view class="loginByPWD-tip1box-tip">支持使用实验空间账号登录</view>
  29. </view>
  30. <!-- 评审账号和密码 -->
  31. <view class="df loginByPWD-tip2box">
  32. <view class="loginByPWD-tip2box-account">评审账号:student01</view>
  33. <view class="loginByPWD-tip2box-pwd">密码:student01</view>
  34. </view>
  35. <!-- 登录按钮 -->
  36. <view class="loginByPWD-loginbtn df jcc aic btn-hover" @click="onLogin">登录</view>
  37. <!-- 注册账号忘记密码 -->
  38. <view class="df fdr loginByPWD-registerOrForgetBox">
  39. <a :href="regURL" class="loginByPWD-register">注册实验空间账号</a>
  40. <!-- <view class="loginByPWD-forget" @click="onForget">忘记密码</view> -->
  41. <a :href="resetURL" class="loginByPWD-forget">忘记密码</a>
  42. </view>
  43. <view :style="{'opacity': isShowTip}" class="loginByPWD-failTip df jcc">登录失败!请查看账号及密码是否正确!</view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. account: '',
  52. password: '',
  53. regURL: mydata_api+'/register',
  54. resetURL: mydata_api+'/find/password',
  55. //是否显示登录失败的提示 1显示0隐藏(即:透明度归零)
  56. isShowTip: 0,
  57. }
  58. },
  59. methods: {
  60. onAccountInput: function(event) {
  61. this.account = event.target.value
  62. },
  63. onPWDInput: function(event) {
  64. this.password = event.target.value
  65. },
  66. inputFocus() {
  67. this.isShowTip = 0;
  68. },
  69. onLogin() {
  70. //测试直接登录用
  71. localStorage.setItem("account", this.account);
  72. localStorage.setItem("password", this.password);
  73. this.$emit("onLogin");
  74. return;
  75. console.log("IlabAccount=",this.account+";Password=", this.password)
  76. let url = mydata_api + "/user/loginin";
  77. console.log("url=",url)
  78. uni.request({
  79. header: {
  80. 'Content-Type': 'application/json;charset=UTF-8'
  81. },
  82. url: url,
  83. method: 'POST',
  84. data: {
  85. "IlabAccount": this.account.toString(),
  86. "Password": this.password.toString()
  87. },
  88. dataType: 'json',
  89. success: (res) => {
  90. localStorage.setItem("account", this.account);
  91. localStorage.setItem("password", this.password);
  92. let data = res.data;
  93. //登录成功
  94. if (data.Code == 100) {
  95. // console.log("登陆成功");
  96. if (data.Image != '') {
  97. mydata_userInfo.avatarSrc = data.Image;
  98. }
  99. console.log("login账户密码登陆成功data=", data);
  100. mydata_userInfo.Name = data.Name;
  101. mydata_userInfo.UserID = data.UserID;
  102. // mydata_userInfo.Position = data.Position;
  103. mydata_userInfo.role = data.Type;
  104. // console.log("登陆成功,个人信息", mydata_userInfo);
  105. if (mydata_userInfo.role == '老师') {
  106. userController.updateStudentList(null, null);
  107. }
  108. else{
  109. mydata_userInfo.role = '学生';
  110. }
  111. userController.updateScore();
  112. userController.updateUserInfo();
  113. // MyRequest.SetUserType(mydata_userInfo.role, null, null);
  114. this.$emit("onLogin");
  115. }
  116. //密码错误
  117. else {
  118. this.isShowTip = 1;
  119. }
  120. // console.log("success+++**+*", res.data.Code)
  121. },
  122. fail: (res) => {
  123. console.log("fail+**+*", res)
  124. }
  125. });
  126. },
  127. onForget() {
  128. // this.$emit("onForget", "onForget")
  129. }
  130. }
  131. }
  132. </script>
  133. <style>
  134. .loginByPWD-listbox {
  135. margin-top: 2.vw;
  136. }
  137. .loginByPWD-inputbox {
  138. margin-top: 2.5vw;
  139. }
  140. .loginByPWD-inputbox-icon {
  141. margin-left: 0.46875vw;
  142. }
  143. .loginByPWD-inputbox-input {
  144. font-size: 1.04vw;
  145. border: none;
  146. margin-left: 1.25vw;
  147. flex-grow: 1;
  148. }
  149. .loginByPWD-line {
  150. margin-top: 0.729vw;
  151. width: 23.54vw;
  152. height: 0.104vw;
  153. background-color: #E6E6E6;
  154. }
  155. .loginByPWD-tip1box {
  156. margin-top: 1.354vw;
  157. }
  158. .loginByPWD-tip1box-checkbox {
  159. margin-left: 0.46875vw;
  160. }
  161. .loginByPWD-tip1box-tip {
  162. font-size: 0.781vw;
  163. margin-left: 1.146vw;
  164. color: #333333;
  165. }
  166. .loginByPWD-tip2box {
  167. font-size: 0.781vw;
  168. font-family: MicrosoftYaHei;
  169. color: #333333;
  170. line-height: 1.041vw;
  171. margin-top: 2.656vw;
  172. }
  173. .loginByPWD-tip2box-account {
  174. margin-left: 0.104vw;
  175. }
  176. .loginByPWD-tip2box-pwd {
  177. margin-left: 2.031vw;
  178. }
  179. .loginByPWD-loginbtn {
  180. height: 3.125vw;
  181. font-size: 0.989vw;
  182. font-family: MicrosoftYaHei;
  183. line-height: 1.302vw;
  184. margin-top: 2.083vw;
  185. border-radius: 8px;
  186. }
  187. .loginByPWD-registerOrForgetBox {
  188. margin-top: 1.562vw;
  189. font-size: 0.781vw;
  190. font-family: MicrosoftYaHei;
  191. color: #EA252C;
  192. line-height: 1.041vw;
  193. }
  194. .loginByPWD-register {
  195. margin-left: 0.104vw;
  196. }
  197. .loginByPWD-forget {
  198. margin-left: 13.906vw;
  199. color: #EA252C;
  200. }
  201. .loginByPWD-failTip {
  202. color: #EA252C;
  203. font-size: 0.989vw;
  204. margin-top: 1vw;
  205. }
  206. </style>