login.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view
  3. style="width: 100vw;height: 100vh;position: relative;background-image: url(/static/index_bg.png);background-size: 100% 100%;overflow: hidden;">
  4. <view style="display: flex;justify-content: center;position: absolute;top: 20%;width: 100%;">
  5. <image src="/static/logo.png" mode="widthFix" style="width: 40vw;"></image>
  6. </view>
  7. <view
  8. style="width: 100%;position: absolute;top: 56%;transform: translateY(-50%);display: flex;justify-content: center;">
  9. <view style="width: 60%;">
  10. <u--form labelPosition="left" ref="uForm" :model="model" :rulse="rules" >
  11. <u-form-item label="" prop="username" borderBottom ref="item1">
  12. <u--input v-model="model.username" placeholder="请输入账号" border="none" prefixIcon="account-fill"
  13. prefixIconStyle="font-size: 54rpx;color: #409EFF"></u--input>
  14. </u-form-item>
  15. <u-form-item label="" prop="password" borderBottom ref="item1">
  16. <view v-if="type==false">
  17. <u--input v-model="model.password" placeholder="请输入密码" type="password" border="none" prefixIcon="lock-fill" prefixIconStyle="font-size: 54rpx;color: #409EFF" @change="change"></u--input>
  18. </view>
  19. <view v-if="type == true" style="width: 84%;">
  20. <view style="display: flex;align-items: center;">
  21. <u-icon name="lock-fill" color="#409EFF" size="54rpx"></u-icon>
  22. <view style="">
  23. {{model.qwe}}
  24. </view>
  25. </view>
  26. <!-- <u--input v-model="model.qwe" placeholder="请输入密码" type="text" readonly border="none" prefixIcon="lock-fill" prefixIconStyle="font-size: 54rpx;color: #409EFF" ></u--input> -->
  27. </view>
  28. <view @longpress="longIn" @touchend="leave">
  29. <u-icon name="eye-off" color="#909399" size="54rpx" v-if="type == false"></u-icon>
  30. <u-icon name="eye-fill" color="#909399" size="54rpx" v-else></u-icon>
  31. </view>
  32. </u-form-item>
  33. </u--form>
  34. </view>
  35. </view>
  36. <view style="width: 100%;position: absolute;top: 70%;display: flex;justify-content: center;">
  37. <view style="width: 60%;">
  38. <u-button text="登录" type="primary" size="large" shape="circle" @click="logOn"></u-button>
  39. </view>
  40. </view>
  41. <view class="wave"></view>
  42. <view class="wave2"></view>
  43. <view class="wave3"></view>
  44. <view class="wave4"></view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. model: {
  52. username: "",
  53. password: "",
  54. qwe:""
  55. },
  56. //表单验证
  57. rules: {
  58. 'username': {
  59. required: true,
  60. message: '请输入账号',
  61. trigger: ['blur', 'change']
  62. },
  63. 'password': {
  64. required: true,
  65. message: '请输入密码',
  66. trigger: ['blur', 'change']
  67. },
  68. },
  69. //密码可见
  70. type: false
  71. }
  72. },
  73. onLoad() {
  74. if(uni.getStorageSync('token') != '' && uni.getStorageSync('userInfo') != ''){
  75. this.seeKaoqin(uni.getStorageSync('userInfo'))
  76. uni.reLaunch({
  77. url:"/pages/index/index"
  78. })
  79. }
  80. },
  81. methods: {
  82. //登陆按钮
  83. logOn() {
  84. let that = this
  85. // uni.switchTab({
  86. // url:"/pages/index/index"
  87. // })
  88. this.$refs.uForm.validate().then(res => {
  89. uni.showLoading({
  90. title: "登录中...",
  91. mask: true
  92. })
  93. uni.$u.http.post('/app/login', that.model).then(qwe => {
  94. // console.log(qwe)
  95. getApp().globalData.token = qwe.token
  96. uni.hideLoading()
  97. uni.setStorageSync('token', qwe.token)
  98. uni.setStorageSync('jtoken', qwe.jtoken)
  99. that.getUserInfo()
  100. }).catch(error => {
  101. uni.hideLoading()
  102. uni.showToast({
  103. title:error.msg,
  104. icon:'none'
  105. })
  106. })
  107. }).catch(errors => {
  108. })
  109. },
  110. //获取个人信息
  111. getUserInfo() {
  112. uni.$u.http.get('/getInfo').then(res => {
  113. uni.setStorageSync('userInfo', res.user)
  114. this.seeKaoqin(res.user)
  115. getApp().globalData.userInfo = res.user
  116. uni.switchTab({
  117. url: "/pages/index/index"
  118. })
  119. })
  120. },
  121. //长按
  122. longIn(){
  123. this.type = true
  124. this.$forceUpdate()
  125. },
  126. //离开长按
  127. leave(){
  128. if(this.type==true){
  129. this.type = false
  130. this.$forceUpdate()
  131. }
  132. },
  133. change(){
  134. this.model.qwe = this.model.password
  135. },
  136. //是否可查看考勤
  137. seeKaoqin(v){
  138. uni.$u.http.get("/oa/attendance/queryPostAttendance/"+v.userId).then(res=>{
  139. uni.setStorageSync('type',res)
  140. })
  141. }
  142. },
  143. onReady() {
  144. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  145. this.$refs.uForm.setRules(this.rules)
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. ::v-deep .u-line {
  151. border-bottom: 2px solid #409EFF !important
  152. }
  153. @keyframes run {
  154. to {
  155. transform: translateX(-100vw);
  156. }
  157. }
  158. .box {
  159. width: 200vw;
  160. list-style: none;
  161. animation: run 4s linear infinite;
  162. }
  163. .wave {
  164. position: fixed;
  165. bottom: -60px;
  166. left: 0;
  167. width: 100vw;
  168. height: 200px;
  169. // outline: 2px dashed gray;
  170. --c: #2196F3;
  171. --b: red;
  172. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  173. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  174. background: var(--w1), var(--w2), var(--w1), var(--w2);
  175. background-position-x: -200%, -100%, 0%, 100%;
  176. background-position-y: 100%;
  177. background-size: 50.5% 100%;
  178. animation: m 2s infinite linear;
  179. opacity: 0.4;
  180. }
  181. .wave2 {
  182. position: fixed;
  183. bottom: -60px;
  184. left: 0;
  185. width: 100vw;
  186. height: 200px;
  187. // outline: 2px dashed gray;
  188. --c: #2196F3;
  189. --b: red;
  190. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  191. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  192. background: var(--w1), var(--w2), var(--w1), var(--w2);
  193. background-position-x: -200%, -100%, 0%, 100%;
  194. background-position-y: 100%;
  195. background-size: 50.5% 100%;
  196. animation: m 3s infinite linear;
  197. opacity: 0.4;
  198. animation-direction:reverse
  199. }
  200. .wave3 {
  201. position: fixed;
  202. bottom: -60px;
  203. left: 0;
  204. width: 100vw;
  205. height: 200px;
  206. // outline: 2px dashed gray;
  207. --c: #2196F3;
  208. --b: red;
  209. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  210. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  211. background: var(--w1), var(--w2), var(--w1), var(--w2);
  212. background-position-x: -200%, -100%, 0%, 100%;
  213. background-position-y: 100%;
  214. background-size: 50.5% 100%;
  215. animation: m 5s infinite linear;
  216. opacity: 0.2;
  217. }
  218. .wave4 {
  219. position: fixed;
  220. bottom: -60px;
  221. left: 0;
  222. width: 100vw;
  223. height: 200px;
  224. // outline: 2px dashed gray;
  225. --c: #2196F3;
  226. --b: red;
  227. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  228. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  229. background: var(--w1), var(--w2), var(--w1), var(--w2);
  230. background-position-x: -200%, -100%, 0%, 100%;
  231. background-position-y: 100%;
  232. background-size: 50.5% 100%;
  233. animation: m 6s infinite linear;
  234. opacity: 0.2;
  235. animation-direction:reverse
  236. }
  237. @keyframes m {
  238. 0% {
  239. background-position-x: -200%, -100%, 0%, 100%
  240. }
  241. 100% {
  242. background-position-x: 0%, 100%, 200%, 300%
  243. }
  244. }
  245. </style>