login.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. this.$common.to('/pages/index/index')
  55. }else{
  56. this.$common.toast('登录失败');
  57. }
  58. })
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. page{
  65. background-color: #fff;
  66. }
  67. @import '@/common/common.scss'
  68. </style>