login.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="main">
  3. <view id="box">
  4. <view id="top" class="">
  5. <view class="top_le"></view>
  6. <view class="top_ri"></view>
  7. </view>
  8. <view class="title">
  9. <view style="font-size: 28px!important;">公文流转管理平台</view>
  10. </view>
  11. <view class="login-form">
  12. <u--form :model="inputForm" labelWidth="100px" labelPosition="left" :rules="rules" ref="uForm">
  13. <u-form-item label="用户名" borderBottom prop="username">
  14. <u-input @focus="isfocus = true" v-model="inputForm.username" />
  15. </u-form-item>
  16. <u-form-item label="密码" borderBottom prop="password">
  17. <u-input @focus="isfocus = true" password v-model="inputForm.password" />
  18. </u-form-item>
  19. <!-- <u-checkbox-group v-model="isrember" placement="column" @change="checkboxChange">
  20. <u-checkbox :customStyle="{marginBottom: '8px'}" label="记住密码" name="true">
  21. </u-checkbox>
  22. </u-checkbox-group> -->
  23. </u--form>
  24. </view>
  25. <!-- <view v-if="isfocus" class="focus_info" >
  26. <view class="flex" v-for="item in accounts">
  27. <u--text decoration='underline' color='#36a7f3' :text="item.username"
  28. @click="checked"></u--text>
  29. </view>
  30. </view> -->
  31. <view class="but">
  32. <u-button type="primary" shape="circle" color="linear-gradient(90deg, #1989FA, #19C2FA)"
  33. @click="bindLogin" text="登录"></u-button>
  34. </view>
  35. <!-- <view class="fot">
  36. <text @tap="reg_ok">免费注册</text>
  37. <text style="display: inline-block;width: 10vw;"></text>
  38. <text @tap="forget_ok">忘记密码</text>
  39. </view> -->
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import * as $auth from "@/common/auth.js"
  45. import loginService from "@/api/auth/loginService"
  46. import {
  47. mapActions
  48. } from 'vuex'
  49. export default {
  50. mounted() {
  51. // if(uni.getStorageSync("accounts")){
  52. // this.accounts =[].concat(uni.getStorageSync("accounts"))
  53. // }
  54. },
  55. data() {
  56. return {
  57. isfocus:false,
  58. captchaImg: '',
  59. accounts: [],
  60. isrember: [],
  61. inputForm: {
  62. 'username': '',
  63. 'password': '',
  64. 'code': '',
  65. 'uuid': ''
  66. },
  67. rules: {
  68. username: [{
  69. required: true,
  70. message: '请输入用户名',
  71. trigger: ['blur', 'change']
  72. }],
  73. password: [{
  74. required: true,
  75. message: '请输入密码',
  76. trigger: ['blur', 'change']
  77. }],
  78. code: [{
  79. required: true,
  80. message: '请输入验证码',
  81. trigger: ['blur', 'change']
  82. }]
  83. }
  84. }
  85. },
  86. created() {
  87. this.getCaptcha()
  88. },
  89. methods: {
  90. ...mapActions(['refreshUserInfo']),
  91. checkboxChange(n) {
  92. console.log('change', n);
  93. this.isrember[0] = n
  94. },
  95. // 登录
  96. bindLogin() {
  97. /**
  98. * 客户端对账号信息进行一些必要的校验。
  99. * 实际开发中,根据业务需要进行处理,这里仅做示例。
  100. */
  101. this.$refs.uForm.validate().then(res => {
  102. loginService.login(this.inputForm).then((data) => {
  103. this.$store.commit('SET_TOKEN', data.token);
  104. // if (this.isrember[0]) {
  105. // this.accounts.push(this.inputForm)
  106. // uni.setStorageSync("accounts", this.accounts)
  107. // }
  108. this.refreshUserInfo();
  109. uni.reLaunch({
  110. url: '../index/index',
  111. });
  112. }).catch(e => {
  113. uni.showToast({
  114. title: e.data
  115. })
  116. this.getCaptcha()
  117. console.error(e)
  118. })
  119. })
  120. },
  121. // 获取验证码
  122. getCaptcha() {
  123. loginService.getCode().then((data) => {
  124. this.captchaImg = 'data:image/gif;base64,' + data.codeImg
  125. this.inputForm.uuid = data.uuid
  126. })
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. // 记住账户展示
  133. .focus_info{
  134. }
  135. #box {
  136. position: relative;
  137. // color: $u-content-color;
  138. }
  139. .title {
  140. position: absolute;
  141. top: 15vh;
  142. width: 100vw;
  143. text-align: center;
  144. font-size: 28rpx;
  145. color: #198bfa;
  146. }
  147. .title view:nth-child(1) {
  148. height: 54px;
  149. font-size: 56rpx;
  150. font-family: PingFang SC;
  151. font-weight: bold;
  152. text-shadow: 0px 2px 24px rgba(58, 199, 118, 0.4);
  153. }
  154. .title view:nth-child(2) {
  155. font-size: 32rpx;
  156. font-family: PingFang SC;
  157. font-weight: 500;
  158. color: #198BFA;
  159. margin-top: 5vw;
  160. }
  161. #top {
  162. width: 100vw;
  163. height: 40vh;
  164. position: relative;
  165. }
  166. .top_ri {
  167. width: 100vw;
  168. height: 100vw;
  169. background: linear-gradient(141deg, #19C0FA 0%, #198BFA 100%);
  170. opacity: 0.1;
  171. border-radius: 50%;
  172. position: absolute;
  173. right: -47vw;
  174. top: -37vw;
  175. }
  176. .top_le {
  177. width: 100vw;
  178. height: 100vw;
  179. background: linear-gradient(141deg, #19C0FA 0%, #198BFA 100%);
  180. opacity: 0.1;
  181. border-radius: 50%;
  182. position: absolute;
  183. left: -34vw;
  184. top: -54vw;
  185. }
  186. .inp {
  187. padding-left: 5vw;
  188. position: relative;
  189. top: -4vh;
  190. }
  191. .inp text {
  192. font-size: 36rpx;
  193. font-family: PingFang SC;
  194. font-weight: 500;
  195. color: #333333;
  196. margin-left: 5px;
  197. }
  198. .but {
  199. padding-left: 50rpx;
  200. padding-right: 50rpx;
  201. margin-top: 60rpx;
  202. }
  203. .fot {
  204. width: 100vw;
  205. height: 26px;
  206. text-align: center;
  207. font-size: 28rpx;
  208. font-family: PingFang SC;
  209. font-weight: 500;
  210. color: #8E8E8E;
  211. margin-top: 20px;
  212. }
  213. .login-form {
  214. padding-left: 100rpx;
  215. padding-right: 30rpx;
  216. }
  217. </style>