login.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="page">
  3. <uni-nav-bar :fixed="true" background-color="#FFE05C" :border="false" :statusBar="true" title="登录" />
  4. <view class="logTitle">
  5. <view class="welcome">
  6. <text>HI,您好!</text>
  7. </view>
  8. <view class="welcome">
  9. <text>欢迎登录技师端</text>
  10. </view>
  11. <view class="flex-row justify-center">
  12. <image src="../../static/logo.png" class="log"></image>
  13. </view>
  14. </view>
  15. <view class="form">
  16. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm">
  17. <view class="formItem">
  18. <u-form-item label="账号" prop="username" borderBottom ref="item1">
  19. <u--input v-model="form.username" border="none"></u--input>
  20. </u-form-item>
  21. </view>
  22. <view class="formItem">
  23. <u-form-item label="密码" prop="password" borderBottom ref="item1">
  24. <u--input v-model="form.password" border="none" type="password"></u--input>
  25. </u-form-item>
  26. </view>
  27. <view class="forgetPassword"><text>忘记密码?</text></view>
  28. <view class="loginButton" @click="login">
  29. <text>登录</text>
  30. </view>
  31. </u--form>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. form: {
  40. username: '',
  41. password: ''
  42. },
  43. rules: {
  44. 'username': {
  45. type: 'string',
  46. required: true,
  47. min: 11,
  48. max: 11,
  49. message: '请输入11位手机号',
  50. trigger: ['blur', 'change']
  51. },
  52. 'password': {
  53. type: 'string',
  54. required: true,
  55. min: 6,
  56. max: 18,
  57. message: '请输入6-18位密码',
  58. trigger: ['blur', 'change']
  59. }
  60. }
  61. }
  62. },
  63. methods: {
  64. login() {
  65. this.$refs.uForm.validate().then(res => {
  66. this.$api.login.techLogin(this.form).then(res => {
  67. uni.setStorageSync('accessToken', res.data.data.access_token)
  68. uni.removeStorageSync('storeId');
  69. uni.removeStorageSync('storeName');
  70. uni.switchTab({
  71. url: "/pages/index/index"
  72. })
  73. })
  74. })
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. @import './index.rpx.css';
  81. </style>