/** * 登录页 Page Object */ class LoginPage { constructor(miniProgram) { this.mp = miniProgram; } /** * 等待登录页渲染 */ async waitForReady() { const page = await this.mp.currentPage(); await page.waitFor(2000); console.log('登录页加载完成'); } /** * 点击微信授权登录按钮 */ async clickWechatLogin() { const page = await this.mp.currentPage(); const loginBtn = await page.$('.login-btn, button[open-type="getUserInfo"], .wechat-login'); if (loginBtn) { await loginBtn.tap(); console.log('点击微信授权登录'); } } /** * 获取当前页面路径 */ async getPath() { const page = await this.mp.currentPage(); return page.path; } /** * 检查是否在当前页面 */ async isCurrentPage() { const path = await this.getPath(); return path.includes('login'); } /** * 获取页面数据 */ async getPageData() { const page = await this.mp.currentPage(); return await page.data(); } } module.exports = { LoginPage };