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

最近开发了一个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。

相关推荐
程序员鱼皮2 分钟前
Stack Overflow,彻底凉了!
前端·后端·计算机·程序员·互联网
Nicholas6813 分钟前
Flutter动画框架之AnimationController源码解析(二)
前端
鹏程十八少24 分钟前
2. Android 第三方框架 okhttp责任链模式的源码分析 深度解读二
前端
贵州数擎科技有限公司26 分钟前
LangChain 快速构建你的第一个 LLM 应用
前端·后端
ze_juejin33 分钟前
Mongoose 与 MongoDB 数据库教程
前端
FogLetter34 分钟前
深入理解React的useLayoutEffect:解决UI"闪烁"问题的利器
前端·react.js
冰糖雪梨dd36 分钟前
h() 函数
前端·javascript·vue.js
每天都想睡觉的190036 分钟前
在Vue、React 和 UniApp 中实现版本比对及更新提示
前端·vue.js·react.js
拾光拾趣录37 分钟前
ESLint:从代码扫描到自动修复
前端·eslint
银之夏雪丶39 分钟前
this你了解多少呢
前端·javascript·面试