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: '', cardList: [], showModel: false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { console.log(options.remainingAmount) let that = this; that.setData({ merChant: JSON.parse(options.merChant), cardid: options.cardid, remainingAmount: options.remainingAmount }) }, bindKeyInput(e) { console.log(e) this.setData({ inputValue: e.detail.value }) }, gotoPayMoney: function() { let that = this; // 卡余额充足的时候,才可以付钱 console.log(Number(that.data.remainingAmount) >= Number(that.data.inputValue)) if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) { 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); if(res.code==200){ wx.navigateTo({ url: '/pages/paySuccess/paySuccess', }) } }) .catch(err => { wx.showModal({ title: "抱歉", content: err.message, showCancel: false }) }) } else if (that.data.inputValue == "") { wx.showModal({ title: '抱歉', content: '请输入金额', showCancel: false }) } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) < Number(that.data.inputValue)) { that.setData({ showModel: true }) that.getList(); } }, // 指纹识别 startAuth() { let that = this; const startSoterAuthentication = () => { wx.startSoterAuthentication({ requestAuthModes: [AUTH_MODE], challenge: 'test', authContent: '请验证已有的指纹以继续', success: (res) => { that.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 }) } }) }, gotonewcard: function() { wx.navigateTo({ url: '/pages/discountCardList/discountCardList' }) this.setData({ showModel: false }) }, getList() { var that = this; var data = { pageNum: 1, pageSize: 100, couponType: "7", couponOrderStatus: 4 } Http.get({ url: config.api.cardorderList, data: data }) .then(res => { console.log(res) if (res.code == 200) { res.data.list.map(file => { file.merchantVoList.map(files => { console.log(files.id) if (files.id == that.data.merChant.merchant_id) { file.flag = true } }) }) that.setData({ showPage: true, cardList: res.data.list }) } }) .catch(err => { wx.showModal({ title: '提示', content: err.errMsg, showCancel: false }) }) }, check: function(e) { let ids = e.currentTarget.dataset.id; this.setData({ ids: ids, cardId: ids, remainingAmount: e.currentTarget.dataset.remainingamount }) }, showModel: function() { this.setData({ showModel: false }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })