login.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. }else{
  66. uni.navigateTo({
  67. url:'../pc/indexNew'
  68. })
  69. }
  70. }
  71. });
  72. }else{
  73. uni.showToast({
  74. title: res.msg,
  75. icon: 'none',
  76. duration: 3000
  77. });
  78. }
  79. })
  80. },
  81. show(num){
  82. if(num==1){
  83. this.passwordType='password'
  84. }else{
  85. this.passwordType='text'
  86. }
  87. }
  88. }
  89. }
  90. </script>
  91. <style scoped>
  92. .content{
  93. width: 100vw;
  94. height: 100vh;
  95. background: url(../../static/pcimg/loginBg.png) no-repeat;
  96. background-size: 100% 100%;
  97. display: flex;
  98. justify-content: center;
  99. align-items: center;
  100. }
  101. .loginLogo{
  102. width: 206px;height: 48px;
  103. position: fixed;
  104. left:100px;top: 50px;
  105. }
  106. .box{
  107. width: 508px;
  108. height: 447px;
  109. background: #FFFFFF;
  110. box-shadow: 0px 0px 19px 0px rgba(202,228,253,0.2);
  111. border-radius: 24px;
  112. }
  113. .title{
  114. font-family: PingFangSC, PingFang SC;
  115. font-weight: 600;
  116. font-size: 24px;
  117. color: #222222;
  118. line-height: 33px;
  119. text-align: center;
  120. padding-top: 52rpx;
  121. }
  122. .lineInput{
  123. height: 47px;
  124. line-height: 47px;
  125. font-size: 18px;
  126. padding-left: 19px;
  127. border: none;
  128. }
  129. .inputBox{
  130. width: 411px;
  131. height: 49px;
  132. border-radius: 8px;
  133. border: 1px solid #D4D9E2;
  134. margin-top: 40px;
  135. margin-left: 49px;
  136. }
  137. .yincIcon{
  138. position: absolute;
  139. top: 20px;right: 24px;
  140. width: 20px;height: 10px;
  141. }
  142. .ckBox{
  143. font-size: 14px;
  144. color: #666666;
  145. padding-left: 49px;
  146. padding-top: 15px;
  147. }
  148. .btn{
  149. width: 411px;
  150. height: 49px;
  151. background: #1472FF;
  152. border-radius: 8px;
  153. text-align: center;
  154. line-height: 49px;
  155. font-size: 18px;
  156. color: #FFFFFF;
  157. margin-top: 49px;
  158. cursor: pointer;
  159. margin-left: 49px;
  160. }
  161. .yanjIcon{
  162. position: absolute;
  163. top: 18px;right: 24px;
  164. width: 19px;height: 14px;
  165. cursor: pointer;
  166. }
  167. input:focus {
  168. outline: none;
  169. box-shadow: none;
  170. }
  171. input[type="text"]:focus {
  172. outline: none;
  173. box-shadow: none;
  174. }
  175. </style>