const util = require("../../utils/util.js"); const config = require("../../config/config.js"); const Http = require("../../utils/HttpBasics"); const AUTH_MODE = 'fingerPrint'; let app = getApp(); Page({ /** * 页面的初始数据 */ data: { merChant: {}, focus: true, inputValue: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { let that = this; that.setData({ merChant: JSON.parse(options.merChant), cardid: options.cardid, remainingAmount: options.remainingAmount }) console.log(that.data.remainingAmount) console.log("------------------remainingAmount-------------------") }, bindKeyInput(e) { console.log(e) this.setData({ inputValue: e.detail.value }) }, gotoPayMoney: function() { let that = this; Http.post({ url: config.api.cardPayOrder, data: { cardId: that.data.cardid, merchantCode: that.data.merChant.merchant_id, totalFee: that.data.inputValue } }) .then(res => { console.log(res); wx.navigateTo({ url: '/pages/paySuccess/paySuccess', }) }) .catch(err => { wx.showModal({ title: "抱歉", content: err.message, showCancel: false }) }) }, // 指纹识别 startAuth() { let that = this; // 卡余额充足的时候,才可以付钱 if (that.data.inputValue != "" && that.data.remainingAmount >= that.data.inputValue) { const startSoterAuthentication = () => { wx.startSoterAuthentication({ requestAuthModes: [AUTH_MODE], challenge: 'test', authContent: '小程序支付', success: (res) => { this.gotoPayMoney(); }, fail: (err) => { } }) } const checkIsEnrolled = () => { wx.checkIsSoterEnrolledInDevice({ checkAuthMode: AUTH_MODE, success: (res) => { console.log(res) if (parseInt(res.isEnrolled) <= 0) { wx.showModal({ title: '错误', content: '您暂未录入指纹信息,请录入后重试', showCancel: false }) return } startSoterAuthentication(); }, fail: (err) => { console.error(err) } }) } wx.checkIsSupportSoterAuthentication({ success: (res) => { console.log(res) checkIsEnrolled() }, fail: (err) => { console.error(err); wx.showModal({ title: '错误', content: '您的设备不支持指纹识别', showCancel: false }) } }) } else if (that.data.inputValue == ""){ wx.showModal({ title: '抱歉', content: '请输入金额', showCancel: false }) } else if (that.data.inputValue != ""&&that.data.remainingAmount < that.data.inputValue){ wx.showModal({ title: '抱歉', content: '余额不足', showCancel:false }) } }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })