C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

157 строки
3.2 KiB

  1. const util = require("../../utils/util.js");
  2. const config = require("../../config/config.js");
  3. const Http = require("../../utils/HttpBasics");
  4. const AUTH_MODE = 'fingerPrint';
  5. let app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. merChant: {},
  12. focus: true,
  13. inputValue: ''
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function(options) {
  19. console.log(options)
  20. let that = this;
  21. that.setData({
  22. merChant: JSON.parse(options.merChant),
  23. cardid: options.cardid
  24. })
  25. },
  26. bindKeyInput(e) {
  27. console.log(e)
  28. this.setData({
  29. inputValue: e.detail.value
  30. })
  31. },
  32. gotoPayMoney: function() {
  33. let that = this;
  34. Http.post({
  35. url: config.api.cardPayOrder,
  36. data: {
  37. cardId: that.data.cardid,
  38. merchantCode: that.data.merChant.merchant_id,
  39. totalFee: that.data.inputValue
  40. }
  41. })
  42. .then(res => {
  43. console.log(res);
  44. wx.navigateTo({
  45. url: '/pages/paySuccess/paySuccess',
  46. })
  47. })
  48. .catch(err => {
  49. wx.showModal({
  50. title: "抱歉",
  51. content: err.message,
  52. showCancel: false
  53. })
  54. })
  55. },
  56. // 指纹识别
  57. startAuth() {
  58. let that = this;
  59. if (that.data.inputValue != "") {
  60. const startSoterAuthentication = () => {
  61. wx.startSoterAuthentication({
  62. requestAuthModes: [AUTH_MODE],
  63. challenge: 'test',
  64. authContent: '小程序支付',
  65. success: (res) => {
  66. this.gotoPayMoney();
  67. },
  68. fail: (err) => {
  69. }
  70. })
  71. }
  72. const checkIsEnrolled = () => {
  73. wx.checkIsSoterEnrolledInDevice({
  74. checkAuthMode: AUTH_MODE,
  75. success: (res) => {
  76. console.log(res)
  77. if (parseInt(res.isEnrolled) <= 0) {
  78. wx.showModal({
  79. title: '错误',
  80. content: '您暂未录入指纹信息,请录入后重试',
  81. showCancel: false
  82. })
  83. return
  84. }
  85. startSoterAuthentication();
  86. },
  87. fail: (err) => {
  88. console.error(err)
  89. }
  90. })
  91. }
  92. wx.checkIsSupportSoterAuthentication({
  93. success: (res) => {
  94. console.log(res)
  95. checkIsEnrolled()
  96. },
  97. fail: (err) => {
  98. console.error(err);
  99. wx.showModal({
  100. title: '错误',
  101. content: '您的设备不支持指纹识别',
  102. showCancel: false
  103. })
  104. }
  105. })
  106. } else {
  107. wx.showModal({
  108. title: '抱歉',
  109. content: '请输入金额',
  110. showCancel: false
  111. })
  112. }
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow: function() {
  118. },
  119. /**
  120. * 生命周期函数--监听页面隐藏
  121. */
  122. onHide: function() {
  123. },
  124. /**
  125. * 生命周期函数--监听页面卸载
  126. */
  127. onUnload: function() {
  128. },
  129. /**
  130. * 页面相关事件处理函数--监听用户下拉动作
  131. */
  132. onPullDownRefresh: function() {
  133. },
  134. /**
  135. * 页面上拉触底事件的处理函数
  136. */
  137. onReachBottom: function() {
  138. },
  139. /**
  140. * 用户点击右上角分享
  141. */
  142. onShareAppMessage: function() {
  143. }
  144. })