|
- 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) {
- 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 (flags) {
- let that = this;
- // 卡余额充足的时候,才可以付钱
- // if(e){
- // if(e.currentTarget.dataset.flags == 'check'){
- // console.log("frhufr")
- // that.setData({
- // ids: e.currentTarget.dataset.id,
- // cardid: e.currentTarget.dataset.id,
- // remainingAmount: e.currentTarget.dataset.remainingamount,
- // })
- // 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) {
- // that.gotoPayMoney();
- // return
- // }
- // startSoterAuthentication();
- // },
- // fail: (err) => {
- // console.error(err)
- // }
- // })
- // }
- // wx.checkIsSupportSoterAuthentication({
- // success: (res) => {
- // console.log(res)
- // checkIsEnrolled()
- // },
- // fail: (err) => {
- // console.error(err);
- // that.gotoPayMoney();
- // }
- // })
- // }
- // }
-
- const startSoterAuthentication = () => {
- wx.startSoterAuthentication({
- requestAuthModes: [AUTH_MODE],
- challenge: 'test',
- authContent: '请验证已有的指纹以继续',
- success: (res) => {
- that.gotoPay()
- },
- fail: (err) => {
-
- }
- })
- }
- const checkIsEnrolled = () => {
- wx.checkIsSoterEnrolledInDevice({
- checkAuthMode: AUTH_MODE,
- success: (res) => {
- console.log(res)
- if (parseInt(res.isEnrolled) <= 0) {
- that.gotoPay();
- return
- }
- startSoterAuthentication();
- },
- fail: (err) => {
- console.error(err)
- }
- })
- }
- wx.checkIsSupportSoterAuthentication({
- success: (res) => {
- console.log(res)
- checkIsEnrolled()
- },
- fail: (err) => {
- console.error(err);
- that.gotoPay();
- }
- })
- },
- gotoPay: 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 => {
- if (res.code == 200) {
- that.setData({
- showModel: false
- })
- wx.navigateTo({
- url: `/pages/paySuccess/paySuccess?data=${JSON.stringify(res.data)}`,
- })
- }
- })
- .catch(err => {
- wx.showModal({
- title: "抱歉",
- content: err.message,
- showCancel: false
- })
- })
- },
- // 指纹识别
- startAuth(e) {
- let that = this;
- if (e) {
- if (e.currentTarget.dataset.flags == 'check') {
- that.setData({
- ids: e.currentTarget.dataset.id,
- cardid: e.currentTarget.dataset.id,
- remainingAmount: e.currentTarget.dataset.remainingamount,
- })
- }
- }
- if (that.data.inputValue == "" || that.data.inputValue == 0) {
- 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('notenogth');
- } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) {
- that.gotoPayMoney();
- }
- },
- 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 => {
- 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
- })
- })
- },
- showModel: function () {
- this.setData({
- showModel: false
- })
- },
- })
|