login.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view>
  3. <view class="box">
  4. <view class="top" style="margin-bottom: 50rpx;">
  5. <text class="title">登录</text>
  6. </view>
  7. <view class="item">
  8. <view class="l">手机号码:</view>
  9. <view class="r">
  10. <u-input v-model="form.key" placeholder="登录名"/>
  11. </view>
  12. </view>
  13. <view class="item">
  14. <view class="l">密码:</view>
  15. <view class="r">
  16. <u-input v-model="form.password" placeholder="输入密码" type="password"/>
  17. </view>
  18. </view>
  19. <!-- <view class="item">
  20. <view class="l">验证码:</view>
  21. <view class="r">
  22. <u-input placeholder="输入验证码"/>
  23. <view class="btn">发送</view>
  24. </view>
  25. </view> -->
  26. </view>
  27. <view class="common-btn" @click="loginFn">确认登录</view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. form:{
  35. key:'',
  36. password:''
  37. }
  38. }
  39. },
  40. methods: {
  41. loginFn(){
  42. if(!this.form.key){
  43. this.$common.toast('请输入登录名');
  44. return;
  45. }
  46. if(!this.form.password){
  47. this.$common.toast('请输入密码');
  48. return;
  49. }
  50. this.$api.doLogin(this.form).then(resp=>{
  51. let data=resp.data;
  52. if(data.tokenInfo){
  53. uni.setStorageSync('token',data.tokenInfo.tokenValue);
  54. uni.setStorageSync('customerId',data.admin.customerId)
  55. uni.setStorageSync('info',data.admin)
  56. this.$common.to('/pages/index/index')
  57. }else{
  58. this.$common.toast('登录失败');
  59. }
  60. })
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. page{
  67. background-color: #fff;
  68. }
  69. @import '@/common/common.scss'
  70. </style>