方法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){
var BIN = require('bankcardinfo');
let cardNo = e.target.value
BIN.getBankBin(cardNo).then(res => {
console.log(res,'插件请求-----------')
this.bankName= res.bankName
}).catch(res=> {
uni.showToast({title:'未查询到此银行卡号',duration: 2000, icon: 'none' });
})
},
|