login.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="body" :style="{height:screenHeight}">
  3. <view class="header">
  4. <view class="circle circle1"></view>
  5. <view class="circle circle2"></view>
  6. <view class="circle circle3"></view>
  7. <view class="text">
  8. <view class="en-text">hello</view>
  9. <view class="cn-text">欢迎登录!</view>
  10. </view>
  11. </view>
  12. <view class="login-box">
  13. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" >
  14. <u-form-item label="" prop="account" ref="account" >
  15. <u--input
  16. v-model="form.account"
  17. border="surround"
  18. placeholder="输入账号"
  19. :customStyle="inputCustomStyle"
  20. ></u--input>
  21. </u-form-item>
  22. <u-form-item label="" prop="password" ref="password" >
  23. <u--input
  24. v-model="form.password"
  25. border="surround"
  26. :password="true"
  27. placeholder="输入密码"
  28. :customStyle="inputCustomStyle"
  29. ></u--input>
  30. </u-form-item>
  31. </u--form>
  32. <u-button
  33. @click="submit"
  34. text="登录"
  35. type="primary"
  36. shape="circle"
  37. :customStyle="{'margin-top':'60rpx',height:'98rpx','box-sizing':'border-box'}"
  38. color="linear-gradient(90deg, #00D17D 0%, #00A447 100%)">
  39. </u-button>
  40. </view>
  41. <view class="tip">
  42. 提示:初始账号和密码由管理员设置,请与管理人员联系
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. bname:'旭烁集团',
  51. //屏幕高度
  52. screenHeight: "",
  53. backUrl:null,
  54. form:{
  55. account:'',
  56. password:''
  57. },
  58. rules: {
  59. account: {
  60. type: 'string',
  61. required: true,
  62. message: '请填写账号',
  63. trigger: ['blur', 'change']
  64. },
  65. password: {
  66. type: 'string',
  67. required: true,
  68. message: '请填写密码',
  69. trigger: ['blur', 'change']
  70. },
  71. },
  72. inputCustomStyle:{
  73. height:'98rpx',
  74. 'border-color':'#eee',
  75. 'padding-left':'30rpx',
  76. 'box-sizing':'border-box',
  77. }
  78. };
  79. },
  80. onLoad() {
  81. // 测试环境填充用户名密码
  82. if(process.env.NODE_ENV=='development'){
  83. this.form.account = 'dls1234';
  84. this.form.password = '654321';
  85. }
  86. let that = this;
  87. uni.getSystemInfo({
  88. success: (res) => {
  89. this.screenHeight = res.windowHeight + "px"
  90. }
  91. });
  92. uni.getStorage({
  93. key: 'backUrl',
  94. success: function (res) {
  95. console.log('getStorage',res);
  96. },
  97. complete(res) {
  98. if(res.data){
  99. that.backUrl = '/'+res.data;
  100. }else{
  101. that.backUrl = '/pages/index/index';
  102. }
  103. console.log('backUrl',that.backUrl);
  104. }
  105. });
  106. },
  107. onReady() {
  108. //onReady 为uni-app支持的生命周期之一
  109. this.$refs.uForm.setRules(this.rules)
  110. },
  111. onShow() {
  112. },
  113. methods: {
  114. submit(){
  115. console.log('form',this.form);
  116. this.$refs.uForm.validate().then(res => {
  117. // uni.$u.toast('校验通过')
  118. this.$u.api.login(this.form).then(res=>{
  119. // console.log('res',res.data);
  120. this.$u.vuex('vuex_user_info', res.data);
  121. uni.reLaunch({url: this.backUrl});
  122. }).catch(err=>{
  123. console.log('login',err);
  124. })
  125. }).catch(errors => {
  126. uni.$u.toast('请正确填写表单')
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .body {
  134. background-color: #fff;
  135. box-sizing: border-box;
  136. }
  137. .header{
  138. position: relative;
  139. height: 368rpx;
  140. overflow: hidden;
  141. background: linear-gradient(325deg, #FCFFFD 0%, #ECFFF4 100%);
  142. .circle{
  143. position: absolute;
  144. border-radius: 50%;
  145. &.circle1{
  146. width: 201rpx;
  147. height: 149rpx;
  148. background: linear-gradient(230deg, #E5FFEC 0%, #C0FFD7 100%);
  149. left:-20rpx;
  150. bottom: -50rpx;
  151. }
  152. &.circle2{
  153. width: 148rpx;
  154. height: 148rpx;
  155. background: linear-gradient(215deg, #E7FFEE 0%, #BFFFDB 100%);
  156. opacity: 0.6;
  157. right:158rpx;
  158. top: 80rpx;
  159. }
  160. &.circle3{
  161. width: 232rpx;
  162. height: 237rpx;
  163. background: linear-gradient(215deg, #F1FFF8 0%, #C3FFD3 100%);
  164. right:-32rpx;
  165. top: -65rpx;
  166. }
  167. }
  168. .text{
  169. position: absolute;
  170. left: 40rpx;
  171. bottom: 80rpx;
  172. .en-text{
  173. position: relative;
  174. text-transform: uppercase;
  175. font-size: 58rpx;
  176. font-family: AlibabaPuHuiTi_2_115_Black;
  177. color: #333333;
  178. line-height: 81rpx;
  179. font-weight: bold;
  180. width: fit-content;
  181. z-index: 5;
  182. &::before{
  183. content: '';
  184. display: block;
  185. width: 104%;
  186. height: 10rpx;
  187. background-color: #FFB100;
  188. position: absolute;
  189. left: -2%;
  190. bottom: 10rpx;
  191. z-index: -1;
  192. }
  193. }
  194. .cn-text{
  195. font-size: 50rpx;
  196. font-family: PingFangSC-Regular, PingFang SC;
  197. font-weight: 400;
  198. color: #333333;
  199. line-height: 70rpx;
  200. }
  201. }
  202. }
  203. .login-box{
  204. position: relative;
  205. top: -24rpx;
  206. padding: 60rpx 40rpx;
  207. border-top-left-radius: 24rpx;
  208. border-top-right-radius: 24rpx;
  209. background-color: #fff;
  210. // box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(0,28,12,0.06);
  211. }
  212. .tip{
  213. position: fixed;
  214. bottom: 108rpx;
  215. width: 100vw;
  216. box-sizing: border-box;
  217. text-align: center;
  218. font-size: 24rpx;
  219. font-weight: 400;
  220. color: #999999;
  221. }
  222. </style>