js输入银行卡号,自动查询银行名称、银行卡类型

8 篇文章 0 订阅

功能1:获取银行名称、银行卡类型
方法1:插件引用(下面代码)

https://github.com/navyxie/bankcardinfo#getBankBin

方法2:阿里云的,具体正在研究中~~~

https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?cardNo=6228481728824558471&cardBinCheck=true 

带logo的引用:
https://github.com/digglife/cnbankcard

uniapp使用步骤:
1.npm install bankcardinfo
2.html和js,这里输入银行卡号,获取用户名称;采用失去焦点,调用cardInput方法

html:
<view class="cardnum">
	<input type="number" v-model="cardNum" @blur="cardInput" class="fs28" placeholder-class="detailAddress" placeholder="银行卡号" />
</view>
js:
cardInput(e){
	//方法1:callback 方式调用,见插件
	var BIN = require('bankcardinfo');
	let cardNo = e.target.value
	//方法2:promise 方式调用, 2.0.0 及以上版本支持,未抛出封装的js文件报错提示
	BIN.getBankBin(cardNo).then(res => {
		console.log(res,'插件请求-----------')
		this.bankName= res.bankName
	}).catch(res=> {
		uni.showToast({title:'未查询到此银行卡号',duration: 2000, icon: 'none'	});
	})
},

功能2:获取银行logo图片功能:

此功能也是用的阿里云的接口,但是放到项目中会报跨域,用能jsonp解决了跨域,又报其他错误(because its MIME type ('image/png') is not executable),暂时没有解决,由于自己项目,有空研究吧。
获取银行logo接口:

https://apimg.alipay.com/combo.png?d=cashier&t=*银行代码*

具体引用下方gitcode链接:

https://gitcode.net/mirrors/digglife/cnbankcard?utm_source=csdn_github_accelerator
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值