login.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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: false,
  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. Promise.all([this.getpermissions(), this.getDictList()]).then(() => {
  95. uni.switchTab({
  96. url: '/pages/index/index',
  97. success: res => {},
  98. fail: () => {},
  99. complete: () => {},
  100. })
  101. });
  102. } else {
  103. this.$refs.uToast.show({
  104. type: 'error',
  105. message: "账号或者密码错误,请重新输入",
  106. })
  107. }
  108. })
  109. },
  110. getpermissions() {
  111. console.log('权限功能', )
  112. //获取用户权限功能
  113. // this.$api.get('/sys/menu/permissions',{})
  114. // .then(res1=>{
  115. // uni.setStorageSync('ButtonPermissions', res1.data.data);//权限列表
  116. //
  117. // })
  118. },
  119. getDictList() {
  120. //获取字典列表, 添加并全局变量保存
  121. this.$api.get('/all', {})
  122. .then(res => {
  123. // console.log('88888', res.data.data)
  124. uni.setStorageSync('getDictDataList', res.data.data);
  125. })
  126. },
  127. // 密码显示/密码隐藏
  128. showOrHide() {
  129. this.isShowPassword = !this.isShowPassword
  130. },
  131. // 找回密码
  132. forget() {
  133. uni.navigateTo({
  134. url: '/pages/login/forget',
  135. success: res => {},
  136. fail: () => {},
  137. complete: () => {},
  138. })
  139. },
  140. // 注册
  141. register() {
  142. uni.navigateTo({
  143. url: '/pages/login/register',
  144. success: res => {},
  145. fail: () => {},
  146. complete: () => {},
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. page {
  154. background-color: #0b0c14;
  155. }
  156. .content {
  157. padding: 100rpx 40rpx;
  158. }
  159. .title {
  160. display: flex;
  161. flex-direction: column;
  162. height: 200rpx;
  163. .thing {
  164. height: 8rpx;
  165. background-image: linear-gradient(to right, #3feaea, #0168e6);
  166. }
  167. .name {
  168. font-weight: bold;
  169. font-size: 50rpx;
  170. line-height: 120rpx;
  171. background: linear-gradient(to right, #3feaea, blue);
  172. background-clip: text;
  173. color: transparent;
  174. letter-spacing: 5rpx;
  175. }
  176. }
  177. .form-box {
  178. .rowinputcaptcha {
  179. display: flex;
  180. justify-content: flex-start;
  181. align-items: center;
  182. height: 110rpx;
  183. //background-color: #2b2f41;
  184. border-radius: 8rpx;
  185. margin-bottom: 50rpx;
  186. input {
  187. width: 300rpx;
  188. font-size: 30rpx;
  189. color: #a1a2a3;
  190. }
  191. }
  192. .row-input {
  193. display: flex;
  194. justify-content: flex-start;
  195. align-items: center;
  196. height: 110rpx;
  197. background-color: #2b2f41;
  198. border-radius: 8rpx;
  199. margin-bottom: 50rpx;
  200. image {
  201. margin: 0 30rpx;
  202. flex-shrink: 0;
  203. width: 38rpx;
  204. height: 38rpx;
  205. }
  206. input {
  207. width: 460rpx;
  208. font-size: 30rpx;
  209. color: #a1a2a3;
  210. }
  211. }
  212. .menu-link {
  213. display: flex;
  214. justify-content: flex-end;
  215. align-items: center;
  216. font-size: 28rpx;
  217. color: #676c7f;
  218. }
  219. .login-btn {
  220. margin-top: 60rpx;
  221. display: flex;
  222. justify-content: center;
  223. align-items: center;
  224. font-size: 35rpx;
  225. letter-spacing: 15rpx;
  226. color: #FFFFFF;
  227. height: 110rpx;
  228. border-radius: 8rpx;
  229. background-image: linear-gradient(to right, #3feaea, #0168e6);
  230. }
  231. .tip-link {
  232. position: fixed;
  233. letter-spacing: 4rpx;
  234. bottom: 50rpx;
  235. left: 40rpx;
  236. font-size: 28rpx;
  237. color: #a1a2a3;
  238. text {
  239. padding-left: 10rpx;
  240. color: #226ef0;
  241. }
  242. }
  243. }
  244. .captchainput {
  245. width: 300rpx;
  246. }
  247. </style>