| | |
| | | |
| | | class LoginService { |
| | | /** 顧客登入-發送OTP **/ |
| | | async sendOtp(loginInfo: LoginRequest, verifyCode: string):Promise<OtpInfo> { |
| | | return http.post(`/otp/sendOtp/${verifyCode}`, loginInfo).then( res => res.data ); |
| | | } |
| | | async sendOtp(loginInfo: LoginRequest, verifyCode: string): Promise<OtpInfo> { |
| | | try { |
| | | const response = await http.post(`/otp/sendOtp/${verifyCode}`, loginInfo); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while sending OTP:', error); |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 顧客登入-驗證OTP |
| | |
| | | } |
| | | |
| | | /** 顧客註冊 **/ |
| | | async register(registerInfo: RegisterInfo):Promise<LoginSuccessToken>{ |
| | | return http.post('/otp/register', registerInfo).then(res => res.data); |
| | | async register(registerInfo: RegisterInfo): Promise<LoginSuccessToken> { |
| | | try { |
| | | const response = await http.post('/otp/register', registerInfo); |
| | | if (response !== null) { |
| | | return response.data; |
| | | } else { |
| | | throw new Error('http.post returned null-like value.'); |
| | | } |
| | | } catch (error) { |
| | | console.error('An error occurred while registering:', error); |
| | | // 可以在此處處理錯誤或回傳預設值 |
| | | throw error; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** 取得驗證碼圖片 **/ |
| | | async getImgOfVerification():Promise<string>{ |
| | | return http.get('/login/validate/get_img_code',{ responseType : 'arraybuffer' }) |