功能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