import { getModule, Mutation, Module, VuexModule } from 'vuex-module-decorators';
//import request from '@/utils/request';
import store from '@/store';
//import { User } from '@/store/modules/session';
//import { url } from '@/utils/url';

// export interface UserInfo {
//   version:string;
// }

@Module({
  dynamic: true,
  store,
  namespaced: true,
  name: 'auth',
})
class AuthService extends VuexModule {
  version = '';
  get getVersion(): string {
    return this.version;
  }
  @Mutation
  setVersion(version: string) {
    this.version = version;
  }
  // @Action
  // async getUserInfo({ loginName }: { loginName: User['loginName'] }): Promise<UserInfo> {
  //   const r: any = await request.post(url.auth.userInfo, {
  //     loginName,
  //   });
  //   if (r.code !== '1') {
  //     throw new Error(r.msg);
  //   } else {
  //     return r.list[0];
  //   }
  //}
  // @Action
  // async checkPassword({ rfPwd, loginName }: { rfPwd: string; loginName: User['loginName'] }) {
  //   const r: any = await request.post(url.auth.pwd.check, {
  //     rfPwd,
  //     loginName,
  //   });
  //   if (r.code !== '1') {
  //     throw new Error(r.msg);
  //   } else {
  //     return r;
  //   }
  // }
}

export const auth = getModule(AuthService);
