每天一个知识点: 判断浏览器类型

最近开发了一个h5,比如微信扫码二维码,就跳转到这个h5上面,对应的支付也会调用微信支付;如果是支付宝扫描二维码,也是跳转到这个h5上面,对应的支付就会调用支付宝支付。技术用的Vue3 + Vant4。

如何判断该浏览器是微信还是支付宝

javascript 复制代码
const getNavigatorType = () => {
  let ua = window.navigator.userAgent.toLowerCase();
  if (ua.match(/MicroMessenger/i) == "micromessenger") {
    //判断微信
    return 'WECHAT';
  } else if (ua.match(/AlipayClient/i) == "alipayclient") {
    //支付宝
    return 'ALIPAY';	  
  } else {	 
    return 'other';
  }
}

根据浏览器的类型,调用支付接口,传对应的类型参数,和账单金额就可以了。

如何实现顶部底部固定,中间订单内容滑动

项目就两个页面,其中一个是待支付订单列表。待支付订单列表用的弹出层来做,这里如果订单项目太多,会出现滚动条,滚动条滑动的的时候,想要的效果是整个弹出成充满页面,向下滑动的时候顶部的标题和底部的支付栏不动,只有中间的订单会滑动。

xml 复制代码
<van-popup :show="true" position="right" style="width: 100%; height:100%; overflow: hidden;" >
    <van-nav-bar 
        title="待支付订单" 
        fixed 
        left-arrow 
        @click-left="$emit('closepopup')">
    </van-nav-bar>
    <div class="container" style="margin-top: 46px;">
        <div class="content">
            <OrderCard :orderList="orderList"> </OrderCard>
        </div>
    </div>
   
    <van-submit-bar
      button-color="#169bd5"
      :price="totalAmount"
      button-text="立即支付"
      tip-icon="info-o"
      @submit="$emit('onSubmit', totalAmount)"
    >
    </van-submit-bar>
</van-popup>

<style scoped lang="less">
 .container {
  overflow: hidden;
  position: relative;
  padding: 8px 12px 0;
  height: 100vh;
  padding-bottom: 100px;
  background-color: rgb(242, 242, 242);
  .content {
    height: calc(100vh - 52px);
    overflow-y: scroll;
    padding-bottom: 50px;
  }
 }
</style>

弹出层加一个overfolow:hidden;用一个容器container把内容包裹住,container设置overflow:hidden; position: relative; 订单内容部分content,设置overflow-y:scroll。

相关推荐
JeffongTan1 天前
在LWC中镶嵌VF Page获取用户IP
前端·javascript·salesforce
陆枫Larry1 天前
Astro 是什么
前端
是立不是利1 天前
写给设计师的 CSS 博客美学指南
前端·css
默_笙1 天前
🏝 Docker 就是"房地产开发":从施工图纸到小区物业的容器化指南
前端·javascript
计算机魔术师1 天前
Rohan Paul 谈用时间跨度衡量智能体能力,并引用 OpenAI 自动化研究实习生里程碑
前端
kyriewen1 天前
我手写了个极简版 React Router——才搞懂 v6 为什么砍了这么多 API
前端·javascript·程序员
a1117761 天前
Shirone 二次元博客主题 开源
前端·开源
IT_陈寒1 天前
Python的切片赋值把我坑惨了,这不是bug是特性
前端·人工智能·后端
掘金酱1 天前
【社区公告】致每一位掘友:关于这次调整, 想再说几句
前端·人工智能
CoderLiu1 天前
程序化工具调用(PTC)与动态工作流引擎:深入大模型工具调用的架构演进与实践
前端·人工智能·后端