|
@@ -118,38 +118,40 @@ export class TalentMiniPage {
|
|
|
* 填写身份标识(手机号/身份证号/残疾证号)
|
|
* 填写身份标识(手机号/身份证号/残疾证号)
|
|
|
* @param identifier 身份标识(11位手机号或身份证号或残疾证号)
|
|
* @param identifier 身份标识(11位手机号或身份证号或残疾证号)
|
|
|
*
|
|
*
|
|
|
- * 注意:使用 focus + type 方法触发自然的用户输入事件
|
|
|
|
|
|
|
+ * 注意:使用 click + type 方法触发自然的用户输入事件
|
|
|
* Taro Input 组件需要完整的事件流才能正确更新 react-hook-form 状态
|
|
* Taro Input 组件需要完整的事件流才能正确更新 react-hook-form 状态
|
|
|
*/
|
|
*/
|
|
|
async fillIdentifier(identifier: string): Promise<void> {
|
|
async fillIdentifier(identifier: string): Promise<void> {
|
|
|
// 先移除覆盖层,确保输入可操作
|
|
// 先移除覆盖层,确保输入可操作
|
|
|
await this.removeDevOverlays();
|
|
await this.removeDevOverlays();
|
|
|
- // 先清空输入框
|
|
|
|
|
- await this.identifierInput.evaluate((el: HTMLInputElement | { value: string }) => {
|
|
|
|
|
- el.value = '';
|
|
|
|
|
- });
|
|
|
|
|
- // 使用 focus + type 方法,触发自然的键盘输入事件
|
|
|
|
|
- await this.identifierInput.focus();
|
|
|
|
|
- await this.identifierInput.type(identifier, { delay: 10 });
|
|
|
|
|
|
|
+ // 点击聚焦,然后清空(使用 type 方法自动覆盖现有内容)
|
|
|
|
|
+ await this.identifierInput.click();
|
|
|
|
|
+ // 等待元素聚焦
|
|
|
|
|
+ await this.page.waitForTimeout(100);
|
|
|
|
|
+ // 使用 type 方法输入,会自动覆盖现有内容
|
|
|
|
|
+ await this.identifierInput.type(identifier, { delay: 50 });
|
|
|
|
|
+ // 等待表单验证更新
|
|
|
|
|
+ await this.page.waitForTimeout(200);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 填写密码
|
|
* 填写密码
|
|
|
* @param password 密码(6-20位)
|
|
* @param password 密码(6-20位)
|
|
|
*
|
|
*
|
|
|
- * 注意:使用 focus + type 方法触发自然的用户输入事件
|
|
|
|
|
|
|
+ * 注意:使用 click + type 方法触发自然的用户输入事件
|
|
|
* Taro Input 组件需要完整的事件流才能正确更新 react-hook-form 状态
|
|
* Taro Input 组件需要完整的事件流才能正确更新 react-hook-form 状态
|
|
|
*/
|
|
*/
|
|
|
async fillPassword(password: string): Promise<void> {
|
|
async fillPassword(password: string): Promise<void> {
|
|
|
// 先移除覆盖层,确保输入可操作
|
|
// 先移除覆盖层,确保输入可操作
|
|
|
await this.removeDevOverlays();
|
|
await this.removeDevOverlays();
|
|
|
- // 先清空输入框
|
|
|
|
|
- await this.passwordInput.evaluate((el: HTMLInputElement | { value: string }) => {
|
|
|
|
|
- el.value = '';
|
|
|
|
|
- });
|
|
|
|
|
- // 使用 focus + type 方法,触发自然的键盘输入事件
|
|
|
|
|
- await this.passwordInput.focus();
|
|
|
|
|
- await this.passwordInput.type(password, { delay: 10 });
|
|
|
|
|
|
|
+ // 点击聚焦
|
|
|
|
|
+ await this.passwordInput.click();
|
|
|
|
|
+ // 等待元素聚焦
|
|
|
|
|
+ await this.page.waitForTimeout(100);
|
|
|
|
|
+ // 使用 type 方法输入
|
|
|
|
|
+ await this.passwordInput.type(password, { delay: 50 });
|
|
|
|
|
+ // 等待表单验证更新
|
|
|
|
|
+ await this.page.waitForTimeout(200);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -289,17 +291,17 @@ export class TalentMiniPage {
|
|
|
* 清除所有认证相关的存储
|
|
* 清除所有认证相关的存储
|
|
|
*/
|
|
*/
|
|
|
async clearAuth(): Promise<void> {
|
|
async clearAuth(): Promise<void> {
|
|
|
- await this.page.evaluate(() => {
|
|
|
|
|
|
|
+ await this.page.evaluate((userKey) => {
|
|
|
// 清除人才小程序相关的认证数据
|
|
// 清除人才小程序相关的认证数据
|
|
|
localStorage.removeItem('talent_token');
|
|
localStorage.removeItem('talent_token');
|
|
|
- localStorage.removeItem(USER_KEY);
|
|
|
|
|
|
|
+ localStorage.removeItem(userKey);
|
|
|
|
|
|
|
|
// 清除其他常见 token 键
|
|
// 清除其他常见 token 键
|
|
|
localStorage.removeItem('token');
|
|
localStorage.removeItem('token');
|
|
|
localStorage.removeItem('auth_token');
|
|
localStorage.removeItem('auth_token');
|
|
|
sessionStorage.removeItem('token');
|
|
sessionStorage.removeItem('token');
|
|
|
sessionStorage.removeItem('auth_token');
|
|
sessionStorage.removeItem('auth_token');
|
|
|
- });
|
|
|
|
|
|
|
+ }, USER_KEY);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|