account-login.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view style="position: relative;">
  3. <view class="bg"></view>
  4. <view class="bg1"></view>
  5. <view class="content">
  6. <view class="top">
  7. <view class="logo">
  8. <image src="@/static/icon/logo.png" mode=""></image>
  9. </view>
  10. </view>
  11. <view style="width: 76%;margin-top: 30rpx;">
  12. <u-form :model="form" :error-type="['message']" ref="uForm">
  13. <u-form-item label-position="top" label="账号" prop="phone" label-width="150">
  14. <view style="border-bottom: 1rpx solid #DDDDDD;">
  15. <u-input :border="false" placeholder="请输入账号" v-model="form.phone" type="number"></u-input>
  16. </view>
  17. </u-form-item>
  18. <u-form-item label-position="top" label="密码" prop="password" label-width="150">
  19. <view style="border-bottom: 1rpx solid #DDDDDD;">
  20. <u-input :border="false" placeholder="请输入登录密码" type="password" v-model="form.password"></u-input>
  21. </view>
  22. </u-form-item>
  23. </u-form>
  24. <view class="text-right margin-top-10 text-sm">
  25. <text @click="$jump('/pages/login/forget')" style="text-decoration: underline;">忘记密码</text>
  26. <text @click="$jump('/pages/login/login')" style="margin-left: 20rpx;text-decoration: underline;">手机号快捷登录</text>
  27. </view>
  28. </view>
  29. <view style="width: 86%;margin-top: 120rpx;">
  30. <view @click="login" class="btn cu-btn round" style="width:100%;height: 90rpx;font-size: 36rpx;">
  31. 立即登录
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import md5Libs from "uview-ui/libs/function/md5";
  39. export default {
  40. data() {
  41. return {
  42. customStyle:{
  43. 'backgroundColor':'#d18c42',
  44. 'color':'#ffffff'
  45. },
  46. form:{
  47. phone:'',
  48. password:''
  49. },
  50. rules: {
  51. phone: [
  52. {
  53. required: true,
  54. message: '请输入账号',
  55. trigger: ['change','blur'],
  56. }
  57. ],
  58. password: [
  59. {
  60. required: true,
  61. message: '请输入密码',
  62. trigger: ['change','blur'],
  63. }
  64. ],
  65. }
  66. }
  67. },
  68. onReady() {
  69. this.$refs.uForm.setRules(this.rules);
  70. },
  71. onLoad() {
  72. if (this.$cache.get('phone')) {
  73. uni.reLaunch({
  74. url:"/pages/index/index"
  75. })
  76. }
  77. },
  78. methods: {
  79. login() {
  80. this.$refs.uForm.validate(valid => {
  81. if (valid) {
  82. this.$dialog.showLoading('登录中..')
  83. setTimeout(()=>{
  84. this.doLogin()
  85. },500)
  86. }
  87. });
  88. },
  89. async doLogin(){
  90. let params={
  91. type:1,
  92. phone:this.form.phone,
  93. password:md5Libs.md5(this.form.password)
  94. }
  95. try{
  96. let res=await this.$api.appaccount.login(params)
  97. this.$cache.put('phone',this.form.phone)
  98. uni.reLaunch({
  99. url:"/pages/index/index"
  100. })
  101. }catch(e){
  102. this.$u.toast('账号或者密码错误!')
  103. }finally{
  104. uni.hideLoading()
  105. }
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. $color:#d18c42;
  112. page{
  113. background-color: #FFFFFF;
  114. }
  115. .btn{
  116. background-color: $color;
  117. color:#FFFFFF;
  118. }
  119. .bg{
  120. z-index: 99;
  121. height: 440rpx;
  122. width: 440rpx;
  123. position: absolute;
  124. right: -240rpx;
  125. top: -240rpx;
  126. background-color: #d18c42;
  127. border-radius: 50%;
  128. box-shadow: 0rpx 0rpx 50rpx #c5803b;
  129. }
  130. .bg1{
  131. height: 500rpx;
  132. width: 500rpx;
  133. position: absolute;
  134. right: -240rpx;
  135. top: -240rpx;
  136. background-color: #d18c42;
  137. border-radius: 50%;
  138. box-shadow: #c6813b;
  139. }
  140. .content{
  141. height: 84vh;
  142. display: flex;
  143. flex-direction: column;
  144. justify-content: center;
  145. align-items: center;
  146. .top{
  147. display: flex;
  148. .logo{
  149. background-color: $color;
  150. width: 160rpx;
  151. height: 160rpx;
  152. border-radius: 40rpx;
  153. display: flex;
  154. justify-content: center;
  155. align-items: center;
  156. image{
  157. width: 100rpx;
  158. height: 100rpx;
  159. }
  160. }
  161. .title{
  162. margin-right: 20rpx;
  163. display: flex;
  164. flex-direction: column;
  165. text-align: left;
  166. text:first-child{
  167. font-size: 46rpx;
  168. color: #000;
  169. margin-bottom: 20rpx;
  170. }
  171. text:last-child{
  172. font-size: 28rpx;
  173. color: #7f7f7f;
  174. }
  175. }
  176. }
  177. }
  178. </style>