login.vue 6.6 KB

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