bindCard.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view>
  3. <view class="step ddflex">
  4. <view :class="'li' + (stepOne ? ' ing' : '') + (stepOneComplete ? ' end' : '')">
  5. <view class="num">1</view>
  6. <image src="../../static/promote/images/gou_h.png" class="s-gou"></image>
  7. <text>验证身份信息</text>
  8. </view>
  9. <view :class="'li' + (stepTwo ? ' ing' : '') + (stepTwoComplete ? ' end' : '')">
  10. <view class="num">2</view>
  11. <image src="../../static/promote/images/gou_h.png" class="s-gou"></image>
  12. <text>验证银行卡信息</text>
  13. </view>
  14. </view>
  15. <block v-if="stepOne">
  16. <view class="form">
  17. <view class="li cards">
  18. <label class="label">身份证信息</label>
  19. <view class="card ddflex">
  20. <view class="linsence" @click="uploadImgs(1)">
  21. <image :src="fileInfo.legalPersonidPositivePic ? fileInfo.legalPersonidPositivePic : picUrlss + 'card_front.png'"></image>
  22. <view>身份证人像面</view>
  23. </view>
  24. <view class="linsence" @click="uploadImgs(2)">
  25. <image :src="fileInfo.egalPersonidOppositePic ? fileInfo.egalPersonidOppositePic : picUrlss + 'card_back.png'"></image>
  26. <view>身份证国徽面</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="li ddflex">
  31. <label class="label">姓名</label>
  32. <view class="item fflex"><input v-model="rName" placeholder="上传身份证人像面自动获取" placeholder-class="placeholder" class="ipt" /></view>
  33. </view>
  34. <view class="li ddflex">
  35. <label class="label">身份证号</label>
  36. <view class="item fflex"><input v-model="rCode" placeholder="上传身份证人像面自动获取" placeholder-class="placeholder" class="ipt" /></view>
  37. </view>
  38. <view class="li ddflex">
  39. <label class="label">有效期限</label>
  40. <view class="item ddflex fflex">
  41. <input v-model="rValidDate" placeholder="上传身份证国徽面自动获取" placeholder-class="placeholder" class="ipt fflex" />
  42. <!-- <view class="chang ddflex">
  43. <image src="../../static/promote/images/gou1.png"></image>
  44. 长期
  45. </view> -->
  46. </view>
  47. </view>
  48. <view class="li dflex">
  49. <label class="label">所在城市</label>
  50. <view class="item dflex flex">
  51. <input :disabled="true" v-model="address" placeholder="点击右侧图标获取" placeholder-class="placeholder" class="ipt flex" />
  52. <image src="../../static/promote/images/dzico.png" class="location" @click="chooseLocation()"></image>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="next" @click="toStepTwo">下一步</view>
  57. </block>
  58. <block v-if="stepTwo">
  59. <view class="form">
  60. <view class="li cards">
  61. <label class="label">银行卡</label>
  62. <view class="linsence" @click="uploadImgs(3)">
  63. <image :src="bankUrl ? bankUrl : picUrlss + 'card.png'"></image>
  64. <view>上传储蓄银行卡正面照</view>
  65. </view>
  66. </view>
  67. <view class="li dflex">
  68. <label class="label">户名</label>
  69. <view class="item flex"><input :disabled="true" v-model="rName" placeholder="请输入户主名称" placeholder-class="placeholder" class="ipt" /></view>
  70. </view>
  71. <view class="li ddflex">
  72. <label class="label">开户银行</label>
  73. <view class="item fflex">
  74. <picker :class="'pickers ' + (bankName ? 'active' : '')" @change="bindPickerBank" range-key="name" :range="bankList">
  75. <view v-if="bankName" class="ipt">{{ bankName }}</view>
  76. <view v-else class="ipt_g">请选择开户银行</view>
  77. <image src="../../../static/pages/images/crico1.png" class="rico"></image>
  78. </picker>
  79. </view>
  80. </view>
  81. <view class="li ddflex">
  82. <label class="label">银行卡号</label>
  83. <view class="item fflex"><input v-model="bankNo" placeholder="上传后自动获取" placeholder-class="placeholder" class="ipt" /></view>
  84. </view>
  85. <view class="li flexs dflex">
  86. <label class="label">预留手机</label>
  87. <view class="item flex">
  88. <input type="number" v-model="bankAcctPhone" maxlength="11" placeholder="请输入银行预留手机号" placeholder-class="placeholder" class="ipt" />
  89. </view>
  90. </view>
  91. </view>
  92. <view class="next" @click="submit()">确定绑卡</view>
  93. </block>
  94. </view>
  95. </template>
  96. <script>
  97. const app = getApp();
  98. // const util = require('../../../utils/util.js');
  99. const req = require('../../../utils/request.js');
  100. const hfParams = require('../../../utils/hfParams.js');
  101. var QQMapWX = require('../../../utils/qqmap.js');
  102. export default {
  103. data() {
  104. return {
  105. picUrlss: req.public.picUrls,
  106. isEdit: false,
  107. stepOne: true,
  108. stepOneComplete: false,
  109. stepTwo: false,
  110. stepTwoComplete: false,
  111. fileInfo: {
  112. legalPersonidPositivePic: '', //正面
  113. egalPersonidOppositePic: '' //反面
  114. },
  115. //身份信息
  116. rName: '',
  117. rCode: '',
  118. rValidDate: '',
  119. location: '',
  120. addIds: '',
  121. address: '', //区域
  122. addressDetails: '',
  123. cityList: [],
  124. bankList: [],
  125. bankUrl: '', //银行卡图片
  126. bankPosition: -1, //下标
  127. bankName: '', //银行名字
  128. bankAcctName: '', //户名
  129. bankNo: '', //卡号
  130. bankAcctPhone: '',
  131. settlementInfo: '',
  132. isEnd: false //是否为查看编辑
  133. };
  134. },
  135. onLoad(opt) {
  136. this.cityList = hfParams.mArea();
  137. this.bankList = hfParams.bank();
  138. if (opt.isEnd) {
  139. this.isEnd = opt.isEnd;
  140. //默认选中上面的标签
  141. let pages = getCurrentPages(); //获取所有页面栈实例列表
  142. let prevPage = pages[pages.length - 2]; //上一页页面实例
  143. this.settlementInfo = prevPage.$vm.settlementInfo;
  144. if (this.settlementInfo) {
  145. this.addIds = this.settlementInfo.provCode + ',' + this.settlementInfo.areaCode;
  146. this.address = this.settlementInfo.address;
  147. this.rName = this.settlementInfo.cardName;
  148. this.bankName = this.getBankName(this.settlementInfo.bankCode);
  149. this.bankAcctName = this.settlementInfo.cardName;
  150. this.bankUrl = this.settlementInfo.bankUrl;
  151. this.bankNo = this.settlementInfo.cardNo.replace(' ','');
  152. this.fileInfo = JSON.parse(this.settlementInfo.fileJson);
  153. this.rCode = this.settlementInfo.legalCertId;
  154. this.rValidDate = this.settlementInfo.legalCertIdExpires;
  155. this.bankAcctPhone = this.settlementInfo.legalMp;
  156. }
  157. }
  158. },
  159. methods: {
  160. getBankName(code) {
  161. for (var i = 0; i < this.bankList.length; i++) {
  162. var bankObj = this.bankList[i];
  163. if (bankObj.code == code) {
  164. this.bankPosition = i;
  165. return bankObj.name;
  166. }
  167. }
  168. },
  169. toStepTwo() {
  170. if (!this.fileInfo.legalPersonidPositivePic) {
  171. req.msg('请上传身份证人像面');
  172. return;
  173. }
  174. if (!this.fileInfo.egalPersonidOppositePic) {
  175. req.msg('请上传身份证国徽面');
  176. return;
  177. }
  178. if (!this.rName) {
  179. req.msg('姓名不能为空');
  180. return;
  181. }
  182. if (!this.rCode) {
  183. req.msg('身份证号不能为空');
  184. return;
  185. }
  186. if (!this.rValidDate) {
  187. req.msg('身份证有效期不能为空');
  188. return;
  189. }
  190. if (!this.addIds) {
  191. req.msg('请选择所在地区');
  192. return;
  193. }
  194. this.stepOne = false;
  195. this.stepOneComplete = true;
  196. this.stepTwo = true;
  197. },
  198. uploadImgs(type) {
  199. // if (!this.isEdit) {
  200. // return;
  201. // }
  202. let that = this;
  203. uni.chooseImage({
  204. count: 1,
  205. sizeType: ['original', 'compressed'],
  206. sourceType: ['album', 'camera'],
  207. success(res) {
  208. uni.showLoading({
  209. title: '上传中'
  210. });
  211. req.uploadFile('/api/nocheck/upload', res.tempFilePaths[0], res => {
  212. uni.hideLoading();
  213. if (type == 1) {
  214. //正面
  215. that.fileInfo.legalPersonidPositivePic = res.src;
  216. that.ocrCard(res.src, 1);
  217. } else if (type == 2) {
  218. //反面
  219. that.fileInfo.egalPersonidOppositePic = res.src;
  220. that.ocrCard(res.src, 2);
  221. } else if (type == 3) {
  222. that.bankUrl = res.src;
  223. uni.showLoading({
  224. title: '识别中'
  225. });
  226. req.getRequest('/baiduAI/bank', { imgUrl: res.src }, json => {
  227. uni.hideLoading();
  228. if (json.result) {
  229. that.bankNo = json.result.bank_card_number;
  230. that.initCheckBank(json.result.bank_name);
  231. }
  232. });
  233. }
  234. });
  235. }
  236. });
  237. },
  238. ocrCard(imgUrl, type) {
  239. uni.showLoading({
  240. title: '识别中'
  241. });
  242. //front back
  243. var idCardDide = type == 1 ? 'front' : 'back';
  244. req.getRequest('/baiduAI/ocrIdcard', { imgUrl: imgUrl, idCardDide: idCardDide }, json => {
  245. uni.hideLoading();
  246. if (type == 1) {
  247. this.rName = json.words_result.姓名.words;
  248. this.rCode = json.words_result.公民身份号码.words;
  249. } else if (type == 2) {
  250. var dataStr = json.words_result.失效日期.words;
  251. if (dataStr === '长期') {
  252. this.rValidDate = '2099-12-31';
  253. } else {
  254. var y = dataStr.slice(0, 4);
  255. var m = dataStr.slice(4, 6);
  256. var d = dataStr.slice(6, 8);
  257. this.rValidDate = y + '-' + m + '-' + d;
  258. }
  259. }
  260. });
  261. },
  262. initCheckBank(name) {
  263. for (var i = 0; i < this.bankList.length; i++) {
  264. var bankObj = this.bankList[i];
  265. if (bankObj.name == name) {
  266. this.bankPosition = i;
  267. this.bankName = name;
  268. }
  269. }
  270. },
  271. chooseLocation() {
  272. var tha = this;
  273. uni.chooseLocation({
  274. success: res => {
  275. if (res.name) {
  276. tha.location = res;
  277. tha.addressDetails = res.address;
  278. tha.reverseGeocoder(res);
  279. }
  280. },
  281. fail: () => {
  282. uni.getSetting({
  283. success: function(res) {
  284. var statu = res.authSetting;
  285. console.log(statu);
  286. if (!statu['scope.userLocation']) {
  287. console.log(123);
  288. uni.showModal({
  289. title: '是否授权当前位置',
  290. content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
  291. success(tip) {
  292. if (tip.confirm) {
  293. uni.openSetting({
  294. success: function(data) {
  295. if (data.authSetting['scope.userLocation'] === true) {
  296. //授权成功之后,再调用chooseLocation选择地方
  297. setTimeout(function() {
  298. uni.chooseLocation({
  299. success: res => {
  300. if (res.name) {
  301. tha.location = res;
  302. tha.addressDetails = res.address;
  303. console.log('地址数据addressDetail》》》:', tha.addressDetails);
  304. tha.reverseGeocoder(res);
  305. }
  306. }
  307. });
  308. }, 1000);
  309. }
  310. }
  311. });
  312. }
  313. }
  314. });
  315. }
  316. }
  317. });
  318. }
  319. });
  320. },
  321. reverseGeocoder(location) {
  322. QQMapWX.initMap();
  323. QQMapWX.reverseGeocoder(location, data => {
  324. this.address = data.ad_info.province + ' ' + data.ad_info.city; //+ ' ' + data.ad_info.district
  325. for (var i = 0; i < this.cityList.length; i++) {
  326. var cityObj = this.cityList[i];
  327. if (data.ad_info.province.indexOf(cityObj.label) != -1) {
  328. for (var k = 0; k < cityObj.children.length; k++) {
  329. var areaObj = cityObj.children[k];
  330. if(data.ad_info.city == '襄阳市') data.ad_info.city = '襄樊市';
  331. if(data.ad_info.city == '普洱市') data.ad_info.city = '思茅市';
  332. if (data.ad_info.city.indexOf(areaObj.label) != -1) {
  333. this.addIds = cityObj.value + ',' + areaObj.value;
  334. }
  335. }
  336. }
  337. }
  338. console.log('解析后的地址地址数据:', this.address + '》》》' + this.addIds);
  339. });
  340. },
  341. bindPickerBank(event) {
  342. this.bankPosition = event.detail.value;
  343. this.bankName = this.bankList[this.bankPosition].name;
  344. },
  345. submit() {
  346. if (!this.bankUrl) {
  347. req.msg('请上传银行卡正面照');
  348. return;
  349. }
  350. if (!this.bankName) {
  351. req.msg('请选择开户银行');
  352. return;
  353. }
  354. if (!this.bankNo) {
  355. req.msg('请输入银行卡号');
  356. return;
  357. }
  358. if (!this.bankAcctPhone) {
  359. req.msg('请输入银行预留手机号');
  360. return;
  361. }
  362. var addIds = this.addIds.split(',');
  363. var params = {
  364. provCode: addIds[0],
  365. areaCode: addIds[1], //商户所在地区
  366. address: this.address,
  367. bankAcctType: 2,
  368. cardName: this.rName,
  369. bankCode: this.bankList[this.bankPosition].code,
  370. bankUrl: this.bankUrl,
  371. cardNo: this.bankNo.replace(' ',''),
  372. fileJson: JSON.stringify(this.fileInfo),
  373. haveLicenseNo: 2,
  374. legalCertName: this.rName,
  375. legalCertId: this.rCode,
  376. legalCertIdExpires: this.rValidDate,
  377. isOpen: 0,
  378. legalMp: this.bankAcctPhone
  379. };
  380. req.postRequest('/api/v3/settlement/create', params, json => {
  381. req.msg('添加成功');
  382. setTimeout(() => {
  383. uni.navigateBack();
  384. }, 1500);
  385. });
  386. }
  387. }
  388. };
  389. </script>
  390. <style>
  391. @import './bindCard.css';
  392. </style>