account-login.vue 3.9 KB

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