login.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="content">
  3. <view class="title">
  4. <text class="thing" style="width: 100rpx;"></text>
  5. <text class="name">用户登录</text>
  6. <text class="thing" style="width: 300rpx;"></text>
  7. </view>
  8. <view class="form-box">
  9. <view class="row-input">
  10. <u-icon name="account" color="#2979ff" size="50" style="padding: 0 20rpx;"></u-icon>
  11. <input v-model="account" placeholder="请输入用户账号" maxlength="18" />
  12. </view>
  13. <view class="row-input">
  14. <u-icon name="lock" color="#2979ff" size="50" style="padding: 0 20rpx;"></u-icon>
  15. <input v-model="password" placeholder="登陆密码" :password="!isShowPassword" />
  16. <u-icon name="eye-fill" color="#2979ff" size="50" style="padding-right:20rpx" v-if="isShowPassword"
  17. @click="showOrHide"></u-icon>
  18. <u-icon name="eye-off" color="#2979ff" size="50" style="padding-right:0rpx" v-else @click="showOrHide">
  19. </u-icon>
  20. </view>
  21. <!-- <view class="rowinputcaptcha">
  22. <u-icon name="hourglass" color="#2979ff" size="50" style="padding: 0 20rpx;"></u-icon>
  23. <input class="captchainput" v-model="captcha" placeholder="验证码"/>
  24. <u--image :showLoading="true" :src="captchaPath" width="150px" height="35px" @click="getCaptcha"></u--image>
  25. </view> -->
  26. <view class="menu-link">
  27. <text @click="forget">找回密码</text>
  28. </view>
  29. <view class="login-btn" @click="loginbtn">登录</view>
  30. <view class="tip-link">
  31. 还没有账号?<text @click="register">注册</text>
  32. </view>
  33. </view>
  34. <u-toast ref="uToast" />
  35. </view>
  36. </template>
  37. <script>
  38. // function getUUID() {
  39. // return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
  40. // return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
  41. // })
  42. // }
  43. const BaseApi= require("@/http/baseApi.js");
  44. export default {
  45. data() {
  46. return {
  47. isShowPassword: true,
  48. account:'admin',
  49. password:'cx868688',
  50. captcha:'',
  51. uuid: '',
  52. captchaPath:'',
  53. }
  54. },
  55. onLoad() {
  56. // this.getCaptcha();
  57. },
  58. methods: {
  59. // 获取验证码
  60. // getCaptcha() {
  61. // this.uuid = getUUID();
  62. // this.captchaPath =BaseApi.BaseApi+ `/captcha?uuid=${this.uuid}`;
  63. // },
  64. loginbtn() {
  65. if(this.account==''){
  66. this.$refs.uToast.show({
  67. type:'error',
  68. message: "请输入账号",
  69. })
  70. // uni.showToast({
  71. // title: "请输入账号",
  72. // icon:'error',
  73. // duration: 1000,
  74. // })
  75. }else if(this.password==''){
  76. this.$refs.uToast.show({
  77. type:'error',
  78. message: "请输入密码",
  79. })
  80. }
  81. let formData = {
  82. username: this.account,
  83. password: this.password,
  84. // uuid:this.uuid,
  85. // captcha:this.captcha,
  86. }
  87. //登录功能
  88. this.$api.post('/login',formData)
  89. .then(res => {
  90. if(res.data.code==0){
  91. uni.setStorageSync('tokendata', res.data.data.token);//token
  92. uni.setStorageSync('Userinformation',formData);//用户信息
  93. //获取用户权限功能
  94. // this.$api.get('/sys/menu/permissions',{})
  95. // .then(res1=>{
  96. // uni.setStorageSync('ButtonPermissions', res1.data.data);//权限列表
  97. // uni.switchTab({
  98. // url: '/pages/index/index',
  99. // success:res=>{},
  100. // fail:()=>{},
  101. // complete:()=>{},
  102. // })
  103. // })
  104. uni.switchTab({
  105. url: '/pages/index/index',
  106. success:res=>{},
  107. fail:()=>{},
  108. complete:()=>{},
  109. })
  110. }else{
  111. this.$refs.uToast.show({
  112. type:'error',
  113. message: "账号或者密码错误,请重新输入",
  114. })
  115. }
  116. })
  117. },
  118. // 密码显示/密码隐藏
  119. showOrHide() {
  120. this.isShowPassword = !this.isShowPassword
  121. },
  122. // 找回密码
  123. forget() {
  124. uni.navigateTo({
  125. url: '/pages/login/forget',
  126. success:res=>{},
  127. fail:()=>{},
  128. complete:()=>{},
  129. })
  130. },
  131. // 注册
  132. register() {
  133. uni.navigateTo({
  134. url: '/pages/login/register',
  135. success:res=>{},
  136. fail:()=>{},
  137. complete:()=>{},
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss">
  144. page {
  145. background-color: #0b0c14;
  146. }
  147. .content {
  148. padding: 100rpx 40rpx;
  149. }
  150. .title {
  151. display: flex;
  152. flex-direction: column;
  153. height: 200rpx;
  154. .thing {
  155. height: 8rpx;
  156. background-image: linear-gradient(to right, #3feaea, #0168e6);
  157. }
  158. .name {
  159. font-weight: bold;
  160. font-size: 50rpx;
  161. line-height: 120rpx;
  162. background: linear-gradient(to right, #3feaea, blue);
  163. background-clip: text;
  164. color: transparent;
  165. letter-spacing: 5rpx;
  166. }
  167. }
  168. .form-box {
  169. .rowinputcaptcha{
  170. display: flex;
  171. justify-content: flex-start;
  172. align-items: center;
  173. height: 110rpx;
  174. //background-color: #2b2f41;
  175. border-radius: 8rpx;
  176. margin-bottom: 50rpx;
  177. input {
  178. width: 300rpx;
  179. font-size: 30rpx;
  180. color: #a1a2a3;
  181. }
  182. }
  183. .row-input {
  184. display: flex;
  185. justify-content: flex-start;
  186. align-items: center;
  187. height: 110rpx;
  188. background-color: #2b2f41;
  189. border-radius: 8rpx;
  190. margin-bottom: 50rpx;
  191. image {
  192. margin: 0 30rpx;
  193. flex-shrink: 0;
  194. width: 38rpx;
  195. height: 38rpx;
  196. }
  197. input {
  198. width: 460rpx;
  199. font-size: 30rpx;
  200. color: #a1a2a3;
  201. }
  202. }
  203. .menu-link {
  204. display: flex;
  205. justify-content: flex-end;
  206. align-items: center;
  207. font-size: 28rpx;
  208. color: #676c7f;
  209. }
  210. .login-btn {
  211. margin-top: 60rpx;
  212. display: flex;
  213. justify-content: center;
  214. align-items: center;
  215. font-size: 35rpx;
  216. letter-spacing: 15rpx;
  217. color: #FFFFFF;
  218. height: 110rpx;
  219. border-radius: 8rpx;
  220. background-image: linear-gradient(to right, #3feaea, #0168e6);
  221. }
  222. .tip-link {
  223. position: fixed;
  224. letter-spacing: 4rpx;
  225. bottom: 50rpx;
  226. left: 40rpx;
  227. font-size: 28rpx;
  228. color: #a1a2a3;
  229. text {
  230. padding-left: 10rpx;
  231. color: #226ef0;
  232. }
  233. }
  234. }
  235. .captchainput{
  236. width: 300rpx;
  237. }
  238. </style>