diff --git a/pages/scanPay/scanPay.js b/pages/scanPay/scanPay.js index ff03d8e..be18dbf 100644 --- a/pages/scanPay/scanPay.js +++ b/pages/scanPay/scanPay.js @@ -12,20 +12,20 @@ Page({ focus: true, inputValue: '', cardList: [], - arrays:[], + arrays: [], showModel: false, - ids:"" + ids: "" }, /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { + onLoad: function(options) { let that = this; that.setData({ merChant: JSON.parse(options.merChant), cardid: options.cardid, - cardids:options.cardid, + cardids: options.cardid, remainingAmount: options.remainingAmount, remainingAmounts: options.remainingAmount, }) @@ -36,62 +36,76 @@ Page({ inputValue: e.detail.value }) }, - gotoPayMoney: function (flags) { + suretoPay: function(e) { let that = this; - const startSoterAuthentication = () => { - wx.startSoterAuthentication({ - requestAuthModes: [AUTH_MODE], - challenge: 'test', - authContent: '请验证已有的指纹以继续', - success: (res) => { - that.gotoPay() - }, - fail: (err) => { - wx.hideLoading(); - that.setData({ - showModel:false, - cardid: that.data.cardids, - ids:"", - remainingAmount: that.data.remainingAmounts - }) - } - }) - } - const checkIsEnrolled = () => { - wx.checkIsSoterEnrolledInDevice({ - checkAuthMode: AUTH_MODE, - success: (res) => { - console.log(res) - if (res.isEnrolled) { - startSoterAuthentication(); - }else{ - that.gotoPay(); - } - }, - fail: (err) => { - console.error(err) - } - }) - } - wx.checkIsSupportSoterAuthentication({ + if (e.currentTarget.dataset.sure == 'sure' && that.data.checked) { + wx.showLoading({ + title: '加载中...', + }) + that.gotoPayMoney(); + } else { + wx.showModal({ + title: '提醒', + content: '请选择消费卡', + showCancel: false + }) + } + }, + gotoPayMoney: function() { + let that = this; + const startSoterAuthentication = () => { + wx.startSoterAuthentication({ + requestAuthModes: [AUTH_MODE], + challenge: 'test', + authContent: '请验证已有的指纹以继续', + success: (res) => { + that.gotoPay() + }, + fail: (err) => { + wx.hideLoading(); + that.setData({ + showModel: false, + cardid: that.data.cardids, + ids: "", + remainingAmount: that.data.remainingAmounts + }) + } + }) + } + const checkIsEnrolled = () => { + wx.checkIsSoterEnrolledInDevice({ + checkAuthMode: AUTH_MODE, success: (res) => { console.log(res) - if(res.supportMode == []){ + if (res.isEnrolled) { + startSoterAuthentication(); + } else { that.gotoPay(); - }else if(res.supportMode == ['fingerPrint']){ - checkIsEnrolled() - }else if(res.supportMode = ['fingerPrint', 'facial'] ){ - checkIsEnrolled() } }, fail: (err) => { - console.error(err); - that.gotoPay(); + console.error(err) } }) - + } + wx.checkIsSupportSoterAuthentication({ + success: (res) => { + console.log(res) + if (res.supportMode == []) { + that.gotoPay(); + } else if (res.supportMode == ['fingerPrint']) { + checkIsEnrolled() + } else if (res.supportMode = ['fingerPrint', 'facial']) { + checkIsEnrolled() + } + }, + fail: (err) => { + console.error(err); + that.gotoPay(); + } + }) }, - gotoPay: function () { + gotoPay: function() { let that = this; console.log(that.data.cardid) Http.post({ @@ -122,12 +136,12 @@ Page({ }) that.setData({ cardid: that.data.cardids, - ids:"", + ids: "", remainingAmount: that.data.remainingAmounts }) }) }, - check:function(e){ + check: function(e) { let that = this; console.log(e.currentTarget.dataset.id) if (e) { @@ -136,6 +150,7 @@ Page({ ids: e.currentTarget.dataset.id, cardid: e.currentTarget.dataset.id, remainingAmount: e.currentTarget.dataset.remainingamount, + checked: true }) } } @@ -159,13 +174,13 @@ Page({ title: '加载中', }) console.log("222") - setTimeout(function(){ + setTimeout(function() { wx.hideLoading(); - },1500) + }, 1500) that.gotoPayMoney(); } }, - gotonewcard: function () { + gotonewcard: function() { wx.navigateTo({ url: '/pages/discountCardList/discountCardList' }) @@ -190,7 +205,7 @@ Page({ if (res.code == 200) { let arrays = []; res.data.list.map(file => { - if (file.remainingAmount / 100 >= that.data.inputValue){ + if (file.remainingAmount / 100 >= that.data.inputValue) { file.merchantVoList.map(files => { if (files.id == that.data.merChant.id) { file.flag = true; @@ -215,11 +230,11 @@ Page({ }) }) }, - showModel: function () { + showModel: function() { this.setData({ showModel: false, cardid: this.data.cardids, - ids:"", + ids: "", remainingAmount: this.data.remainingAmounts }) console.log(this.data.cardid) diff --git a/pages/scanPay/scanPay.wxml b/pages/scanPay/scanPay.wxml index c28bef3..b94580f 100644 --- a/pages/scanPay/scanPay.wxml +++ b/pages/scanPay/scanPay.wxml @@ -45,7 +45,7 @@ - +