login.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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" :model="model" :rulse="rules" ref="uForm">
  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. uni.reLaunch({
  76. url:"/pages/index/index"
  77. })
  78. }
  79. },
  80. methods: {
  81. //登陆按钮
  82. logOn() {
  83. let that = this
  84. // uni.switchTab({
  85. // url:"/pages/index/index"
  86. // })
  87. this.$refs.uForm.validate().then(res => {
  88. uni.showLoading({
  89. title: "登录中...",
  90. mask: true
  91. })
  92. uni.$u.http.post('/app/login', that.model).then(qwe => {
  93. // console.log(qwe)
  94. getApp().globalData.token = qwe.token
  95. uni.hideLoading()
  96. uni.setStorageSync('token', qwe.token)
  97. uni.setStorageSync('jtoken', qwe.jtoken)
  98. that.getUserInfo()
  99. }).catch(error => {
  100. uni.hideLoading()
  101. uni.showToast({
  102. title:error.msg,
  103. icon:'none'
  104. })
  105. })
  106. }).catch(errors => {
  107. })
  108. },
  109. //获取个人信息
  110. getUserInfo() {
  111. uni.$u.http.get('/getInfo').then(res => {
  112. uni.setStorageSync('userInfo', res.user)
  113. getApp().globalData.userInfo = res.user
  114. uni.switchTab({
  115. url: "/pages/index/index"
  116. })
  117. })
  118. },
  119. //长按
  120. longIn(){
  121. this.type = true
  122. this.$forceUpdate()
  123. },
  124. //离开长按
  125. leave(){
  126. if(this.type==true){
  127. this.type = false
  128. this.$forceUpdate()
  129. }
  130. },
  131. change(){
  132. this.model.qwe = this.model.password
  133. }
  134. },
  135. onReady() {
  136. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  137. this.$refs.uForm.setRules(this.rules)
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. ::v-deep .u-line {
  143. border-bottom: 2px solid #409EFF !important
  144. }
  145. @keyframes run {
  146. to {
  147. transform: translateX(-100vw);
  148. }
  149. }
  150. .box {
  151. width: 200vw;
  152. list-style: none;
  153. animation: run 4s linear infinite;
  154. }
  155. .wave {
  156. position: fixed;
  157. bottom: -60px;
  158. left: 0;
  159. width: 100vw;
  160. height: 200px;
  161. // outline: 2px dashed gray;
  162. --c: #2196F3;
  163. --b: red;
  164. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  165. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  166. background: var(--w1), var(--w2), var(--w1), var(--w2);
  167. background-position-x: -200%, -100%, 0%, 100%;
  168. background-position-y: 100%;
  169. background-size: 50.5% 100%;
  170. animation: m 2s infinite linear;
  171. opacity: 0.4;
  172. }
  173. .wave2 {
  174. position: fixed;
  175. bottom: -60px;
  176. left: 0;
  177. width: 100vw;
  178. height: 200px;
  179. // outline: 2px dashed gray;
  180. --c: #2196F3;
  181. --b: red;
  182. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  183. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  184. background: var(--w1), var(--w2), var(--w1), var(--w2);
  185. background-position-x: -200%, -100%, 0%, 100%;
  186. background-position-y: 100%;
  187. background-size: 50.5% 100%;
  188. animation: m 3s infinite linear;
  189. opacity: 0.4;
  190. animation-direction:reverse
  191. }
  192. .wave3 {
  193. position: fixed;
  194. bottom: -60px;
  195. left: 0;
  196. width: 100vw;
  197. height: 200px;
  198. // outline: 2px dashed gray;
  199. --c: #2196F3;
  200. --b: red;
  201. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  202. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  203. background: var(--w1), var(--w2), var(--w1), var(--w2);
  204. background-position-x: -200%, -100%, 0%, 100%;
  205. background-position-y: 100%;
  206. background-size: 50.5% 100%;
  207. animation: m 5s infinite linear;
  208. opacity: 0.2;
  209. }
  210. .wave4 {
  211. position: fixed;
  212. bottom: -60px;
  213. left: 0;
  214. width: 100vw;
  215. height: 200px;
  216. // outline: 2px dashed gray;
  217. --c: #2196F3;
  218. --b: red;
  219. --w1: radial-gradient(100% 57% at top, #0000 100%, var(--c) 100.5%) no-repeat;
  220. --w2: radial-gradient(100% 57.5% at bottom, var(--c) 100%, #0000 100.5%) no-repeat;
  221. background: var(--w1), var(--w2), var(--w1), var(--w2);
  222. background-position-x: -200%, -100%, 0%, 100%;
  223. background-position-y: 100%;
  224. background-size: 50.5% 100%;
  225. animation: m 6s infinite linear;
  226. opacity: 0.2;
  227. animation-direction:reverse
  228. }
  229. @keyframes m {
  230. 0% {
  231. background-position-x: -200%, -100%, 0%, 100%
  232. }
  233. 100% {
  234. background-position-x: 0%, 100%, 200%, 300%
  235. }
  236. }
  237. </style>