实现用户登录成功后,回跳到我们上次浏览的页面, 类似于(当我们没有登录就浏览购物页,点击付款后会提示我们没有登录,给我们返回到登录页,登录成功后会回跳到付款页)

需求:
1.我们登录成功后,回跳到上一次浏览的页面
类似于淘宝、京东的访客模式
需求
第一种解决方案

思路分析: 我们会发现响应的数据会经过响应拦截器,发现通过window.location.hash=hash这个语句可以来调整地址栏的地址,状态码403/401拦截后,利用window.location.href将页面重定向到指定的路由地址(登录页),登录成功后,获取传递过来的url 参数,最后进行回跳(京东、淘宝、苏宁都是这种方式进行回跳)

实现过程

1.在拦截器里跳转传递url参数到登录页

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
   
    // 对响应数据做点什么
    if(response.data.statusCode == 401 || response.data.statusCode == 403){
   
        Toast.fail(response.data.message)
        console.log(window.location.hash);    //  #/articleDetail/12
        window.location.href = '#/login?returnurl=' + window.location.hash.<
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,下面是一个简单的下单付款页面的 HTML 和 CSS 代码: HTML 代码: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>下单付款页面</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>订单详情</h1> <form> <label for="name">姓名:</label> <input type="text" id="name" name="name" required> <label for="email">邮箱:</label> <input type="email" id="email" name="email" required> <label for="address">地址:</label> <textarea id="address" name="address" required></textarea> <label for="card">信用卡号:</label> <input type="text" id="card" name="card" required> <label for="date">过期日期:</label> <input type="month" id="date" name="date" required> <button type="submit">确认支付</button> </form> </div> </body> </html> ``` CSS 代码: ``` * { box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #f2f2f2; } .container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 0 10px #ccc; } h1 { text-align: center; } form { display: flex; flex-direction: column; } label { margin-top: 10px; font-weight: bold; } input[type="text"], input[type="email"], input[type="month"], textarea { padding: 10px; border: none; border-radius: 5px; margin-bottom: 20px; box-shadow: 0 0 10px #ccc; } button { padding: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #3e8e41; } ``` 你可以将这些代码复制到你的 HTML 和 CSS 文件中,并根据需要进行修改。这个页面包含了姓名、邮箱、地址、信用卡号和过期日期等信息,并有一个确认支付的按钮。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值