login.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="content">
  3. <image src="../../static/pcimg/loginLogo.png" mode="" class="loginLogo"></image>
  4. <view class="box">
  5. <view class="title">登录</view>
  6. <view class="inputBox">
  7. <input v-model="accountName" type="text" placeholder="账号" class="lineInput"/>
  8. </view>
  9. <view class="inputBox" style="position: relative;">
  10. <input v-model="password" v-if="passwordType=='password'" type="password" placeholder="密码" class="lineInput"/>
  11. <input v-model="password" v-else type="text" placeholder="密码" class="lineInput"/>
  12. <image v-if="passwordType=='password'" src="../../static/pcimg/yc.png" mode="" class="yincIcon" @click="show(2)"></image>
  13. <image v-else src="../../static/pcimg/yj.png" mode="" class="yanjIcon" @click="show(1)"></image>
  14. </view>
  15. <view class="ckBox">
  16. <checkbox-group>
  17. <label>
  18. <checkbox style="transform:scale(0.7)" value="cb" />记住密码
  19. </label>
  20. </checkbox-group>
  21. </view>
  22. <view class="btn" @click="login">登录</view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. passwordType: 'password',
  31. accountName:'',
  32. password:'',
  33. index:'',
  34. }
  35. },
  36. onLoad(opt) {
  37. this.index=opt.index
  38. },
  39. methods: {
  40. login(){
  41. uni.showLoading({
  42. title: '加载中'
  43. })
  44. this.$http('/trainingOpenApi/login', {
  45. accountName:this.accountName,
  46. password:this.password
  47. }, 'POST').then(res => {
  48. uni.hideLoading();
  49. //console.log(res.code)
  50. if(res.code==1){
  51. var helpToken=res.data.helpToken
  52. const currentTime = Date.now();
  53. const expirationTime = currentTime + 7 * 24 * 60 * 60 * 1000; // 一周后过期
  54. uni.setStorage({
  55. key: 'helpToken',
  56. data:{
  57. value: helpToken,
  58. expiration: expirationTime
  59. },
  60. success: function () {
  61. if(this.index==2){
  62. uni.navigateTo({
  63. url:'../pcLh/indexNew'
  64. })
  65. }
  66. if(this.index==3){
  67. uni.navigateTo({
  68. url:'../pc3/indexNew'
  69. })
  70. }else{
  71. uni.navigateTo({
  72. url:'../pc/indexNew'
  73. })
  74. }
  75. }
  76. });
  77. }else{
  78. uni.showToast({
  79. title: res.msg,
  80. icon: 'none',
  81. duration: 3000
  82. });
  83. }
  84. })
  85. },
  86. show(num){
  87. if(num==1){
  88. this.passwordType='password'
  89. }else{
  90. this.passwordType='text'
  91. }
  92. }
  93. }
  94. }
  95. </script>
  96. <style scoped>
  97. .content{
  98. width: 100vw;
  99. height: 100vh;
  100. background: url(../../static/pcimg/loginBg.png) no-repeat;
  101. background-size: 100% 100%;
  102. display: flex;
  103. justify-content: center;
  104. align-items: center;
  105. }
  106. .loginLogo{
  107. width: 206px;height: 48px;
  108. position: fixed;
  109. left:100px;top: 50px;
  110. }
  111. .box{
  112. width: 508px;
  113. height: 447px;
  114. background: #FFFFFF;
  115. box-shadow: 0px 0px 19px 0px rgba(202,228,253,0.2);
  116. border-radius: 24px;
  117. }
  118. .title{
  119. font-family: PingFangSC, PingFang SC;
  120. font-weight: 600;
  121. font-size: 24px;
  122. color: #222222;
  123. line-height: 33px;
  124. text-align: center;
  125. padding-top: 52rpx;
  126. }
  127. .lineInput{
  128. height: 47px;
  129. line-height: 47px;
  130. font-size: 18px;
  131. padding-left: 19px;
  132. border: none;
  133. }
  134. .inputBox{
  135. width: 411px;
  136. height: 49px;
  137. border-radius: 8px;
  138. border: 1px solid #D4D9E2;
  139. margin-top: 40px;
  140. margin-left: 49px;
  141. }
  142. .yincIcon{
  143. position: absolute;
  144. top: 20px;right: 24px;
  145. width: 20px;height: 10px;
  146. }
  147. .ckBox{
  148. font-size: 14px;
  149. color: #666666;
  150. padding-left: 49px;
  151. padding-top: 15px;
  152. }
  153. .btn{
  154. width: 411px;
  155. height: 49px;
  156. background: #1472FF;
  157. border-radius: 8px;
  158. text-align: center;
  159. line-height: 49px;
  160. font-size: 18px;
  161. color: #FFFFFF;
  162. margin-top: 49px;
  163. cursor: pointer;
  164. margin-left: 49px;
  165. }
  166. .yanjIcon{
  167. position: absolute;
  168. top: 18px;right: 24px;
  169. width: 19px;height: 14px;
  170. cursor: pointer;
  171. }
  172. input:focus {
  173. outline: none;
  174. box-shadow: none;
  175. }
  176. input[type="text"]:focus {
  177. outline: none;
  178. box-shadow: none;
  179. }
  180. </style>