|
- const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px';
- const util = require("../../utils/util.js");
- const config = require("../../config/config.js");
- const Http = require("../../utils/HttpBasics");
- const imgurl = require("../../utils/imgurl");
- const AUTH_MODE = 'fingerPrint';
- let app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- navigationBarHeight,
- merChant: {},
- focus: true,
- inputValue: '',
- cardList: [],
- arrays: [],
- showModel: false,
- showInput:false,
- ids: "",
- wmyes: imgurl.wmyes.url,
- wmclose: imgurl.wmclose.url
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- let that = this;
- that.setData({
- merChant: JSON.parse(options.merChant),
- cardid: options.cardid,
- cardids: options.cardid,
- remainingAmount: options.remainingAmount,
- remainingAmounts: options.remainingAmount,
- })
- },
- bindKeyInput(e) {
- console.log(e)
- this.setData({
- inputValue: e.detail.value
- })
- },
- suretoPay: function(e) {
- let that = this;
- 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: ["fingerPrint"],
- challenge: 'test',
- authContent: '请验证已有的指纹以继续',
- success: (res) => {
- console.log(res)
- that.gotoPay()
- },
- fail: (err) => {
- console.log(err);
- wx.hideLoading();
- that.setData({
- showModel: false,
- showInput: false,
- cardid: that.data.cardids,
- ids: "",
- remainingAmount: that.data.remainingAmounts
- })
- if(err.errCode==90008||err.errCode == 90009){
- }else{
- that.gotoPay();
- }
- }
- })
- }
- 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({
- 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() {
- let that = this;
- console.log(that.data.cardid)
- Http.post({
- url: config.api.cardPayOrder,
- data: {
- cardId: that.data.cardid,
- merchantId: that.data.merChant.id,
- totalFee: that.data.inputValue
- }
- })
- .then(res => {
- if (res.code == 200) {
- wx.hideLoading();
- that.setData({
- showModel: false,
- showInput: false
- })
- wx.navigateTo({
- url: `/pages/paySuccess/paySuccess?data=${JSON.stringify(res.data)}`,
- })
- }
- })
- .catch(err => {
- wx.hideLoading()
- wx.showModal({
- title: "抱歉",
- content: err.message,
- showCancel: false
- })
- that.setData({
- cardid: that.data.cardids,
- ids: "",
- remainingAmount: that.data.remainingAmounts
- })
- })
- },
- check: function(e) {
- let that = this;
- console.log(e.currentTarget.dataset.id)
- 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,
- checked: true
- })
- }
- }
- },
- startAuth(e) {
- let that = this;
- 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,
- showInput:'disabled'
- })
- that.getList();
- console.log("1111")
- } else if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) {
- wx.showLoading({
- title: '加载中',
- })
- console.log("222")
- setTimeout(function() {
- wx.hideLoading();
- }, 1500)
- that.gotoPayMoney();
- }
- },
- gotonewcard: function() {
- wx.navigateTo({
- url: '/pages/discountCardList/discountCardList'
- })
- this.setData({
- showModel: false,
- showInput: 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) {
- let arrays = [];
- res.data.list.map(file => {
- if (file.remainingAmount / 100 >= that.data.inputValue) {
- file.merchantVoList.map(files => {
- if (files.id == that.data.merChant.id) {
- file.flag = true;
- arrays.push(file);
- }
- })
- }
- })
- console.log(arrays)
- that.setData({
- showPage: true,
- cardList: res.data.list,
- arrays: arrays
- })
- }
- })
- .catch(err => {
- wx.showModal({
- title: '提示',
- content: err.errMsg,
- showCancel: false
- })
- })
- },
- showModel: function() {
- this.setData({
- showModel: false,
- showInput: false,
- cardid: this.data.cardids,
- ids: "",
- remainingAmount: this.data.remainingAmounts
- })
- console.log(this.data.cardid)
- },
- })
|