class.pwd.login.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import {service as dibootApi} from '@/utils/dibootApi.js'
  2. import Member from './class.member.js'
  3. export default class PwdLogin extends Member {
  4. constructor() {
  5. super()
  6. }
  7. /**
  8. * 登陆
  9. */
  10. go(form) {
  11. return new Promise(async (reslove, reject) => {
  12. try {
  13. uni.showLoading({title: '登陆中'})
  14. const res = await dibootApi.post('/system/login', {client:"TQ-HW-PC",...form})
  15. if(res.code === 0) {
  16. console.log('登录成功',res)
  17. uni.setStorageSync("authtoken", res.token)
  18. this.getMemberInfo()
  19. let tipMsg = { title: '登录成功', type: 'success' }
  20. this.$tip ? this.$tip.show(tipMsg) : uni.showToast(tipMsg)
  21. reslove({code: true})
  22. } else {
  23. this.$tip ? this.$tip.show({ title: res.msg, type: 'error', duration: '3000'}) : uni.showToast({ title: res.msg, icon: 'error'})
  24. }
  25. } catch(e) {
  26. console.log(e)
  27. this.$tip ? this.$tip.show({ title: e.errMsg, type: 'error', duration: '3000'}) : uni.showToast({ title: '网络异常', icon: 'error'})
  28. } finally {
  29. uni.hideLoading()
  30. }
  31. })
  32. }
  33. }